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

脉冲同步器(快到慢)

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 qa;
reg [2:0]qb;

 assign sig_b=qb[2]^qb[1];

 always@(posedge clka or negedge rst_n)
 if(!rst_n)begin
	qa<=0;
 end else begin
	qa<=(sig_a)?(~qa):qa;
 end


 always@(posedge clkb or negedge rst_n)
 if(!rst_n)begin
	qb<=0;
 end else begin
	qb={qb[1:0],qa};//三拍
 end

endmodule

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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