The First Run

The first run of a new chip proves that power, clocks, resets, the boot path and the bench channel all work together. Run the pre-built chip from power-good to "hello". Then learn the three views you will use every day: the console, the trace and the waves.

You Will Be Able To

  • Put the first run of ap_soc in order: power-on reset, clocks, resets, first fetch, main, pass.
  • Read the console, the result block and the retire trace of a run.
  • Choose between the console, the trace and the waves for a question.
  • Explain why "hello" on the console is not yet a pass.
Lesson
V2.2
Time
26 min
Runs on
Your browser
Check
5 questions

Day one of integration. The chip compiles, the bench compiles, and someone types the run command for the first time. Either a line of text appears, or nothing does and the hunt begins in clocks, resets and boot code.

From Power-Good to HelloStep through the first run of the chip. Times in ns are from the probe; cycles are counted by the bench from the release of the bus reset.
  • Power
  • Clock / reset
  • Memory
  • Processor
  • Peripheral
  • Power
  • Clock
  • Reset
  • Data
From Power-Good to HelloStep through the first run of the chip. Times in ns are from the probe; cycles are counted by the bench from the release of the bus reset. power Power-on reset released at 13 ns clock reset Clocks RC ready 45 ns; PLLlocked 165 ns;clk_sys on the PLL260 ns clock reset Resets bus at 375 ns, coreat 405 ns memory Boot ROM first fetch at 415 ns processor Core start-up code, thenmain peripheral Mailbox TB_STATUS,TB_PUTC inap_sysctl start oscillatorsclock runningfetch from 0instructionsstatus, characters
  1. power Power-on resetreleased at 13 ns
    • start oscillators → Clocks
  2. clock reset ClocksRC ready 45 ns; PLL locked 165 ns; clk_sys on the PLL 260 ns
    • clock running → Resets
  3. clock reset Resetsbus at 375 ns, core at 405 ns
    • fetch from 0 → Boot ROM
  4. memory Boot ROMfirst fetch at 415 ns
    • instructions → Core
  5. processor Corestart-up code, then main
    • status, characters → Mailbox
  6. peripheral MailboxTB_STATUS, TB_PUTC in ap_sysctl
  1. 13 ns: power is good

    The power-on reset cell lets go. Every flop is still held in reset, and the oscillators start.

  2. 45 to 260 ns: clocks

    The RC oscillator runs first. The PLL locks on the reference, and clk_sys switches to it without a short pulse.

  3. 375 and 405 ns: resets, in order

    The bus leaves reset first. The core follows two cycles of the always-on clock later, so the bus is ready for its first fetch.

  4. 415 ns: the first fetch

    The core asks the boot ROM for address 0. From here the bench counts cycles.

  5. Cycle 152: main entered

    Start-up code writes 1, then 2 to TB_STATUS. The bench now knows the test really started.

  6. Cycle 807: pass

    main prints two lines through TB_PUTC and returns 0; the kit writes the pass word.

Read the diagram as text
  • Power-on reset: released at 13 ns
  • Clocks: RC ready 45 ns; PLL locked 165 ns; clk_sys on the PLL 260 ns
  • Resets: bus at 375 ns, core at 405 ns
  • Boot ROM: first fetch at 415 ns
  • Core: start-up code, then main
  • Mailbox: TB_STATUS, TB_PUTC in ap_sysctl
  • Power-on reset → Clocks: start oscillators
  • Clocks → Resets: clock running
  • Resets → Boot ROM: fetch from 0
  • Boot ROM → Core: instructions
  • Core → Mailbox: status, characters

The first run of the lab image on ap_soc v1.5 (ROM layout).

Before You Start

Read The Specification Is Data and Before main first. Clocks and resets are taught in the SoC Architecture track, Clock Sources and the Chip-Level Clock Tree.

Five questions this page answers
Question
1Why is the first run its own milestone?
2In what order does the chip come out of power-up?
3What do the console, the trace and the waves each show?
4How do you read the result block?
5Why is a greeting on the console not yet a pass?

