Release Order and Reset in the Middle of Work

A reset falls at once and lets go in steps. Check the steps edge by edge. Then check what a reset does to work in progress: a bus transfer, a DMA copy, a line of output.

You Will Be Able To

  • Explain why a chip releases its resets in a fixed order, and what breaks if it does not.
  • Write the rules of a release-order checker that stays silent through every legal reset.
  • Predict what a warm reset leaves of a DMA copy that was in progress.
  • Say what software must assume after a reset that struck in the middle of work.
Lesson
V9.2
Time
26 min
Runs on
Your browser
Check
5 questions

Two resets released in the wrong order still end with both high, so an end-state test passes. This lesson checks the order edge by edge, and pulls the reset pin in the middle of a DMA copy.

A Reset in the Middle of a Copy, and the Release in StepsThe bus and core resets fall together and rise one after the other; one column is one cycle of clk_sys.
012345678910111213141516171819202122232425262728293031323334resetn_sysresetn_coreclk_aonhtrans (core)IDLEboth fallbus upcore up
Scroll horizontally ↔
  1. Cycle 3

    The pin's reset arrives. The bus and the core fall in the same cycle, with no clock.

  2. Cycle 29

    26 cycles later the bus leaves reset, on a rising edge of clk_sys, through its two synchronizer flops.

  3. Cycle 31

    The core follows 2 cycles later: its first fetch finds a bus that already runs.

Recorded on ap_soc v1.5 with the bench's sample window (Verilator 5.052 2026-09-05). clk_aon is shown only at the moments clk_sys was sampled.

Before You Start

Read A Test for Every Reset Source first. How a reset is asserted at once and released through flops is taught in Reset Architecture. DMA tests are in Scenarios That Cross Blocks.

Five questions this page answers
Question
1Why must the bus leave reset before the core?
2What rules does a release-order checker hold, and which legal behaviour must it allow?
3What happens to a DMA copy when the chip is reset in the middle?
4Why is a reset request held until its reset arrives?
5What must a test assume after a reset that cut its work short?

The Idea: Fall Together, Rise in Steps

Three Release StepsAt power-up ap_crg releases the always-on logic, then the bus, then the core. A warm reset releases the bus, then the core.
  • Clock / reset
  • Bus
  • Processor
  • Reset
Three Release StepsAt power-up ap_crg releases the always-on logic, then the bus, then the core. A warm reset releases the bus, then the core. clock reset Cause gone pin, watchdog,software clock reset Always-on logic power-on only bus Bus andperipherals 4 clk_aon edges later processor Core 2 clk_aon edgesafter the bus stretch, then twoclk_sys flopsthen the core
  1. clock reset Cause gonepin, watchdog, software
    • stretch, then two clk_sys flops → Bus and peripherals
  2. bus Bus and peripherals4 clk_aon edges later
    • then the core → Core
  3. processor Core2 clk_aon edges after the bus
  4. clock reset Always-on logicpower-on only
  1. The bus first

    The bus leaves reset 4 edges of clk_aon after the cause has gone.

  2. Then the core

    The core follows 2 edges later, so its first fetch finds a running bus.

Read the diagram as text
  • Cause gone: pin, watchdog, software
  • Always-on logic: power-on only
  • Bus and peripherals: 4 clk_aon edges later
  • Core: 2 clk_aon edges after the bus
  • Cause gone → Bus and peripherals: stretch, then two clk_sys flops
  • Bus and peripherals → Core: then the core

ap_crg.sv: HOLD and HOLD_CORE, each request through ap_reset_sync on clk_sys (facts 27.11).

A reset is asserted with no clock: the moment the cause appears, every flop of the domain is cleared. That is safe, because clearing needs no timing. Letting go is not. Each domain is released on its own clock, through flops, so that all its flops start on the same edge.

Between domains, the order matters. The core's first act is a fetch over the bus. If the core runs before the bus does, that fetch meets a fabric still in reset. ap_soc therefore releases the bus first and the core two cycles of clk_aon later. That order is a requirement, so the chip level checks it at every reset.

Work in progress is the other half. A reset can strike in the middle of a bus transfer, a DMA job or a printed line. Some state is lost, some survives, and the test must know which.

New Words

New words on this page
WordMeaning
Assert and releaseAsserting a reset puts flops into reset; releasing lets them run. ap_soc asserts at once and releases on a clock edge.
Release orderThe fixed sequence in which domains leave reset. At power-up on ap_soc: the always-on logic, the bus, the core. A warm reset leaves the always-on logic alone.
StretchHow long a warm reset is held after its cause has gone: 4 cycles of clk_aon on ap_soc.
Reset requestThe level a source raises to ask for a reset. ap_soc holds it until the reset arrives, then the reset clears it.
Release-order checkerA passive checker at the reset controller that reports a release in the wrong order, or a reset that never ends.
Partial resultWhat a job leaves behind when a reset stops it: some bytes copied, the rest untouched.

