Resetting a digital circuit makes sure it starts in a known state. There are two main ways to reset: synchronous and asynchronous. Each way controls when and how the reset happens.
Reset strategy (sync vs async) in Verilog
module example_sync_reset(input clk, input reset, input d, output reg q); always @(posedge clk) begin if (reset) q <= 0; // synchronous reset else q <= d; end endmodule module example_async_reset(input clk, input reset, input d, output reg q); always @(posedge clk or posedge reset) begin if (reset) q <= 0; // asynchronous reset else q <= d; end endmodule
Synchronous reset happens only on the clock edge.
Asynchronous reset can happen anytime, independent of the clock.
always @(posedge clk) begin if (reset) q <= 0; // synchronous reset else q <= d; end
always @(posedge clk or posedge reset) begin if (reset) q <= 0; // asynchronous reset else q <= d; end
This testbench shows how synchronous and asynchronous resets affect outputs differently. The clock toggles every 5 time units. Reset is asserted and deasserted at different times to see the effect.
module testbench(); reg clk = 0; reg reset = 0; reg d = 0; wire q_sync, q_async; // Clock generation always #5 clk = ~clk; // Synchronous reset module example_sync_reset sync_reset(.clk(clk), .reset(reset), .d(d), .q(q_sync)); // Asynchronous reset module example_async_reset async_reset(.clk(clk), .reset(reset), .d(d), .q(q_async)); initial begin $monitor($time, " clk=%b reset=%b d=%b q_sync=%b q_async=%b", clk, reset, d, q_sync, q_async); // Initial values d = 1; reset = 1; // Assert reset #10; reset = 0; // Deassert reset #20; d = 0; #20; reset = 1; // Assert reset again #10; reset = 0; #20; $finish; end endmodule
Asynchronous reset can cause glitches if not handled carefully.
Synchronous reset is safer for timing but may delay reset response.
Check your FPGA or ASIC documentation for recommended reset style.
Reset makes sure your circuit starts correctly.
Synchronous reset happens with the clock; asynchronous reset happens anytime.
Choose reset style based on your design needs and hardware rules.
Practice
Solution
Step 1: Understand synchronous reset behavior
Synchronous reset activates only on the clock edge, so the reset signal is sampled with the clock.Step 2: Understand asynchronous reset behavior
Asynchronous reset activates immediately when asserted, independent of the clock.Final Answer:
Synchronous reset is triggered by the clock edge, asynchronous reset works immediately. -> Option AQuick Check:
Reset timing difference = synchronous on clock, async immediate [OK]
- Confusing which reset depends on clock
- Thinking async reset waits for clock edge
- Assuming both resets behave the same
Solution
Step 1: Identify synchronous reset syntax
Synchronous reset is checked inside a clock-only sensitivity list, typically @(posedge clk).Step 2: Check reset condition inside the block
The reset condition is inside the always block, using if (rst) to reset synchronously.Final Answer:
always @(posedge clk) begin if (rst) q <= 0; else q <= d; end -> Option BQuick Check:
Sync reset inside clock-only always block [OK]
- Including reset in sensitivity list for sync reset
- Using asynchronous sensitivity list for sync reset
- Missing clock edge in always block
q after the asynchronous reset rst is deasserted?reg q; always @(posedge clk or posedge rst) begin if (rst) q <= 1'b0; else q <= d; end
Solution
Step 1: Analyze asynchronous reset sensitivity
The always block triggers on posedge clk or posedge rst, so when rst is asserted, q resets immediately.Step 2: Behavior after reset deassertion
After rst is deasserted, q updates on clock edges following the value of d.Final Answer:
q will immediately reset to 0 when rst is asserted, then follow d on clock edges. -> Option AQuick Check:
Async reset immediate, then sync update [OK]
- Thinking async reset waits for clock edge
- Assuming q holds value during reset
- Confusing reset assertion and deassertion timing
always @(posedge clk or posedge rst) begin if (rst) q <= 0; else q <= d; end
Solution
Step 1: Check sensitivity list for synchronous reset
Synchronous reset should only be sensitive to the clock edge, not the reset signal.Step 2: Identify the error
Including posedge rst makes the reset asynchronous, which contradicts the synchronous reset intent.Final Answer:
The reset should not be in the sensitivity list for synchronous reset. -> Option DQuick Check:
Sync reset sensitivity = clock only [OK]
- Including reset in sensitivity list for sync reset
- Misunderstanding sensitivity list purpose
- Using blocking assignment instead of non-blocking
Solution
Step 1: Understand immediate reset need
Immediate clearing requires asynchronous reset to react without waiting for clock.Step 2: Avoid metastability by synchronizing reset
To prevent metastability, the asynchronous reset signal should be passed through synchronizer flip-flops before use.Step 3: Combine both requirements
Using async reset with synchronizer achieves immediate reset and safe clock domain crossing.Final Answer:
Use an asynchronous reset with a synchronizer circuit on the reset signal. -> Option CQuick Check:
Async reset + synchronizer = immediate and safe reset [OK]
- Using only synchronous reset ignoring immediate reset
- Using async reset without synchronization causing metastability
- Trying to use two resets on same flip-flop incorrectly
Ready to prove it?
Pass the test and this pattern moves unknown
