Goal: Extend I²C verification to UVM+SV — I²C agent (transaction, sequence, driver, monitor, scoreboard); run on Verilator.
← Previous: Module 7: I²C | Next: (End of Series)
This module applies UVM to the I²C DUT. Before running commands:
- Read the detailed I²C learning guide: I2C_LEARNING_GUIDE.md — what I²C is, how it works (START/STOP, address+R/W, data, timing), and how it maps to our RTL.
- Read the protocols + UVM overview: LEARNING_GUIDE_PROTOCOLS_AND_UVM.md — Part B § 5. How UVM Maps to a Protocol and § 8. I²C UVM Mapping (where UVM sits, how transaction/driver/monitor/scoreboard map to I²C).
Then follow Overview → Topics Covered → Example → Exercises.
- Module doc: module8/README.md
- Example: module8/examples/i2c_uvm/ — I²C RTL + full UVM agent (same DUT as Module 7)
Quick run (from repo root):
cd module8/examples/i2c_uvm
make SIM=verilator TEST=test_i2c_uvmOr: ./scripts/module8.sh --run
Module 8 builds on Module 7 (I²C protocol + RTL + basic testbench):
- Same DUT: i2c_master, clk_div (reused from module7/examples/i2c_baseline).
- UVM testbench: I²C agent — transaction (addr + data), sequence (directed writes), driver (start/addr/data_in, wait for done), monitor (observe SCL/SDA and reconstruct bytes), scoreboard (expected vs observed).
- Toolchain: Verilator + UVM_HOME + Make (same pattern as Module 6, SPI UVM).
- I²C UVM agent: I2cTransaction, I2cSequence, I2cDriver, I2cMonitor, I2cScoreboard.
- Interface: i2c_if (clk, rst_n, start, addr, data_in, scl, sda, clk_div_tick, busy, done) connects UVM to DUT.
- How to hook up a UVM monitor and scoreboard to a bus-oriented DUT.
- Module 7 (I²C protocol + RTL + basic TB).
- Verilator, Make, C++ compiler, UVM (UVM_HOME or vendored UVM).
- Transaction (I2cTransaction): address and data to write; monitor fills observed_addr/observed_data.
- Sequence (I2cSequence): produces directed transactions (e.g. same addr, different data bytes).
- Driver (I2cDriver): gets transaction, drives start/addr/data_in for one cycle, waits for done.
- Monitor (I2cMonitor): watches SCL/SDA; after START, samples SDA on rising SCL to reconstruct 8 bits of address+W and 8 bits of data.
- Scoreboard (I2cScoreboard): compares expected (from test) vs observed_addr/observed_data.
- Same as Module 6 (SPI UVM): Verilator with -sv, --timing, --trace, UVM include paths,
make SIM=verilator TEST=test_i2c_uvm. Run with+UVM_TESTNAME=test_i2c_uvm.
| Component | Role |
|---|---|
| dut/ | i2c_master.v, clk_div.v (same as Module 7) |
| test_i2c_uvm.sv | Interface, I2cTransaction, I2cSequence, I2cDriver, I2cMonitor, I2cScoreboard, I2cAgent, I2cEnv, test_i2c_uvm top module |
Run: cd module8/examples/i2c_uvm && make SIM=verilator TEST=test_i2c_uvm
UVM is used only in the testbench around the I²C DUT. The transaction is (address, data); the driver drives start/addr/data_in and waits for done; the monitor observes SCL/SDA, reconstructs address+data (sample SDA on rising SCL), and sends to the scoreboard. See LEARNING_GUIDE_PROTOCOLS_AND_UVM.md § 8 for the full mapping.
-
Run i2c_uvm
- Run
make SIM=verilator TEST=test_i2c_uvminmodule8/examples/i2c_uvm. Confirm UVM phases, DRIVER/MONITOR/SCOREBOARD messages, and scoreboard pass.
- Run
-
Trace one transaction
- For one (addr, data) transaction, trace: sequence → driver (start, addr, data_in, wait for done) → DUT generates START/addr/data/STOP → monitor samples SDA on rising SCL → scoreboard compares expected vs observed addr and data.
-
Change the sequence
- Add or change an (addr, data) pair in the I²C sequence and update expected values in the test/scoreboard. Re-run and confirm pass.
-
Compare across protocols
- Compare UART (Module 4), SPI (Module 6), and I²C (Module 8) UVM agents: same UVM pattern (transaction, sequence, driver, monitor, scoreboard), different protocol units (byte vs byte vs addr+data) and bus signals.
- Can describe the I²C UVM agent and how it maps to I²C (addr+data, monitor on SCL/SDA).
- Can run i2c_uvm and interpret UVM output.
- Can compare UVM structure across UART, SPI, and I²C.
This completes the 8-module series. You can now compare methodology and UVM patterns across UART, SPI, and I²C.