Lab 05: Protocol rules and backpressure
In this lab you’ll write assertions for the router’s output rules and bind them into the router, finish a sink driver whose sequence chooses, for each output beat, how long the sink waits before taking it, and write a virtual sequence that changes the routing table, the traffic and the backpressure together. You start from the Lab 04 testbench, which already catches two of this lab’s three planted bugs, B10 and B12. Your assertions name the rule that the router broke and the cycle it broke it in. The third bug, B11, shows only on packets of more than 8 beats, which no Lab 04 test sends, and your virtual sequence sends them.
Package: labs/lab-05-protocol-rules-and-backpressure/
Before you start
- Finish Lab 04.
- Read Assertions for interface rules, Reactive agents and backpressure and Virtual sequences.
- Keep the router specification open in another tab, at Valid/ready rules. The rule names on this page (I1, I2, O1, O2, O6, O7 and O8) are the ones defined there.
The package is Lab 04’s testbench with our solution to Lab 04 in it: the second output agent, the scoreboard lines for output 1, the real level(), router_stall_test, router_noroute_pkt and the factory override. If your own Lab 04 printed 2 of 2 caught., your code did the same job, but use ours anyway, because your Lab 04 edits were in router_env_pkg.sv and router_tests_pkg.sv, and this lab adds to both files. What we added for you:
| File | What Lab 05 adds |
|---|---|
tb/router_sva.sv, tb/router_sva_bind.sv |
the assertion module and the bind that puts it in the router; you write three of its assertions (Part 2) |
tb/router_ifs.sv, tb/router_tb_top.sv |
router_sva_if, which carries the assertions’ failure count to the scoreboard |
tb/router_agents_pkg.sv |
an output agent whose driver can answer each beat from a sequence (you finish it in Part 3); an oversize length kind in router_pkt, switched off until a sequence gives it a weight; how long each output beat waited, which the output monitor records; the cycle in which each APB transfer completed; and gap_pct and w_over on router_rand_seq, which send_rand sets (Part 4) |
tb/router_env_pkg.sv |
cg_wait, a virtual sequencer, and three scoreboard changes: it reports the assertions’ failure count, it follows route writes made while packets are coming in, and it fails a test that checked nothing |
tb/router_vseq_pkg.sv |
the virtual sequences; you write router_lab05_vseq (Part 4) |
tb/router_tests_pkg.sv |
router_test (Lab 04’s router_inject_test, then your virtual sequence), router_lab05_test (the sequence alone) and router_sink_test (Part 3) |
Time: about 2 h. On the course’s 2 CPUs our first build took 106 s, and the rebuilds after the edits in Parts 2, 3 and 4 took 103 s, 32 s and 105 s.
Part 1: The Lab 04 testbench against this lab’s bugs
Which of this lab’s bugs does the testbench you already have catch, and how close does it get to the cycle where the router went wrong?
Go to the lab folder and start the build:
cd labs/lab-05-protocol-rules-and-backpressure make buildThe banner says a cold build takes 1.5 to 2.5 minutes on 2 CPUs, and ours took 106 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 59.791 MB sources in 431 modules, into 27.944 MB in 3213 C++ files needing 198.696 MB - Verilator: Walltime 106.395 s (elab=0.811, cvt=3.129, bld=101.669); cpu 5.091 s on 2 threads; allocated 355.551 MBRun the graded test,
router_test. It runs everythingrouter_inject_testdid in Lab 04 and thenrouter_lab05_vseq, which is empty for now:make runYou should see
ok: 0 UVM_ERROR, 0 UVM_FATAL 1.72 s, and above it:UVM_INFO labs/lab-05-protocol-rules-and-backpressure/tb/router_env_pkg.sv(257) @ 61465000: uvm_test_top.env.sb [SB] 805 packets in: 144 to output 0, 190 to output 1, 194 NOROUTE, 277 FULL; the highest level a header saw was 16 UVM_INFO labs/lab-05-protocol-rules-and-backpressure/tb/router_env_pkg.sv(259) @ 61465000: uvm_test_top.env.sb [SB] beats checked: 648 on output 0, 799 on output 1; 5 DROP_CNT reads checked UVM_INFO labs/lab-05-protocol-rules-and-backpressure/tb/router_env_pkg.sv(263) @ 61465000: uvm_test_top.env.sb [SVA] the bound assertions (router_sva.sv) counted 0 failuresThe two
[SB]lines are the onesrouter_inject_testprinted at the end of Lab 04, Part 4, number for number, so the stimulus is unchanged. (The line numbers afterrouter_env_pkg.svdiffer, because the file has grown.) The[SVA]line is new.Look at how long the output beats waited.
cg_waitrecords, for each packet an output delivers, the longest any of its beats waited forready:noneis 0 cycles,short_wait1 to 3,long_wait4 to 20 andstalledmore than 20.cp_len.oversizecounts packets of 9 beats or more on the input, before the router cuts them.make cov grep -E "cg_wait.cp_wait|cp_len.oversize" build/coverage/bins.txtYou should see:
0 __vlAnonCG_cg_pkt.cp_len.oversize 257 __vlAnonCG_cg_wait.cp_wait.none 2 __vlAnonCG_cg_wait.cp_wait.short_wait 18 __vlAnonCG_cg_wait.cp_wait.long_wait 57 __vlAnonCG_cg_wait.cp_wait.stalledLab 04’s sink flips a coin every cycle. At 100% a beat never waits, and at 5% a beat waits about 20 cycles on average, so a packet whose longest wait is 1 to 3 cycles is rare.
Run the grader against this lab’s three bugs:
make check-allYou should see:
ok the golden design 0 UVM_ERROR, 0 UVM_FATAL 1.7s ------------------------------------------------------------------------ MISSED tier 4 B11_cut_packet_has_no_last 0 UVM_ERROR, 0 UVM_FATAL 1.7s caught tier 4 B10_output_reloads_while_stalled 50 UVM_ERROR 0.5s caught tier 5 B12_out1_uses_out0_ready 50 UVM_ERROR 0.1s ------------------------------------------------------------------------ 2 of 3 caught. Still hiding from this test: B11_cut_packet_has_no_last hides behind: sending only legal packets of 8 beats or fewermake check, which grades the first bug in the list, saysVERDICT: FAIL -- your test passes B11_cut_packet_has_no_last too.Lab 04’s stall test already makes the twoout_readysignals differ and lets beats wait on a stalled output, and that is all B12 and B10 need. B11 needs a packet of more than 8 beats, and none of Lab 04’s tests sends one.Look at the first errors for the two bugs the testbench catches:
make run BUG=B10 make run BUG=B12You should see, from the first:
caught: 50 UVM_ERROR 0.54 s log: build/runs/router_test-s1-B10/run.log UVM_ERROR [OUT] output 0: got 04 in cycle 56, expected 03and from the second:
caught: 50 UVM_ERROR 0.08 s log: build/runs/router_test-s1-B12/run.log UVM_ERROR [OUT] output 1: got 80 in cycle 24, and no beat was expectedPredict a cycle before you go on. In phase 1 output 0 is ready in 5% of cycles. The router accepts the 8-beat packet
03 a4 ab 49 70 74 f5 71in cycles 45 to 52, into an empty output 0, and output 0’s sink is first ready again in cycle 56. By rule O8, in which cycle is03first onout0_data? B10 loads the next beat into the output register even whileout0_readyis 0. In which cycle doesout0_datafirst change while03waits? Write that cycle down; Part 2 checks it.TipAnswerO8 puts a beat into an empty output two cycles after its input handshake, so
03is on the output from cycle 47. B10 loadsa4over it at the next edge, soout0_datafirst changes in cycle 48. The scoreboard sees only beats that are taken, and output 0’s sink took nothing until cycle 56, by which time the router had moved through the whole packet and on to04, the next header. The router went wrong 8 cycles before the scoreboard could see anything.
Check: make check-all printed 2 of 3 caught., and you’ve written down a cycle for B10.
Part 2: Assertions for the output rules
Which rule did B10 break, and in which cycle?
Open
tb/router_sva.sv. The modulerouter_svahas two assertions written for you,a_I1anda_I2, for the source’s rules I1 and I2, so they check the testbench’s own source driver. Reada_I1with the specification’s I1 beside it. The part left of|=>(the antecedent) picks the cycles the rule talks about, and|=>means “then, in the next cycle”.disable iff (!rst_n)switches the check off whilerst_nis 0, because a reset ends a beat without a handshake and that doesn’t break the rule. A failure adds one ton_I1and calls$error.In
router_sva_out, which is instantiated once per output, write the three assertions the TODOs describe:a_O1: onceout_validis 1, it stays 1 until the handshake;a_O2: whileout_validis 1 andout_readyis 0,out_dataandout_lastdon’t change;a_O6: a beat taken whenbeatsis 7 hasout_last= 1. (beatscounts the beats of the current output packet already taken, and the file keeps it for you.) This one is about the cycle of the handshake itself, so it uses|->(the same cycle).
Count each one’s failures in its own counter (
n_O1,n_O2,n_O6) and give each one an$errormessage, asa_I1does. The outputs on this page show our messages. For O1 and O2 they area_I1’s anda_I2’s withO1andO2in place ofI1andI2, andout_in place ofin_. For O6 it isO6: an output packet is longer than 8 beats.Open
tb/router_sva_bind.sv. Why does the testbench attach the assertions withbindinstead of instantiatingrouter_svainrouter_tb_top?TipAnswerbindputs an instance ofrouter_svainside everyrouter, wired to the router’s own ports, without editing the router’s RTL or the top module. The same file works on the golden design and with any planted bug switched on, and the checker sees the same pins that the rules are written about. The top module reads the failure count back out through the router instance,dut.u_sva.n_fail, and hands it to the scoreboard throughrouter_sva_if.Rebuild and run on the golden design:
make build make runThe rebuild took us 103 s. You should see
ok, the same two[SB]lines as in Part 1, and[SVA] the bound assertions (router_sva.sv) counted 0 failures. A failure here means one of your assertions is wrong, because the golden router keeps all three rules.Run B10 with the simulator’s own error limit.
PLUSARGS=on the command line replaces the Makefile’s+verilator+error+limit+100000:make run BUG=B10 PLUSARGS= cat build/runs/router_test-s1-B10/exit_statusYou should see the run stop at the first failure, then
1:[475000] %Error: router_sva.sv:50: Assertion failed in router_tb_top.dut.u_sva.u_out0.a_O2: O2: out_data or out_last changed while the beat waited %Error: labs/lab-05-protocol-rules-and-backpressure/tb/router_sva.sv:50: Verilog $stop Aborting... ------------------------------------------------------------------------ caught: 1 assertion 0.07 s log: build/runs/router_test-s1-B10/run.log router_sva.sv:50: Assertion failed in router_tb_top.dut.u_sva.u_out0.a_O2: O2: out_data or out_last changed wh ------------------------------------------------------------------------The line number is the line of the
$errorcall in youra_O2, so yours may differ, here and later. The time, 475000, is in picoseconds, so the failure was at 475 ns. The clock’s period is 10 ns and its first rising edge is at 5 ns, so the edge that ends cycle \(n\) is at \(10n - 5\) ns, and this failure was sampled at the edge that ends cycle 48. Compare it with your prediction from Part 1.Verilator’s default error limit is 1, so the first failing assertion ends the run with exit status 1, and nothing after it is checked. That’s why the Makefile raises the limit. With the limit raised, every failure prints, each assertion’s counter keeps counting, and the scoreboard reports their sum at the end of the test.
Run B10 again with the Makefile’s limit, and find the first check of each kind that fired:
make run BUG=B10 grep -m1 "%Error" build/runs/router_test-s1-B10/run.log grep -m1 "UVM_ERROR" build/runs/router_test-s1-B10/run.logYou should see
caught: 50 UVM_ERROR, 244 assertions, then:[475000] %Error: router_sva.sv:50: Assertion failed in router_tb_top.dut.u_sva.u_out0.a_O2: O2: out_data or out_last changed while the beat waited UVM_ERROR labs/lab-05-protocol-rules-and-backpressure/tb/router_env_pkg.sv(193) @ 555000: uvm_test_top.env.sb [OUT] output 0: got 04 in cycle 56, expected 03The assertion fired at the edge that ends cycle 48, and the scoreboard reported its first error 8 cycles later, in cycle 56.
To see the rule break, record both runs and open them in Surfer:
make waves make waves BUG=B10 surfer build/runs/router_test-s1/waves.fst & surfer build/runs/router_test-s1-B10/waves.fst &Add
valid,ready,dataandlastfromin_sandout0,level0fromdut, andn_O2fromdut.u_sva.u_out0, and look at 435 to 575 ns:The golden router. The packet
03 a4 ab 49 70 74 f5 71comes in one beat per cycle from the edge at 445 ns.03reachesout0_dataat the edge at 455 ns, in cycle 47, and stays there whileout0_readyis 0;level0climbs as the rest of the packet arrives.out0_readyis 1 in cycle 56, the sink takes03at the edge at 555 ns, anda4follows.n_O2stays 0.B10.
out0_datachanges from03toa4at the edge at 465 ns, whileout0_readyis 0, and then steps through the rest of the packet, one beat per cycle.n_O2counts its first failure at the edge at 475 ns, which ends cycle 48, and one more for nearly every cycle after. Whenout0_readyrises in cycle 56, the beat on the output is04.Run the grader again:
make check-allYou should see B10 caught by your assertions as well, B12 with one assertion, and B11 still missed:
MISSED tier 4 B11_cut_packet_has_no_last 0 UVM_ERROR, 0 UVM_FATAL 1.7s caught tier 4 B10_output_reloads_while_stalled 50 UVM_ERROR, 244 assertions 0.6s caught tier 5 B12_out1_uses_out0_ready 50 UVM_ERROR, 1 assertion 0.1s ------------------------------------------------------------------------ 2 of 3 caught.The one assertion on B12 is
a_O6, on output 1, at the edge at 635 ns (cycle 64); the scoreboard’s first error was in cycle 24. Rungrep -m1 "%Error" build/grade/B12/run.logto see it. B11 is the bug that breaks O6, but youra_O6passes on B11 and fails on B12. Why?TipAnswerAn assertion can only fail on something that the stimulus makes the router do. Under B11, O6 can fail only on the 8th beat of a packet that has a 9th, and nothing in
router_testsends a packet longer than 8 beats yet, so on B11 the router never has a packet to cut.B12 moves output 1 on
out0_ready. In phase 1 output 0 is ready in 5% of cycles and output 1 in all of them, so in most cycles output 1’s sink takes the beat on its pins, but the buffer behind them doesn’t move on to the next beat. The pins show a handshake in each of those cycles with the same data, which is what the scoreboard saw in cycle 24 (got 80 ... and no beat was expected). Each repeat is one more beat of the packet on output 1’s pins, so once eight beats in a row have had noout_last, O6 fails. O1 and O2 are about cycles whereout_readyis 0, andout1_readyis 1 all through phase 1; the run stops at 50 errors in cycle 73, long before phase 2 stalls output 1.
Check: make check-all prints 50 UVM_ERROR, 244 assertions for B10, and your answer to Part 1’s prediction matches cycle 48.
Part 3: A sink that answers each beat
What changes when each sink takes its beats at its own pace, instead of flipping a coin every cycle?
Read the output agent in
tb/router_agents_pkg.sv:out_cfg,out_ready_item,out_ready_seq,out_ready_driverandout_agent.out_cfg.modepicks how the sink answers. InSNK_PCT, the default, the driver is Lab 04’s: every cycleout_readyis 1 with probabilityready_pctpercent. In the other modes it is a reactive driver. The router decides when a beat appears, and the driver answers each beat with an item fromout_ready_seq: withpre_readyset,readyis already 1 when the beat appears; otherwise the sink waitsdelaycycles after the beat’s first cycle on offer, then raisesready.SNK_FASTmakes every itempre_ready,SNK_SLOWgives every beat a delay of 4 to 20, andSNK_RANDOMrandomizes each item. The driver looks at the output at the falling edge in the middle of each cycle and drives the next cycle’sreadyjust after the rising edge; that loop is written for you. Why does it ask for items withtry_next_item()and notget_next_item(), as Lab 04’s source driver does?TipAnswerget_next_item()blocks until the sequence hands over an item. The source driver can wait, because nothing happens on the input until it has a packet. The sink driver can’t wait like that, because it has to driveout_readyin every cycle, and the router may put a beat on the output whether or not an item is ready.try_next_item()returns in the same time step, with no item if the sequence hasn’t handed one over, and the driver then keepsreadyat 0 for the next cycle.router_sink_testis Lab 03’srouter_rand_testwith both sinks inSNK_RANDOM. Run it as shipped, on its own, and look at its waits:rm -rf build/runs make run UVM_TESTNAME=router_sink_test make cov grep -E "cg_wait.cp_wait" build/coverage/bins.txtYou should see
okin about 4 s, and:UVM_INFO labs/lab-05-protocol-rules-and-backpressure/tb/router_env_pkg.sv(257) @ 57695000: uvm_test_top.env.sb [SB] 805 packets in: 353 to output 0, 451 to output 1, 1 NOROUTE, 0 FULL; the highest level a header saw was 9803 __vlAnonCG_cg_wait.cp_wait.none 0 __vlAnonCG_cg_wait.cp_wait.short_wait 0 __vlAnonCG_cg_wait.cp_wait.long_wait 1 __vlAnonCG_cg_wait.cp_wait.stalledThe
[SB]line is the onerouter_rand_testprinted in Lab 04, Part 2, and 803 of the 804 packets that came out never waited, because as shipped the driver is always ready in the per-beat modes, whatever the item says. The onestalledpacket is fromclose_holes(), which stalls output 0 in Lab 04’s mode,SNK_PCT.Fill in the two TODOs in
out_ready_driver::run_phase: the countdown while a beat waits, and the expression forrdy, the next cycle’sready.rdymust be 0 while the driver has no item. The countdown has to stop at 0. A beat whose wait is over can still be on offer if a virtual sequence then stalls its output (Part 4), and the countdown goes on running in every cycle the beat waits.wait_leftis unsigned, so one more count would wrap it round to about four billion, and once the sink was back in a per-beat mode it would never raisereadyfor that beat.Before you rebuild, predict what happens to the
[SB]line’sFULLcount and to the fourcp_waitbins.TipAnswerEach beat now waits 0 cycles when its item is
pre_readyand otherwise 1 to 13, so most packets land inshort_waitorlong_wait. A sink that waits a cycle or more on most beats takes them more slowly than the input can bring them, so an output sometimes fills past 8 beats, and the packets that arrive for it then are FULL drops.Rebuild, clear the runs and look again:
make build rm -rf build/runs make run UVM_TESTNAME=router_sink_test make cov grep -E "cg_wait.cp_wait" build/coverage/bins.txtThe rebuild took us 32 s. If your driver does what the TODOs say, you should see
okand:UVM_INFO labs/lab-05-protocol-rules-and-backpressure/tb/router_env_pkg.sv(257) @ 58285000: uvm_test_top.env.sb [SB] 805 packets in: 317 to output 0, 401 to output 1, 1 NOROUTE, 86 FULL; the highest level a header saw was 13129 __vlAnonCG_cg_wait.cp_wait.none 305 __vlAnonCG_cg_wait.cp_wait.short_wait 283 __vlAnonCG_cg_wait.cp_wait.long_wait 1 __vlAnonCG_cg_wait.cp_wait.stalledLab 04’s sinks put 2 packets in
short_waitin the whole ofrouter_test, and your driver puts 305 there in one run ofrouter_sink_test. The run passed, so every phase’sDROP_CNTread matched the scoreboard’s count, which means the scoreboard predicted all 86 FULL drops.Run the grader:
make check-allYou should see
2 of 3 caught.again, with the same counts as in Part 2.router_testkeeps its sinks inSNK_PCT, so your driver changes none of its stimulus, and B11 still needs a packet longer than 8 beats.
Check: router_sink_test passes with 305 in short_wait, and make check-all says 2 of 3 caught.
Part 4: A virtual sequence
How do you make the configuration, the traffic and the backpressure change together, from one place?
Read
router_vsequencerintb/router_env_pkg.sv, thenrouter_base_vseqandrouter_lab05_vseqintb/router_vseq_pkg.sv. The helpers you’ll use areroute(n, en, port),ctrl(en),sink(p, mode),stall(p),burst(dst, n, len),send_rand(n, gap_pct, w_over),backpressure(),cycles(n),drain()andrd(A_...). Most of them are the base test’s steps from Lab 04, rewritten as tasks of a sequence, and they start the same Lab 04 sequences that the steps started. Why does the virtual sequencer hold each sink’sout_cfg, and not only its sequencer?TipAnswerEach sink’s
out_ready_seqis started by its agent and runs for the whole test, one item per beat. A virtual sequence steers the backpressure by changingmodeandready_pctinout_cfg. The sequence readsmodefor every item, and the driver readsmodeevery cycle, andready_pcttoo while the mode isSNK_PCT. Starting another sequence on a sink’s sequencer would compete with the one already running there.Run the test that runs your sequence alone, as it is now:
make run UVM_TESTNAME=router_lab05_testYou should see:
FAIL: 1 UVM_ERROR 0.07 s log: build/runs/router_lab05_test-s1/run.log UVM_ERROR [SB] no packet came in and no DROP_CNT read was checked, so nothing was checkedThe scoreboard fails a test that checked nothing.
make regress, which runs every test in the Makefile, fails for the same reason until you finish this part.Read
write_apband the start ofwrite_inin the scoreboard. In Lab 04 a route write changed the scoreboard’s routing table at once, which was safe because the tests wrote routes only between phases. Nowwrite_apbputs the write inpendingwith the cycle it completed, andwrite_inapplies it at the first header of a later cycle. Why the cycle, and not the order in which the two calls arrive?TipAnswerThe specification’s Routing section says a header accepted in the cycle a register write completes still uses the old value. The APB monitor and the input monitor both report at the same clock edge, and SystemVerilog leaves the order of processes woken by the same edge to the simulator, so a header and a route write in the same cycle could reach the scoreboard in either order. The cycle stamps don’t depend on that order.
Write
router_lab05_vseq::body(). The TODO lists four steps:- Configure the router: every route enabled, two DSTs to each output, and
CTRL.ENset. - Stall output 1 and send packets to both outputs, then stall output 0 instead, with a
drain()after each. - Send oversize packets (9 beats or more) to every DST with both sinks in
SNK_RANDOM, then drain. - In one
fork, run random packets with oversize ones among them (send_rand’sw_over),backpressure(), and a branch that moves two routes to the other output and back while the packets are in flight. Then drain, and readDROP_CNT.
Step 4 has this shape.
backpressure()loops untiltraffic_doneis set:traffic_done = 0; fork begin send_rand(...); // the packets traffic_done = 1; end backpressure(); // each sink changes its mode on its own begin ... // route changes, with cycles() between them end join- Configure the router: every route enabled, two DSTs to each output, and
Predict how each oversize packet should come out, and which bug your sequence now reaches.
TipAnswerCut to 8 beats, with
out_laston the 8th; the router takes the rest from the input and throws them away (example E6 in the specification). With B11, the 8th beat has noout_last, so O6 fails on it, and the scoreboard, which already expected the cut, sees the wrongout_laston the same beat.Rebuild, then run both tests and look at the coverage:
make build rm -rf build/runs make run UVM_TESTNAME=router_lab05_test make run make cov grep -E "cg_wait.cp_wait|cp_len.oversize" build/coverage/bins.txtThe rebuild took us 105 s. You should see
okfrom both runs andoversizeabove 0. The counts depend on your sequence. Ours were 77 foroversize, over the two runs, androuter_testsaid:UVM_INFO labs/lab-05-protocol-rules-and-backpressure/tb/router_env_pkg.sv(257) @ 87215000: uvm_test_top.env.sb [SB] 1122 packets in: 240 to output 0, 270 to output 1, 194 NOROUTE, 418 FULL; the highest level a header saw was 16 UVM_INFO labs/lab-05-protocol-rules-and-backpressure/tb/router_env_pkg.sv(259) @ 87215000: uvm_test_top.env.sb [SB] beats checked: 1108 on output 0, 1219 on output 1; 6 DROP_CNT reads checkedThe first 805 packets are Lab 04’s, as in Part 1, and our sequence sent the other 317.
Run the grader:
make check-allYou should see
3 of 3 caught.Ours:ok the golden design 0 UVM_ERROR, 0 UVM_FATAL 2.8s ------------------------------------------------------------------------ caught tier 4 B11_cut_packet_has_no_last 33 UVM_ERROR, 26 assertions 2.8s caught tier 4 B10_output_reloads_while_stalled 50 UVM_ERROR, 244 assertions 0.6s caught tier 5 B12_out1_uses_out0_ready 50 UVM_ERROR, 1 assertion 0.1s ------------------------------------------------------------------------ 3 of 3 caught. Every bug in the list, each one caught by a check that fired.On B11 our
a_O6failed at the edge that ends cycle 6265, and the scoreboard reported the same beat in the same cycle (output 0: got a7 in cycle 6265, expected a7 last). At the end of the run the scoreboard added[SVA] the bound assertions (router_sva.sv) counted 26 failures. What did O6 add that the scoreboard’s error didn’t already give you?TipAnswerO6 names the rule, and it needs no model of the router. It checks one line of the specification against the pins, so it would catch B11 in any testbench that binds the file and sends an oversize packet, including one whose scoreboard didn’t know that the router cuts long packets. The scoreboard knows what every beat should be, so it catches far more, but its message gives only the beat that was wrong and what it expected instead.
Now run B12 against your sequence alone, which stalls output 1 first, and compare the first check of each kind:
make run UVM_TESTNAME=router_lab05_test BUG=B12 grep -m1 "%Error" build/runs/router_lab05_test-s1-B12/run.log grep -m1 "UVM_ERROR" build/runs/router_lab05_test-s1-B12/run.logOurs said
caught: 50 UVM_ERROR, 34 assertions, and:[395000] %Error: router_sva.sv:50: Assertion failed in router_tb_top.dut.u_sva.u_out1.a_O2: O2: out_data or out_last changed while the beat waited UVM_ERROR labs/lab-05-protocol-rules-and-backpressure/tb/router_env_pkg.sv(193) @ 3605000: uvm_test_top.env.sb [OUT] output 1: got 46 in cycle 361, expected 44Our O2 failed in cycle 40 and the scoreboard complained in cycle 361. In
router_testthe scoreboard was first. Why is it so much later here?TipAnswerStep 2 of the sequence stalls output 1 while output 0 takes its beats. Under B12 output 1’s buffer moves on
out0_ready, so its beats leave whileout1_readyis 0. None of them has a handshake on output 1’s pins, so its monitor reports nothing. By the time the stall ends, every beat routed to output 1 has left its buffer, so output 1’s sink has nothing to take either, anddrain()waits its full 300 cycles, because the scoreboard still expects those beats. Output 1’s first handshake of the run is in cycle 361, when the second half of step 2 sends it new packets, and that is the scoreboard’s first chance to compare a beat on output 1. O2 watches the pins, so it fails in the first cycle the beat on output 1 changes while it waits. Inrouter_test’s phase 1 the readies differed the other way round, output 1 ready and output 0 stalled, and then the scoreboard sees the extra beats at once.Check that your testbench still passes the golden design on other seeds:
make seeds SEEDS="1 2 3 4 5"You should see
5 ok (5 runs).
Finishing
You’re done when make check-all prints 3 of 3 caught. with your assertions, your sink driver and your virtual sequence in tb/, and make seeds SEEDS="1 2 3 4 5" prints 5 ok (5 runs).
Questions:
B12 breaks rule O7, because it makes output 1 depend on
out0_ready. Your file has noa_O7. Which checks caught B12, and why is there no assertion for O7?TipAnswerThe scoreboard in
router_test, from cycle 24, and O6 on output 1 in cycle 64; inrouter_lab05_test, O2 and O1 on output 1 first and the scoreboard much later (Part 4, step 8). O7 says what an output does not depend on, and the specification points out that no single trace can show that. You can only see its consequences, when the twoout_readysignals differ and output 1 then does something that O1, O2, O6 or the scoreboard’s model forbids. Lab 04’s stall test was the first test to make them differ while both outputs carried traffic, which is why your Lab 04 testbench already caught B12.Your O1 and O2 are disabled while
rst_nis 0. What would O1 do on the golden design, withoutdisable iff, in a test that resets the router while a beat waits on a stalled output?TipAnswerIt would fail. A reset lowers
out_validat once, with no handshake (the specification’s Valid/ready rules and example E8), and that is what O1’s consequent forbids. Rules about normal operation don’t hold across a reset, so their assertions are switched off during one.
Submit: nothing for this lab.
Next on the Course path: read Register models and Regressions and seeds, then do Lab 06: The register block.

