题解 | #脉冲同步器(快到慢)#

脉冲同步器(快到慢)

https://www.nowcoder.com/practice/9f7c92635b5f49579e8e38fd8c8450d7

`timescale 100ps/100ps

module pulse_detect(
	input 				clka	, 
	input 				clkb	,   
	input 				rst_n		,
	input				sig_a		,

	output  		 	sig_b
);
//典型的慢采快问题,不能直接采集,需要展宽。
//展宽信号
wire sig_b;
reg pluse_a;
reg [1:0]pluse_r;
always@(posedge clka or negedge rst_n)begin 
	if(!rst_n)
     pluse_a<=0;
	 else if(sig_a)
	 pluse_a<=1;
	 else if(pluse_r[1])  //B时钟域返回的信号
	 pluse_a<=0;
	 else 
	 pluse_a<=pluse_a;
end
//传输到b时钟域
reg [2:0]pluse_b;
always@(posedge clkb or negedge rst_n)begin 
	if(!rst_n)
        pluse_b<=0;
		else pluse_b<={pluse_b[1],pluse_b[0],pluse_a};
end
//产生反馈信号
always@(posedge clka or negedge rst_n)begin 
	if(!rst_n)
        pluse_r<=0;
		else {pluse_r[1],pluse_r[0]}<={pluse_r[0],sig_b};  //用脉冲信号去反馈
end
assign sig_b=(!pluse_b[2])&(pluse_b[1]);
//assign sig_b=pluse_b[2];
endmodule

全部评论

相关推荐

能干的三文鱼刷了10...:公司可能有弄嵌入式需要会画pcb的需求,而且pcb能快速直观看出一个人某方面的实力。看看是否有面试资格。问你问题也能ai出来,pcb这东西能作假概率不高
点赞 评论 收藏
分享
05-19 19:57
蚌埠学院 Python
2237:Gpa70不算高,建议只写排名,个人技能不在多而在精,缩到8条以内。项目留一个含金量高的,减少间距弄到一页,硕士简历也就一页,本科不要写很多
实习,投递多份简历没人回...
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务