题解 | #脉冲同步器(快到慢)#
脉冲同步器(快到慢)
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 Sa; always@(posedge clka or negedge rst_n) begin if(!rst_n) begin Sa <= 1'b0; end else begin Sa <= sig_a?(~Sa):Sa; end end reg Sb_r1,Sb_r2,Sb_r3; always@(posedge clkb or negedge rst_n) begin if(!rst_n) begin {Sb_r1,Sb_r2,Sb_r3} <= 'd0; end else begin {Sb_r1,Sb_r2,Sb_r3} <= {Sa,Sb_r1,Sb_r2}; end end assign sig_b = Sb_r2^Sb_r3; endmodule