The Idea: Everything Has to Work at Once

A block bench can start one block at a time. A chip cannot. Before the first instruction, the power-on reset must release and two oscillators must start. Then the PLL must lock, the clock must switch, and the resets must let go in the right order. Then the core fetches from ROM, start-up code runs, and the firmware talks to the bench through the mailbox.

So the first run tests the whole spine of the chip in one go. When it fails, the cause can be anywhere, and you need to know which view to open. When it passes, every later test builds on it.

New Words

New words on this page
WordMeaning
Power-on resetA cell that holds the chip in reset until the supply is good, then lets go once.
PLL lockThe moment the PLL's output is stable; until then clk_sys runs from the RC oscillator.
Reset release orderWhich part leaves reset first: here the bus, then the core.
ConsoleThe lines the firmware writes through TB_PUTC; the bench prints each with its cycle.
Result blockThe key=value lines the bench prints at the end: verdict, reason, counters.
Retire traceOne line per instruction the core finished: cycle, pc, instruction, effect.
WavesThe values of chosen signals over time, from a probe beside the bench.
Bring-up ladderThe order for debugging a run that prints nothing: clocks, resets, first fetch, start-up code, main.

The Smallest Example: Read a Result Block

The lab program prints a greeting, the chip identity and the straps, then returns 0.

The lab program, built for the ROM layout.
#include "hal.h"
#include "tb.h"

int main(void)
{
    tb_puts("hello from ap_soc\n");
    tb_puts("chip ");
    tb_put_hex(reg_read32(SYSCTL_CHIP_ID));
    tb_puts(" straps ");
    tb_put_hex(reg_read32(SYSCTL_STRAPS));
    tb_putc('\n');
    return 0;
}

Here are some keys of its result block. Read them before anything else; they say how the run ended and what it touched.

Keys of the result block
KeyValueMeaning
verdict, reasonpass, passHow the run ended, by the bench's rules
main_entered1TB_STATUS = 2 was written: the test really started
cycles, retired815, 440clk_sys cycles after the bus reset; instructions finished
compares, mismatches440, 0Records checked against the reference model; how many differed
checker_errors0Broken bus rules, block monitor errors, bench errors
visited0089Regions touched: bits 0 ROM, 3 SRAM, 7 ap_sysctl
console_bytes48Bytes written to TB_PUTC

Measured on our bench (soc_tb on Verilator 5.052 2026-09-05; riscv64-unknown-elf-gcc 14.2.0, -Os). cycles and retired change with the compiler.

Three Views, Three Prices

The console is what the firmware chose to say. It is cheap and short, and it is only as good as the program's honesty. The retire trace is what the core actually did, one line per instruction: precise, but thousands of lines. The waves show any signal you probe, inside or outside the core. They are the only view of clocks and resets, and the most expensive to record.

Open them in that order. The console and the result block tell you whether and where to look. The trace finds the instruction that went wrong. The waves explain why a wire did what it did.

When the Console Stays Empty

The bad day of the opening is common: the first run prints nothing at all. Then the cheap views have nothing to say. So you walk the spine from the bottom up and stop at the first step that did not happen. Every later step depends on it, so fixing a later one first wastes the day.

The bring-up ladder: the first rung that fails is the bug
RungWhere you lookWhat a failure there looks like
1. ClocksWaves: osc_ready, pll_locked, on_pllclk_sys never switches to the PLL, so the chip may never leave reset
2. ResetsWaves: resetn_sys, then resetn_coreThe core is held in reset: no fetch, retired = 0
3. First fetchWaves: fetch; the first trace recordThe pc is not the reset vector, or ROM is empty: on ap_rv32 the core traps at address 0 for ever
4. Start-up codeTrace: the stores of TB_STATUS = 1, then 2main_entered = 0: main never ran
5. mainResult block, then the consoleverdict and reason name what ended the run

Signal names are the probe lanes of this page. Rung 3: with mtvec at 0, a trap at an empty address jumps straight back to it (facts ledger DIG-111).

