TO Be coming

Nov 17, 2026

Day 14: Week 2 Review + Advanced Mini-Project — Virtual Sequences, Advanced Scoreboard, Coverage

Day 14: Week 2 Review + Advanced Mini-Project — Virtual Sequences, Advanced Scoreboard, Coverage
Advertisement
Top banner — drop your 728×90 or responsive ad unit here.

Day 14: Week 2 Review + Advanced Mini-Project — Virtual Sequences, Advanced Scoreboard, Coverage

A 30-day SystemVerilog/UVM verification series. Week 2 has added virtual sequences, advanced scoreboards, coverage, callbacks, end-of-test discipline, and debugging tools. Today they have to work together.

Week 2 is behind you. You can coordinate multiple agents, compare out-of-order transactions, collect coverage, inject errors, end tests cleanly, and debug a failing seed. Each of those is easy in isolation. Together, in one environment, they interact — and the interactions are where the real learning is.

Today's mini-project is the checkpoint before Week 3's RAL work. It has no new concepts. It has one question: can you build an environment where the layered pieces all fit? If yes, you understand Week 2. If not, this is the day to find out, not on Day 21 in the middle of an RAL bug.


1. The Week 2 Checklist

Audit yourself before you build. If any answer is "not sure," reread that day.

FromConceptCan you explain it?
Day 8Virtual sequencer + virtual sequenceWhy does the virtual sequence have no item port of its own?
Day 9Two-import pattern; analysis fifoWhen does write() need to be pushed into a fifo?
Day 10Covergroups, coverpoints, crossesWhy do individual coverpoints miss corner bugs?
Day 11Callbacks, events, barriersWhen is a callback the wrong answer?
Day 12Drain time, reset, error injection, timeoutsWhy does drain time exist?
Day 13Verbosity, ID filters, transaction recordingWhere does UVM_HIGH belong and where doesn't it?
The interaction that catches most people: virtual sequences wait for events (Day 11) whose triggers come from scoreboards (Day 9) which need drain time (Day 12) whose overflow is caught by timeouts (Day 12) reported at the right verbosity (Day 13). Get any one of those wrong and the test either hangs, truncates, or fails confusingly. This is the layered world Week 2 unlocks.

2. What You Are Building

Start with the Day 7 testbench and add the Week 2 pieces:

  • Virtual sequencer and virtual sequence — coordinate write and read agents from a virtual sequence.
  • Two-import scoreboard — separate wr_imp and rd_imp, or use an uvm_tlm_analysis_fifo on the expected side.
  • Coverage collector — uvm_subscriber with covergroups for write data, read data, and the wr/rd/enable crosses.
  • Error injection callback — corrupt one in N writes, and make the scoreboard expect errors.
  • Drain time and timeouts — the standard end-of-test discipline.
  • Verbosity discipline — the default run produces fewer than 500 lines.

Same directory structure as Day 7, plus the new files:

fifo_tb/
├── fifo_if.sv
├── fifo_tx.sv
├── fifo_sequencer.sv
├── fifo_vseqr.sv              // NEW: virtual sequencer
├── fifo_driver.sv
├── fifo_monitor.sv
├── fifo_agent.sv
├── fifo_agent_cfg.sv
├── fifo_scoreboard.sv         // upgraded: two-import or analysis fifo
├── fifo_coverage.sv           // NEW: uvm_subscriber
├── fifo_driver_cb.sv          // NEW: callback base + concrete
├── fifo_seq_lib.sv            // plus virtual sequence
├── fifo_env.sv                // upgraded: vseqr, coverage, callbacks
├── fifo_base_test.sv
├── fifo_err_test.sv           // NEW: enables error callback
├── fifo_tb_top.sv

3. Build Order

