Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
sample the signal (after synchronizing it to the clock) and perform a falling edge detection using a FF to delay the signal (after the synchrnoizer) and checking if the old state of the signal is 1 while the most recent state of the signal is 0.
always @ ( posedge signal1 or negedge signal2 )
begin
if ( signal1 = 1 ) and ( signal2 = 0 )
begin
\\ do some logic
end
end
alway @* begin
if (signal1 && !signal2) begin
// do this stuff
end
end
Code Verilog - [expand] 1 2 3 4 5 6 7 8 9 // assuming that signal1 is a clock and signal2 is synchronous to signal1 (from some other logic clocked by signal1) wire signal1; wire signal2; reg signal2_dly; reg redge; always @(posedge signal1) begin signal2_dly <= signal2; redge <= ~signal2_dly & signal2; end
Code Verilog - [expand] 1 2 3 4 5 6 7 8 9 // assuming that signal1 is a clock and signal2 is asynchronous to signal1 wire signal1; wire signal2; reg [2:0] sig2_sync; reg redge; always @(posedge signal1) begin sig2_sync <= {sig2_sync[1:0], signal2}; redge <= ~sig2_sync[2] & sig2_sync[1]; // [0] & [1] are part of the two stage syncrhonizer end