The same ladder works for any chip. Only the names change. Climb it in order, and the first broken rung is where the bug lives.

The Rules

  1. Rule 1: Read the result block first.

    verdict and reason come from the bench's rules, not from what the firmware printed.

  2. Rule 2: Power-up has an order.

    Power-on reset, clocks, PLL lock, clock switch, bus reset, core reset, first fetch.

  3. Rule 3: Count cycles from the bus reset.

    Every cycle number in a console line, a trace row or a result block starts there.

  4. Rule 4: Use the cheapest view that answers the question.

    Console, then trace, then waves.

Sources for These Rules

The power-up numbers of the analog model and ap_crg: docs/soc/ap_soc-facts.md 27.1 and 27.11.

The bench's result block, console lines and cycle count: tools/soc/ap_soc/bench/soc_tb/README.md; facts 27.12.

What a run costs on this bench: docs/soc-verification-plan.md section 6.2 and facts 27.13.

Now Run It: Power-Good to Hello

The lab image ran on the chip bench. The bench printed two console lines, each with the cycle of its newline, then its result block.

The bench's console lines, measured on our bench (soc_tb on Verilator 5.052 2026-09-05; riscv64-unknown-elf-gcc 14.2.0, -Os).
CONSOLE 375: hello from ap_soc
CONSOLE 788: chip 2a5310c5 straps 00000000

The same image ran again on an Icarus build of the bench with a probe beside it. The probe sampled seven signals every 20 ns.

Power-Up, Sampled Every 20 ns
01234567891011121314151617181920212223por_nosc_readypll_lockedon_pllresetn_sysresetn_corefetchpor_nlockPLLbuscore
Scroll horizontally ↔

One column every 20 ns from 1 ns, recorded by a probe beside soc_tb (Icarus 12) on the lab image. The lane on_pll is 1 once clk_sys comes from the PLL; fetch is the core's first instruction request.

Walk the waves with rule 2. por_n rises at 13 ns, the RC oscillator is ready at 45 ns, and the PLL locks at 165 ns. At 260 ns clk_sys moves to the PLL. The bus leaves reset at 375 ns and the core at 405 ns. The first fetch is at 415 ns.

Then the trace takes over. The core's first records set gp and sp, as in the start-up lesson. The console says hello at cycle 375, and the run passes at cycle 807. 440 records matched the model, and no checker complained: rule 1, read before the console.

The first four records of the retire trace.
    9 | 00000000 | auipc gp, 0x80001          | x3 = 80001000
   10 | 00000004 | addi gp, gp, -2048         | x3 = 80000800
   11 | 00000008 | auipc sp, 0x80010          | x2 = 80010008
   12 | 0000000c | addi sp, sp, -8            | x2 = 80010000

Why It Is Built This Way

Why does the firmware talk through the mailbox and not through UART0? A UART byte costs 80 cycles at the test divider, and its pad needs the pin mux set first. A mailbox write costs one bus transfer, and works before any peripheral is set up. Only tests of the UART itself pay for the UART.

Why does the bench count cycles from the bus reset, not from time 0? Because power-up takes a fixed few hundred ns that no test can change. Counting from the bus reset makes every test's numbers comparable.

The Trap: Hello Before the Verdict

The first console line arrives and the team cheers. But the console is only what the firmware said. The same run could have broken a bus rule, disagreed with the reference model, or never written a pass word. Each of those shows in the result block, not on the console.

So make it a habit: read verdict and reason, then the error counters, and only then the console. A run that prints every line you hoped for and ends with reason checker has failed. The practice problems give you a first run that never says hello at all.

At Scale

ap_soc~12 blocks
Phone-class SoChundreds of blocks

This section looks ahead. The lab run takes about 800 cycles after reset.

  1. Long boots

    A product boot loader can take millions of cycles before main. Teams keep a fast path for most tests, like the back-door SRAM layout, and test the full boot separately (module V9).

  2. Waves on demand

    Recording waves for a whole chip is slow and huge. Benches record them only for a failing test, often only for a window around the failure.

  3. First silicon

    On the first real chips, the same "hello" test is often the first program run. The mailbox is replaced by a UART or a debugger, but the order of power-up is the same.

