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

建立时间和保持时间

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

单比特信号的跨时钟处理

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

打两拍

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

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

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

在这里插入图片描述

代码
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

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

原理图

在这里插入图片描述

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

优点: 对时序比较友好
缺点: 相邻的脉冲太近时,会检测不到
在这里插入图片描述

代码
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
原理图

在这里插入图片描述

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

农民真快落

我琢磨着也没人给我打赏呀。。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值