A checker for the decade counter reports zero errors on counters that are plainly broken. Find its three faults and repair it, so it counts every cycle the counter differs from its own model.
Hardware context: A 4-bit adder with carry in and a decade counter under test. Repairing a checker that passes broken designs.
This checker watches a decade counter. On a good counter it reports no errors, as it should. On a counter that counts while enable is low, or shows x after reset, it also reports no errors. On a counter that misses one count, it reports one error and then nothing, though every later count is wrong.
Repair count_check. It has three faults. Its ports, its counters and its timing are right.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
scenario | 4 | input of each check |
Full specification
| When | What the checker does |
|---|---|
| Each rising edge | Moves its own model from rst and en only. rst gives 0; en gives the next count, 9 going to 0; otherwise it holds. |
| Each falling edge with rst at 0 | Adds 1 to checks. If count differs from the model in any way, x included, adds 1 to errors. |
| After a mismatch | Keeps its own model. It never copies the counter's value. |
So a counter that falls one count behind is wrong at every later check, and the checker says so at every one.
Examples
Example 1
A Good Counter- Input
rst 11000000000000000000; en 00111111111111110000; count 0 0 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 4 4 4
- Output
errors = 0, checks = 18
A good counter: 18 checks out of reset, no errors. The broken checker also passes this case.
Example 2
A Counter That Counts While Enable Is Low- Input
rst 11000000000000000000; en 00111100001111110000; count 0 0 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7
- Output
errors = 13, checks = 18
This counter counts while enable is low. From the first idle clock on it runs ahead of the model, so most later checks fail.
Example 3
A Counter That Shows x Until It First Counts- Input
rst 11000000000000000000; en 00000011111111111100; count x x x x x x x 1 2 3 4 5 6 7 8 9 0 1 2 2
- Output
errors = 5, checks = 18
This counter shows x until its first count. Each x is an error; then it counts correctly.
Constraints and Contract
- Keep the module name, the ports, errors, checks and exp.
- Between traces the bench sets errors and checks to 0 and holds rst high for two clocks.
Hints
Hint 1
Where does the model get the value it adds 1 to?
Hint 2
Which cycles does the compare skip?
Hint 3
What does != give when count is x, and what does an if do with that?
What the grader checks: Nine traces of 20 clocks each, driven as a counter's flip-flops would change. They cover a good counter, counting while idle, x after reset, a missed count, 10, a skipped 5 and a mid-run reset. The bench reads errors and checks at the end of each trace.
9 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 problems on this path