UART TX/RX, verified with UVM
The UVM testbench is the real project here. The UART is a parameterized transmitter and a 16x-oversampling receiver, and it gives me something small enough to run my UVM skills on: a driver, a sequencer, two monitors, a scoreboard with a reference model and coverage, plus SystemVerilog assertions on the interface.
It has two modes. In loopback the TX feeds the RX. In bit-bang mode the testbench drives the RX line itself, which injects a bad stop bit to test rx_error and scales the bit period to check the baud-rate tolerance.
My simulator, Questa Starter Edition, has no randomize() or covergroup, so the stimulus uses $urandom_range and the coverage is counted by hand in a uvm_subscriber.
- Language
- SystemVerilog, UVM
- Framing
- 8N1 at 115200 baud, 100 MHz clock
- Checks
- Scoreboard, 6 assertions with cover properties, hand-coded coverage
loopback result
1000of 1000 passed
- failures0
- coverage100%
- corner values6 of 6
bit-bang: one frame, stop bit forced low
- S
- D0
- D1
- D2
- D3
- D4
- D5
- D6
- D7
- P
The red stop bit is the injected error. The receiver should raise rx_error and leave rx_data alone.
testbench tree
uvm_test └─ env ├─ agent │ ├─ driver │ ├─ sequencer │ └─ monitor ×2 tx and rx ├─ scoreboard reference model └─ coverage uvm_subscriber