Bit Bash, Aliasing and Unmapped Space
A sweep with two patterns can pass a register whose fields are crossed. Walk a single one through every bit, give every neighbour its own value, and make every hole answer ERROR. Then see what each check costs on the seat.
You Will Be Able To
- Explain why two repeated patterns miss two crossed fields, and walking ones do not.
- Write an alias check that gives neighbouring addresses distinct values.
- List the kinds of hole a chip has and the answer each must give.
- Estimate what bit bash, alias and hole checks cost on the seat.
- Lesson
- V6.3
- Time
- 26 min
- Runs on
- Your browser
- Check
- 5 questions
The register sweep of the last lesson passed. Then a seeded fault crossed two fields of one register, and the sweep still passed. Its two patterns, A5 and 5A in every byte, had set both fields to the same value each time.
- Memory
- Peripheral
- Bus
- External
- Control / FSM
- Control
- Data
- Each address has one owner
Within a register, every bit does what its field says. Bit bash checks that, bit by bit.
- Holes answer ERROR
An address with no owner must answer ERROR and change nothing, on the AHB map and inside every APB page.
- Nothing answers twice
A decoder that ignores one address bit makes a mirror image: one register at two addresses. Distinct values at neighbouring addresses find it.
Read the diagram as text
- ROM 0x0000_0000: 4 KiB
- ap_clint 0x0200_0000: MSIP, MTIMECMP, MTIME
- ap_plic 0x0C00_0000: priority word 0 is a hole
- APB window 0x1000_0000: 4 KiB pages, one per block
- Page 0x1000_7000: nobody owns it: ERROR
- SRAM 0x8000_0000: 64 KiB; 0x8001_0000 is a hole
- A mirror image: a decoder that ignores an address bit
- Default subordinate: the two-cycle ERROR
- APB window 0x1000_0000 → Page 0x1000_7000: PSLVERR at once
- ap_plic 0x0C00_0000 → Default subordinate: no register: ERROR
- SRAM 0x8000_0000 → A mirror image: if one address bit were ignored
Addresses from tools/soc/ap_soc/map.json (version 1.5); the error answers of facts 27.6 and 27.7.
Before You Start
Read Register Tests From the Description and Address Decode and Aliases first.
| Question | |
|---|---|
| 1 | Why can two patterns pass a register with crossed fields? |
| 2 | What is a walking one, and what does it find? |
| 3 | How do you find an alias, and why must the values differ? |
| 4 | Which kinds of hole does ap_soc have, and what must each answer? |
| 5 | What do these checks cost on the seat? |
The Idea: Prove Each Bit, Each Address and Each Gap
A register test can pass for the wrong reason. Write a pattern, read the same pattern back, and you have shown that the bits came back. You have not shown that each bit came back from its own place.
Two kinds of wiring bug hide this way. Inside a register, two fields can be crossed, so bit 3 reads what bit 4 holds. Across the map, a decoder can ignore an address bit, so one register answers at two addresses. Both pass any check whose values cannot tell the places apart.
The third gap is the one between registers. An address that nobody owns must answer ERROR and change nothing. Otherwise a stray pointer in firmware writes silently into a mirror, or into nothing.
New Words
| Word | Meaning |
|---|---|
| Bit bash | Writing and reading back values chosen so that every bit is shown to work on its own. |
| Walking one | A value with a single 1, moved through every bit position in turn (a walking zero is its opposite). |
| Crossed fields | Two fields whose wires are swapped, so a read returns one field's value in the other's place. |
| Alias, mirror image | One register or word that answers at more than one address. |
| Hole | An address that no register or memory owns; on ap_soc it answers ERROR. |
| Default subordinate | The part of the fabric that answers every AHB address with no target, with the two-cycle ERROR. |
The Smallest Example: Two Crossed Bits
An 8-bit register has its read wiring crossed: bit 1 returns whatever bit 3 holds. Try the sweep's two patterns first: A5 is 10100101 and 5A is 01011010. In each, bit 3 and bit 1 are equal, so the crossing changes nothing.
| Written | Bit 3 | Bit 1 | Read back | Seen? |
|---|---|---|---|---|
| 10100101 (A5) | 0 | 0 | 10100101 | no |
| 01011010 (5A) | 1 | 1 | 01011010 | no |
| 00000010 (a walking one) | 0 | 1 | 00000000 | yes |
| 00001000 (a walking one) | 1 | 0 | 00001010 | yes |
Worked by hand; the example below prints the same lines.
A value can show a crossing only if it sets the two crossed bits differently. A walking one does that for every pair of bits at once. Each step sets exactly one bit, so every other bit differs from it.
The Rules
Rule 1: Every bit must be set alone at least once.
Walking ones across a field show each bit in its own place. Walking zeros add the opposite case: one bit clear while the rest are set.
Rule 2: Repeated byte patterns are not enough.
A5 and 5A set bits in pairs that repeat every byte, so many crossings keep their values equal.
Rule 3: Neighbours get distinct values.
Write every register of a block with its own value first, then read them all back. A shared value hides an alias.
Rule 4: Visit both ends of every window.
A decoder cut too small answers correctly at the bottom of its window and mirrors at the top.
Rule 5: Every hole answers ERROR and changes nothing.
On ap_soc, a hole of the AHB map gets the two-cycle ERROR. A hole of the APB window, or an offset with no register, gets PSLVERR.
Rule 6: Mind what a check disturbs.
Writes to a control field act. Bash only plain read-and-write fields, and restore the reset value after.
Sources for These Rules
Holes and their answers: facts 27.6 and 27.7; tools/soc/ap_soc/map.json. The default subordinate: ap_ahb_default.sv. AHB requires a default subordinate that answers ERROR to a transfer at a missing address: AMBA AHB, IHI 0033C 4.2.1.
What the gates of this chip learned, plan §3.10. Stage E3: a window decoded too small was found only when the routes visited the top of every window. Stage E9: a repeated-byte pattern hid crossed fields, and distinct field values closed it.
Bit bash and walking-ones sequences in UVM: IEEE 1800.2 Annex E.2 and E.6. Aliases through several maps: Annex E.4.
The Lab: Walk, Neighbours, Holes
Three short tables on the seat. The first walks a one through the 16 bits of GPIO IRQ_ENABLE. That is 34 rows: a write and a read for each bit, then 0.
core w 10001018 00000001 ffffffff 00000000 0 1
core r 10001018 00000000 0000ffff 00000001 0 1
core w 10001018 00000002 ffffffff 00000000 0 1
core r 10001018 00000000 0000ffff 00000002 0 1The second gives three neighbouring DMA registers, SRC, DST and LEN, three different values before reading any back (rule 3). If DST mirrored SRC, the read of SRC would return the value of DST.
The third reads and writes holes. They are the APB page nobody owns, an AHB address with no target and the word just past SRAM. Then the priority word of source 0 in ap_plic, an empty GPIO offset, and a write to ROM.
core re 10007000 00000000 ffffffff 00000000 0 1
core we 10007000 00000000 ffffffff 00000000 0 1
core re 40000000 00000000 ffffffff 00000000 0 1
core re 80010000 00000000 ffffffff 00000000 0 1
core re 0c000000 00000000 ffffffff 00000000 0 1
core re 10001ffc 00000000 ffffffff 00000000 0 1
core we 10001ffc 00000000 ffffffff 00000000 0 1
core we 00000000 00000000 ffffffff 00000000 0 1| Table | Rows | Cycles | Verdict |
|---|---|---|---|
| Walking ones, one 16-bit field | 34 | 123 | pass |
| Three neighbours | 6 | 39 | pass |
| Eight holes | 8 | 49 | pass |
Recorded on ap_soc v1.5 with Verilator 5.052 2026-09-05, +core=bfm. Cycles include the bench's start and end words.
All three pass, so on these registers and holes ap_soc keeps rules 1, 3 and 5. A whole 16-bit field took 123 cycles to walk on the seat. That is cheap enough to run at every drop of the RTL.
Why It Is Built This Way
Why does ap_soc answer ERROR in every hole, when some chips return zero? For a hole of the AHB map, AHB itself asks for it. Its default subordinate answers a transfer to a missing address with ERROR. Inside an APB page the protocol leaves it open, and ap_soc chose ERROR too (facts 27.6). ERROR is the one answer a stray access cannot mistake for data. Firmware traps, a test sees it at once, and the sweep has one rule for every block.
Why walk single bits instead of trying every value? A 32-bit register has four billion values; a walk has 32. The walk catches every crossing of two bits, because no two bits share a value in it.
Traps
The pattern trap is the one in the hook, and it is a true story of this chip. The first fault sweep of stage E9 used repeated bytes, and crossed fields escaped. The fix was values whose fields differ, which is what rule 1 asks for.
The window trap is also this chip's own. In stage E3 a seeded fault cut one window too small. Every test that used the bottom of that window passed. Only when the route test visited the top of every window did the mirror show.
The disturbance trap bites on control fields. A walking one through PINMUX moves pads; through CLK_GATE it stops a block's clock in the middle of the test. Walk such fields too, but know what each step does, and read the result before the next step.
The quiet-hole trap: a read of a hole that answers OKAY with zero looks like a register that holds zero. Always use a row that expects ERROR (core re), never a read with mask 0.
At Scale
This section looks ahead. ap_soc's map is small: a few windows, a few holes between them, and an empty offset in every page.
Sparse maps
A large chip's map is mostly holes. Teams check one address per hole region and both ends of every window, generated from the map file.
Walking address bits
For memories, an address walk writes distinct values at addresses that differ in one address bit. A stuck or shorted address line then shows.
Security windows
With access control, a hole for one manager may be a register for another. The hole check then runs per manager and per privilege.
Try It
Run it: the two sweep patterns read back the same, and two of the walking ones read back WRONG.
Replace the patterns with 33 and CC (the predict question below). What changes?
Why is a walking one the smallest test that finds every crossing of two bits?
walking one 00000001: read back 00000001, same walking one 00000010: read back 00000000, WRONG walking one 00000100: read back 00000100, same walking one 00001000: read back 00001010, WRONG walking one 00010000: read back 00010000, same walking one 00100000: read back 00100000, same walking one 01000000: read back 01000000, same walking one 10000000: read back 10000000, same pattern 10100101: read back 10100101, same pattern 01011010: read back 01011010, sameCheck Yourself
Common Mistakes
Wrong Bash every register with A5 and 5A only.
Bits that pair up in both patterns can be crossed and pass.
Fix Walk a single one through every bit of each plain field.
Wrong Write one value to every register of a block, then read them back.
An alias reads back the same value and passes.
Fix Give each neighbour its own value before any read.
Wrong Read a hole with mask 0 to see that it answers.
A hole that answers OKAY with zero passes.
Fix Use a row that expects ERROR, and write the hole too.
Remember
- A check proves only what its values can tell apart.
- Walking ones show every bit in its own place; repeated patterns do not.
- Distinct values at neighbouring addresses, and both ends of every window, find aliases.
- Every hole answers ERROR and changes nothing. AHB asks for it in the map's holes; ap_soc makes it the rule inside every page.