Write the two grant rules of an arbiter with the one-hot functions: at most one grant always, exactly one while owned.
Hardware context: A four-master bus arbiter with a one-hot grant vector and a bus-owned flag. Allow an idle grant vector on every edge, and require exactly one grant while the bus is owned.
A four-master arbiter drives gnt, one bit per master. Signal bgack is 1 while a master owns the bus.
Write two concurrent assertions on the rising edge of clk. Rule no_fight: at every edge, at most one grant is high. An idle bus with no grant is legal.
Rule one_owner: while bgack is 1, exactly one grant is high. Count each failure of each rule in its own counter.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
clk | 1 | stimulus, the same for every design |
bgack | 1 | stimulus, the same for every design |
req | 4 | stimulus, the same for every design |
gnt | 4 | stimulus, the same for every design |
your fight_errors | 32 | stimulus, the same for every design |
your owner_errors | 32 | stimulus, the same for every design |
Full specification
module grant_check (
input logic clk,
input logic [3:0] req, // one request bit per master
input logic [3:0] gnt, // one grant bit per master
input logic bgack, // 1 while a master owns the bus
output int fight_errors, // edges with more than one grant
output int owner_errors // edges where the bus is owned but not exactly one grant is high
);
// no_fight: at every rising edge, at most one grant is high (all zeros is legal).
// one_owner: while bgack is 1, exactly one grant is high.
endmodule
| Output | Goes up when |
|---|---|
| fight_errors | an edge sees two or more grants (whether or not anyone asked) |
| owner_errors | an edge sees bgack = 1 and not exactly one grant |
The program shown here has an idle start, two owners and three bugs. Two grants at 35, an owned bus with no grant at 55, and two unrequested grants at 75.
The full check also runs a second program that this page does not show. It has another clock period and other bugs.
Examples
Example 1
Two Grants, with or Without a Request- Input
Program: 2 owners, 3 bugs
- Output
fight_errors = 2
The edges at 35 and 75 see two grants. Idle edges with no grant are legal.
Example 2
Owned Means Exactly One- Input
Program: 2 owners, 3 bugs
- Output
owner_errors = 2
At 35 the owned bus has two grants, and at 55 it has none.
Example 3
Two Grants While Owned- Input
Program: 2 owners, 3 bugs
- Output
fight_errors = 1
By t=60 only the edge at 35 has seen two grants. That bug breaks both rules at once.
Constraints and Contract
- Write each rule as a concurrent assertion that uses a bit-vector function.
- Count failures of no_fight in fight_errors and of one_owner in owner_errors.
- Do not change the ports.
Hints
Hint 1
Which function accepts all zeros: $onehot or $onehot0?
Hint 2
A grant nobody asked for is still a grant. Does no_fight need to look at req at all?
Hint 3
Exactly one grant is needed only while the bus is owned. Put bgack in an antecedent.
What the grader checks: Two copies of your checker each watch a fixed program. One is shown here; the other is hidden, with another clock and other bugs. Graded on each: the two failure counts. The source must state each rule as a concurrent assertion with a bit-vector function.
6 checks on Verilator · server. 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