Draft preview. Lessons are being written and reviewed.

Digital Design / Module 4: Sequential logic

23. Synchronous and asynchronous resets

Choose a reset style and defend it.

Lecture coming soon

See it move

The idea

Flops power up with unknown values, so a reset brings a design to a known state. There are two styles.

// Synchronous: acts only at a clock edge
always_ff @(posedge clk)
  if (rst) q <= 1'b0;
  else     q <= d;

// Asynchronous: acts immediately
always_ff @(posedge clk or negedge rst_n)
  if (!rst_n) q <= 1'b0;
  else        q <= d;

Comparing them

SynchronousAsynchronous
Needs a running clockYesNo
Effect on the data pathAdds logic in front of DUses a special flop
on reset lineIgnored between edgesResets the flop
DangerShort pulses can be missedRelease near an edge

The danger of releasing a reset

Applying an async reset is safe at any time. Releasing it isn't. If reset goes away too close to the clock edge, flops may go , or some flops may leave reset a cycle before others. The checks for this are recovery (release must come far enough before the edge, like setup) and removal (it must come far enough after, like hold).

The standard answer

Assert asynchronously and de-assert synchronously. A reset does this; you can see it in the Reset synchronizers lesson.

always_ff @(posedge clk or negedge arst_n)
  if (!arst_n) {r2, r1} <= 2'b00;
  else         {r2, r1} <= {r1, 1'b1};

assign rst_n = r2;

Common mistake

Resetting everything. Data registers in large datapaths often don't need a reset; only the control logic and valid bits do. Skipping reset on them saves area and routing. Be sure that nothing depends on their values before the first valid write, though.

Key ideas

  • Sync reset needs a clock edge; async acts immediately.
  • Async assert with sync de-assert is the usual safe pattern.
  • De-assertion has recovery and removal checks.

Your exercise

Write a reset synchronizer.

Find the bug

This code has one deliberate bug. Read the symptom, then click the line you think is wrong.

What goes wrong: This flop should reset at once, even with no clock running. It clears only at the next clock edge.

Interview questions

coreWhat are recovery and removal?

basicWhat is the difference between a synchronous and an asynchronous reset, and which one works when the clock is not running?

basicWhy do flops need a reset at all, and what happens in simulation to a toggle flop, q <= ~q, that has none?

coreThis flop is meant to have an active-low asynchronous reset. In simulation, when rst_n is released between clock edges, q takes the value of d immediately, without any clock edge. Why?

always @(posedge clk or rst_n)
  if (!rst_n) q <= 1'b0;
  else        q <= d;

coreIn this reset synchronizer, arst_n is released between clock edges. After how many rising clock edges does rst_n go high, and how quickly does it go low when arst_n is asserted again?

always @(posedge clk or negedge arst_n)
  if (!arst_n) {r2, r1} <= 2'b00;
  else         {r2, r1} <= {r1, 1'b1};

assign rst_n = r2;

coreAsserting an asynchronous reset is safe at any time, but releasing it is not. What goes wrong if the release lands close to a clock edge?

coreA synchronous-reset design is reset with a pulse lasting 3 ns, on a 10 ns clock. Sometimes the design resets and sometimes it does not. Why?

advancedIn a large datapath, which registers really need a reset, and what do you gain and risk by leaving the others without one?

advancedIn the two-flop reset synchronizer, why is there no metastability concern when reset is asserted, and why does the release need two flops rather than one?

Practise these 9 questions with animations