Front Door and Back Door at Chip Level
Reach one register two ways: through the bus, and by naming its flop. Learn what each door proves and how a register model keeps both honest. See why this site's UVM engine needs a back door of its own.
You Will Be Able To
- Say what a front-door access proves that a back-door access cannot, and the reverse.
- Use both doors to tell a broken write path from a broken read path.
- Explain mirror, predict and mirror-check in a register model.
- Explain why this bench's back door is a bench task and not uvm_hdl_*.
- Lesson
- V6.4
- Time
- 26 min
- Runs on
- Your browser
- Check
- 5 questions
A read of a register returns the wrong value. Did the write never land, or does the read path lie? Through the bus alone, the two look the same. One read of the flop by its name tells them apart.
- Test
- Manager
- Bus
- Storage
- Tool
- Model
- Transaction / TLM
- Data
- Control
- Analysis
- The front door
A transfer goes through the seat, the fabric and the bridge. It tests the whole path, and it costs bus cycles.
- The back door
The bench reads or sets the flop by its name. No transfer, no time on the bus, no decode.
- The mirror
A register model keeps what it believes each register holds. Both doors update it; a check compares it with the chip.
Read the diagram as text
- Test: table, host C or UVM
- Seat: the core's data port
- Fabric and bridge: decode, lanes, PSLVERR
- tb_arg_q: the flop inside ap_sysctl
- Bench task: force for one cycle, or read
- Register model: mirror: what it believes
- Test → Seat: front door
- Seat → Fabric and bridge: a transfer
- Fabric and bridge → tb_arg_q: write and read paths
- Test → Bench task: back door
- Bench task → tb_arg_q: by name, no bus
- Register model → Test: expected value
TB_ARG of ap_sysctl. The bench task is backdoor_deposit in soc_tb.sv; the model is soc_uvm/soc_reg_pkg.sv.
Before You Start
Read Bit Bash, Aliasing and Unmapped Space and Back-Door Loading first. The UVM side is taught in Memories and a backdoor without VPI.
| Question | |
|---|---|
| 1 | What does a front-door access prove that a back-door access cannot? |
| 2 | What can only the back door do? |
| 3 | How do two doors tell a write bug from a read bug? |
| 4 | What are a mirror and a prediction? |
| 5 | Why is the back door of this bench a bench task? |
The Idea: Two Doors, Two Different Proofs
The front door is a real bus transfer. It goes through the seat, the fabric, the bridge and the block's decoder to the flop. When it works, every part on that path worked. That is what software will use, so it is the proof that matters.
The back door skips the path. The bench names the flop in the design and reads or sets it directly. It takes no bus cycles, it disturbs nothing, and it shows what is really stored.
Used together, they split the blame. Write through the front door and read through the back: you test the write path alone. Write through the back and read through the front: you test the read path alone.
New Words
| Word | Meaning |
|---|---|
| Front door | An access through the bus, as software makes it. |
| Back door | An access by the bench that names the storage directly: a flop, or a memory word. |
| Deposit | A back-door write: the bench forces the flop for one cycle and lets go, and the flop keeps the value. |
| Mirror | What a register model believes a register holds now. |
| Predict | Updating the mirror from an access: after a write, the value written; after a read, the value read. |
| Mirror check | A read whose value is compared with the mirror; a difference is an error. |
| uvm_hdl_* | UVM routines that reach a design signal by its path name through the simulator (DPI and VPI). |
The Smallest Example: Which Path Lies?
Two registers, A at offset 0 and B at offset 4. The read multiplexer has a bug: a read of B returns the flop of A. You write B through the front door, then read B back.
| Access | Value | What it tells you |
|---|---|---|
| Front-door read of B | 1111_1111 (A's value) | Something is wrong |
| Back-door read of B's flop | BBBB_BBBB | The write landed |
| Together | The read path is wrong |
The example below prints the same three lines.
The Rules
Rule 1: The front door is the proof that software can.
Only a bus access tests decode, byte lanes, the bridge and the error answer.
Rule 2: The back door shows what is stored.
It costs no bus cycles and changes nothing else, so it is how a test loads data fast and checks results quietly.
Rule 3: Cross the doors to locate a bug.
Front in and back out tests the write path. Back in and front out tests the read path.
Rule 4: A back-door read waits for the clock edge.
A front-door write lands at the edge that ends its data phase. A back door read before that edge sees the old value.
Rule 5: A model's mirror must follow both doors.
After every access the model predicts the new value. A mirror check then compares the chip with what the model believes.
Rule 6: A back door must exist for each register you use it on.
Someone must map each register to its storage. This bench reads six registers by name and deposits into three of them. Its table rows also reach every word of ROM and SRAM.
Sources for These Rules
The bench's doors: soc_tb.sv (backdoor_deposit, peek, poke) and the README ("The sequence table": tb arg, poke, peek); facts 27.12.
Rule 4 was found at stage E7 (plan §3.10). A back-door read right after a front-door write saw the old value, so the back door now waits for the edge.
IEEE 1800.2-2020: register read, write, peek, poke, update and mirror in 18.4.4, and a register's back door in 18.4.6. The class uvm_reg_backdoor is in 19.5 and the HDL access routines in 19.6. The access test that crosses the doors is Annex E.3.1.
Prediction after a back-door write, and after a front-door access when auto-prediction is on: uvm-core 2020.3.1, reg/uvm_reg.svh (do_write, do_read).
The Lab: Both Doors in a Table, Then in UVM
The table front end has two back doors. The row tb arg deposits a word in TB_ARG. The rows tb poke and tb peek reach any word of ROM or SRAM.
tb arg 00000000 c0de0001 ffffffff 00000000 0 1
core r 1000402c 00000000 ffffffff c0de0001 0 1
tb poke 80003000 5eed1234 00000004 00000000 0 1
core r 80003000 00000000 ffffffff 5eed1234 0 1
core w 80003004 feedf00d ffffffff 00000000 0 1
tb peek 80003004 00000000 ffffffff feedf00d 0 1verdict=pass cycles=32 bus_transfers=5Rule 2 at work: the six rows made only 5 bus transfers. Two of those were the bench's own start and end words. The back-door rows cost no transfer at all.
The UVM environment of this bench has a register model of all 79 registers, generated from the same table as the sweep. Its back door is a class of ours:
class soc_reg_backdoor extends uvm_reg_backdoor;
soc_api api;
virtual task read(uvm_reg_item rw);
uvm_reg rg; bit [31:0] value; bit ok;
void'($cast(rg, rw.element));
api.backdoor_read(rg.get_address()[31:0], value, ok); // the bench names the flop
rw.status = ok ? UVM_IS_OK : UVM_NOT_OK;
rw.value[0] = value;
endtask
// write(): the same, through api.backdoor_write
endclassWhy not the standard way? UVM's own back door reaches a signal by its path name, through routines such as uvm_hdl_read and uvm_hdl_deposit (IEEE 1800.2, 19.6). The standard leaves their insides to the simulator's C interface. In this site's UVM engine the six C routines are stubs that only report an error. So the model's back door calls a bench task instead, and needs no C at all.
put(regs.sysctl_tb_arg, 32'hCAFE_0001, UVM_BACKDOOR); // back door in
expect_read(regs.sysctl_tb_arg, 32'hFFFF_FFFF, 32'hCAFE_0001); // front door out
put(regs.sysctl_tb_arg, 32'h1234_5678); // front door in
expect_read(regs.sysctl_tb_arg, 32'hFFFF_FFFF, 32'h1234_5678, UVM_BACKDOOR); // back door out
put(regs.uart_div, 32'h0000_0007); // front door in
expect_read(regs.uart_div, 32'h0000_FFFF, 32'h0000_0007, UVM_BACKDOOR); // back door out
regs.uart_div.mirror(status, UVM_CHECK, UVM_FRONTDOOR, .parent(this)); // read, compare with the mirrorUVM_INFO [REG] 67 registers read through the front door, every reset value of the model holds; 11 more answered ERROR to a read, as the model says
verdict=pass cycles=343 UVM_ERROR=0 UVM_FATAL=0The test read every reset value through the front door and found the model right. Then it crossed the doors on TB_ARG and on DIV. Its last line is a mirror check (rule 5). The model predicted DIV = 7 after the front-door write, and the read must agree.
Why It Is Built This Way
Why a bench task, when the plan first said "bench DPI"? Because the bench is SystemVerilog and already knows the flop's name. A task can force it and read it with no C at all. DPI would add a layer that does the same thing.
Why so few registers on the UVM back door? Each one is a line someone writes and keeps right. The bench reads six by name: the four mailbox registers, PINMUX and UART0 DIV. It deposits into three, TB_ARG, PINMUX and DIV, the ones tests set without the bus. Memories have no UVM back door here; the table rows poke and peek reach them word by word.
Traps
The race trap is this bench's own story. At stage E7, a back-door read right after a front-door write saw the old value. The write lands at the clock edge that ends its data phase; the read came first. The fix was rule 4: wait for the edge.
The silent-mirror trap: a test writes through the back door, and the model is never told. The next mirror check then fails on a chip that is right. In uvm-core 2020.3.1, a back-door write through the model predicts by itself. A deposit made around the model does not.
The blind-door trap: a back door can be wrong too. If it names the wrong flop, front and back disagree on a good chip. Check each back door once against the front door before you trust it.
At Scale
This section looks ahead. ap_soc's bench maps six registers and two memories to their storage.
Generated paths
On a large chip the path to every register's storage is generated with the register model. The back door then covers all of them.
Memories by the back door
Large memories are loaded and checked by the back door, because loading megabytes through the bus would take most of a test.
Simulators with VPI
Commercial simulators run uvm_hdl_* routines for real; the class of this bench stands in where they are stubs.
Try It
Run it: the front-door read of B returns A's value, and the back door shows B's flop holds the write.
Set bug to 0 (the predict question below). What is the last line now?
What would the two reads print if the write path were broken instead?
front door, read B: 11111111 back door, flop of B: bbbbbbbb the write landed; the read path is wrongCheck Yourself
Common Mistakes
Wrong Check a register only through the back door.
The back door skips decode, lanes and the bridge, which software needs.
Fix Keep a front-door check of every register; use the back door to locate bugs and load data.
Wrong Read by the back door in the same instant as a front-door write ends.
The write lands at the next clock edge, so the read sees the old value.
Fix Wait for the edge, as this bench's back door does.
Wrong Deposit into a flop around the model and then mirror-check.
The mirror still holds the old value.
Fix Write through the model's back door, or predict after the deposit.
Remember
- The front door proves the path software uses; the back door proves the storage.
- Crossing the doors tells a write bug from a read bug.
- A register model predicts every access; a mirror check compares the chip with that belief.
- On this site's engine uvm_hdl_* are stubs, so the model's back door is a bench task.