Reset Across Clock Domains, the Reset Tree and Scan

One reset synchronizer makes a clean release for one clock. A chip has several clocks, a hundred thousand flip-flops on each, and a factory tester that wants the reset for itself.

You Will Be Able To

  • Explain why each clock domain needs a reset synchronizer of its own.
  • Say what limits the delay of a reset tree, and what happens beyond the limit.
  • Explain why a tester must control every reset during scan.
Lesson
S5.12
Time
26 min
Runs on
Your browser
Check
6 questions

The reset synchronizer was added, reviewed and signed off. The real-time clock still starts wrong once in a few hundred boots. Its flip-flops use the reset that the synchronizer makes. Whose clock is that reset in step with?

Before You Start

You need Reset Architecture: assert with no clock, release in step with the clock, and the two-flop reset synchronizer.

You need Planning Clock Domains: unrelated clocks share no edges. You need Clock Sources and the Chip-Level Clock Tree: a tree of buffers, and its delay.

Five questions this page answers
Question
1Why does each clock domain need a reset synchronizer of its own?
2A reset released in step with the core clock feeds a flip-flop on the RTC clock. What is wrong?
3What limits the delay of a reset tree?
4What happens to a leaf that the release reaches too late?
5Why does a tester control every reset during scan?

The Idea: A Release Belongs to One Clock

A reset synchronizer releases its reset just after an edge of one clock. That is what makes the release safe. It is safe for that clock only.

A chip has clocks that share no edges. Feed the release of one clock to flip-flops on another, and for them it comes at any moment. Some day it lands right beside one of their edges. All the trouble of a raw release is back. So the first rule is short: one reset synchronizer for each clock domain.

Inside one domain there is a second job. The local reset must reach every flip-flop of the domain. It is spread through buffers, in a reset tree. The release leaves the synchronizer just after a clock edge. It must be at every leaf before the next edge. A tree that is slower than that puts some flip-flops a cycle behind the rest.

The third job comes at the factory. To test a chip, a machine called the tester loads patterns into its flip-flops and reads them back. A reset that fires on its own would wipe a pattern. So the chip has a test mode, in which the tester gets direct control of every reset.

New Words

New words on this page
WordMeaning
Reset treeThe buffers and wires that carry one local reset to every flip-flop of its domain.
Reset tree delayThe time from the output of the synchronizer to the clear input of a flip-flop.
TesterThe machine at the factory that drives the pins of a new chip and checks its answers.
Scan chainThe flip-flops of a chip, linked in test mode into one long shift register that the tester can load and read.
Test modeA state of the chip, chosen by a pin, in which the tester controls clocks and resets.
Inner resetA reset made inside the chip: by a watchdog, by software, or by a reset synchronizer.
Reset bypassA mux that, in test mode, feeds a clear input from the reset pin of the tester.

One Picture: Two Domains and a Tester

One Reset Pin, Two Clocks, One TreeStep through the picture. It starts with a wrong wiring and ends with the tester in control.
  • Pads
  • Memory
  • Clock / reset
  • Processor
  • Peripheral
  • Debug
