Round-Robin Arbiter (4 Masters)
advanced · state_machine · 290 XP
Sign in to write your solution, run it in the simulator and submit it for grading.
Sign in or create a free account →Problem
Round-Robin Arbiter (4 Masters)
Arbitrate access to a shared resource among 4 requesters. Only one requester is granted access at a time. After serving a requester, the arbiter grants the next requesting master in **round-robin order** (0→1→2→3→0→...), preventing starvation.
**Interface**
| Port | Direction | Width | Description |
|------------|-----------|-------|------------------------------------|
| `clk` | input | 1 | Clock |
| `rst` | input | 1 | Sync reset |
| `req` | input | 4 | Request signals (one per master) |
| `grant` | output | 4 | One-hot grant signal (only 1 bit=1) |
| `busy` | output | 1 | ANY grant is active (OR of all grants) |
**Arbitration Rules**
1. Start at master 0; check if `req[0]=1`. If yes, grant. If no, check 1, 2, 3 in order.
2. After granting master X, next search starts from X+1 (wraps: 3→0).
3. **Fairness:** No master is served twice until all others are served once (round-robin property).
4. When a requester deasserts `req[i]`, deassert the corresponding `grant[i]` immediately.
5. Deassert `grant` when the requester no longer needs it (when `req=0`).
**Priority encoding:** One-hot output means only 1 grant bit is high at any time.
**Examples**
- `req=4'b0001`: master 0 requesting → `grant=4'b0001`
- `req=4'b1010` (0 and 2 requesting): serve starting from last served + 1; if last was 0, serve 1 (no req) → skip to 2 → `grant=4'b0100`
- `req=4'b1111` (all requesting): serve in order 0, then 1, 2, 3, then back to 0
**State machine approach:** Use a pointer register `next_master[1:0]` that rotates 0→1→2→3→0. On each clock, find the next requesting master starting from `next_master`. If found, grant and rotate the pointer.
Constraints
- grant must be one-hot: exactly 0 or 1 bit high, never multiple bits.
- When req[i]=0, grant[i] must go low (can't grant non-requesting master).
- Round-robin: after serving master X, next eligible check starts from X+1.
- busy = OR of all grant bits (high if ANY grant is active).
Examples
Input: req=0b0001 (only master 0)
Output: grant=0b0001
Grant master 0
Input: req=0b1111 (all requesting), last served=0
Output: grant=0b0010
Next in round-robin is 1
Input: req=0b1010 (masters 1 and 3), last served=2
Output: grant=0b1000
Next from 2 is 3, which is requesting
Input: Master with grant deasserts req
Output: grant deasserted immediately
Service ends
Common questions
- What does the Round-Robin Arbiter (4 Masters) problem ask you to build?
- Round-Robin Arbiter (4 Masters) Arbitrate access to a shared resource among 4 requesters. Only one requester is granted access at a time. After serving a requester, the arbiter grants the next requesting master in **round-robin order** (0→1→2→3→0→...), preventing starvation.
- What constraints does Round-Robin Arbiter (4 Masters) have?
- grant must be one-hot: exactly 0 or 1 bit high, never multiple bits.; When req[i]=0, grant[i] must go low (can't grant non-requesting master).; Round-robin: after serving master X, next eligible check starts from X+1.; busy = OR of all grant bits (high if ANY grant is active).
- What is an example input and output for Round-Robin Arbiter (4 Masters)?
- Input req=0b0001 (only master 0) gives output grant=0b0001. Grant master 0
- Which Verilog concepts does Round-Robin Arbiter (4 Masters) practise?
- state_machine, arbiter, round-robin, interview, fairness.