Fix a read-data check that fires on an idle bus and misses beats with a single x or z bit.
Hardware context: A read-data bus that is undriven or floating between beats. Reject any x or z bit on a read beat, and only on edges where the beat is valid.
A read channel drives rdata while rvalid is 1. Every bit of a beat must be 0 or 1. While rvalid is 0 the bus is idle, and x or z there is legal.
The checker rdata_check reports failures on idle cycles, and it misses beats where only some bits are unknown. Fix it.
It must report each bad beat once, at the edge where it is read. It also records the time of the first failure.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
clk | 1 | stimulus, the same for every design |
rvalid | 1 | stimulus, the same for every design |
rdata | 8 | stimulus, the same for every design |
your errors | 32 | your checker's error count |
Full specification
module rdata_check (
input logic clk,
input logic rvalid, // 1 while rdata carries a read beat
input logic [7:0] rdata,
output int errors, // beats with an x or z bit
output int first_time // $time of the first failure
);
// your check
endmodule
This problem runs on Icarus 12, a four-state simulator, so x and z bits keep their values. It has no concurrent assertions, so the check is an immediate assertion at each rising edge.
The program shown here has two good beats and idle cycles with an all-x and an all-z bus. Its bad beats have one x bit at 25 and four z bits at 65.
The full check also runs a second program that this page does not show, with another clock period and other bad beats.
Examples
Example 1
Only the Two Bad Beats Fail- Input
Program: 2 good beats, 2 bad beats, idle x and z
- Output
errors = 2
The idle all-x and all-z cycles are not checked. One x bit, or four z bits, on a beat is a failure.
Example 2
The First Bad Beat Is Read at 25- Input
Program: 2 good beats, 2 bad beats, idle x and z
- Output
first_time = 25
The beat with one x bit is written at 20 and read at the edge at 25.
Example 3
Idle x and z Are Not Failures- Input
Program: 2 good beats, 2 bad beats, idle x and z
- Output
errors = 1
The all-x bus at 35 and the all-z bus at 45 come with rvalid = 0. So the count is still 1 at t=50.
Constraints and Contract
- Check each beat with an immediate assertion that uses
$isunknown. - Count each failure in errors and record first_time at the first one.
- Do not change the ports.
Hints
Hint 1
What does rdata !== 8'bx compare? Is 0011x100 equal to all x?
Hint 2
Which function is 1 when any bit is x or z?
Hint 3
An idle bus is allowed to be unknown. Which signal says that the bus carries a beat?
What the grader checks: Two copies of your checker each watch a fixed program on Icarus 12. One is shown here; the other is hidden, with another clock and other bad beats. Graded on each: the number of failures and the time of the first one. The source must check rdata with $isunknown in an immediate assertion.
6 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 3 steps and the final capstone