One Reset Pin, Two Clocks, One TreeStep through the picture. It starts with a wrong wiring and ends with the tester in control. component Reset pin released at a momentof its own component Coresynchronizer two flip-flops on thecore clock component RTC synchronizer two flip-flops on theRTC clock component Reset tree buffers that spreadthe core reset component Core flip-flops on the core clock,period 10 ns component RTC flip-flops on the RTC clock,period 14 ns component Tester a machine at thefactory, on its ownreset pin clearclearcore resetto every leafwrong: core resetRTC resetin test modein test mode
  1. component Reset pinreleased at a moment of its own
    • clear → Core synchronizer
    • clear → RTC synchronizer
  2. component Core synchronizertwo flip-flops on the core clock
    • core reset → Reset tree
    • wrong: core reset → RTC flip-flops
  3. component Core flip-flopson the core clock, period 10 ns
  4. component RTC flip-flopson the RTC clock, period 14 ns
  5. component RTC synchronizertwo flip-flops on the RTC clock
    • RTC reset → RTC flip-flops
  6. component Reset treebuffers that spread the core reset
    • to every leaf → Core flip-flops
  7. component Testera machine at the factory, on its own reset pin
    • in test mode → Core flip-flops
    • in test mode → RTC flip-flops
  1. One synchronizer, two clocks

    The core synchronizer makes a release that is in step with the core clock. Someone wires that release to the RTC flip-flops as well. To the RTC clock it comes at any moment.

  2. A synchronizer for each clock

    Give the RTC domain a reset synchronizer of its own, on the RTC clock. Both are cleared by the same pin. Each releases in step with its own clock.

  3. Two releases at two times

    The two domains now leave reset at different moments. That is correct. Each moment is right for its own clock.

  4. The reset tree

    The core reset feeds very many flip-flops. Buffers spread it, as they spread a clock. The release leaves the synchronizer just after a clock edge and must reach every leaf before the next one.

  5. The tester takes over

    At the factory, a tester loads patterns into the flip-flops. In test mode a mux at each reset gives its own reset pin direct control. No reset made inside the chip can fire.

Read the diagram as text
  • Reset pin: released at a moment of its own
  • Core synchronizer: two flip-flops on the core clock
  • RTC synchronizer: two flip-flops on the RTC clock
  • Reset tree: buffers that spread the core reset
  • Core flip-flops: on the core clock, period 10 ns
  • RTC flip-flops: on the RTC clock, period 14 ns
  • Tester: a machine at the factory, on its own reset pin
  • Reset pin → Core synchronizer: clear
  • Reset pin → RTC synchronizer: clear
  • Core synchronizer → Reset tree: core reset
  • Reset tree → Core flip-flops: to every leaf
  • Core synchronizer → RTC flip-flops: wrong: core reset
  • RTC synchronizer → RTC flip-flops: RTC reset
  • Tester → Core flip-flops: in test mode
  • Tester → RTC flip-flops: in test mode

Reset in a chip with two unrelated clocks. The core clock and the RTC clock are those of the page on clock domains.

The Smallest Example, Worked by Hand

Use two clocks of our chip. The core clock has a period of 10 ns and rises at 5, 15, 25 ns and so on. The RTC clock has a period of 14 ns and rises at 7, 21, 35 ns and so on. Each domain has a reset synchronizer of two flip-flops.

The pin is released twice. Work out when each local reset rises: it is the second edge of its own clock after the release.

Two releases, two domains, by hand
Release at 14 nsRelease at 132 ns
Core edges after the release15, 25135, 145
Core reset rises25 ns145 ns
RTC edges after the release21, 35133, 147
RTC reset rises35 ns147 ns
Next RTC edge after the core reset rises35 ns147 ns
Core reset to that RTC edge10 ns2 ns
RTC reset to the next RTC edge14 ns14 ns

Read the last two rows. Suppose the core reset fed the RTC flip-flops. It would reach them 10 ns before an edge on the first press and 2 ns before one on the second. The gap changes with every press, and nothing keeps it away from 0. The RTC reset always has a whole RTC period.

Now the tree of the core domain, after the second press. The core reset rises at 145 ns and the next core edge is at 155 ns. Each buffer adds 1 ns.

Three leaves of one reset tree, by hand
LeafBuffersRelease arrivesTime left before 155 nsStarts on the edge at
Near2147 ns8 ns155 ns
Far5150 ns5 ns155 ns
Long12157 nsnone: 2 ns late165 ns

The long leaf starts a cycle after its neighbours. The synchronizer did its work, and the tree undid it.

The Rules

  1. Rule 1: Each clock domain has a reset synchronizer of its own.

    All are cleared by the same incoming reset. Each releases in step with its own clock.

  2. Rule 2: A local reset feeds only flip-flops of its own clock.

    For any other clock its release comes at any moment.

  3. Rule 3: Domains leave reset at different times.

    A signal between two domains must be safe while one of them is still in reset.

  4. Rule 4: The delay of a reset tree must be less than one clock period.

    More exactly: the period, less the recovery time of the flip-flop.

  5. Rule 5: A timing tool checks the release at every leaf.

    Reset paths are timed. They are not cut from the timing check.

  6. Rule 6: In test mode the tester controls every clear input.

    A reset bypass at each inner reset hands control to a pin. This rule is common practice.

