专栏前言
本专栏的内容主要是记录本人学习Verilog过程中的一些知识点,刷题网站用的是牛客网
`timescale 100ps/100ps
module pulse_detect(
input clka ,
input clkb ,
input rst_n ,
input sig_a ,
output sig_b
);
reg Q_sig_a ;
reg Q_buff0, Q_buff1, Q_buff2 ;
always @ (posedge clka or negedge rst_n)
if (!rst_n) Q_sig_a <= 0 ;
else if (sig_a) Q_sig_a <= ~Q_sig_a ;
else Q_sig_a <= Q_sig_a ;
always @ (posedge clkb or negedge rst_n)
if (!rst_n) begin
Q_buff0 <= 0 ;
Q_buff1 <= 0 ;
Q_buff2 <= 0 ;
end
else begin
Q_buff0 <= Q_sig_a ;
Q_buff1 <= Q_buff0 ;
Q_buff2 <= Q_buff1 ;
end
assign sig_b = Q_buff2 ^ Q_buff1 ;
endmodule