RTL Studio Open IDE

1.3 · UVM CLASS

Controlled randomness for FIFO traffic

Constrain sequence items to produce valid mixed read/write FIFO traffic patterns.

Watch on YouTube

What you practice

Controlled randomness for FIFO traffic (1.3). Constrain sequence items to produce valid mixed read/write FIFO traffic patterns. It is in Constraints — Part 1 · Stimulus Generation of the UVM Masterclass. Create randomized transactions and deliver them safely to the DUT.

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

This lesson teaches how to constrain UVM sequence items to generate only valid, interesting FIFO traffic patterns, ensuring writes and reads never occur simultaneously and payloads stay within expected ranges.

Learning objectives

  • Add constraints to fifo_seq_item to restrict write/read enable signals and payload values.
  • Ensure stimulus avoids illegal FIFO states (e.g., both wr_en and rd_en asserted).
  • Verify constrained sequences produce valid FIFO traffic via simulation logs.
  • Prepare for later CDV missions that depend on controlled FIFO behavior.

Theory

UVM constraints let you restrict randomization to valid design behavior, avoiding illegal or uninteresting stimulus.

Constraint TypeSyntax ExamplePurpose
Rangedata inside {[0:255]};Limit payload to 8-bit range
Mutual exclusion(wr_en + rd_en) inside {[1:1]};Enforce exactly one operation per cycle

Constraints are declared inside a constraint block in the sequence item class and are evaluated during randomize(). They prevent invalid states (e.g., both write and read enabled) and improve coverage quality.

Practice

  1. Open RtlStudio and select this chapter — files appear automatically in Explore.
  2. In Explore, open student/tb/tb_top.sv.
  3. Locate the fifo_seq_item class definition inside student/tb/tb_top.sv (it is defined inline in the testbench file).
  4. Add a constraint valid_fifo block inside fifo_seq_item to enforce:

- data inside {[0:255]}; - (write_en + read_en) inside {[1:1]};

  1. Run Simulation and check the Log panel for constrained values and INFO: PASS.

Summary

Students extended the fifo_seq_item class with a constraint block to enforce valid FIFO stimulus patterns, ensuring writes and reads are mutually exclusive and payloads fall within a defined range. They verified the constraints by running the fifo_sequence and observing constrained random values in the logs. The key takeaway is that controlled randomness improves test quality by focusing on meaningful, pedagogically relevant scenarios. This foundation prepares students for deeper coverage analysis and CDV mission 3.6 on FIFO full behavior.

Run it in the Verilog IDE

  1. Open the UVM workspace in the IDE. The DUT and the testbench compile together in the browser.
  2. Run the SystemVerilog simulation with Verilator and read the phase and scoreboard lines in the log.
  3. When the check is on pins rather than a print, open the VCD next to that log.
  4. 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 Controlled randomness for FIFO traffic. Change the source, run the Verilog simulator again, and read the waveform without leaving the IDE. Simulation guide · Yosys guide.