The Smallest Example: Counting Edges

A warm cause goes away at 100 ns. clk_aon rises at 7, 21, 35 ns and every 14 ns after. The bus waits 4 of its edges and the core 6. Each request then passes two flops on clk_sys, which rises at 5, 15, 25 ns. Work out both release times.

The release, by hand
StepTime
First clk_aon edge after 100 ns105 ns
Bus request after 4 more edges161 ns
Two clk_sys edges later: the bus175 ns
Core request two clk_aon edges after the bus's189 ns
Two clk_sys edges later: the core205 ns

The example below runs this release; the times are its output.

The core runs 30 ns after the bus here. The distance is 2 cycles of clk_aon, 28 ns. The clk_sys flops round it to 2 or 3 cycles of clk_sys, as the phase of the clocks decides. A checker must accept both.

The Rules

  1. Rule 1: The core is never out of reset while the bus is in reset.

    At every edge, resetn_core high with resetn_sys low is a bug. Check it during resets too, not only at the end.

  2. Rule 2: The core leaves after the bus, never in the same edge.

    Compare what the core does now with what the bus did at the last edge.

  3. Rule 3: Every reset ends, and every request is taken back.

    A request held for ever keeps the chip in reset. A requester outside its own reset never takes it back.

  4. Rule 4: Do not limit the length of a reset the board controls.

    The pin is held as long as the board holds it. A checker that limits the length of every reset cries wolf.

  5. Rule 5: A reset in the middle of work must not break a bus rule.

    Bus and DMA are reset together, so no transfer is left half done. The bench's AHB and APB checkers watch every edge.

  6. Rule 6: After the reset, assume only what the chip promises.

    SRAM keeps its words; registers return to their reset values; a job that was cut is not finished. Software must find out what is left.

Sources for These Rules

The release order and the stretch: tools/soc/ap_soc/rtl/ap_crg.sv (HOLD and HOLD_CORE, ap_reset_sync); facts 27.11.

The request held until its reset: ap_sysctl.sv (SOFT_RESET bit 1, facts 27.9); ap_watchdog.sv ("The reset request stays 1 until the reset arrives").

The bench's bus checkers and the rule "HTRANS is IDLE during reset": the bench README, "The end of a test" (facts 27.12).

