P4.15.1 The Lock-Aware Arbiter

MediumImplementIcarus · browser samples / server checksReview the topic

Write the arbiter of a three-manager AHB interconnect. It uses round robin, and only where no burst is open and no lock is held.

Hardware context: The arbiter of a three-manager AHB interconnect. Implement a round-robin arbiter that honours HMASTLOCK and BUSY.

Lesson P4.15 lost an increment because its arbiter switched at a locked IDLE. This arbiter serves three managers. It must find the moments when giving the bus away is safe.

Write module ahb_lock_arbiter. It sees the shared bus, driven by the owner, and one request bit per manager. At an edge where it is safe, it gives the bus to the next requesting manager after the owner, in round-robin order.

Safe means three things at once. HREADY is high, so the address phase is being taken. The owner's HTRANS is IDLE, not BUSY, because BUSY keeps a burst open. And HMASTLOCK is low, so this cycle leaves the bus unlocked.

Signals in the Timeline

SignalWidthRole
edges6input of each check
Full specification
The module you write (keep these ports)
module ahb_lock_arbiter (
  input  logic       hclk,
  input  logic       hresetn,     // active low
  input  logic [2:0] req,         // req[x]: manager x presents NONSEQ or SEQ and waits for the bus
  input  logic [1:0] htrans,      // the shared bus, driven by the owner: 0 IDLE, 1 BUSY, 2 NONSEQ, 3 SEQ
  input  logic       hmastlock,   // the shared bus HMASTLOCK
  input  logic       hready,      // the shared bus HREADY
  output logic [1:0] owner        // the manager that drives the shared address phase
);
  // your arbiter
endmodule
At a rising edgeowner after the edge
HRESETn low0
HREADY 1, HTRANS IDLE, HMASTLOCK 0, another manager requestsThe first requesting manager after the owner: owner + 1, then owner + 2 (mod 3)
anything elseunchanged

The result is {switches[7:0], trail[63:0]}. switches counts owner changes over 40 edges; trail holds the owner after each of the first 32 edges, two bits each.

Examples

Example 1

Round Robin
Input
All three request in turn while the owner is IDLE and unlocked: the bus moves 0, 1, 2, 0, 1, 2.
Output
switches = 6, trail = 0x249

At each safe edge the bus moves to the next requester after the owner, so every manager gets a turn.

Example 2

A Locked IDLE Is Not a Safe Point
Input
Manager 1 waits through a locked read, two locked IDLE cycles and a locked write; the bus moves at the unlocked IDLE.
Output
switches = 1, trail = 0x5555555555555500

The owner is IDLE in two cycles, but HMASTLOCK is high. The bus moves only at the IDLE with HMASTLOCK low.

Example 3

BUSY Is Not IDLE
Input
The owner runs a burst with two BUSY cycles; manager 2 waits until the owner is IDLE.
Output
switches = 1, trail = 0xaaaaaaaaaaaaa800

BUSY has HTRANS[1] low like IDLE, but it keeps the burst open. The bus waits for the real IDLE.

Constraints and Contract

  • Keep the module name and the ports. owner is a register.
  • Ignore req[owner]: the owner is the one on the bus.
  • The inputs change between edges; every input is 0 or 1.

Hints

Hint 1

Find the next requester combinationally: check owner + 1, then owner + 2, modulo 3.

Hint 2

HTRANS IDLE is 2'b00. BUSY, 2'b01, also has HTRANS[1] low, so test the whole value.

Hint 3

The lock rule needs no state of its own here. A cycle with HMASTLOCK low and HREADY high is the cycle that unlocks the bus.

What the grader checks: Your arbiter replays ten traces of 40 edges: five directed corners and five seeded mixes. They hold requests, bursts with BUSY, locked sequences and wait states. Its owner after every edge is compared with a model.

10 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 1 steps and the final capstone

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

Round Robin

Input
All three request in turn while the owner is IDLE and unlocked: the bus moves 0, 1, 2, 0, 1, 2.
Expected output
switches = 6, trail = 0x249

At each safe edge the bus moves to the next requester after the owner, so every manager gets a turn.

Run samples executes all 3 public checks. Check all tests runs 10 checks on the server.

Icarus · browser samples / server checks