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.

One Register Reached Two WaysThe front door is a bus transfer through the fabric and the bridge. The back door is the bench naming the flop that holds the value.
  • Test
  • Manager
  • Bus
  • Storage
  • Tool
  • Model
  • Transaction / TLM
  • Data
  • Control
  • Analysis
One Register Reached Two WaysThe front door is a bus transfer through the fabric and the bridge. The back door is the bench naming the flop that holds the value. test Test table, host C or UVM manager Seat the core's data port bus Fabric and bridge decode, lanes,PSLVERR storage tb_arg_q the flop insideap_sysctl tool Bench task force for one cycle,or read model Register model mirror: what itbelieves front doora transferwrite and read pathsback doorby name, no busexpected value
  1. test Testtable, host C or UVM
    • front door → Seat
    • back door → Bench task
  2. manager Seatthe core's data port
    • a transfer → Fabric and bridge
  3. bus Fabric and bridgedecode, lanes, PSLVERR
    • write and read paths → tb_arg_q
  4. storage tb_arg_qthe flop inside ap_sysctl
  5. tool Bench taskforce for one cycle, or read
    • by name, no bus → tb_arg_q
  6. model Register modelmirror: what it believes
    • expected value → Test
  1. The front door

    A transfer goes through the seat, the fabric and the bridge. It tests the whole path, and it costs bus cycles.

  2. The back door

    The bench reads or sets the flop by its name. No transfer, no time on the bus, no decode.

  3. 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.

Five questions this page answers
Question
1What does a front-door access prove that a back-door access cannot?
2What can only the back door do?
3How do two doors tell a write bug from a read bug?
4What are a mirror and a prediction?
5Why 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

New words on this page
WordMeaning
Front doorAn access through the bus, as software makes it.
Back doorAn access by the bench that names the storage directly: a flop, or a memory word.
DepositA back-door write: the bench forces the flop for one cycle and lets go, and the flop keeps the value.
MirrorWhat a register model believes a register holds now.
PredictUpdating the mirror from an access: after a write, the value written; after a read, the value read.
Mirror checkA 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.

Two doors on one bug
AccessValueWhat it tells you
Front-door read of B1111_1111 (A's value)Something is wrong
Back-door read of B's flopBBBB_BBBBThe write landed
TogetherThe read path is wrong

The example below prints the same three lines.

The Rules

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

Back in, front out for TB_ARG and an SRAM word; then front in, back out for the next word.
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 1
The result block of the table on the seat.
verdict=pass cycles=32 bus_transfers=5

Rule 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:

soc_uvm/soc_uvm_pkg.sv, shortened: the model's back door asks the bench, which names the flop.
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
endclass

Why 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.

The end of soc_reg_vseq: TB_ARG through both doors, then a mirror check of UART0 DIV.
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 mirror
soc_reg_test on the bench's UVM build (Verilator 5.052, uvm-core 2020.3.1); built in 75 s on the laptop.
UVM_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=0

The 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

ap_soc~12 blocks
Phone-class SoChundreds of blocks

This section looks ahead. ap_soc's bench maps six registers and two memories to their storage.

  1. 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.

  2. 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.

  3. 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?

RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: front door, read B: 11111111 back door, flop of B: bbbbbbbb the write landed; the read path is wrong

Check Yourself

Predict the outputThe read multiplexer is now right (bug = 0). What is the last line printed?
// Two registers A (offset 0) and B (offset 4). bug = 0: the read mux answers a read of B with A's flop.
// The front door writes and reads through the bus; the back door names the flop.
module tb;
  bit [31:0] flop [2];
  function automatic bit [31:0] front_read(int index);
    return flop[(0 && index == 1) ? 0 : index];
  endfunction
  initial begin
    flop[0] = 32'h1111_1111;
    flop[1] = 32'hbbbb_bbbb;              // a front-door write of B
    $display("front door, read B: %h", front_read(1));
    $display("back door, flop of B: %h", flop[1]);
    if (front_read(1) != flop[1]) $display("the write landed; the read path is wrong");
    else $display("both doors agree");
  end
endmodule
ConceptWhat can only a front-door access prove?
ConceptA front-door read is wrong; a back-door read of the flop is right. What is broken?
ConceptWhy does this bench's UVM model use a class of its own as the back door?
ConceptWhat does a mirror check compare?

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.

Practice

Report a problem with this page