Same incremental discipline as Day 7. Build and run after each step.

  1. Start from Day 7. Confirm the smoke test still passes. This is your baseline.
  2. Add the virtual sequencer and virtual sequence. Wire handles in connect_phase. Run. The test should still pass, now coordinated through the virtual layer.
  3. Upgrade the scoreboard to the two-import pattern. Replace the combined write() with write_wr() and write_rd(). Confirm the same pass.
  4. Add coverage collector. Wire the monitor to it. Confirm bins are being hit.
  5. Add error injection callback. Create a callback class that corrupts one in 10 writes. Enable it in a subclass test. Add the error-expectation tracking to the scoreboard. Confirm the error test passes cleanly (no spurious UVM_ERROR).
  6. Add drain time and timeouts. Confirm the test ends deterministically.
  7. Tune verbosity. Default run should be under 500 lines. HIGH should be available per-component when needed.
Resist combining steps. Adding coverage while the scoreboard is broken means you cannot tell whether the scoreboard is failing or the coverage is. Add one piece, verify, add the next. This is the discipline that turns UVM work from frustrating to tractable.

4. Reference Implementations (Skeletons)

fifo_coverage.sv — the coverage collector:

class fifo_coverage extends uvm_subscriber #(fifo_tx);
    `uvm_component_utils(fifo_coverage)

    fifo_tx tr;

    covergroup cg_fifo;
        option.per_instance = 1;

        cp_wr: coverpoint tr.wr_en;
        cp_rd: coverpoint tr.rd_en;

        cp_wdata: coverpoint tr.wdata {
            bins zero = {8'h00};
            bins max  = {8'hFF};
            bins low  = {[8'h01:8'h7F]};
            bins high = {[8'h80:8'hFE]};
        }

        cp_rdata: coverpoint tr.rdata {
            bins zero = {8'h00};
            bins max  = {8'hFF};
            bins low  = {[8'h01:8'h7F]};
            bins high = {[8'h80:8'hFE]};
        }

        cross_wr_rd: cross cp_wr, cp_rd;
    endgroup

    function new(string name, uvm_component parent);
        super.new(name, parent);
        cg_fifo = new();
    endfunction

    function void write(fifo_tx t);
        tr = t;
        cg_fifo.sample();
    endfunction
endclass

fifo_driver_cb.sv — the error-injection callback:

class fifo_driver_cb extends uvm_callback;
    `uvm_object_utils(fifo_driver_cb)
    rand int unsigned corrupt_one_in = 10;

    function new(string name = "fifo_driver_cb");
        super.new(name);
    endfunction

    virtual task pre_drive(fifo_driver drv, fifo_tx tr);
        // default: do nothing
    endtask
endclass

class fifo_err_cb extends fifo_driver_cb;
    `uvm_object_utils(fifo_err_cb)

    virtual task pre_drive(fifo_driver drv, fifo_tx tr);
        if (tr.wr_en && ($urandom_range(1, corrupt_one_in) == 1)) begin
            tr.wdata ^= 8'h01;         // flip LSB
            tr.corrupt_expected = 1;
        end
    endtask
endclass

The driver registers the callback type and calls the hooks. The error test attaches the concrete callback. Nothing in the driver mentions error injection.

fifo_scoreboard.sv — upgraded to be error-aware:

`uvm_analysis_imp_decl(_wr)
`uvm_analysis_imp_decl(_rd)

class fifo_scoreboard extends uvm_scoreboard;
    `uvm_component_utils(fifo_scoreboard)

    uvm_analysis_imp_wr #(fifo_tx, fifo_scoreboard) wr_export;
    uvm_analysis_imp_rd #(fifo_tx, fifo_scoreboard) rd_export;

    fifo_tx    expected [$];
    int        num_writes, num_reads, num_mismatch, num_err_ok;

    function new(string name, uvm_component parent);
        super.new(name, parent);
        wr_export = new("wr_export", this);
        rd_export = new("rd_export", this);
    endfunction

    function void write_wr(fifo_tx tr);
        if (tr.wr_en) begin
            expected.push_back(tr);
            num_writes++;
        end
    endfunction

    function void write_rd(fifo_tx tr);
        fifo_tx e;
        if (!tr.rd_en) return;
        if (expected.size() == 0) begin
            `uvm_error("SB", "read on empty FIFO")
            return;
        end
        e = expected.pop_front();
        num_reads++;
        if (tr.rdata !== e.wdata) begin
            if (e.corrupt_expected) begin
                // corrupted write, error was expected — record but do not error
                num_err_ok++;
            end else begin
                num_mismatch++;
                `uvm_error("SB", $sformatf("mismatch: exp %0h got %0h",
                          e.wdata, tr.rdata))
            end
        end
    endfunction

    function void check_phase(uvm_phase phase);
        if (num_writes == 0 && num_reads == 0)
            `uvm_error("SB", "no traffic observed")
        if (num_mismatch)
            `uvm_error("SB", $sformatf("%0d mismatches", num_mismatch))
        if (expected.size())
            `uvm_error("SB", $sformatf("%0d expected not observed", expected.size()))
        `uvm_info("SB", $sformatf("wr=%0d rd=%0d mismatch=%0d err_expected=%0d",
                  num_writes, num_reads, num_mismatch, num_err_ok), UVM_LOW)
    endfunction