Try It

Run the slice: it rebuilds the console from the writes the run made to TB_PUTC and TB_STATUS.

Compare its cycles with the bench's console lines above. The slice uses the cycle the store retired, so they can differ by one.

Move the pass write before the second line. Predict what the slice prints.

RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: STATUS 23: boot ROM reached STATUS 152: main entered CONSOLE 376: hello from ap_soc CONSOLE 789: chip 2a5310c5 straps 00000000 STATUS 807: pass

Check Yourself

Predict the outputA made-up variant: the program writes 0xBAD00007 to TB_STATUS just before the pass word. What is the last line the slice prints?
// The writes one run made to ap_sysctl's mailbox, in order, as the retire trace recorded them.
// A slice of the bench's monitor: build console lines; the first pass or fail word ends the test.
module tb;
  localparam int N = 52;
  int          cycle [N];
  logic [7:0]  offset [N];
  logic [31:0] data [N];
  string line = "";
  bit done = 0;
  initial begin
    cycle[0] = 23; offset[0] = 8'h20; data[0] = 32'h00000001;
    cycle[1] = 152; offset[1] = 8'h20; data[1] = 32'h00000002;
    cycle[2] = 172; offset[2] = 8'h24; data[2] = 32'h00000068;
    cycle[3] = 184; offset[3] = 8'h24; data[3] = 32'h00000065;
    cycle[4] = 196; offset[4] = 8'h24; data[4] = 32'h0000006c;
    cycle[5] = 208; offset[5] = 8'h24; data[5] = 32'h0000006c;
    cycle[6] = 220; offset[6] = 8'h24; data[6] = 32'h0000006f;
    cycle[7] = 232; offset[7] = 8'h24; data[7] = 32'h00000020;
    cycle[8] = 244; offset[8] = 8'h24; data[8] = 32'h00000066;
    cycle[9] = 256; offset[9] = 8'h24; data[9] = 32'h00000072;
    cycle[10] = 268; offset[10] = 8'h24; data[10] = 32'h0000006f;
    cycle[11] = 280; offset[11] = 8'h24; data[11] = 32'h0000006d;
    cycle[12] = 292; offset[12] = 8'h24; data[12] = 32'h00000020;
    cycle[13] = 304; offset[13] = 8'h24; data[13] = 32'h00000061;
    cycle[14] = 316; offset[14] = 8'h24; data[14] = 32'h00000070;
    cycle[15] = 328; offset[15] = 8'h24; data[15] = 32'h0000005f;
    cycle[16] = 340; offset[16] = 8'h24; data[16] = 32'h00000073;
    cycle[17] = 352; offset[17] = 8'h24; data[17] = 32'h0000006f;
    cycle[18] = 364; offset[18] = 8'h24; data[18] = 32'h00000063;
    cycle[19] = 376; offset[19] = 8'h24; data[19] = 32'h0000000a;
    cycle[20] = 401; offset[20] = 8'h24; data[20] = 32'h00000063;
    cycle[21] = 413; offset[21] = 8'h24; data[21] = 32'h00000068;
    cycle[22] = 425; offset[22] = 8'h24; data[22] = 32'h00000069;
    cycle[23] = 437; offset[23] = 8'h24; data[23] = 32'h00000070;
    cycle[24] = 449; offset[24] = 8'h24; data[24] = 32'h00000020;
    cycle[25] = 477; offset[25] = 8'h24; data[25] = 32'h00000032;
    cycle[26] = 489; offset[26] = 8'h24; data[26] = 32'h00000061;
    cycle[27] = 501; offset[27] = 8'h24; data[27] = 32'h00000035;
    cycle[28] = 513; offset[28] = 8'h24; data[28] = 32'h00000033;
    cycle[29] = 525; offset[29] = 8'h24; data[29] = 32'h00000031;
    cycle[30] = 537; offset[30] = 8'h24; data[30] = 32'h00000030;
    cycle[31] = 549; offset[31] = 8'h24; data[31] = 32'h00000063;
    cycle[32] = 561; offset[32] = 8'h24; data[32] = 32'h00000035;
    cycle[33] = 581; offset[33] = 8'h24; data[33] = 32'h00000020;
    cycle[34] = 593; offset[34] = 8'h24; data[34] = 32'h00000073;
    cycle[35] = 605; offset[35] = 8'h24; data[35] = 32'h00000074;
    cycle[36] = 617; offset[36] = 8'h24; data[36] = 32'h00000072;
    cycle[37] = 629; offset[37] = 8'h24; data[37] = 32'h00000061;
    cycle[38] = 641; offset[38] = 8'h24; data[38] = 32'h00000070;
    cycle[39] = 653; offset[39] = 8'h24; data[39] = 32'h00000073;
    cycle[40] = 665; offset[40] = 8'h24; data[40] = 32'h00000020;
    cycle[41] = 693; offset[41] = 8'h24; data[41] = 32'h00000030;
    cycle[42] = 705; offset[42] = 8'h24; data[42] = 32'h00000030;
    cycle[43] = 717; offset[43] = 8'h24; data[43] = 32'h00000030;
    cycle[44] = 729; offset[44] = 8'h24; data[44] = 32'h00000030;
    cycle[45] = 741; offset[45] = 8'h24; data[45] = 32'h00000030;
    cycle[46] = 753; offset[46] = 8'h24; data[46] = 32'h00000030;
    cycle[47] = 765; offset[47] = 8'h24; data[47] = 32'h00000030;
    cycle[48] = 777; offset[48] = 8'h24; data[48] = 32'h00000030;
    cycle[49] = 789; offset[49] = 8'h24; data[49] = 32'h0000000a;
    cycle[50] = 805; offset[50] = 8'h20; data[50] = 32'hbad00007;
    cycle[51] = 807; offset[51] = 8'h20; data[51] = 32'h0000900d;
    for (int i = 0; i < N && !done; i++) begin
      if (offset[i] == 8'h24) begin
        if (data[i][7:0] == 8'h0a) begin $display("CONSOLE %0d: %s", cycle[i], line); line = ""; end
        else line = $sformatf("%s%c", line, data[i][7:0]);
      end else if (offset[i] == 8'h20) begin
        if (data[i] == 32'h1)              $display("STATUS %0d: boot ROM reached", cycle[i]);
        else if (data[i] == 32'h2)         $display("STATUS %0d: main entered", cycle[i]);
        else if (data[i] == 32'h900d)      begin $display("STATUS %0d: pass", cycle[i]); done = 1; end
        else if (data[i][31:16] == 16'hbad0) begin $display("STATUS %0d: fail, code %h", cycle[i], data[i][15:0]); done = 1; end
      end
    end
  end
endmodule
ConceptWhich leaves reset first on ap_soc?
ConceptThe console shows every expected line, and reason = checker. Did the test pass?
ConceptYou need to know why the core reset released late. Which view do you open?
ConceptWhy does firmware print through TB_PUTC instead of UART0?

Common Mistakes

Wrong Call a run passed because the console looks right.

The console is what the firmware said; the bench may have seen a broken rule or a model mismatch.

Fix Read verdict, reason and the error counters first.

Wrong Open the waves first.

They are the slowest view to record and read.

Fix Console and result block, then the trace, then the waves.

Wrong Compare cycle counts from runs with different reset points.

Power-up time is not part of the test.

Fix Count from the release of the bus reset, as the bench does.

Remember

  • The first run tests the chip's spine: power, clocks, resets, boot, bus and bench channel.
  • Power-up order on ap_soc: power-on reset, oscillators, PLL lock, clock switch, bus reset, core reset, first fetch.
  • Console, trace and waves answer different questions at different prices.
  • The result block, not the console, says whether a run passed.

Practice

Report a problem with this page