The Specification Is Data
Most of a chip's specification is tables: addresses, registers, wires, pins, interrupts. Kept as data files, they build the RTL and the tests. Learn to read them as the thing under test, and run a test made straight from them.
You Will Be Able To
- Name the files of ap_soc's hand-off package and what each one decides.
- Read a row of each file and find the fact a test needs.
- Turn rows of data into a chip test, and read a failing row as a disagreement.
- Explain why a test made from the same data as the RTL can agree with a wrong design.
- Lesson
- V2.1
- Time
- 24 min
- Runs on
- Your browser
- Check
- 5 questions
Integration week. The designer says GPIO is interrupt source 2, and the firmware header says 3. The document says 2 in one table and 3 in another. Nobody is lying. Each copied the number from somewhere, and the copies drifted.
- External
- Processor
- Pads
- Debug
- Data
- Interrupt
- Debug
- The map
Where every block lives, and which addresses belong to nobody.
- The registers
Every register: offset, fields, access, reset value. A tool makes the register RTL and the C header from them.
- Wires, pins, interrupts
Which output drives which input, which pad carries which function, which wire is which interrupt source.
- Checks from the same tables
The same rows become tests: read every reset value, probe every hole, prove every wire. A disagreement is a bug in the chip or in the data.
Read the diagram as text
- map.json: 16 regions: base, size, kind
- regs/*.json: 64 registers in 10 files
- ap_soc v1.5: the RTL under test
- connect.csv: 357 wires: from, to, width, clock, power
- pins.csv: 35 rows: pad, PINMUX value, function
- irq.csv: 16 interrupt sources
- Generated checks: register sweep, map walk, wiring proofs
- map.json → ap_soc v1.5: decoders
- regs/*.json → ap_soc v1.5: register blocks
- connect.csv → ap_soc v1.5: top level
- pins.csv → ap_soc v1.5: pin mux
- irq.csv → ap_soc v1.5: interrupt map
- Generated checks → ap_soc v1.5: check
Row counts measured from the files in tools/soc/ap_soc/ by our script.
Before You Start
Read The Generated Header and The Chip-Level Verification Plan first. The Memory Map explains regions and holes.
| Question | |
|---|---|
| 1 | Why does a chip keep its specification as data? |
| 2 | Which file of the package decides what? |
| 3 | How do you read one row of each? |
| 4 | How does a table of data become a chip test? |
| 5 | When can a test made from the data miss a bug? |
The Idea: One Table, Many Readers
A chip specification has two kinds of content. Some is behaviour: how the DMA moves a byte, when the watchdog bites. Much more is tables: where UART0 lives, what DIV resets to, which wire is interrupt 2, which pad carries UART TX. Those tables have many readers: the RTL, the C header, the bench, the document and the plan.
If each reader types its own copy, the copies drift, as in the opening scene. So chip teams keep each table once, as a data file, and generate the rest. The ap_soc chip does this: tools make the decoders, the register blocks, the top level and the pin mux from its files.
For verification this changes the question. The files become part of the thing under test. A check asks: does the chip do what the row says? And when the answer is no, someone must decide which one is wrong.
New Words
| Word | Meaning |
|---|---|
| Hand-off package | The data files that describe the chip for everyone who builds or checks it. |
| map.json | The address map: each region's name, base, size and kind (memory, device, reserved). |
| regs/*.json | One file per block: every register's offset, fields, access and reset value. |
| connect.csv | Every wire of the top level: from, to, width, clock domain, power domain. |
| pins.csv and irq.csv | Which function each pad carries for each PINMUX value; which wire is each interrupt source. |
| Generated check | A test or proof made by a tool from the rows of a data file. |
The Smallest Example: One Row of Each File
Read one row of each file and say what it decides.
| File | Row | What it decides |
|---|---|---|
| map.json | UART0: base 0x10000000, size 0x00001000, device | UART0 answers in that 4 KiB window |
| regs/uart.json | DIV: offset 0x10, field cycles 15:0, rw, reset 0x10 | DIV reads 16 after reset |
| irq.csv | 2,GPIO,u_gpio.irq,clk_sys, | GPIO's request is ap_plic source 2, in the clk_sys domain |
| pins.csv | IO0,2,uart_tx,out,... | PINMUX value 2 on pad IO0 gives UART TX |
| connect.csv | u_dm.haddr,u_fabric.m_haddr[31:0],32,clk_sys | The debug module drives manager 0's address |
Whole files: map.json 16 regions, regs 64 registers, connect.csv 357 rows. Also pins.csv 35, irq.csv 16, blocks.csv 31 (30 instances and the top).
Each row is a promise and a test at once. The DIV row promises a reset value; a test reads 0x1000_0010 after reset and expects 0x10. The irq.csv row promises a wire; a test makes GPIO ask and expects claim 2.
The Rules
Rule 1: Each table lives in one file.
RTL, header, document and tests are made from it, never typed again.
Rule 2: Every row is a check.
A reset value, a hole, a wire or a pad function is something a test can prove.
Rule 3: A failing row is a disagreement.
The chip or the data is wrong; the specification decides which.
Rule 4: Check the data against its source.
A test made from wrong data agrees with RTL made from the same wrong data.
Sources for These Rules
The package and its generators: docs/soc-verification-plan.md section 3.2 (data files); tools/soc/ap_soc/regs/README.md; top-gen.mjs.
The register numbers: docs/soc/ap_soc-facts.md sections 27.3 to 27.6 (the facts file is the source the data is checked against).
Keeping register and map tables as data that generate RTL, headers and tests is common practice; standard formats are IP-XACT and SystemRDL. Not tied to one book of the library.
Now Run It: A Test Made from the Files
A short script read gen/ap_soc_regmodel.csv (made from regs/*.json) and map.json, and wrote 62 rows for the bus-manager seat. Of these, 44 read a reset value, 11 read a register that must answer ERROR, and 7 probe holes and reserved pages. Here are the first rows.
core r 02000000 00000000 00000001 00000000 0 1
core r 02004000 00000000 ffffffff ffffffff 0 1
core r 02004004 00000000 ffffffff ffffffff 0 1
core r 0c000004 00000000 00000007 00000000 0 1
core r 0c000008 00000000 00000007 00000000 0 1
core r 0c00000c 00000000 00000007 00000000 0 1The table ran on the chip with no processor: verdict=pass after 260 cycles and 64 transfers, visited = 1ff6. Rules 1 and 2 at work: nobody typed an address or a reset value.
Then one row was changed to what an older register file said: core r 10000010 00000000 0000ffff 00000008 0 1. The run failed at once, and the bench said why.
BENCH 61: seat: read 10000010 = 00000010, expected 00000008 (mask 0000ffff)That is rule 3. The chip says 16; the row says 8. The facts file, the specification of this chip, says DIV resets to 16, so the data was wrong, not the chip.
Why It Is Built This Way
The other way is a specification in prose, with tables inside documents. People read it well; tools cannot. Every reader retypes the numbers, and each change must be made in every copy. The drift in the opening scene is the usual result.
Data files cost something too. Someone must write the generators, and a mistake in a file now spreads everywhere at once. So the package of ap_soc is checked against the facts file by its own gate. And some checks must come from somewhere else.
The Trap: The Test That Agrees with the Design
Suppose regs/uart.json says DIV resets to 8, and the specification says 16. The register RTL is generated from the file, so it resets to 8. A sweep generated from the same file expects 8. It passes, on a wrong chip.
Generated checks prove that the chip matches the data. They cannot prove that the data matches the intent. So keep a few checks that do not come from the files. A smoke program written by hand, firmware from the software team and a review of the files against the specification are three. The practice problems ask you to read the files the way such a review does.
At Scale
This section looks ahead. ap_soc has six small files.
Standard formats
Industry keeps registers in standard formats, such as IP-XACT or SystemRDL, so tools from different vendors can read them. The idea is the same as regs/*.json.
Thousands of rows
A large chip has tens of thousands of registers and wires. Nobody reads them all; generated checks do, and reviews sample them.
Versions
The package changes during the project. Each RTL drop names the package version it was made from, so a failing row can be traced to a change.
Try It
Run the slice: it reads PINMUX = 0x6 through rows of pins.csv.
Set PINMUX to 0x0A and predict the function of IO1.
Set PINMUX so that IO4 gets value 3 (bits 9:8). Predict what IO4 carries.
IO0: PINMUX value 2 -> uart_tx IO1: PINMUX value 1 -> gpio IO2: PINMUX value 0 -> released (input, no function) IO3: PINMUX value 0 -> released (input, no function) IO4: PINMUX value 0 -> released (input, no function) IO5: PINMUX value 0 -> released (input, no function)Check Yourself
Common Mistakes
Wrong Copy a reset value from the document into a test.
The copy drifts when the register changes.
Fix Read it from the data file, or the header made from it.
Wrong Trust a generated sweep to find a wrong reset value.
It was made from the same data as the RTL, so both agree.
Fix Review the data against the specification, and keep checks that come from elsewhere.
Wrong Fix a failing generated row by changing the expected value.
The chip might be the one that is wrong.
Fix Decide from the specification which side is wrong, then fix that side.
Remember
- Most of a chip specification is tables; ap_soc keeps them as data files.
- The same files generate the RTL and the checks, so nothing is typed twice.
- Every row is a check; a failing row is a disagreement the specification settles.
- Checks made from the data cannot find a mistake in the data: keep some from elsewhere.