The check of rules 4 and 5 is worked on a real cell library in Recovery and Removal. A signal that must cross between two domains while one is in reset is the subject of the next page.

Sources for These Rules

The reset synchronizer, used where the release cannot be controlled against the clock of a block: Sutherland, RTL Modeling with SystemVerilog for Simulation and Synthesis, section 8.1.5.6. Several clocks in one design: section 8.1.6.

Scan design, and what a scan chain is for: Weste and Harris, CMOS VLSI Design, fourth edition, section 15.6.2.

Rule 6, the reset bypass in test mode, is common design practice. No book in our reference library states it, so it is not quoted from one.

Rules 4 and 5 use the timing checks named in IEEE 1800-2023, clauses 31.3.4 and 31.3.5.

The clock periods, the release times and the buffer of 1 ns are numbers of our lab.

Now Run It

The lab at the end of this page has both synchronizers and a core reset tree with three leaves. It also has a scan chain of three flip-flops. It presses reset twice.

Printed by the lab on Icarus. All times are in nanoseconds.
press 1: pad released t=14
core_n rises t=25
rtc_n rises t=35
shared: core_n rises 10 ns before an RTC edge
own: rtc_n rises 14 ns before the next RTC edge
press 2: pad released t=132
core_n rises t=145
rtc_n rises t=147
shared: core_n rises 2 ns before an RTC edge
own: rtc_n rises 14 ns before the next RTC edge
near leaf: +2 ns, reset off t=147, starts t=155
far leaf: +5 ns, reset off t=150, starts t=155
long leaf: +12 ns, reset off t=157, starts t=165
scan, function mode: chain=101
inner reset fires: chain=000
scan, test mode: chain=101
inner reset fires: chain=101
tester reset pin: chain=000

Rule 1 at work: after the first press core_n rises at 25 and rtc_n at 35. Each rises on an edge of its own clock.

Rule 2, in the two "shared" rows. The core reset rises 10 ns before an RTC edge on the first press and 2 ns before one on the second. The two "own" rows both say 14 ns.

Rule 4 at work, in the three leaf rows. The near and far leaves start at 155. The long leaf gets its release at 157 and starts at 165, one cycle late.

Rule 6, in the last five rows. In function mode an inner reset wipes the pattern 101 to 000. In test mode the same inner reset changes nothing. Only the reset pin of the tester clears the chain.

This lab leaves things out. Each buffer is a delay of 1 ns, with no wire and no recovery time. A simulator of 0 and 1 cannot show a flip-flop upset by a release 2 ns before its edge. It shows only how close the release came.

Why It Is Built This Way

Design choiceThe alternativeWhat the choice buys, and costs
A synchronizer for each clockOne synchronizer on the fastest clockEvery release is in step with its own clock. Domains start at different times.
One synchronizer for a domain, then a treeA synchronizer beside every flip-flopOne release decision for the whole domain. The tree must be timed.
Time the reset treeMark every reset path as not timedA late leaf is found by a tool. The tree may need more buffers or a slower release.
A reset bypass in test modeTrust inner resets to stay quietThe tester can load and keep any pattern. A mux sits on every inner reset.

The Trap: The Synchronizer That Was There

Back to the real-time clock that starts wrong. The review asked one question: is there a reset synchronizer? There was one, on the core clock. Its output fed the whole chip, the RTC flip-flops included.

On most boots the core release fell far from an RTC edge. Once in a few hundred it fell beside one. A simulation never showed it, because the two clocks started the same way in every run.

The second trap is quieter. A chip passes every test at room temperature. In the cold its reset buffers are slower. One corner of a large block now gets its release after the clock edge. That corner starts a cycle late. Rule 5 exists to find that leaf before the chip is made.

