【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
原理图
相关推荐
YYRAN_ZZU7 小时前
Lattice 自定义IP业务逻辑核
嵌入式硬件·fpga开发
FPGA小徐10 小时前
FPGA FIFO一篇完整解释
fpga开发
I'm a winner18 小时前
【IP核】 Xilinx FPGA LVDS 高速接口,含验证工程与板级测试用例
tcp/ip·fpga开发·测试用例
I'm a winner20 小时前
基于Xilinx FPGA的LVDS高速串行通信系统 - 完整源码解决方案(一)(文末附源码)
fpga开发
国科安芯21 小时前
航天器多路并联大功率电源系统设计与ASP4644均流特性分析
单片机·嵌入式硬件·fpga开发·安全性测试
techdashen2 天前
从网络栈继续往下:micro:bit、2.4GHz、调制方式,以及一个不太靠谱但很有趣的想法
网络·fpga开发
FPGA小徐2 天前
FIR 数字滤波器 --verilog设计实现
fpga开发
zlinear数据采集卡2 天前
从协议解析到波形实时显示:硬核拆解ZLinear采集卡上位机软件的开发架构
arm开发·单片机·嵌入式硬件·fpga开发·架构·开源
pcjiushizhu2 天前
ModelSim 仿真时 Simulate 无反应或只显示 Loading 的解决方法:网卡问题排查
fpga开发
FPGA小迷弟2 天前
vivado中的AXI Interconnect到底应该怎么用,他的底层原理是什么,一篇文档全部理清楚!!!
网络协议·tcp/ip·fpga开发·verilog·fpga