SRAM keeps its words through a warm reset: facts 27.9 (ap_ahb_sram: only the wrapper's control flops are reset).

The Lab: A Pin Reset in the Middle of a Copy

The firmware fills 1,024 bytes at 0x8000_4000, clears the destination at 0x8000_6000 and starts one DMA copy. It writes event 0x92 and waits. The bench's table waits for that event, then 300 more cycles, and pulls the reset pin for 200 ns. The program runs again, finds TB_ARG set and reports what the reset left.

The event, and the two lines of the second boot.
EVENT 13562: 00000092
CONSOLE 25829: cause 00000003 dma status 00000000
CONSOLE 26247: copied 00000036 stray 00000000

Rule 6 at work: the copy was cut after 54 bytes. The rest of the destination still held the zeros of the clear (stray 0). The DMA's STATUS read 0: not BUSY, not DONE. The reset stopped the job and cleared its record. RESET_CAUSE read 0x03: power-on, then the pin.

Rules 1 and 2 at work, in the waveform at the top. The bus and the core fell together and rose bus first. The bench's AHB and APB checkers watched every edge of the run and found nothing: rule 5.

The reset lasted 26 cycles of clk_sys: 200 ns of the pin, its synchronizer, and the stretch. The core left 2 cycles after the bus, 20 ns. At power-up, lesson V3.2 recorded 30 ns: the same 28 ns of clk_aon, rounded to another number of clk_sys cycles.

Why It Is Built This Way

Why hold a request until its reset arrives? Because the request may come from one clock and the reset controller runs on another. A pulse of one clk_sys cycle could be missed by clk_aon; a level cannot. The reset then clears the requester, so the request ends by itself.

Why reset the DMA with the bus? A manager reset alone, while the fabric runs, can leave a transfer half done on the bus. Resetting both together means no transfer survives the reset at all. V9.6 shows a reset that reaches only part of the chip, and what it breaks.

Traps

The first trap is a checker written for the release at power-up only. It says "once the bus is up, it stays up", and reports at the first warm reset. A release-order checker must hold through every reset, again and again.

The second is a checker that limits how long a reset lasts. The board holds the pin as long as it likes; a test may hold it for a long time on purpose. Limit the length of a request that should end, not of a reset the board controls.

The third is a test that assumes the job it started has finished. After a reset, a DMA job may be cut, and its STATUS says nothing about how far it got. A test that checks the whole destination reports a chip bug that is really its own assumption.

At Scale

ap_soc~12 blocks
Phone-class SoChundreds of blocks

This section looks ahead. ap_soc has three release steps.

  1. Long release sequences

    Large chips release tens of domains in a planned order: memories, fabrics, clusters, cores, accelerators. The order is a table in the specification, and a checker reads it.

  2. Reset during traffic

    Teams raise resets at random moments under heavy traffic. They check that no bus rule breaks and every block comes back clean.

  3. Quiesce before reset

    Some chips stop traffic before a warm reset: a handshake that drains the bus. Then the test checks the drain as well.

Try It

Run it: the release times of the bus and the core after one cause.

Count the clk_aon edges between the cause going away and the bus's request.

Change STRETCH to 2. Does the order change, or only the times?

RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: cause gone at 100 ns bus released at 175 ns core released at 205 ns

Check Yourself

Predict the outputSTRETCH is now 2. What is the last line printed?
// The release order of ap_crg (tools/soc/ap_soc/rtl/ap_crg.sv), cut down to one warm cause: the bus waits
// STRETCH cycles of clk_aon after the cause is gone, the core STRETCH + 2. Each request then passes ap_reset_sync on clk_sys.
// ap_reset_sync: a reset for one clock domain. It is asserted at once, with no clock, when the
// request falls, and released on the second rising edge of clk after the request is gone, so
// every flop of the domain leaves reset in the same cycle (facts 11, S5.5).
// Plan: docs/soc-verification-plan.md section 3.8, stage E4.
module ap_reset_sync (
  input  logic clk,       // the clock of the domain
  input  logic arst_n,    // the request, active low, from any domain
  output logic resetn     // the reset of the domain, active low
);
  logic first_q;  // first flip-flop: its D input is tied to 1

  always_ff @(posedge clk or negedge arst_n) begin
    if (!arst_n) begin
      first_q <= 1'b0;
      resetn  <= 1'b0;
    end else begin
      first_q <= 1'b1;
      resetn  <= first_q;
    end
  end
endmodule

module tb;
  localparam int STRETCH = 2;
  logic clk_sys = 0, clk_aon = 0, cause = 1;
  logic [3:0] bus_count = STRETCH, core_count = STRETCH + 2;
  logic bus_req_n = 0, core_req_n = 0;
  wire resetn_sys, resetn_core;
  initial begin #5; forever begin clk_sys = 1; #5; clk_sys = 0; #5; end end    // rising at 5, 15, 25 ns
  initial begin #7; forever begin clk_aon = 1; #7; clk_aon = 0; #7; end end    // rising at 7, 21, 35 ns
  always @(posedge clk_aon) begin
    bus_count  <= cause ? 4'(STRETCH) : (bus_count != 0 ? bus_count - 1 : 0);
    core_count <= cause ? 4'(STRETCH + 2) : (core_count != 0 ? core_count - 1 : 0);
    bus_req_n  <= !cause && bus_count == 0;
    core_req_n <= !cause && core_count == 0;
  end
  ap_reset_sync sys_sync (.clk(clk_sys), .arst_n(bus_req_n), .resetn(resetn_sys));
  ap_reset_sync core_sync (.clk(clk_sys), .arst_n(core_req_n), .resetn(resetn_core));
  initial begin
    #100 cause = 0;
    $display("cause gone at 100 ns");
  end
  always @(posedge resetn_sys) $display("bus released at %0t ns", $time);
  always @(posedge resetn_core) begin $display("core released at %0t ns", $time); #1 $finish; end
endmodule
ConceptWhy does ap_soc release the bus before the core?
ConceptIn the lab, what did the DMA's STATUS read after the pin reset?
ConceptWhich rule makes a release-order checker cry wolf at a long pin reset?
ConceptWhy does ap_soc hold a reset request until the reset arrives?

Common Mistakes

Wrong Check only that both resets are high at the end.

A wrong order leaves the same end state and races at the first fetch.

Fix Check the order at every edge of every release.

Wrong Limit how long any reset of the bus may last.

The board controls the pin; a long pin reset is legal.

Fix Limit how long a request may outlive its reset.

Wrong Assume a DMA job finished because the chip came back.

A warm reset stops the job and clears its STATUS.

Fix After a reset, find out what is left, then start the job again.

Remember

  • Resets fall at once and rise in steps: the bus, then the core; at power-up the always-on logic goes first.
  • A release-order checker holds through every reset and allows long resets the board controls.
  • A warm reset stops a DMA job and clears its STATUS; SRAM keeps the bytes already copied.
  • After a reset in the middle of work, a test finds out what is left before it goes on.

Practice

Report a problem with this page