Altera_Forum
Honored Contributor
16 years agoSync reset with push-button not reliable
I'm using Quartus II 9.1 Web Edition with a DE1 (Cyclone II Starter Kit) board and I have some problems with resetting my tiny design that I can't figure out. When I have all my flops reset synchronously, my design will reset improperly maybe 1 out 10 times. For example, I have some registers that are driven by the following block:
always @ (posedge CLOCK_50)
if (!rst_n) begin
a3 <= 4'b0;
a2 <= 4'b0;
a1 <= 4'b0;
a0 <= 4'b0;
end
else if (trigger & !done & ms_timeout) begin
a3 <= a3_next;
a2 <= a2_next;
a1 <= a1_next;
a0 <= a0_next;
end
When my reset signal, rst_n, is tied directly to KEY[0], I get traces like the attached (generated from the SignalTap II Logic Analyzer), showing a0 changing from 0 to 1 although the reset is deasserted and "trigger" is low throughout the trace. If I make all the flops reset asynchronously, everything works fine. But what really puzzles me: If I synchronize the rst_n signal like this:
reg rst_n;
always @ (posedge CLOCK_50 or negedge KEY)
if (!KEY)
rst_n <= 1'b0;
else
rst_n <= 1'b1;
instead of just having it be wired directly to KEY[0], everything works even when all the flops are reset synchronously again. With my admittedly not very extensive knowledge on reset techniques, the purpose of synchronizing a reset like above is to avoid meta-stability on deassertion of aync resets. However, if that was the problem, why did the code then *work* with async reset and *not* work with sync reset? I'm sure I'm missing something here. Can anybody tell me what it is? Sebastian