Turn a testbench that only prints into one that checks every row of a majority voter and counts the wrong ones.
Hardware context: A room thermostat that places a heater control block, and the testbench of a three-input voter. Write a self-checking bench that catches eleven faulty voters, seven of them wrong on one row only, and passes the correct one.
A team tests its majority voter with a bench that prints eight rows. Someone looks at the rows and says they are fine. Last week a voter with one pair of inputs missing passed that way.
This is a Verify problem. You write the bench, not the voter. Your bench drives the inputs a, b and c and reads y. It adds 1 to errors for every row where y is wrong.
The check runs your bench on one correct voter and on eleven faulty ones. Some faulty voters are wrong on one row only. You pass when errors stays 0 on the correct voter and ends above 0 on every faulty voter.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
variant | 4 | input of each check |
Full specification
module bench (
output logic a, // you drive the three inputs of the voter
output logic b,
output logic c,
input logic y, // the output of the voter
output int errors // add 1 for every row where y is wrong
);
// your initial block
endmodule
| Rule | Detail |
|---|---|
| The voter | y must be 1 when at least two of a, b and c are 1, and 0 otherwise. |
| Timing | The voter is plain gates. Wait 1 ns after you change the inputs before you read y. The check runs with a timescale of 1 ns, so #1 is 1 ns. |
| Time limit | Your bench must finish within 35 ns. |
| errors | Start at 0. Add 1 for each wrong row. Never count down. |
| Expected value | Compute it in the bench. Do not copy the expression of the voter: count the 1s, or list the rows. |
For each voter you get alarm = yes or no. The correct voter must give no alarm. Each faulty voter must give an alarm.
Examples
Example 1
The Correct Voter Must Not Raise an Alarm- Input
Voter: the correct design
- Output
alarm = no
On the correct voter every row matches, so errors must still be 0 at the end.
Example 2
A Voter That Needs All Three Votes- Input
Voter: All three votes needed (y is 1 only for the row 111)
- Output
alarm = yes
This voter gives 0 for the rows with exactly two 1s. A bench that checks those rows counts three errors.
Example 3
A Voter with One Pair Missing- Input
Voter: One pair missing (y is 0 for the row 011)
- Output
alarm = yes
This voter is wrong in one row only, 011. Only a bench that visits that row can catch it.
Constraints and Contract
- Use only your ports: no names from inside the voter or the fixture.
- Drive a, b and c from one initial block, and finish within the time limit.
Hints
Hint 1
A loop from 0 to 7 visits every row. The three low bits of the loop counter are the three inputs.
Hint 2
The expected output is 1 when the inputs hold two or three 1s. The sum a + b + c counts them.
Hint 3
Compare with !== so that an unknown output also counts as wrong. Then add 1 to errors.
What the grader checks: Your bench runs on one correct majority voter and on eleven voters with one planted fault each. Seven of them are wrong on a single row, one fault for each row. Passing shows that your bench checks every row and raises no false alarm.
12 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