23. Find the bug: fixed-priority arbiter
Write a test that passes the correct design and fails every buggy version.
The spec: a combinational arbiter for four requesters with fixed priority. Requester 0 has the highest priority and requester 3 the lowest. There is no clock.
- mask disables requesters: a requester takes part only when its req bit is 1 and its mask bit is 0.
- grant has exactly one bit set, for the highest-priority requester taking part, or is 0 when none takes part.
- any is 1 when at least one requester takes part.
Ports
| Port | Dir | Bits | What it is |
|---|---|---|---|
req | in | 4 | Requests. |
mask | in | 4 | 1 disables that requester. |
grant | out | 4 | One-hot grant, or 0. |
any | out | 1 | Some requester takes part. |
Example
req = 0110, mask = 0000: grant = 0010 (requester 1 beats 2). req = 0110, mask = 0010: grant = 0100.
Writing the test
The test is a table of steps, as on the Verilog playground. Each step can set inputs, tick the clock (clk) a number of times, then check outputs. Inputs start at 0 and registers start unknown, so begin with a reset. It must pass the correct design and fail all 4 buggy versions.
{ "set": { "rst": 0, "en": 1 }, "tick": 3, "expect": { "count": 3 }, "note": "counts up" }Written hints
AI hint
Submissions
No submissions yet. Submit your answer and it shows here. Sign in to keep them.
1 step, 0 with checks.
Submit your answer to have it graded. The hidden test runs on the server; you see whether it passes and, if not, the first case it gets wrong.