endclass

fifo_vseqr.sv and the virtual sequence — see Day 8's code. Same structure, wired into the env.

The test with drain time and timeout:

class fifo_base_test extends uvm_test;
    `uvm_component_utils(fifo_base_test)
    fifo_env env;

    function new(string name, uvm_component parent);
        super.new(name, parent);
    endfunction

    virtual function void build_phase(uvm_phase phase);
        super.build_phase(phase);
        env = fifo_env::type_id::create("env", this);
    endfunction

    virtual task run_phase(uvm_phase phase);
        fifo_write_then_read_seq vseq;
        phase.raise_objection(this);
        phase.phase_done.set_drain_time(this, 200ns);

        vseq = fifo_write_then_read_seq::type_id::create("vseq");
        vseq.start(env.vseqr);

        phase.drop_objection(this);
    endtask
endclass

5. Week 2 Self-Assessment

Before you move to Day 15, every one of these should be true:

  • The full environment compiles with no warnings from your own code.
  • The smoke test passes in under one second of simulated time.
  • The scoreboard reports mismatch=0 err_expected=0 on the pass run.
  • The error test passes with a nonzero err_expected count and no spurious UVM_ERROR.
  • Coverage bins are hit for write data, read data, and the wr/rd cross.
  • A deliberately broken DUT causes a mismatch, and the scoreboard tells you which ID.
  • Running a fresh seed still passes. Run ten seeds. If any fail, you have a race — the most common cause is the drain time being too short.
  • The default run log is under 500 lines.

If any of these is not true, fix it before Day 15. The RAL week builds on a clean base; a buggy base makes RAL debugging impossible.


6. What Day 15 Will Add

Tomorrow begins Week 3 with the Register Abstraction Layer (RAL). You will learn the four RAL building blocks — uvm_reg, uvm_reg_field, uvm_reg_block, and uvm_mem — and what each models. RAL turns "write to address 0x104" into "write to the CTRL register's ENABLE field," with access policies, mirroring, and prediction built in.


7. Quiz

Ten questions spanning Week 2.

Question 1 of 10
Loading…
    0 / 10
    Advertisement
    Bottom banner — drop your 728×90 or responsive ad unit here.

    Coming Up Next: Day 15 — RAL Introduction

    • uvm_reg — a single register with fields, access policies, and a mirror value.
    • uvm_reg_field — one field within a register, with access type (RO/RW/WO/W1C) and reset value.
    • uvm_reg_block — a container for registers, with address maps.
    • uvm_mem — a memory array modeled for read/write access through RAL.
    ← Back to the 30-Day UVM Course
    See all 30 days, week by week.

    Series: 30 days of SystemVerilog/UVM verification. Day 14 — Week 2's checkpoint.

    No comments:

    Post a Comment

    SiteMap