【IC设计】跨时钟异步处理系列——单比特跨时钟

文章目录

建立时间和保持时间

  1. 所谓的建立时间或者保持时间都是在描述一种时钟变化的边沿上的数据状态。
  2. 建立时间:在时钟的有效沿(以上升沿为例)到来之前,数据的输入端信号必须保持稳定的最短时间
  3. 保持时间:在时钟的有效沿(以上升沿为例)到来之后,数据的输入端信号必须保持稳定的最短时间

单比特信号的跨时钟处理

慢时钟域的信号传输到快时钟域

打两拍

快时钟域的信号传输到慢时钟域

如图所示,第一行是脉冲信号,第二行是慢时钟域的时钟。如果从快时钟域要同步一个脉冲信号到慢时钟域,容易出现上升沿没有采样到脉冲信号的情况。

方案一 脉冲展宽+同步 (打拍打拍,进行或)

代码
rust 复制代码
module fast2slow_cdc 
(
    input   i_clk_f     ,
    input   i_pluse_f   ,
    input   i_rst_n     ,
    input   i_clk_s     ,
    output  o_pluse_s  
);
/*
always @(posedge i_clk_f) begin
    r_pluse[0] <= i_pluse_f  ;
    r_pluse[1] <= r_pluse[0] ;
    r_pluse[2] <= r_pluse[1] ;
    r_pluse[3] <= r_pluse[2] ;
    r_pluse[4] <= r_pluse[3] ;
end
*/

reg [2:0]    r_pluse    ;
always @(posedge i_clk_f or negedge i_rst_n) begin
    if(~i_rst_n)    begin
        r_pluse <=  'b0;
    end
    else begin
        r_pluse <= {r_pluse[1:0],i_pluse_f};
    end
end

wire   w_pluse ;
assign  w_pluse = |r_pluse ;


reg   r_pluse_d0  ;
reg   r_pluse_d1  ;
always @(posedge i_clk_s) begin
    r_pluse_d0 <= w_pluse    ;
    r_pluse_d1 <= r_pluse_d0 ;
end

assign  o_pluse_s = r_pluse_d1 ;

endmodule

存在的问题:采用脉冲展宽+同步,在或时可能产生毛刺

原理图

方案二 脉冲电平检测+双触发器同步+边沿检测

优点: 对时序比较友好
缺点: 相邻的脉冲太近时,会检测不到

代码
rust 复制代码
module fast2slow_cdc2(
	input	i_clk_f			,
	input	i_pluse_f		,
	input	i_clk_s			,
	output	o_pluse_s
);
	reg	r_temp	=	0	;
	always@(posedge i_clk_f)	begin
		if(i_pluse_f)
			r_temp	    <=	~r_temp;
		else
			 r_temp	<=	r_temp;
	end
	reg	r_temp_d0;
	reg	r_temp_d1;
	reg	r_temp_d2;
	always@(posedge i_clk_s)	begin
		r_temp_d0	<=	r_temp		;
		r_temp_d1	<=	r_temp_d0	;
		r_temp_d2	<=	r_temp_d1	;
	end
	assign o_pluse_s	=	r_temp_d2	^	r_temp_d1	;
endmodule
原理图
相关推荐
XINVRY-FPGA4 小时前
XCVU47P-2FSVH2892E Xilinx Virtex UltraScale+ FPGA AMD
c语言·c++·人工智能·嵌入式硬件·阿里云·fpga开发·fpga
黄小鹿1 天前
高云GW5AT-LV60 FPGA图像处理板
fpga开发
orange....1 天前
VIVADO ZYNQ 7045 bit压缩
fpga开发
千宇宙航1 天前
闲庭信步使用SV进行图像处理系列教程介绍
图像处理·fpga开发
从今天开始学习Verilog1 天前
新人FPGA学习记录之图像处理
图像处理·学习·fpga开发
芝士不会写代码1 天前
【FPGA学习】DE2-115实现LED流水灯
学习·fpga开发
FPGA_ADDA1 天前
宽带中频10.4G采集卡
fpga开发·信号处理·高速数据采集·10g采集卡
ehiway2 天前
中科亿海微SoM模组——FPGA+DSP核心板
fpga开发
点灯大师李2 天前
PL端软核FIFO读写
fpga开发
sz66cm2 天前
FPGA基础 -- Verilog 共享任务(task)和函数(function)
fpga开发