UVMIEEE 1800.2SystemVerilogVerilator

Verify This!

A UVM course that runs end to end on Verilator.

Almost every UVM course out there assumes Questa, VCS or Xcelium —licences a student does not have—. This one is seven days of class, ≈ 31 h, and every one of its examples really runs on free tools. No licences, no account, no signup form. Coming from RTL or C and never wrote a class? Start anyway: day 2 is entirely the object-oriented programming UVM takes for granted.

En español: este curso nació en castellano. Ir al curso en español ›

The English course is complete — all eight days, rewritten rather than machine-translated. The examples, the exercises and the diagrams are shared by both versions and run exactly as they are.

8units
444slides
38examples that run
19self-checking exercises
$0in licences

Start in 60 seconds

# nothing to install: Code ▸ Codespaces ▸ Create codespace
make u4/tests

# or on your own machine, with Verilator ≥ 5.050:
git clone https://github.com/leandrotozzi/verifythis
cd verifythis && make doctor && make u4/tests

That compiles and runs one section of day 3 against UVM 2020.3.1 on Verilator, and prints the Report Summary you can see just below. CI runs the 38 examples and the 19 solutions every night ↗ — if something broke, that link says so before I do.

Why it exists

A verification course you can run, not only read

Verification is half the work of a chip and almost nobody learns it hands on, because the simulator costs more than the salary. This fixes that.

Free tools

Verilator, and with functional coverage

Since 5.050 Verilator measures covergroup, which is a topic of the course. There is no Questa flow: you take the simulator home and keep practising without asking anybody for a licence.

Written, not generated

Written by someone who teaches it

Seven days of class with presenter notes: the classic trap, the reason behind the number, the mistake everybody makes the first time. It is not a reference, and it is not a manual run through a translator.

Verified

The badge says whether they run today

The 38 examples are run by continuous integration on every change, and every night the nineteen exercise solutions are run too. The promise is not held up by a screenshot.

Genuinely free

MIT, Apache-2.0 and CC BY 4.0

Teach it at your university, adapt it, charge for it if you want. Just cite the source. There is no paywall, no mailing list, no "leave us your email". And there is no fine print: fork it without asking anybody.

The proof

This is what one section looks like running

UVM 2020.3.1 on Verilator, on the course DUT. Zero errors and the real functional coverage number — not a placeholder.

make u4/tests
$ make u4/tests
==> code/u4/tests/run.sh
UVM_INFO @ 0: reporter [RNTST] Running test random_test...

--- UVM Report Summary ---

** Report counts by severity
UVM_INFO   :    1
UVM_WARNING:    0
UVM_ERROR  :    0
UVM_FATAL  :    0

Coverage Summary:
  covergroup : 86.8% (66/76)

Syllabus

Eight units in seven days, from the first class to a UVM testbench written from scratch

It starts at why verification exists as a discipline and ends with a capstone: an APB slave, its specification, and the whole testbench from a blank page. Every day closes with a multiple-choice review and at least one self-checking exercise, and each is between four and five and a half hours of class — ≈ 31 h, plus the optional day 8.

Day 1 · Units 1 and 2 · Why we verify, and the testbench without UVM

  1. Industry trends
  2. What UVM is
  3. The VTALU spec (the DUT)
  4. The verification plan: the five columns
  5. The conventional testbench
  6. Functional coverage: covergroup, bins, cross
  7. SystemVerilog interfaces and BFM

≈ 4 h · It closes looking at real waves with GTKWave.

Day 2 · Unit 3 · The OOP UVM takes for granted

  1. Classes and extensions
  2. Polymorphism, virtual and abstract classes
  3. Static variables and methods
  4. Parameterized classes
  5. The Factory pattern
  6. A testbench without a single module

≈ 4 h · The real wall for whoever comes from RTL. Spend any spare time here.

Day 3 · Unit 4 · UVM walks in

  1. uvm_test and +UVM_TESTNAME
  2. uvm_component and the phases
  3. uvm_env: structure against stimulus
  4. Reporting: verbosity and actions

