25. Round-robin arbiter
Four requesters share one resource. Each cycle, grant at most one of them, fairly.
req[i] = 1 means requester i wants the resource this cycle. grant is combinational: it has exactly one bit set (the winner) when any request is active, and is 0 when none is.
Fairness: remember the last requester that was granted. The search for a winner starts at the requester just after it and goes upward, wrapping from 3 to 0, so the requester that was just served has the lowest priority next time. The remembered value changes only on a clock edge where some grant was given; if nobody requests, it stays as it was.
rst (synchronous, active high) sets the remembered value to 3, so that requester 0 has the highest priority after reset.
Ports
| Port | Dir | Bits | What it is |
|---|---|---|---|
clk | in | 1 | Clock. |
rst | in | 1 | Synchronous reset, active high. |
req | in | 4 | Requests, one bit per requester. |
grant | out | 4 | One-hot grant, or 0. |
Example
After reset with req = 1111, the grants on successive cycles are 0001, 0010, 0100, 1000, 0001. With req = 1010 and requester 1 just served, the grant goes to requester 3.
Written hints
AI hint
Submissions
No submissions yet. Submit your answer and it shows here. Sign in to keep them.
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.
Press Build to check your code with Yosys. Errors and warnings show here, and a clean build draws the logic diagram.
Build your design to drive it by hand and see its signals here.