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.
- Power
- Clock / reset
- Memory
- Processor
- Peripheral
- Power
- Clock
- Reset
- Data
- 13 ns: power is good
The power-on reset cell lets go. Every flop is still held in reset, and the oscillators start.
- 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.
- 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.
- 415 ns: the first fetch
The core asks the boot ROM for address 0. From here the bench counts cycles.
- Cycle 152: main entered
Start-up code writes 1, then 2 to TB_STATUS. The bench now knows the test really started.
- 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.
| Question | |
|---|---|
| 1 | Why is the first run its own milestone? |
| 2 | In what order does the chip come out of power-up? |
| 3 | What do the console, the trace and the waves each show? |
| 4 | How do you read the result block? |
| 5 | Why 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
| Word | Meaning |
|---|---|
| Power-on reset | A cell that holds the chip in reset until the supply is good, then lets go once. |
| PLL lock | The moment the PLL's output is stable; until then clk_sys runs from the RC oscillator. |
| Reset release order | Which part leaves reset first: here the bus, then the core. |
| Console | The lines the firmware writes through TB_PUTC; the bench prints each with its cycle. |
| Result block | The key=value lines the bench prints at the end: verdict, reason, counters. |
| Retire trace | One line per instruction the core finished: cycle, pc, instruction, effect. |
| Waves | The values of chosen signals over time, from a probe beside the bench. |
| Bring-up ladder | The 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.
#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.
| Key | Value | Meaning |
|---|---|---|
| verdict, reason | pass, pass | How the run ended, by the bench's rules |
| main_entered | 1 | TB_STATUS = 2 was written: the test really started |
| cycles, retired | 815, 440 | clk_sys cycles after the bus reset; instructions finished |
| compares, mismatches | 440, 0 | Records checked against the reference model; how many differed |
| checker_errors | 0 | Broken bus rules, block monitor errors, bench errors |
| visited | 0089 | Regions touched: bits 0 ROM, 3 SRAM, 7 ap_sysctl |
| console_bytes | 48 | Bytes 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.
| Rung | Where you look | What a failure there looks like |
|---|---|---|
| 1. Clocks | Waves: osc_ready, pll_locked, on_pll | clk_sys never switches to the PLL, so the chip may never leave reset |
| 2. Resets | Waves: resetn_sys, then resetn_core | The core is held in reset: no fetch, retired = 0 |
| 3. First fetch | Waves: fetch; the first trace record | The pc is not the reset vector, or ROM is empty: on ap_rv32 the core traps at address 0 for ever |
| 4. Start-up code | Trace: the stores of TB_STATUS = 1, then 2 | main_entered = 0: main never ran |
| 5. main | Result block, then the console | verdict 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
Rule 1: Read the result block first.
verdict and reason come from the bench's rules, not from what the firmware printed.
Rule 2: Power-up has an order.
Power-on reset, clocks, PLL lock, clock switch, bus reset, core reset, first fetch.
Rule 3: Count cycles from the bus reset.
Every cycle number in a console line, a trace row or a result block starts there.
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.
CONSOLE 375: hello from ap_soc
CONSOLE 788: chip 2a5310c5 straps 00000000The same image ran again on an Icarus build of the bench with a probe beside it. The probe sampled seven signals every 20 ns.
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.
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 = 80010000Why 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
This section looks ahead. The lab run takes about 800 cycles after reset.
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).
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.
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.
STATUS 23: boot ROM reached STATUS 152: main entered CONSOLE 376: hello from ap_soc CONSOLE 789: chip 2a5310c5 straps 00000000 STATUS 807: passCheck Yourself
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.