RTL Design / Module 6: FSMs & Control
Lesson 6.5

Arbiters — fixed priority & round-robin

When multiple masters want the same shared resource (bus, memory port, DMA channel), an arbiter picks one winner per cycle. Fixed priority is simple and fast; round-robin rotates the winner for fairness. Both are classic combinational or registered FSM patterns.

Arbiter contract

Given req[N-1:0], produce grant[N-1:0] where at most one bit is high. Grant only goes to a requesting port. When req==0, grant==0.

Arbiters sit between independent masters and a shared slave — AXI interconnects, on-chip SRAM ports, DMA channels. The RTL is usually a combo priority encoder plus optional registered grant and a small hold FSM when bursts must not be interrupted.

1

Arbiter block diagram

Arbiter block diagram

req[] in, grant[] out — at most one grant active. Shared slave sees one master per transfer.

SchemeFairnessLogic depthTypical use
Fixed priorityLow index always winsShallow (priority encoder)Latency-critical path, known traffic
Round-robinEqual long-term shareDeeper (mask + rotate)DMA channels, fair bus access
Weighted RRProportional bandwidthDeepestQoS tiers, network switches
2

Fixed priority — grant highest pending req

fixed_priority_arb.v
// Fixed-priority arbiter — req[0] has highest priority
module fixed_priority_arb #(
  parameter N = 4
)(
  input  wire [N-1:0] req,
  output wire [N-1:0] grant
);
  reg [N-1:0] g;
  integer i;

  always @(*) begin
    g = {N{1'b0}};
    for (i = 0; i < N; i = i + 1)
      if (req[i]) begin
        g[i] = 1'b1;
        i = N;  // break — first set bit wins
      end
  end
  assign grant = g;
endmodule

// Alternative one-liner style:
// assign grant = req & (~req + 1);  // isolates lowest set bit
// For HIGHEST priority: reverse req, isolate low, reverse back
Fixed priority fairness

When req[0] is always high, lower-priority masters never get grant — acceptable only when designed for it.

3

Round-robin — rotate starting point

Maintain a mask register: after granting port k, next search starts at k+1. Wrap around to 0.

Round-robin rotation
round_robin_arb.v
module round_robin_arb #(
  parameter N = 4
)(
  input  wire         clk,
  input  wire         rst_n,
  input  wire [N-1:0] req,
  output reg  [N-1:0] grant
);
  reg [N-1:0] mask;  // rotate pointer: search above mask first
  reg [N-1:0] g;
  integer i;

  always @(*) begin
    g = {N{1'b0}};
    // Pass 1: req & mask (ports above last grant)
    for (i = N-1; i >= 0; i = i - 1)
      if (req[i] & mask[i]) begin g[i] = 1'b1; i = -1; end
    // Pass 2: wrap — req & ~mask
    if (g == {N{1'b0}})
      for (i = N-1; i >= 0; i = i - 1)
        if (req[i] & ~mask[i]) begin g[i] = 1'b1; i = -1; end
  end

  always @(posedge clk or negedge rst_n) begin
    if (!rst_n) begin
      grant <= {N{1'b0}};
      mask  <= {{(N-1){1'b1}}, 1'b0}; // start at 0
    end else begin
      grant <= g;
      if (|g) begin
        // Set mask: all bits below granted index = 1
        mask <= {N{1'b1}} << (find_grant_index(g) + 1);
      end
    end
  end
endmodule
Trap

Grant must be registered or qualified with req — never grant a port that dropped its request between combo eval and clock edge. Production arbiters gate grant <= g & req.

4

Grant-holding FSM — lock through burst

Production arbiters don't re-arbitrate every cycle. Once a master wins, hold grant until it drops req or signals transfer complete — prevents mid-burst collisions on the shared bus.

Grant hold FSM
grant_hold_fsm.v
localparam IDLE = 1'b0, LOCKED = 1'b1;
reg        arb_state;
reg [N-1:0] held_grant;

always @(posedge clk or negedge rst_n) begin
  if (!rst_n) begin
    arb_state  <= IDLE;
    held_grant <= {N{1'b0}};
  end else case (arb_state)
    IDLE: if (|req) begin
            held_grant <= pick_winner(req);  // combo RR or fixed
            arb_state  <= LOCKED;
          end
    LOCKED: if (!(held_grant & req)) begin  // winner dropped req
            held_grant <= {N{1'b0}};
            arb_state  <= IDLE;
          end
    default: arb_state <= IDLE;
  endcase
end

assign grant = (arb_state == LOCKED) ? held_grant : {N{1'b0}};
5

Compact round-robin — mask update

rr_mask_update.v
// After granting index gnt_idx, update mask for next cycle:
// mask = all 1s shifted left by (gnt_idx + 1), wrap at N

function automatic [N-1:0] update_mask;
  input [N-1:0] old_mask;
  input integer gnt_idx;
  begin
    if (gnt_idx == N-1)
      update_mask = {{(N-1){1'b1}}, 1'b0};
    else
      update_mask = {N{1'b1}} << (gnt_idx + 1);
  end
endfunction
6

Arbiter + handshake integration

Real arbiters hold grant until the master completes a transfer (req drops or ack received). This is a small FSM:

🔒

Lock grant

Once granted, hold until transfer completes — don't re-arbitrate mid-burst.

⏱️

Split vs united

Combo grant (fast) vs registered grant (timing-safe) — register for high N.

⚖️

Starvation check

Sim with all req high forever — verify RR rotates; fixed-pri matches spec.

▶ Test arbiters in simulator
7

Arbiter design checklist

  • At most one grant bit high per cycle
  • grant & req == grant — never grant idle ports
  • Fixed-pri: document who wins and why (starvation acceptable?)
  • Round-robin: mask/pointer resets correctly out of reset
  • Register grant for timing when N > 8 or Fmax is tight
  • Hold grant through burst until master releases req
  • TB: all-req-high test for fairness; single-req tests for encoding

🎯 What to remember

  • Fixed priority = simple, fast, unfair — use when you mean it.
  • Round-robin = mask + wrap search — fair long-term bandwidth.
  • Grant ⊆ req always — gate registered grant with current req.
  • Arbiters are often small FSMs wrapped around combo grant logic.
Advertisement