Lab 06: The register block
In this lab you’ll give the Lab 05 testbench a register model. You write the fields of four of the router’s registers and the adapter that turns register operations into APB transfers, and run UVM’s built-in reset sequence through the model and your adapter. Then you run UVM’s bit-bash sequence and connect a predictor, which updates the model from every transfer on the bus. After that you test the 246 addresses that the model can’t reach, and make the scoreboard check irq against STATUS and INT_EN in every cycle. The Lab 05 testbench misses all five of this lab’s planted bugs (B01, B02, B03, B04 and B14), and with your additions it catches all five by the end of Part 5. Part 6 shows what peek and poke do on this router.
Package: labs/lab-06-the-register-block/
Before you start
- Finish Lab 05.
- Read Register models and Regressions and seeds.
- Keep the router specification open at its Register map, APB, INT_EN and Reset sections, and the UVM register layer page beside it, which lists the arguments of a field’s
configure(), the access policies, and the messages the register layer prints.
The package is the Lab 05 testbench with our solution to Lab 05 filled in: the three assertions, the sink driver’s answer to each beat, and the body of router_lab05_vseq. If your own Lab 05 printed 3 of 3 caught., your code did the same job, but keep ours, because this lab’s additions are in the same files you edited. Here is what we added for you:
| File | What Lab 06 adds |
|---|---|
tb/router_ral_pkg.sv |
the register model and its adapter; four registers’ fields and the adapter are yours (Part 2) |
tb/router_ifs.sv, tb/router_tb_top.sv, tb/router_agents_pkg.sv |
router_sys_if and sys_monitor, which report rst_n and irq every cycle |
tb/router_env_pkg.sv |
the environment makes the register model, the adapter and the predictor, and you write the predictor’s connections (Part 3); the scoreboard models STATUS and INT_EN, checks STATUS reads, PSLVERR and reads of bad addresses, and has an irq check for you to write (Part 5) |
tb/router_vseq_pkg.sv |
helpers that go through the model (wr_reg, rd_reg, check_reg, rd_all_regs), router_lab06_vseq with one TODO per part, and router_backdoor_vseq |
tb/router_tests_pkg.sv |
router_test runs router_lab06_vseq first, then everything Lab 05’s router_test ran; router_lab06_test and router_backdoor_test |
tb/router_regs.vlt |
the five register signals the back door reaches (Part 6) |
Time: about 2 h. You’ll build the simulator seven times. On the course’s 2 CPUs our first build took 127 s, and the rebuilds after each part’s edits took 107 s (Part 2), 108 s and 113 s (Part 3), 35 s (Part 4), and 105 s and 107 s (Part 5), which comes to about 12 minutes of building. Each make check-all runs six simulations, each taking about 5 s or less.
Part 1: The Lab 05 testbench against the registers
What does your Lab 05 testbench check about the registers?
Go to the lab folder and start the build:
cd labs/lab-06-the-register-block make buildOurs took 127 s. Near the end it prints Verilator’s report:
- V e r i l a t i o n R e p o r t: Verilator 5.050 2026-07-01 rev v5.050 - Verilator: Built from 63.624 MB sources in 449 modules, into 29.574 MB in 3440 C++ files needing 213.243 MB - Verilator: Walltime 126.831 s (elab=0.857, cvt=3.307, bld=121.710); cpu 5.400 s on 2 threads; allocated 369.230 MBRun the graded test,
router_test, and pull the scoreboard’s summary out of the log:make run grep -o '\[SB\] [0-9a-z].*' build/runs/router_test-s1/run.logYou should see
ok: 0 UVM_ERROR, 0 UVM_FATAL 3.44 sfrommake run, and fromgrep:[SB] 1123 packets in: 287 to output 0, 355 to output 1, 192 NOROUTE, 289 FULL; the highest level a header saw was 16 [SB] beats checked: 1281 on output 0, 1552 on output 1; 6 DROP_CNT reads checked [SB] registers: 6 reads, 0 of STATUS checked; 0 transfers to bad addresses; irq checked in 0 cycles, wrong in 0The third line is new in this lab. The six reads are
router_inject_test’s fiveDROP_CNTreads and the one at the end of your Lab 05 sequence. Nothing checksirqyet, so the line says it was checked in 0 cycles.At the end of Lab 05 (Part 4, step 6),
router_testprinted1122 packets in: 240 to output 0, 270 to output 1, 194 NOROUTE, 418 FULLon the same seed. Your Lab 05 code hasn’t changed, androuter_lab06_vseq, whichrouter_testnow starts first, does nothing yet. Why are the numbers different?TipAnswerMaking a sequence and starting it both draw from the random state of the thread that does it. In
router_testthat is the test’s own thread, which then goes on to pick Lab 04’s routing tables and to start the sequences that randomize Lab 04’s packets. So all of those random choices come out differently, even thoughrouter_lab06_vseqdoes nothing. That is why Lab 05’srouter_testmade and started its own sequence only after Lab 04’s steps. We also ran this lab’srouter_testwithrouter_lab06_vseqleft out, and it printed Lab 05’s two lines number for number, so nothing else this lab added changes the stimulus, and the checks are the same either way.make check-allrunsrouter_teston the golden router and on the five bugs. Runpython3 ../common/bugs.py, which lists all 15 bugs, find this lab’s five in the list, and read their “hides behind” hints. Write down how many you expect the starter to catch, then run it:make check-allYou should see:
ok the golden design 0 UVM_ERROR, 0 UVM_FATAL 3.6s ------------------------------------------------------------------------ MISSED tier 1 B01_status_write_clears_all 0 UVM_ERROR, 0 UVM_FATAL 3.6s MISSED tier 1 B02_irq_ignores_int_en 0 UVM_ERROR, 0 UVM_FATAL 3.6s MISSED tier 1 B03_route3_readback_swapped 0 UVM_ERROR, 0 UVM_FATAL 3.6s MISSED tier 1 B04_misaligned_address_accepted 0 UVM_ERROR, 0 UVM_FATAL 3.6s MISSED tier 6 B14_enable_resets_to_one 0 UVM_ERROR, 0 UVM_FATAL 3.6s ------------------------------------------------------------------------ 0 of 5 caught.make check, which grades the first bug in the list, saysVERDICT: FAIL -- your test passes B01_status_write_clears_all too.B14 makes
CTRL.ENreset to 1 instead of 0. Why doesn’t your testbench see it?TipAnswerA wrong reset value shows only between the reset and the first write to the register. A read of
CTRLin that window would show it, and so would a packet offered then, becausein_readystays 0 after reset until software setsCTRL.EN. Lab 04’s steps writeCTRLbefore the first packet and never read it, and the scoreboard wouldn’t check a read ofCTRLanyway, since the only register reads it checks are those ofDROP_CNTandSTATUS. B02 hides because nothing checksirqyet, as the third[SB]line says.
Check: 0 of 5 caught., and irq checked in 0 cycles.
Part 2: The register model
What does UVM need to know about each register, and what does the reset sequence do with it?
Open
tb/router_ral_pkg.svand readrouter_reg_ctrl,router_reg_int_enandrouter_reg_block::build(). Each register’sbuild()creates its fields and configures each one with a width, a position, an access policy, whether it’s volatile (changed by the router on its own), and a reset value. The block’sbuild()adds each register to a map at its address. The specification’s Register map section gives each field’s policy and volatility, and the register layer page explains each argument ofconfigure().Write
build()forrouter_reg_status,router_reg_drop_cnt,router_reg_levelandrouter_reg_route, as theirTODOs describe. Passis_randas 1 only for anRWfield.Write the adapter’s two functions at the bottom of the file.
reg2bus()fills in anapb_itemfrom a register operation, andbus2reg()does the reverse for a finished transfer. Give a transfer that ended withPSLVERRthe statusUVM_NOT_OK.In
tb/router_vseq_pkg.sv, write the Part 2 step ofrouter_lab06_vseq: create auvm_reg_hw_reset_seq, set itsmodeltoregs, and start it withstart(null, this). It reads every register it can check, through the model and so through your adapter, and compares each with its reset value. Runmake lint, which takes seconds and prints any syntax error with its line; ours printed0 warnings. Then runmake build(107 s for us).Write down which of the ten registers you expect the reset sequence to read. Then run the test and list the ones it did:
make run grep -o 'Verifying reset value of register [^ ]*' build/runs/router_test-s1/run.logYou should see
okand seven lines:Verifying reset value of register regs.ID Verifying reset value of register regs.CTRL Verifying reset value of register regs.INT_EN Verifying reset value of register regs.ROUTE0 Verifying reset value of register regs.ROUTE1 Verifying reset value of register regs.ROUTE2 Verifying reset value of register regs.ROUTE3Why are
STATUS,DROP_CNTandLEVELmissing?TipAnswerEvery field in them is volatile. UVM doesn’t compare a volatile field when it reads one, since the design may have changed it since the model last looked, and the reset sequence skips a register in which no field would be compared. If your run printed more than seven lines, one of your fields in those three registers isn’t marked volatile.
Run
make check-all. B14’s row becomescaught tier 6 B14_enable_resets_to_one 1 UVM_ERROR 3.4sand the other four stay
MISSED, for1 of 5 caught.That error comes from the register model, and this prints it:grep '^UVM_ERROR' build/grade/B14/run.log | grep -o '\[[A-Za-z_]*\] .*'[RegModel] Register "regs.CTRL" value read from DUT (0x0000000000000001) does not match mirrored value (0x0000000000000000) (valid bit mask = 0x0000000000000001)router_testrunsrouter_lab06_vseqbefore Lab 04’s steps. What would the reset sequence report on the golden router if it ran after them?TipAnswerIt would report errors, although the router is right. The sequence resets the model to the reset values and then compares every read with them, but the router is reset only once, at time 0, and Lab 04’s steps and your Lab 05 sequence leave
CTRL.ENat 1 and the routing table set. SoCTRLand at least some of theROUTEnwould read back what those steps wrote, and the sequence would call each of them wrong. A reset sequence has to run while the registers still hold their reset values, which in this testbench means first.
Check: B14 is caught, and the other four are MISSED.
Part 3: The predictor and the bit bash
How does the register model keep its mirror in step with the router, and what does the bit-bash sequence test?
Write the first half of the Part 3 step: run a
uvm_reg_bit_bash_seqthe way you ran the reset sequence. The register layer page says what it writes and reads for each bit, and what it skips.Write the second half. Lab 04 and Lab 05 set up the router with raw APB transfers, which go around the model, and the
route()andctrl()you use here send raw transfers too. After the five writes that theTODOlists, readCTRLand the fourROUTEnwithcheck_reg(), which compares each read with the model’s mirror.The predictor isn’t connected yet, and the model’s auto-predict is off (
set_auto_predict(0)inrouter_env::connect_phase). Predict whatrouter_testdoes on the golden router, then build (108 s for us) and run it:make build make run grep '^UVM_ERROR' build/runs/router_test-s1/run.log | grep -o '\[[A-Za-z_]*\] .*'You should see
FAIL: 5 UVM_ERROR 4.33 sfrommake run, and fromgrep:[RegModel] Register "regs.CTRL" value read from DUT (0x0000000000000001) does not match mirrored value (0x0000000000000000) (valid bit mask = 0x0000000000000001) [RegModel] Register "regs.ROUTE0" value read from DUT (0x0000000000000001) does not match mirrored value (0x0000000000000000) (valid bit mask = 0x0000000000000003) [RegModel] Register "regs.ROUTE1" value read from DUT (0x0000000000000003) does not match mirrored value (0x0000000000000000) (valid bit mask = 0x0000000000000003) [RegModel] Register "regs.ROUTE2" value read from DUT (0x0000000000000002) does not match mirrored value (0x0000000000000000) (valid bit mask = 0x0000000000000003) [RegModel] Register "regs.ROUTE3" value read from DUT (0x0000000000000003) does not match mirrored value (0x0000000000000000) (valid bit mask = 0x0000000000000003)The test fails on the golden router. Which side is wrong, and would turning auto-predict on fix it?
TipAnswerThe mirror is wrong; the router returned what was written. The mirror changes only when something tells the model about a transfer. Auto-predict updates it after each operation the model itself sends, but
route()andctrl()sent raw transfers, so with auto-predict on the mirror would still hold the reset values and the five errors would stay. Since the golden router is right, the bug is in the testbench, which has no predictor to update the mirror from every transfer on the bus, whoever started it.Write the Part 3
TODOinrouter_env::connect_phase: give the predictor the map and the adapter, connect the APB monitor’s analysis port,apb.mon.ap, to itsbus_in, and turn on the map’s check-on-read, so the predictor compares every read it sees with the mirror. A predictor is usually connected to the bus monitor, because the monitor sees every transfer on the bus, whoever started it. The scoreboard gets its APB transfers from the same port.Build (113 s for us) and run:
make build make run grep -o 'Verifying bits in register [^ ]*' build/runs/router_test-s1/run.logYou should see
ok: 0 UVM_ERROR, 0 UVM_FATAL 4.45 s, and ten lines, fromVerifying bits in register regs.IDtoVerifying bits in register regs.ROUTE3. The list includesSTATUS, although every field ofSTATUSis volatile and the bit bash skips the bits of volatile fields. What does it test inSTATUS?TipAnswerIt tests bits 3 to 31, which belong to no field. The bit bash treats a bit with no field as read-only. The model expects it to read 0, so both writes set it to 1, and after each one the bit bash checks that it still reads 0. That way it tests the reserved bits of every register that has them. In
STATUS,DROP_CNTandLEVEL, whose fields are all volatile, the reserved bits are the only ones it tests.Run
make check-all. You should seecaughton B03 (4UVM_ERRORs) and B14 (2), and the other threeMISSED, for2 of 5 caught.B14 has one error more than in Part 2, because the predictor now checks the reset sequence’s read ofCTRLas well. Look at B03’s first two errors:grep '^UVM_ERROR' build/grade/B03/run.log | grep -o '\[[A-Za-z_]*\] .*' | head -2[RegModel] Register "regs.ROUTE3" value read from DUT (0x0000000000000002) does not match mirrored value (0x0000000000000001) (valid bit mask = 0x0000000000000003) [uvm_reg_bit_bash_seq] Writing a 1 in bit #0 of register "regs.ROUTE3" with initial value 'h0000000000000000 yielded 'h0000000000000002 instead of 'h0000000000000001Where did the 1 written to
ENcome back, and why did your Lab 05 testbench never notice B03?TipAnswerIt came back in bit 1,
PORT, because B03 swapsROUTE3’s two fields when it’s read. The route itself works, because B03 is in the read path only, so every packet still went whereROUTE3sent it. Lab 04’s steps and your Lab 05 sequence never read aROUTEn, so no read ever came back with the fields swapped. A test that never reads a register can’t see a bug in its read path. The bit bash reads the register back after every write, and each write changes one bit.
Check: B03 and B14 are caught, and B01, B02 and B04 are MISSED.
Part 4: The addresses outside the map
Which addresses can the register model never test?
The APB address has 8 bits, so there are 256 addresses, and the map has a register at ten of them. A transfer to any of the other 246 completes with
PSLVERR; a bad read returns 0 and a bad write changes nothing. The model can’t send a transfer to an address it has no register for, so you have to reach these with raw transfers. Write the Part 4 step: read every bad address withrd(a), write each withwr(a, 32'hFFFF_FFFF), then read every register withrd_all_regs().good_addr(a)is 1 for the ten good addresses. The scoreboard already checksPSLVERRon every transfer and the data of every bad read.Write down what the golden router should return for a read of
0x01, and whatpslverrshould be. Then build (35 s for us), runmake check-all, and look at the scoreboard’s summary in the golden run, whose logmake check-allkeeps inbuild/grade/golden/:make build make check-all grep -o '\[SB\] [0-9a-z].*' build/grade/golden/run.logYou should see B04
caughtwith50 UVM_ERROR(the run stops at 50) and3 of 5 caught., and the last of the three[SB]lines should be:[SB] registers: 856 reads, 59 of STATUS checked; 492 transfers to bad addresses; irq checked in 0 cycles, wrong in 0Look at B04’s first two errors:
grep '^UVM_ERROR' build/grade/B04/run.log | grep -o '\[[A-Za-z_]*\] .*' | head -2[APB] a read of 01, completing in cycle 4145: pslverr is 0, but 01 is a bad address [APB] a read of 01, completing in cycle 4145 returned d1050001; a read of a bad address returns 0d1050001isID’s value. Why did a read of0x01return it?TipAnswerThe registers are 4 bytes apart, so the router finds the register from
paddr[7:2], and for0x01that’s 0, the word whereIDlives. The router calls an address bad if no register is at its word or ifpaddr[1:0]isn’t00. B04 drops the second test, so a misaligned address reaches the register below it, for reads and writes alike.To see these reads in a waveform, record
router_lab06_test, which runs your sequence alone, on the golden router and on B04. It runs cycle for cycle like the first part ofrouter_test, so the read of01completes in cycle 4145 there too:make waves UVM_TESTNAME=router_lab06_test make waves UVM_TESTNAME=router_lab06_test BUG=B04 surfer build/runs/router_lab06_test-s1-B04/waves.fst &Add
clkfromrouter_tb_top,psel,penable,pwrite,paddr,pready,pslverrandprdatafromapb, andbad_addrfromdut.u_regs. Cycle n ends at the rising edge at 10n − 5 ns, so the read of01takes cycles 4143 to 4145, from 41415 to 41445 ns. The first error in the B04 run’s log is printed at 41445000 ps, the edge at which that read completes.The golden router, 41360 to 41540 ns.
pslverris 1 in the last cycle of the reads of01,02and03, and each of those reads returns 0.With B04,
bad_addrstays 0,pslverrnever rises, and the reads of01,02and03all returnd1050001.How many cycles does each read take, and in which of them does the router decide what
prdatawill be?TipAnswerEach read takes three cycles: a setup cycle (
psel1,penable0), a first access cycle withpready0, and a second withpready1, in which the read completes. The router copies the register intoprdataat the edge that ends the first access cycle (rule A8), soprdatachanges in the middle of each read.pslverris 1 only in the cycle in which a bad transfer completes (rule A7). The idle cycle withpsel0 between reads comes from the APB driver, which waits for a clock edge before it starts each transfer.
Check: B03, B04 and B14 are caught, and B01 and B02 are MISSED.
Part 5: The interrupt
Does irq follow STATUS and INT_EN in every cycle?
The specification’s INT_EN section defines
irqas the OR, over the three bits, ofSTATUS[i] & INT_EN[i], with no delay. The scoreboard already models both registers cycle by cycle. Each drop, oversize packet, or write toSTATUSorINT_ENwaits inchangesuntiladvance()reaches the cycle in which it takes effect, as route writes waited inpendingin Lab 05, and the functionirq()combines the two registers. Write the two Part 5TODOs inrouter_scoreboard::write_sys(), which the sys monitor calls every cycle: in a reset cycleirqmust be 0, and in every other cycle it must equalirq().You haven’t written any stimulus for
irqyet. Write down which of B01 and B02 the check will catch with the stimulus you already have, then build (105 s for us), runmake check-alland look at B02’s error:make build make check-all grep '^UVM_ERROR' build/grade/B02/run.log | grep -o '\[[A-Za-z_]*\] .*'You should see
4 of 5 caught., with B01 stillMISSEDand B02 caught by oneUVM_ERROR. You chose the wording of your message; in the reference code’s wording it is:[IRQ] irq is 1 from cycle 5921, but STATUS = 001 and INT_EN = 000 make it 0In the golden run, the scoreboard’s summary (the
grepin Part 4, step 2) now saysirq checked in 14681 cycles, wrong in 0. Why does B02 show up in Lab 04’s traffic, and why does B01 still hide?TipAnswerYour
router_lab06_vseqsends no packets yet, so the drop that setSTATUS.NOROUTEwas in Lab 04’s traffic. Every phase ofrouter_inject_testdisables a route and sends packets to it (in the first phase the routing table is010-).INT_ENstays 0 all through that traffic, because Lab 04’s steps and your Lab 05 sequence never write it, and the bit bash leaves each of its bits the way it found it. Soirqmust stay 0, but B02, which ignoresINT_EN, raises it at the first NOROUTE drop. Nothing after that drop clearsSTATUS, soirqstays wrong and the check reports it once. B01 shows only when something writesSTATUSwhile a bit that the write shouldn’t clear is set. The only writes toSTATUSso far are the bit bash’s, right after reset, when every bit is 0.Write the Part 5 step of
router_lab06_vseq:- disable
DST1 withroute(1, 0, 0)and make both sinks fast withsink(p, SNK_FAST); - with
INT_ENstill 0, set all threeSTATUSbits, sending the packets withburst(): one 1-beat packet toDST1, which is a NOROUTE drop, and one 9-beat packet toDST0, which is OVERSIZE; thendrain(), stall output 0 withstall(0), and send ten 1-beat packets toDST0, the last of which is dropped as FULL; - read
STATUS; - turn each
INT_ENbit on by itself, waiting two cycles after each write; - set
INT_ENto'b111, then clear theSTATUSbits one at a time by writing'b001,'b100and'b010, and readSTATUSafter each write; drain(), thenrd_all_regs().
Write
INT_ENandSTATUSwithwr_reg()and read them withrd_reg(). The model doesn’t check a read ofSTATUS, because its fields are volatile, but the scoreboard checks every one.- disable
Build (107 s for us) and run
make check-all. You should see:ok the golden design 0 UVM_ERROR, 0 UVM_FATAL 4.8s ------------------------------------------------------------------------ caught tier 1 B01_status_write_clears_all 3 UVM_ERROR 4.8s caught tier 1 B02_irq_ignores_int_en 1 UVM_ERROR 4.7s caught tier 1 B03_route3_readback_swapped 4 UVM_ERROR 4.7s caught tier 1 B04_misaligned_address_accepted 50 UVM_ERROR 1.4s caught tier 6 B14_enable_resets_to_one 2 UVM_ERROR 4.7s ------------------------------------------------------------------------ 5 of 5 caught. Every bug in the list, each one caught by a check that fired.B01’s first two errors, with the reference code, are:
[IRQ] irq is 0 from cycle 5969, but STATUS = 110 and INT_EN = 111 make it 1 [STATUS] a read of 08, completing in cycle 5972 returned 00000000; it should return 00000006, STATUS in cycle 5971The first write of
'b001clearedNOROUTEand, with B01,FULLandOVERSIZEtoo. B02 is still caught by one error, but the error is nowirq is 1 from cycle 5909, in your own step. Why doesn’t Lab 04’s traffic catch B02 any more?TipAnswerYour step ends with
INT_ENat'b111, and nothing writes it again, so Lab 04’s traffic and your Lab 05 sequence run with every enable on. With every enable on,|(STATUS & INT_EN)equals|STATUS, so B02 makes no difference toirq. That is the situationbugs.pymeans when it says that B02 hides behind “turning on every interrupt enable before looking at irq”. Your step catches B02 earlier, after the NOROUTE drop and whileINT_ENis still 0.The register model has a mirror of
INT_ENandSTATUSas well. Why does the scoreboard keep its own copy of both, instead of reading the mirror?TipAnswerThe mirror of
STATUSis out of date most of the time, because the router sets its bits on its own and the model learns their value only when something reads the register. The mirror ofINT_ENchanges at the wrong moment for this check. The predictor updates it when the monitor reports the write, at the edge that ends the cycle in which the write completes, and the router uses the new value from the next cycle. The scoreboard checksirqfor a cycle at that same edge, so it would get the old or the newINT_ENdepending on which monitor the simulator woke first. That is the race that your Lab 05 scoreboard avoided by stamping route writes with their cycle. To checkirqexactly in every cycle, the scoreboard has to apply each change to the registers in the cycle in which the router applies it, so it keeps its own copy of both.
Check: 5 of 5 caught., and irq checked in 14840 cycles, wrong in 0 in the golden run.
Part 6: The back door
What do peek and poke do on this router?
A back-door access reads (
peek) or writes (poke) a register through the signal that holds it, with no bus transfer and no simulation time. Read the HDL paths at the end ofrouter_reg_block::build(),tb/router_regs.vlt(the register layer page says how they fit together), androuter_backdoor_vseqintb/router_vseq_pkg.sv.The sequence writes
CTRLwith a raw transfer and peeks it twice, then peeksSTATUSandDROP_CNTafter a NOROUTE drop. Then it pokesCTRL,INT_ENandDROP_CNTin turn, and peeks each one at once, one rising edge later and two rising edges later. Write down what you expect each peek to return, then run the test and pull out its lines:make run UVM_TESTNAME=router_backdoor_test sed -n 's/.*@ \([0-9]*\): .*\[BACKDOOR\] /\1 ps /p' build/runs/router_backdoor_test-s1/run.logYou should see
ok: 0 UVM_ERROR, 0 UVM_FATAL 0.09 sand:65000 ps peek CTRL as the write of 1 returns: 1 (UVM_IS_OK) 75000 ps peek CTRL one rising edge later: 1 (UVM_IS_OK) 125000 ps peek STATUS after a NOROUTE drop: 1 (UVM_IS_OK) 125000 ps peek DROP_CNT: 1 (UVM_IS_OK) 125000 ps poke CTRL with 0 (UVM_IS_OK) 125000 ps peek at once: 0 (UVM_IS_OK) 135000 ps peek one rising edge later: 0 (UVM_IS_OK) 145000 ps peek two rising edges later: 0 (UVM_IS_OK) 145000 ps poke INT_EN with 6 (UVM_IS_OK) 145000 ps peek at once: 6 (UVM_IS_OK) 155000 ps peek one rising edge later: 6 (UVM_IS_OK) 165000 ps peek two rising edges later: 6 (UVM_IS_OK) 165000 ps poke DROP_CNT with 505 (UVM_IS_OK) 165000 ps peek at once: 505 (UVM_IS_OK) 175000 ps peek one rising edge later: 505 (UVM_IS_OK) 185000 ps peek two rising edges later: 505 (UVM_IS_OK)Each poked value is still there two rising edges later. We measured that only on these three registers of this router, so before you rely on a poke in another design, peek the register after a rising edge, as this test does.
CTRLandINT_ENchange only on a write or a reset, but the router assigns bothDROP_CNTcounters at every rising edge. Why does the poked505survive?TipAnswerrouter_regs.svcomputes each counter’s next value from its present one, in the functionbump(), which clears the counter only on a write toDROP_CNTand adds one only on a drop. With neither, the next value is the present value, and after a poke the present value is the poked one.Before the test reads anything through the front door, it pokes each register back to the value it had.
+BACKDOOR_READBACKadds one front-door read ofDROP_CNTbefore that, whileDROP_CNTstill holds the poked505:make run UVM_TESTNAME=router_backdoor_test PLUSARGS="+verilator+error+limit+100000 +BACKDOOR_READBACK"The
sedcommand now prints one more line,225000 ps front-door read of DROP_CNT: 505 (UVM_IS_OK)and
make runprints:FAIL: 1 UVM_ERROR 0.09 s log: build/runs/router_backdoor_test-s1/run.log UVM_ERROR [DROP_CNT] read 00000505, expected 00000001 (FULL_CNT 0, NOROUTE_CNT 1)The router returned what was poked. Why does the scoreboard call it wrong?
TipAnswerThe scoreboard works out what
DROP_CNTshould hold from the drops it sees on the input and the writes it sees on the bus, and a poke is neither. It has seen one NOROUTE drop and no write toDROP_CNT, so as far as it knowsDROP_CNTholds00000001. A testbench that sets registers through the back door has to tell every model that keeps its own copy of them.peekis the safer of the two. It shows youSTATUSandDROP_CNTwithout a bus transfer, and since it doesn’t change the router, no model needs to hear about it.
Check: the sixteen lines above and ok from the shipped test, and the one [DROP_CNT] error with +BACKDOOR_READBACK.
Finishing
You’re done when make check-all prints 5 of 5 caught. with the register fields, adapter, predictor connections, irq check and router_lab06_vseq steps you wrote in tb/, and make seeds SEEDS="1 2 3 4 5" prints 5 ok (5 runs).
Questions:
Before this lab, the scoreboard checked one register,
DROP_CNT. What did the register model add, and what did it leave for the scoreboard and for raw transfers?TipAnswerIt added stimulus made from the register description. The reset sequence read every register it could check, and the bit bash wrote and read back every bit it could check, which caught B14 and B03 without a step written for either bug. It also added access by name (
wr_reg(regs.int_en, ...)), a mirror that the model compares with every read of a register that doesn’t change on its own, and the back door. It left the 246 bad addresses (B04), the volatile registers, and what the registers do to the rest of the router, such asirq(B01 and B02), to raw transfers and the scoreboard.
Submit: nothing for this lab.
Going further (optional)
Run your testbench against every bug in the catalogue:
make check-all BUG_LIST="B01 B02 B03 B04 B05 B06 B07 B08 B09 B10 B11 B12 B13 B14 B15"The reference solution catches 14 of the 15, and its output ends with:
caught tier 6 B14_enable_resets_to_one 2 UVM_ERROR 4.8s
MISSED tier 6 B15_output_valid_survives_reset 0 UVM_ERROR, 0 UVM_FATAL 4.9s
------------------------------------------------------------------------
14 of 15 caught.
It misses only B15, which hides behind “resetting only at time 0, when every buffer is already empty”. You’ll meet B15 in Lab 07.
Next on the Course path: the reading on verification plans and sign-off and on writing the verification report, then Lab 07: Capstone.

