HDL & Verification

What type of reset does the code above have, and how does it behave?

always @(posedge clk or negedge rst_n)
    if (!rst_n) q <= 0;
    else        q <= d;
  1. AA synchronous reset: q becomes 0 only at a rising clock edge while rst_n is 0
  2. BAn asynchronous reset: when rst_n goes to 0, q becomes 0 immediately without waiting for a clock
  3. Cq becomes 0 when rst_n goes to 1
Show answer and explanation

Answer: B. An asynchronous reset: when rst_n goes to 0, q becomes 0 immediately without waiting for a clock

Because "negedge rst_n" is in the sensitivity list, the block also runs the instant rst_n falls from 1 to 0, and q becomes 0 regardless of the clock. This is an asynchronous reset. The "_n" suffix is a convention for active-low signals. It can reset even when the clock is stopped, but the timing of reset release needs care.

  • A. The reset edge is also a trigger, so it is not synchronous.
  • B. Correct. The reset edge is in the sensitivity list.
  • C. _n indicates active-low.
Practice this topic Back to topic

More HDL & Verification questions

  1. What is the difference between synchronous and asynchronous resets?
  2. In circuits using asynchronous reset, why is reset release (the 0-to-1 transition) synchronized to the clock through two flip-flops before distribution?
  3. What is the basic structure of a state machine written in an HDL?
  4. In the state machine above, why does the second always block begin with "next = state;"?
  5. What characterizes a Mealy state machine?