The third trap costs money at the factory. A watchdog that nobody stopped fires in the middle of a scan pattern. Good chips fail the test and are thrown away.

At Scale

This page2 domains, 3 leaves
A phone chiphundreds of reset domains

This section looks ahead. Two domains and three leaves become a reset plan for a whole chip.

  1. A reset plan, like a clock plan

    A table lists every reset domain: its source, its clock, its synchronizer and what it may talk to while in reset.

  2. An order of release

    Some domains must be running before others start. The last page of this module puts the releases in order.

  3. Tools that read the plan

    A checking tool finds flip-flops whose reset comes from another clock. It finds signals that cross between reset domains.

  4. Test of the reset itself

    The tester also checks that each reset really clears its flip-flops. Test Hooks at Chip Level returns to scan.

Try It

Run the lab. It presses reset twice, then looks at the tree, then at the scan chain.

Change the delay of the long leaf from 12 to 9. On which core edge does it start now?

Move the second release from 132 to 120. How close is core_n to an RTC edge now?

Names Printed by the Lab
NameMeaning
pad releasedThe time at which the reset pin goes high. The lab calls the pin pad_n.
core_n, rtc_nThe local reset of the core domain and of the RTC domain. 0 means reset.
sharedWhat the wrong wiring would give: how long before an RTC edge core_n rises.
ownThe same for rtc_n, the release of the RTC synchronizer.
near leaf, far leaf, long leafThree leaves of the core reset tree, after 2, 5 and 12 buffers of 1 ns.
reset off, startsWhen the release reaches that leaf, and the core edge on which its flip-flop starts.
chainA scan chain of three flip-flops.
inner resetA reset made inside the chip, such as the one a watchdog asks for.
RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: press 1: pad released t=14 core_n rises t=25 rtc_n rises t=35 shared: core_n rises 10 ns before an RTC edge own: rtc_n rises 14 ns before the next RTC edge press 2: pad released t=132 core_n rises t=145 rtc_n rises t=147 shared: core_n rises 2 ns before an RTC edge own: rtc_n rises 14 ns before the next RTC edge near leaf: +2 ns, reset off t=147, starts t=155 far leaf: +5 ns, reset off t=150, starts t=155 long leaf: +12 ns, reset off t=157, starts t=165 scan, function mode: chain=101 inner reset fires: chain=000 scan, test mode: chain=101 inner reset fires: chain=101 tester reset pin: chain=000

Check Yourself

