Write the checks that report an unknown on the control signals of a command unit. Stay silent on the correct unit and catch four copies that each hide one.
Hardware context: A strobe generator with a run flag, a period register and a counter; and a command unit with a mode bit, an enable, a limit table and an opcode register. Write the X checks that stay quiet on the correct command unit and catch four copies that hide an unknown.
A command unit passed its tests: every result on y was a clean number. Four suspect copies also pass. Each has one unknown inside it, and an if or a casex turns that unknown into a clean result before it reaches y.
Write x_checks, the unit's own X checker. Every copy already instantiates it inside an ifndef SYNTHESIS guard, wired to the signals the unit decides with. Report an unknown on a signal at each clock edge where the unit reads it.
Be exact about "where the unit reads it". The bench drives x on op, idx and data whenever the unit must ignore them, and the payload flops have no reset. An unknown that nobody reads is not an error, and the correct unit must not raise an alarm. Count every failure in errors. The starter holds one check as a model.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
clk | 1 | stimulus, the same for every design |
rst_n | 1 | stimulus, the same for every design |
in_valid | 1 | stimulus, the same for every design |
rep | 1 | stimulus, the same for every design |
op | 2 | stimulus, the same for every design |
mode_q | 1 | output of the design under test |
hold | 1 | output of the design under test |
vld_q | 1 | output of the design under test |
op_q | 2 | output of the design under test |
limit | 8 | output of the design under test |
out_valid | 1 | output of the design under test |
y | 8 | output of the design under test |
your errors | 32 | your checker's error count |
Full specification
module x_checks (
input logic clk,
input logic rst_n, // asynchronous, active-low
input logic mode_q, // the mode bit
input logic hold, // the pause request inside the unit
input logic vld_q, // stage 1 holds a command
input logic [1:0] op_q, // its opcode
input logic [2:0] idx_q, // its table index
input logic [7:0] d_q, // its data
input logic [7:0] limit, // the limit the table gives for idx_q
input logic out_valid,
input logic [7:0] y,
output int errors
);
// your checks
endmodule
| Signal | The unit reads it |
|---|---|
| mode_q, hold, vld_q | at every rising edge out of reset |
| op_q | at an edge where vld_q is 1 |
| idx_q, limit | at an edge where vld_q is 1 and op_q is 01 (ADD) |
| d_q | at an edge where vld_q is 1 and op_q is 01 (ADD) or 10 (PASS) |
| out_valid | at every rising edge out of reset |
| y | at an edge where out_valid is 1 |
| op | Command | Result |
|---|---|---|
| 01 | ADD | data + 1, limited by limit: over it gives limit (mode 1) or 0 (mode 0) |
| 10 | PASS | data |
| 11 | ZERO | 0; data and idx are not read |
| 00 | none | no result |
rep = 1 runs the last opcode again. A command enters stage 1 at one edge (vld_q, op_q, idx_q, d_q) and its result leaves on y at the next.
Scenarios: 1. Adds over the limit before the mode is written; 2. A repeat before the first command; 3. Every table entry, and the two past the end; 4. Pauses, and data nobody reads; 5. Random traffic A; 6. Random traffic B. Before each one the bench cycles the power while rst_n is low. All state is unknown at the reset edge (cycle 1). 16 more edges follow. Inputs, rst_n included, change while clk is low.
A check is in time if errors moves by the end of the cycle in which the unknown is read. For each unit you get alarm = yes or no. For the correct unit you also get first_alarm_scenario and first_alarm_cycle, the first edge where your count changed.
Simulator note: This problem runs on Icarus Verilog 12, which has no concurrent assertions. Write the checks as if statements or immediate assert statements inside a clocked block.
Examples
Example 1
The Correct Unit Must Not Raise an Alarm- Input
Unit: the correct design Scenarios: 6, each a power cycle under reset and 16 edges
- Output
alarm = no
In scenario 4 a ZERO command arrives with data at x, and idle cycles carry x on op, idx and data. The unit reads none of it, so your count must stay 0.
Example 2
A Mode Bit with No Reset Must Be Caught- Input
Unit: The mode bit has no reset Scenarios: 6, each a power cycle under reset and 16 edges
- Output
alarm = yes
After the power cycle, mode_q is x at the first edge out of reset. The results still look clean, because the if on mode_q takes its else branch.
Example 3
A Floating Pause Input Must Be Caught- Input
Unit: The pause input is left open Scenarios: 6, each a power cycle under reset and 16 edges
- Output
alarm = yes
hold is z at every edge. The if that reads it takes its else branch, so the unit never pauses and every result still looks clean.
Constraints and Contract
- Use only your ports: no hierarchical names into the unit or the fixture.
- Every check counts its failure in errors; errors never decreases.
- No check may fail while rst_n is 0.
Hints
Hint 1
Start with the three signals the unit reads at every edge. $isunknown(sig) is 1 when any bit of sig is x or z.
Hint 2
Your checker is RTL too, and its own if statements are optimistic. What does if (op_q == 2'b01 && ...) do when op_q is unknown?
Hint 3
Check the qualifier before the thing it qualifies: first vld_q, then op_q, then the fields that this opcode reads. Report an unknown qualifier and stop there.
What the grader checks: Your checker sits inside the correct unit and four variants with one hidden unknown each. Six fixed scenarios run, with a power cycle before each. Passing shows it reports these unknowns on this stimulus and stays quiet on legal ones. It does not check the results themselves; that is a scoreboard's job.
5 checks on Icarus · browser samples / server checks. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 2 steps and the final capstone