≈ 4 h 30 · The uvm_config_db, its hierarchical scope, and the reporting everything that follows gets debugged with.

Day 4 · Unit 5 · How the components talk

  1. One producer, many listeners: the Observer pattern
  2. A single place that watches the wire: uvm_analysis_port
  3. When somebody has to wait: threads
  4. Who waits for whom: put and get

≈ 4 h · Here the stimulus splits in two: who decides what to send and who knows how.

Day 5 · Unit 6 · The data

  1. Copying an object that contains another: deep copy
  2. Transactions
  3. Constrained random: dist, inside, with

≈ 4 h 30 · The data stops being a struct and becomes objects that travel.

Day 6 · Unit 7 · The reusable testbench

  1. uvm_agent, uvm_sequencer, is_active
  2. Callbacks: uvm_callback, `uvm_do_callbacks, error injection in the driver
  3. uvm_sequence, body(), start_item / finish_item

≈ 4 h 45 · The get_next_item / item_done handshake: 90 % of what you are going to write.

Day 7 · Unit 8 · The other half

  1. Virtual sequences: two sequencers, a single scenario
  2. Assertions (SVA): assert property, |-> against |=>, cover property
  3. The capstone: an APB slave, its spec, and the whole testbench from scratch
  4. The three appendices, the glossary and the wrap-up

≈ 5 h 15 · In the morning, how the DUT is talked to. In the afternoon, a testbench from a blank page.

Day 8 · Optional · What comes after the capstone

  1. RAL (unit 9): the register map over the capstone APB
  2. The reference model in C, through import "DPI-C"
  3. The second capstone: a FIFO with backpressure, where the scoreboard cannot be a table

≈ 4 h · It comes after the wrap-up: all three need the capstone to be done already.

Day 8 is optional and comes after the wrap-up, and both of those are on purpose: its three pieces need the day 7 capstone to be done already. RAL, the UVM register layer, replaces the scoreboard you have just written — it runs on Verilator, with the two uvm-core sequences that generate their own tests from the model, and as far as we know it is the only version of this that exists on a free simulator. The reference model in C through DPI replaces its prediction. And the second capstone only teaches something to whoever already handed in the first: the bug to catch is in a flag and not in the data, so a scoreboard that only compares what comes out passes green.

Day 7 closes with three appendices: from the VTALU to a real bus —what changes and what does not when the interface is AXI or APB—, the debug toolbox —the seven knobs of the course, and which one to use for each symptom— and the 21 silent traps —everything that compiles, runs and lies—. It closes with an ES ↔ EN glossary, because everything you read after this course is going to be in English.

How to run it

Five roads, from installing nothing to compiling everything

The deck opens with a double click on any machine and with no internet. To run the examples, start with the first road: it is the only one that asks nothing of you.

Start here

GitHub Codespaces

The repository brings a devcontainer with Verilator, UVM and ccache already inside. You open the repo in the browser and run the examples right there, from any machine — even a netbook.

# Code ▸ Codespaces ▸ Create codespace
make u4/tests   # and the second section, in seconds

Free accounts come with 60 core-hours a month, plenty for the course. It goes first because on macOS and Windows installing Verilator is half an afternoon that teaches nothing about UVM.

Without installing Verilator

Docker

The same devcontainer image, on your machine and with the repo mounted from outside: you edit with your usual editor and run inside.

docker build -t verifythis .
docker run --rm -it -v "$PWD":/work \
  verifythis make u4/tests

The ccache cache lives in .ccache/ of the mounted repo, so it survives the --rm. RAM tuning in docs/docker.md (in Spanish).

Linux · macOS

Native

The fastest road once installed. Careful: it needs Verilator ≥ 5.050 —covergroups landed there— and the distro package is almost always behind.

git clone https://github.com/leandrotozzi/verifythis
cd verifythis
verilator --version   # ≥ 5.050
make u4/tests

Two more packages are needed: z3, which is the randomize() solver and without which day 5 lies silently, and ccache, which makes the second UVM section compile in seconds. The recipe to build Verilator from source is in docs/en/setup.md.

Windows

WSL 2

If you want the course on your machine and not in the browser: once Ubuntu is installed, everything else is identical to Linux.

wsl --install -d Ubuntu   # PowerShell, as admin
# and inside Ubuntu:
sudo apt install git make g++ perl ccache z3
# Verilator 5.052 from source, and done

Clone inside the WSL filesystem (~/), not in /mnt/c: there the build becomes several times slower.

Not even that

EDA Playground

A simulator in the browser, with no local account and no install. Good for pasting a single class and playing with one concept: polymorphism, a constraint, a covergroup.

# edaplayground.com
# paste the example from code/u6 and hit Run

It does not run the whole course —the testbenches are many files—, but it is the safety net for whoever cannot install anything today. And its commercial simulators support the transition bins Verilator does not yet.

Frequently asked

What people always ask

Do I need a Questa, VCS or Xcelium licence?

No. The course runs end to end on Verilator, which is free software, plus Accellera's reference implementation of UVM (uvm-core 2020.3.1), which downloads itself. There is no Questa flow in the repository: the run.do were deleted.

Is it any good if I come from RTL design and never wrote a class?

Yes, and it is designed for exactly that. The whole of day 2 is object-oriented programming in SystemVerilog —classes, inheritance, polymorphism, parameterized classes, the factory— because that is the real wall for whoever arrives from RTL. UVM only shows up on day 3.

I installed everything and something does not work: where do I start?

With make doctor. It says whether this machine can run the course and what is missing, with the exact command for your package manager. The two most expensive failure modes are silent: without z3, randomize() returns 0 without saying a thing; with a Verilator older than 5.050, functional coverage reports 0 % without a warning.

And if the problem is that the testbench runs but lies, the list is in the 21 silent traps: everything that compiles, runs and gives no warning.

How long does it take?

Seven days of class when taught, about 30 and a half hours — plus an optional day 8, after the wrap-up, with RAL, the reference model in C through DPI and a second capstone. On your own, count double: half the time goes into running the examples, and that half is the one that teaches. As a semester course, the 15-week map is in docs/en/for-teachers.md.

Which UVM version does it use?

UVM 2020.3.1, Accellera's reference implementation of IEEE 1800.2-2020. Not 1.2, which is pre-IEEE. Verilator supports it officially since 5.052.

Can I teach it at my university or company?

Yes, including for money. The slides are under CC BY 4.0, the examples in code/ under Apache-2.0 and the tooling under MIT: the only condition is citing the source and keeping the NOTICE. The repository ships the deck as PDF and as PPTX with editable text and speaker notes.

And to teach it as a course there are three more things: docs/en/for-teachers.md —the seven-day course mapped onto a 15-week semester, what can be skipped and what to assess in each midterm—, the bank with the 58 questions without the answer marked, and a CITATION.cff for GitHub's Cite this repository button.

Is this The UVM Primer rewritten?

No. It is the book I learned UVM with, it is in the references, and several of the examples in code/ derive from its own —which its author published under Apache-2.0 and which are credited here in the NOTICE—. But the structure is another one: 8 units grouped by the problem they solve, not 24 chapters by feature. The DUT is another. The simulator is another. And there are four units of material the book does not cover: the verification plan as a backbone, assertions (SVA), virtual sequences and callbacks, and a capstone with a different DUT written from a blank page. The full list is in docs/en-que-se-diferencia.md (in Spanish).

What is left out?

uvm_event and uvm_barrier, the run-time phases, and TLM2. They are named on the wrap-up slide, with where to go next. The course is introductory and prefers to say what it does not cover.

Does everything work the same as on a commercial simulator?

Almost. Verilator 5.052 does not compile covergroup transition bins yet, ignores binsof/intersect in a cross, and has two limitations with dist and solve…before. All four are documented with a minimal repro and the portable workaround, because hiding them would be worse than not having them.

How do I report a bug or ask something?

In the repository's Discussions for questions, and in the Issues if you found something broken. Fixes by pull request are welcome.