Predict the outputIn this run the second release is at 96 ns. The core clock rises at 5, 15, 25 ns and so on. The long leaf is 12 buffers of 1 ns from the synchronizer. What is the last row the lab prints?
`timescale 1ns/1ns
module tb;
  logic pad_n = 0;                             // the reset pad. 0 means: reset is pressed
  logic core_clk = 0, rtc_clk = 0;             // two clocks that share no edges
  always #5 core_clk = ~core_clk;              // period 10 ns
  always #7 rtc_clk = ~rtc_clk;                // period 14 ns

  // One reset synchronizer for each clock domain.
  logic core_s1, core_n, rtc_s1, rtc_n;
  always_ff @(posedge core_clk or negedge pad_n)
    if (!pad_n) begin core_s1 <= 0; core_n <= 0; end
    else begin core_s1 <= 1; core_n <= core_s1; end
  always_ff @(posedge rtc_clk or negedge pad_n)
    if (!pad_n) begin rtc_s1 <= 0; rtc_n <= 0; end
    else begin rtc_s1 <= 1; rtc_n <= rtc_s1; end

  // The reset tree of the core domain. Each buffer is modelled as a delay of 1 ns.
  wire #2 leaf_near = core_n;
  wire #5 leaf_far = core_n;
  wire #12 leaf_long = core_n;
  logic ff_near, ff_far, ff_long;              // 1 means: this flip-flop has left reset
  always_ff @(posedge core_clk or negedge leaf_near) if (!leaf_near) ff_near <= 0; else ff_near <= 1;
  always_ff @(posedge core_clk or negedge leaf_far) if (!leaf_far) ff_far <= 0; else ff_far <= 1;
  always_ff @(posedge core_clk or negedge leaf_long) if (!leaf_long) ff_long <= 0; else ff_long <= 1;

  // A scan chain of three flip-flops. Its clear comes from a reset made inside the chip,
  // or, in test mode, straight from a pin of the tester.
  logic scan_clk = 0, scan_in = 0, inner_reset_n = 1, test_mode = 0, tester_reset_n = 1;
  wire chain_clear_n = test_mode ? tester_reset_n : inner_reset_n;
  logic [2:0] chain;
  always_ff @(posedge scan_clk or negedge chain_clear_n)
    if (!chain_clear_n) chain <= 0; else chain <= {chain[1:0], scan_in};
  task automatic shift_in(input logic [2:0] bits);
    for (int i = 2; i >= 0; i--) begin scan_in = bits[i]; #1 scan_clk = 1; #1 scan_clk = 0; end
  endtask

  // When does each leaf of the tree let go, and on which core edge does its flip-flop start?
  time near_off, far_off, long_off, near_go, far_go, long_go;
  always @(posedge leaf_near) near_off = $time;
  always @(posedge leaf_far) far_off = $time;
  always @(posedge leaf_long) long_off = $time;
  always @(posedge ff_near) near_go = $time;
  always @(posedge ff_far) far_go = $time;
  always @(posedge ff_long) long_go = $time;

  time core_up, rtc_up, rtc_after_core, rtc_after_rtc;
  task automatic press(input int number, input time release_at);
    #(release_at - $time) pad_n = 1;
    $display("press %0d: pad released t=%0d", number, $time);
    fork
      begin @(posedge core_n); core_up = $time; @(posedge rtc_clk); rtc_after_core = $time; end
      begin @(posedge rtc_n); rtc_up = $time; @(posedge rtc_clk); rtc_after_rtc = $time; end
      @(posedge ff_long);
    join
    $display("core_n rises t=%0d", core_up);
    $display("rtc_n rises t=%0d", rtc_up);
    // A wrong wiring would feed core_n to flip-flops of the RTC clock. How close is it to an RTC edge?
    $display("shared: core_n rises %0d ns before an RTC edge", rtc_after_core - core_up);
    $display("own: rtc_n rises %0d ns before the next RTC edge", rtc_after_rtc - rtc_up);
  endtask

  initial begin
    press(1, 30);
    @(negedge core_clk) pad_n = 0;
    press(2, 96);
    // The tree of the core domain, after the second press.
    $display("near leaf: +2 ns, reset off t=%0d, starts t=%0d", near_off, near_go);
    $display("far leaf: +5 ns, reset off t=%0d, starts t=%0d", far_off, far_go);
    $display("long leaf: +12 ns, reset off t=%0d, starts t=%0d", long_off, long_go);

    $finish;
  end
endmodule
ConceptWhy does each clock domain need a reset synchronizer of its own?
ConceptA reset released in step with the core clock feeds a flip-flop on the RTC clock. What is wrong?
ConceptWhat limits the delay of a reset tree?
ConceptA release reaches one leaf after the next clock edge. What happens?
ConceptWhy does a tester control every reset during scan?

Common Mistakes

Wrong Use one reset synchronizer for the whole chip.

Its release is in step with one clock only.

Fix Give each clock domain a synchronizer of its own.

Wrong Leave reset paths out of the timing check.

A slow tree releases some flip-flops a cycle late.

Fix Time the release at every leaf.

Wrong Let inner resets run during scan.

A reset that fires on its own wipes the pattern.

Fix In test mode, give the tester control of every clear input.

Remember

  • Each clock domain has a reset synchronizer of its own. A local reset feeds only flip-flops of its own clock.
  • A reset tree must deliver the release to every leaf within one clock period.
  • A leaf that gets the release too late starts a cycle after its neighbours.
  • In test mode the tester controls every clear input.

Practice

Report a problem with this page