Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutRoadmapCareersInternshipsFAQContactPrivacyTerms
Skip to lesson

Course contents

  • How to Use This Puzzle Bank
  • SystemVerilog Language Puzzles25
  • Difficulty Guide
  • Full Topic Map
  • Interview-Day Tips
  • Study Route: One Week Before the Interview
  • Study Route: Two Weeks
  • Study Route: Four Weeks (Full Course)4
  • OOP & Testbench Puzzles25
  • Concurrency & Timing Puzzles25
  • Randomization & Constraint Puzzles25
  • SVA Assertion Puzzles25
  • Functional Coverage Puzzles25
  • Logic & Aptitude Puzzles25
  • Scenario & Debug Puzzles25
  • UVM Testbench Puzzles25
  • Clock, Reset & CDC Puzzles25
    • Reset Puzzles
      • A Reset Pulse Between Two Clock Edges
      • The Counter Nobody Reset
      • Asynchronous Assert, Synchronous Release
      • Reset Has Lower Priority Than Enable
      • Reset Release Order Across Domains
      • Reset Released With a Blocking Assignment
    • Clock Gating & Clock Mux Puzzles
    • CDC Basics Puzzles
    • Verifying CDC & Reset Puzzles
    • Clock, Reset & CDC Puzzles: Tricky Q&A
  • Bus and Interface Protocol Puzzles25
  • Interview Prep: Puzzle Rounds7
  • DV Puzzle Cheatsheet
Loading lesson

←Reset Puzzles
  1. Topics
  2. DV Interview Puzzles
  3. Clock, Reset & CDC Puzzles
  4. Reset Puzzles
  5. Reset Released With a Blocking Assignment
On this page

    VLSI DV Interview PuzzlesAll levels

    Reset Released With a Blocking Assignment

    The testbench waits for the clock edge at t=15 and then releases reset with a blocking assignment. The DUT is a synchronous-reset counter. What value of cnt does the print at t=46 show? Is the result defined? Fix the testbench so that every simulator agrees.

    Puzzle

    Difficulty: Hard · Puzzle 6 of 6 · Topic: Reset Puzzles

    The testbench waits for the clock edge at t=15 and then releases reset with a blocking assignment. The DUT is a synchronous-reset counter. What value of cnt does the print at t=46 show? Is the result defined? Fix the testbench so that every simulator agrees.

    Code

    tb.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    `timescale 1ns/1ns
    module tb;
      reg clk = 0, rst_n = 0;
      reg [3:0] cnt;
      always #5 clk = ~clk;                       // posedges at 5, 15, 25, 35, 45
      always @(posedge clk)
        if (!rst_n) cnt <= 4'd0; else cnt <= cnt + 1;
      initial begin
        repeat (2) @(posedge clk);                // wake up at the edge at t=15
        rst_n = 1;                                // blocking: same time step as the DUT's read of rst_n
      end
      initial begin
        #46 $display("t=%0d cnt=%0d", $time, cnt);
        $finish;
      end
    endmodule

    Hint

    Two active-region processes read and write the same variable in the same time step.

    Step-by-step solution

    Diagram
    1) At t=15 two processes become runnable in the same active region: the DUT's always block (reads rst_n) and the initial block (writes rst_n = 1).
    2) The language does not define their order. If the DUT runs first it sees rst_n=0, resets, and the counter first counts at t=25: edges 25, 35, 45 give cnt=3.
    3) If the initial block runs first the DUT sees rst_n=1 at t=15 and counts at 15, 25, 35, 45: cnt=4.
    4) So the print is 3 or 4 depending on scheduling order: the code has a race and the result is not defined.
    5) Fix: drive the release a small delay after the edge (#1), or from a clocking block. The DUT then reads the old, still-asserted value at t=15, and cnt=3 in every tool.

    Answer

    Answer: It is a race: cnt prints 3 or 4 depending on which process the simulator runs first, and the language defines neither. Driven a small delay after the edge (or from a clocking block), the DUT reads the old value at t=15 and every tool prints cnt=3.

    How this was checked

    Checked by running the code in Icarus Verilog 13 and Verilator 5; the printed output supports the answer above. Icarus, fixed testbench (release 1 ns after the edge): deterministic cnt=3. Verilator, fixed testbench: the same value, as the fixed version has no race. The blocking version is deliberately not run: its result is undefined by the language.

    Why candidates get it wrong

    Reporting whatever number your simulator printed. A single tool's order is an implementation detail and can change with a version, a switch or a seed. The only acceptable answer is that the result is undefined; the check below therefore runs only the fixed testbench.

    Interviewer follow-up

    Why does driving through a clocking block remove the race, and what does the DUT see on the first edge after release? Model answer: the clocking block drives its outputs a defined skew after the edge (in a later region), so the DUT reads the old, still-asserted reset at the edge; it sees the release at the next edge, exactly as with the #1 delay. A non-blocking assignment in a testbench process is often suggested too, but its ordering against the DUT is tool-dependent in some simulators, so prefer a clocking block or an explicit delay.

    Related topics

    • Back to Reset Puzzles

    • Clock, Reset & CDC Puzzles section

    Previous

    241 / 293

    Next: Clock Gating & Clock Mux Puzzles

    Up next

    Up nextClock Gating & Clock Mux Puzzles

    Sign in to save progress

    Practice this lessonPrevious lessonReport an error

    See also

    • A Reset Pulse Between Two Clock Edges
    • The Counter Nobody Reset
    • Asynchronous Assert, Synchronous Release