Synchronous reset

Use an active-low reset to compare a pulse that overlaps a sampling edge with one that falls entirely between edges. Mark when Q takes the reset value and when the first data word can be written after release.

The panel holds 31 in Q. First pull rst_n low between rising edges. Then hold it low across a rising edge. Which pulse clears the register?

The rising edge samples reset

This reset is active-low and synchronous. rst_n=0 requests a clear. Q becomes 00 when a rising edge samples reset low. That clear takes priority over any value then on D.

rst_n falls at 19 ns while Q still holds 52. The rising edge at 25 ns samples reset and clears Q to 00.
Check whether the reset pulse overlaps a sampling edge.

Test rst_n first at each rising edge

The block runs on posedge clk. At the rising edge, it checks rst_n first and captures D when reset is inactive.

module synchronous_reset8 (
    input  logic       clk,
    input  logic       rst_n,
    input  logic [7:0] d,
    output logic [7:0] q
);
    always_ff @(posedge clk) begin
        if (!rst_n)
            q <= 8'h00;
        else
            q <= d;
    end
endmodule

Compare two low pulses

Rising edges are 10 ns apart. The data is hexadecimal, and Q shows the simulated value after each event. The pulse from 7 to 9 ns lies entirely between E0 and E1. The pulse from 19 to 27 ns overlaps E2.

nsEventrst_nQ
5E0 stores 31131
7 to 9Low pulse and release0→131
15E1 stores 52152
19Reset goes low again052
25E2 samples reset000
27Reset releases100
35E3 stores A61A6
The low pulse from 7 to 9 ns leaves Q unchanged. The wider reset clears Q at 25 ns, and Q loads A6 at 35 ns.
Reset falls at 19 ns. Q clears on the rising edge at 25 ns.

After release at 27 ns, Q holds the cleared value until 35 ns. If the clock stops, synchronous reset waits for the next rising edge. Apply the same stimulus to the asynchronous-reset circuit to compare when Q clears.

Replay the lab

Extract the executable lab on Linux or WSL and run bash run.sh. Icarus Verilog 12.0 checked 8 timed observations. The archive contains the RTL, testbench, log, VCD and generic Yosys structure. The checks include two assertions, two releases and four rising edges. Continue with F07 on registers, F14 on clock-domain crossings.

Interactive lab

Store a word with rst_n high. Then pull rst_n low and release it without applying an edge.

Stored Q
Show the last eight observations

    Teaching film

    Read the transcript

    Run the RTL yourself

    Extract the lab and follow the commands in its README. Compare the simulated outputs and waveform with your predictions from the interactive lab.

    Download Synchronous reset RTL (.zip)

    Check your understanding

    1. Which pin value requests reset in this example?
    2. The low pulse from 7 to 9 ns lies between rising edges. What happens to Q?
    3. At 25 ns, rst_n is low and D is A6. What is Q after the update?
    4. Reset releases at 27 ns and the next rising edge is at 35 ns. When does A6 reach Q?
    5. If reset stays low but the clock stops, when does this circuit clear Q?