FPGA设计中跨时钟域的异步处理
在FPGA开发设计中,经常是多个时钟同时工作于同一模块中,不同时钟域的信号间要保证稳定通信,必须要处理好时序问题,也就是要充分考虑信号的建立和保持时间,以下是在设计中常用的单脉冲信号的处理方法:
`timescale 1 ps / 1 ps
module PULSE_GEN (
XRST , // (i) Reset Input ( Asynchronous )
CLK_I , // (i) Clock At Input Side
CLK_O , // (i) Clock At Output Side
PULSE_I , // (i) Pulse Input
PULSE_O // (o) Pulse Output
) ;
parameter P_TYPE = 8'd0 ;
//==========================================================
// Declare the port directions
//==========================================================
input XRST ; // (i) Reset Input ( Asynchronous )
input CLK_I ; // (i) Clock At Input Side
input CLK_O ; // (i) Clock At Output Side
input PULSE_I ; // (i) Pulse Input
output PULSE_O ; // (o) Pulse Output
//==========================================================
// Internal signals define
//==========================================================
reg r_PULSE_I ;
reg [2:0] r_PULSE_O ; // r_PULSE_O[0], r_pluse_o[1] Should Not Be Duplicated
// Synthesis Attribute MAX_FANOUT of r_PULSE_O is 9999;
//==========================================================
// RTL Body
//==========================================================
generate
if(P_TYPE == 0) begin :TYPE_0_PULSEGEN
//==========================================================
// Input Pulse Keep ( CLK_I domain )
//==========================================================
always @( posedge CLK_I or negedge XRST ) begin
if( !XRST ) begin
r_PULSE_I <= 1'b0 ;
end else begin
if ( PULSE_I == 1'b1 ) begin
r_PULSE_I <= ~r_PULSE_I ;
end
end
end
//==========================================================
// Output Pulse Sync. And Generate ( CLK_O Domain )
//==========================================================
always @( posedge CLK_O or negedge XRST ) begin
if( !XRST ) begin
r_PULSE_O <= 3'b000 ;
end else begin
r_PULSE_O <= { r_PULSE_O[1:0] , r_PULSE_I } ;
end
end
assign PULSE_O = (r_PULSE_O[2] != r_PULSE_O[1] ) ; // 0 -> 1
end
endgenerate
endmodule
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· SQL Server 2025 AI相关能力初探
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库