Synchronous FIFO
Build a UVM agent, reference queue, scoreboard, and coverage collector for a synchronous FIFO.
Before you begin
Prerequisites
- SystemVerilog classes, queues, and basic constrained-random stimulus.
- UVM sequence items, drivers, monitors, and analysis ports.
- A working simulator with a UVM library, or an EDA Playground UVM setup.
Design contract
Use this contract as the reference for both the DUT and the checks. If you make an assumption beyond it, record that assumption in your project notes.
| Area | Required behavior |
|---|---|
| Depth and width | Use DEPTH=4 entries, each DATA_WIDTH=8 bits. |
| Reset | rst_n is active-low and synchronous. A sampled low reset clears occupancy and makes empty high and full low. |
| Accepted operations | At a rising edge, accept a write only when write_en && !full; accept a read only when read_en && !empty. Requests blocked by the pre-edge flags are ignored. |
| Simultaneous requests | When occupancy is between empty and full, accept both a read and a write on the same edge. At empty, accept only the write; at full, accept only the read. |
| Read data | After an accepted read edge, data_out shows the oldest stored word. If no read is accepted, data_out holds its value. |
What you will learn
A FIFO verification environment must preserve ordering while checking occupancy, full, empty, simultaneous operations, and reset. The queue model predicts data; flags are checked from the observed interface.
- Build a queue-based scoreboard using monitored accepted operations
- Check data ordering and full/empty behavior
- Verify simultaneous operations and reset recovery
- Collect occupancy-by-operation coverage
Step 1: Understand the design contract
Before writing stimulus, identify the input transaction, the expected behavior, the boundary conditions, and the evidence that proves the result. This contract is the reference for both the DUT and the verification environment.
| Verification question | Answer to define |
|---|---|
| What does the DUT receive? | inputs, transactions, configuration, or protocol requests |
| What should it produce? | output data, state transition, response, flag, or error |
| What does the testbench observe? | monitor data, response timing, status, waveform, or coverage |
| What can fail? | normal operation, boundary, reset, timing, ordering, and invalid input |
Step 2: Study the DUT contract or starter snippet
// Behavioral contract for the project DUT.
// Parameters: DEPTH=4, DATA_WIDTH=8.
// Reset: active-low synchronous rst_n.
// Accept write when write_en && !full.
// Accept read when read_en && !empty.
// Flags are evaluated from occupancy before the active edge.
// If both operations are accepted, remove the oldest word and
// append the new word on the same edge.
// data_out changes to the removed word after an accepted read.
This project may provide RTL, a behavioral contract, or pseudocode here. Treat it as the stated project scope, not as a complete implementation. Identify the inputs, outputs, acceptance event, response timing, and reset behavior before writing checks.
Questions to answer
- What is the legal input range?
- What is the exact acceptance event?
- What happens at the minimum and maximum values?
- How does reset affect pending or stored state?
- What response indicates an invalid operation?
Step 3: Build the verification stimulus
Keep the stimulus separate from the checking logic. A driver or task applies inputs; a monitor or observation block samples what the DUT actually did.
class fifo_scoreboard extends uvm_scoreboard;
logic [7:0] expected_queue[$];
function void write(fifo_item observed);
logic [7:0] expected_data;
if (observed.read_accepted) begin
if (expected_queue.size() == 0)
`uvm_error("FIFO_SB", "Accepted read with no expected data")
else begin
expected_data = expected_queue.pop_front();
if (observed.read_data !== expected_data)
`uvm_error("FIFO_SB", $sformatf("Expected %02h, got %02h", expected_data, observed.read_data))
end
end
if (observed.write_accepted)
expected_queue.push_back(observed.write_data);
endfunction
endclass
For an intermediate or advanced project, move this operation into a sequence item and driver. The sequence should describe the scenario, while the driver should own protocol timing and signal assignment.
Step 4: Verify the important scenarios
Build the item, sequence, driver, monitor, agent, scoreboard, and coverage collector. First prove reset and one write/read pair. Then fill to full and drain to empty, checking flags and every returned byte. Test blocked writes while full, blocked reads while empty, simultaneous read/write at interior occupancy, and reset with queued entries. The monitor should publish accepted operations derived from the interface handshake, not the driver's requested operations.
| Scenario | Expected evidence |
|---|---|
| Nominal operation | one legal request produces one correct result |
| Boundary operation | minimum, maximum, last, or transition value is handled correctly |
| Invalid operation | error, rejection, ignore, or documented recovery occurs |
| Reset interruption | state and pending work return to the specified condition |
| Repeated/concurrent traffic | ordering, correlation, and no-loss behavior remain correct |
Make the result self-checking
The code above is a project-specific starting point, not a complete testbench. Your finished test should calculate expectations independently from the DUT and report failures with enough context to reproduce them.
- Count each check and fail the run when an expected behavior is violated.
- Use monitor observations as evidence; do not pass a test solely because the driver requested an operation.
- Include the scenario, expected value, actual value, and transaction context in mismatch messages.
- End only after outstanding responses are checked and the scoreboard is drained.
Example successful summary
Example successful run (illustrative):
FIFO PASS: reset flags
FIFO PASS: write/read data order
FIFO PASS: full and empty boundaries
FIFO PASS: simultaneous operations
FIFO PASS: reset with pending data
FIFO SUMMARY: 5 scenarios, 0 mismatches
This is an illustrative pass summary, not a captured simulator transcript. Your run should report the scenarios and checks you actually executed, along with zero unexpected errors.
Common mistakes and debugging
| Symptom | First thing to inspect |
|---|---|
| Expected result never arrives | reset, handshake, enable condition, and end-of-test drain |
| Data mismatch | transaction ordering, bit/byte order, and reference-model calculation |
| Only boundary cases fail | inclusive versus exclusive limits and width truncation |
| Only random tests fail | seed, race, uninitialized state, or unsupported combination |
| Test hangs | objections, waits, queues, and missing response timeout |
| Test passes too easily | ensure checking uses monitor observations, not driver intent |
UVM extension
Once the direct testbench works, organize the project as UVM components: a sequence item carries the transaction, a sequence creates scenarios, a driver applies protocol activity, a monitor publishes observations, and a scoreboard checks an independent expectation.
class project_item extends uvm_sequence_item;
rand logic [31:0] data;
`uvm_object_utils(project_item)
function new(string name = "project_item");
super.new(name);
endfunction
endclass
class project_scoreboard extends uvm_scoreboard;
`uvm_component_utils(project_scoreboard)
uvm_analysis_imp #(project_item, project_scoreboard) analysis_export;
function void write(project_item observed);
// Calculate expected behavior independently.
// Compare with observed and report useful context.
endfunction
endclass
Do not add UVM classes just for decoration. The value is the separation of responsibilities and the ability to reuse the same sequence and checks when the interface or DUT configuration changes.
Project milestones
- Reset the DUT and confirm empty=1 and full=0.
- Write one value, read it back, and check the observed data against the reference queue.
- Fill all four entries, check full, and verify an additional write is rejected.
- Drain all entries in order, check empty, and verify an additional read is rejected.
- Exercise simultaneous operations at empty, an interior occupancy, and full; then reset with data pending.
Submit these artifacts
- A verification plan mapping each milestone to its checker and expected result.
- A reproducible simulation log with simulator, UVM version, and random seed recorded.
- A queue-based scoreboard and coverage report for occupancy crossed with read/write operation.
- A short note documenting the simultaneous-operation and reset assumptions used by the DUT.
Project goals and acceptance criteria
- Build a queue-based scoreboard using monitored accepted operations.
- Check data ordering and full/empty behavior.
- Verify simultaneous operations and reset recovery.
- Collect occupancy-by-operation coverage.
- Include at least one boundary and one negative or error scenario.
- Capture console and waveform evidence for the first failure and final passing run.
- Document assumptions, unsupported cases, and remaining verification risk.