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_itemto restrict write/read enable signals and payload values. - Ensure stimulus avoids illegal FIFO states (e.g., both
wr_enandrd_enasserted). - 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 Type | Syntax Example | Purpose |
|---|---|---|
| Range | data 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
- Open RtlStudio and select this chapter — files appear automatically in Explore.
- In Explore, open
student/tb/tb_top.sv. - Locate the
fifo_seq_itemclass definition insidestudent/tb/tb_top.sv(it is defined inline in the testbench file). - Add a
constraint valid_fifoblock insidefifo_seq_itemto enforce:
- data inside {[0:255]}; - (write_en + read_en) inside {[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
- 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 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.