What you practice
UVM subscriber and covergroup on analysis port (3.5). Encapsulate functional coverage in a subscriber with a FIFO full/empty covergroup on the analysis port. It is in Subscriber — Part 3 · Env and Coverage of the UVM Masterclass. Assemble the verification environment, compare data, and hunt coverage.
The UVM bench compiles in that same browser SystemVerilog simulator. You edit the test in the IDE, run Verilator, and read the log beside the waveform.
What you will learn
You will learn how to capture functional coverage in a UVM subscriber connected to a monitor’s analysis port, using a covergroup that samples FIFO status flags.
Learning objectives
- Understand the role of
uvm_subscriberin UVM coverage collection. - Define a covergroup with coverpoints for FIFO
fullandemptyflags. - Connect the subscriber’s analysis port to the monitor’s analysis port in the environment.
- Call
sample()in the subscriber’swrite()method to record coverage. - Verify coverage collection via simulation logs.
Theory
UVM subscribers are passive components that consume data from an analysis port, commonly used for coverage and scoreboard logging. A covergroup defines coverage points and bins; it must be instantiated and sampled explicitly, typically inside the write() method of a subscriber.
| Component | Purpose |
|---|---|
uvm_subscriber #(T) | Generic consumer of T-type items from an analysis port |
covergroup | Groups coverpoints/bins to collect functional coverage |
sample() | Explicit method call to record a coverage snapshot |
write(T item) | Virtual method invoked when an item arrives on the analysis port |
The subscriber is connected to the monitor’s analysis port in the environment’s connect_phase(). The covergroup instance is sampled each time write() is called, ensuring coverage is collected for every transaction.
Practice
Open this chapter in RtlStudio. Files appear automatically in Explore.
- Open
student/tb/tb_top.sv— it already imports coverage infrastructure and runsfifo_base_test. - In the
fifo_envclass (defined ingolden/tb/env/fifo_env.sv), locate theconnect_phase()method and confirmu_coverageis connected tou_monitor.ap. - In the
fifo_coveragesubscriber (defined ingolden/tb/env/fifo_coverage.sv), locate thewrite()method. - In
fifo_coverage, instantiate a covergroupcg_fifowith coverpoints forfull_flagandempty_flag(booleans extracted from thefifo_seq_item). - In the
write()method, callcg_fifo.sample()after extracting flags from the item. - Run Simulation and verify
INFO:log output.
Summary
You implemented a UVM subscriber to capture transaction data from the monitor’s analysis port and encapsulated functional coverage using a covergroup. You defined coverpoints for FIFO status flags and ensured the covergroup was sampled inside the subscriber’s write() method. You connected the subscriber to the monitor in the environment’s connect_phase, completing the coverage collection pipeline. This reinforced how UVM components interact to gather functional coverage without affecting the DUT or test logic.
Run it in the Verilog IDE
- Open the UVM workspace in the IDE. The DUT and the testbench compile together in the browser.
- Run the SystemVerilog simulation with Verilator and read the phase and scoreboard lines in the log.
- When the check is on pins rather than a print, open the VCD next to that log.
- Edit the sequence, driver, or scoreboard in the IDE and rerun. You stay in the same simulator.
The lesson is done when the simulation matches UVM subscriber and covergroup on analysis port. Change the source, run the Verilog simulator again, and read the waveform without leaving the IDE. Simulation guide · Yosys guide.