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

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • RTL Foundations36
  • Combinational Design25
  • Sequential Design27
  • FSM & Control27
  • Timing & Clocking39
  • Reset & CDC34
  • Memory & Buses57
  • Advanced RTL28
  • Senior & Interview76
    • Low-Power RTL Hub
    • DFT and Scan Hub
    • Physical Awareness Hub
    • Waveform Debug Hub
    • STA and ECO Hub
    • RTL-to-Implementation Closure
    • DFT-Ready RTL
    • Capstone: Resilient Streaming Peripheral
    • Principal Design Review
    • Senior RTL Interview Questions & Model Answers
      • Interview: Combinational and Arithmetic
      • Interview: Sequential and Pipelines
        • Blocking vs non-blocking: the race demo
        • Pipeline latency vs throughput
        • Stalling without deadlock
        • Enables, resets and counters
      • Interview: FSM and Control
      • Interview: Timing and STA
      • Interview: CDC and Reset
      • Interview: Memories and Buses
      • Interview: Low-Power Design
      • Interview: Debug and ECO
      • Interview: Coding and Whiteboard
  • Glossary and Notation
Loading lesson

‹Interview: Sequential and Pipelines
  1. Topics
  2. RTL Design
  3. Senior & Interview
  4. Senior RTL Interview Questions & Model Answers
  5. Interview: Sequential and Pipelines
  6. Enables, resets and counters

Part 9 · Senior · Senior

Enables, resets and counters

Reset, enable, and load priority in a counter, with wrap and full-state coverage in the testbench.

On this page

    Why this matters

    A loadable counter with enable and reset hides three corner questions: what wins when load and enable arrive together, when terminal count is high, and which registers need a reset at all.

    After this lesson you can: write a counter with reset, load and enable in a documented priority, place terminal count correctly, and justify the reset style.

    The question

    The interviewer asks for a loadable counter with enable and reset, then presses on the corners: load and enable together, the wrap cycle, and reset style. The question fuses two common questions into one whiteboard exercise.

    What is really under test is control priority and state coverage. The candidate must fix an order for simultaneous controls and prove every state is reachable.

    Model answer

    Priority is reset first, then load, then enable. Simultaneous load and enable loads; reset beats both. Document the order in the code so review never re-derives it.

    Reset only what the protocol needs, usually the control state. Datapath registers that are always written before use need no reset, which saves area and eases timing.

    Control

    Priority

    Behaviour

    Reset

    Highest

    Count returns to zero on the next edge (synchronous) or at once (asynchronous assert).

    Load

    Middle

    Count takes the load value, even with enable high.

    Enable

    Lowest

    Count advances by one; low holds the value with the clock still running.

    Terminal count

    Status, not control

    High exactly while count holds all ones, one cycle before the wrap.

    The if/else chain of load_cnt as hardware: the enable mux sits furthest from the flop, the load mux nearest, and reset bypasses both as the asynchronous clear.

    Read right to left from the flop: whatever is closest to D overrides everything to its left.

    • load = 1: the load mux passes load_val, whatever en chose.

    • load = 0: the en mux decides between count + 1 and holding count.

    • rst_n low: clears the flop directly, so reset never sits in the D path.

    Either reset style is acceptable if applied per the project's reset policy. This counter takes an active-low asynchronous reset with synchronized release assumed at the domain level, the common reusable form.

    Follow-ups

    Synchronous or asynchronous reset, and why? Async-assert/sync-release works without a running clock and keeps reset off the D-path, but the release must be synchronized to avoid recovery/removal failures. Synchronous reset needs a running clock and adds logic to the D-path, but is simpler for timing and STA and has no recovery/removal checks.

    Load and enable arrive together with different values. Which wins? Load, by the documented priority. The testbench below asserts it with enable held high during the load.

    How do you prove the wrap is correct? Walk the full state space: sixteen enables from reset must visit every value exactly once, with terminal count high only on fifteen.

    Common wrong answers

    A weaker candidate resets every register including the datapath. Unneeded resets add routing and load to the reset tree and block retiming across the boundary.

    Another builds the enable by gating the clock. Clock gating needs a glitch-free cell and DFT handling; a synchronous enable on the data path holds state with none of that.

    A third flags terminal count one cycle late, on the wrap itself. Terminal count means the last value is present now, so downstream logic can act in the same cycle as the wrap.

    Common pitfall

    An enable that is really a clock gate in disguise (clk & en feeding flop clocks) breaks scan and invites glitches. Keep the clock free-running and gate the data update with the enable.

    Interview

    Write the priority as code order: reset branch, then load branch, then enable branch. Reviewers read priority top to bottom.

    Check yourself Load is high with value ten while enable is high. What does the counter hold after the edge?

    Ten. Load outranks enable, so the advance is skipped for that cycle.

    Check yourself The counter holds fifteen with enable high. What are terminal count and the next value?

    Terminal count is high now. The next value is zero; fifteen is the last state, not the wrap itself.

    Solution and testbench

    A loadable counter plus the testbench that checks priority, wrap, terminal count, and full-state coverage.

    load_cnt.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    module load_cnt #(parameter int W = 4) (
      input  logic         clk, rst_n, en, load,
      input  logic [W-1:0] load_val,
      output logic [W-1:0] count,
      output logic         tc
    );
      assign tc = (count == {W{1'b1}});              // high on the last value, before the wrap
      always_ff @(posedge clk or negedge rst_n)
        if (!rst_n)      count <= '0;                // reset wins over everything
        else if (load)   count <= load_val;          // load beats enable
        else if (en)     count <= count + 1'b1;      // enable advances, low holds
    endmodule
    

    Remember

    • Priority is reset, then load, then enable; load and enable together loads.

    • Terminal count is high while the last value is present, not on the wrap itself.

    • Reset only the control state; datapath registers written before use need none.

    Rule of thumb: keep the clock free-running and gate the data update with the enable.

    Keep going

    • Practice: Parameterised up/down counter with load, enable and wrap or saturate

    • Code lab: Counter with load

    • Interview: run a mock interview on this topic

    Related topics

    • Synchronous reset and register enable

    • Up/down counter with reload

    Previous

    320 / 350

    Next: Interview: FSM and Control

    Up next

    Up nextInterview: FSM and Control

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • Blocking vs non-blocking: the race demo
    • Pipeline latency vs throughput