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

脉冲同步器(快到慢)

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
);


reg		level,level_1,level_2,level_3	;
always@(posedge clka or negedge rst_n)
	if(!rst_n)
		level	<=	1'b0;
	else	if(sig_a)
		level	<=	~level;
	else	
		level	<=	level;

always@(posedge clkb or negedge rst_n)
	if(!rst_n)
		begin
			level_1	<=	1'b0;
			level_2	<=	1'b0;
			level_3	<=	1'b0;
		end
	else
		begin
			level_1	<=	level;
			level_2	<=	level_1;
			level_3	<=	level_2;
		end

assign	sig_b = level_2 ^ level_3;
endmodule

全部评论

相关推荐

喜欢走神的孤勇者练习时长两年半:爱华,信华,等华,黑华
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务