Part of Curriculum: Advanced SoC and Chiplet RTL (Module 1: Fixed Priority vs Round-Robin Arbitration)
View Full Roadmap →
Level 3 Hard ★ Flagship #27 50 pts ✓ Solved

Round-Robin Arbiter — Request Arbitration

Arbitration & Interconnect · memory, fifo, protocols, apb, uart, hard, fair-arbitration

Implement a 4-client round-robin arbiter. When multiple clients assert req[3:0], grant rotates fairly to prevent client starvation.

Write a synthesizable Verilog module named top_module matching the ports below exactly.
📐 Circuit Schematic Diagram
req[3:0]grant[3:0]>clkrst_nROUND-ROBIN ARBITERDIGITAL HARDWARE BLOCK
⚡ Timing & Synthesizability Constraints

Timing Contract: Grant updates on `posedge clk`. Exactly one active grant output `grant[3:0]` is asserted when at least one request is active.

RTL Constraints: Priority rotates circularly to the client immediately following the client that was just granted.

Objective: Understand rotating priority masks, fair arbitration, and avoiding resource starvation.

Prerequisites: Fixed priority arbiters, one-hot priority masking.
NameDirWidthDescription
clkinput1Master clock
areset_ninput1Active-low asynchronous reset
reqinput44-bit request vector from clients
grantoutput44-bit one-hot grant vector
Expected Waveform (Golden Timing Contract)
💡 Need Guidance? Progressive Hints (3 Levels)
Hint 1: Conceptual Direction & Hardware Primitives
Store `last_grant`: the index of the client that was serviced most recently.
Hint 2: Implementation Architecture & Approach
Rotate priority so search starts at `(last_grant + 1) % 4`.
Hint 3: Edge Cases, Timing & Verilog Syntax
Only update `last_grant` when at least one client is granted.
🔒 Reveal Verified Reference RTL Solution (Click to expand)
⚠️ Self-Discovery Warning: Try solving and simulating first! Viewing the verified reference implementation will bypass the real debugging experience.
Verified Synthesizable RTL
module top_module(
  input        clk,
  input        areset_n,
  input  [3:0] req,
  output reg [3:0] grant
);
  reg [1:0] last_grant;

  function [3:0] get_grant;
    input [1:0] last;
    input [3:0] r;
    reg [3:0] g;
    begin
      g = 4'b0000;
      case (last)
        2'd0: begin
          if (r[1]) g = 4'b0010;
          else if (r[2]) g = 4'b0100;
          else if (r[3]) g = 4'b1000;
          else if (r[0]) g = 4'b0001;
        end
        2'd1: begin
          if (r[2]) g = 4'b0100;
          else if (r[3]) g = 4'b1000;
          else if (r[0]) g = 4'b0001;
          else if (r[1]) g = 4'b0010;
        end
        2'd2: begin
          if (r[3]) g = 4'b1000;
          else if (r[0]) g = 4'b0001;
          else if (r[1]) g = 4'b0010;
          else if (r[2]) g = 4'b0100;
        end
        default: begin // 2'd3
          if (r[0]) g = 4'b0001;
          else if (r[1]) g = 4'b0010;
          else if (r[2]) g = 4'b0100;
          else if (r[3]) g = 4'b1000;
        end
      endcase
      get_grant = g;
    end
  endfunction

  always @(posedge clk or negedge areset_n) begin
    if (!areset_n) begin
      grant      <= 4'b0000;
      last_grant <= 2'd3;
    end else begin
      grant <= get_grant(last_grant, req);
      if (get_grant(last_grant, req) != 4'b0000) begin
        case (get_grant(last_grant, req))
          4'b0001: last_grant <= 2'd0;
          4'b0010: last_grant <= 2'd1;
          4'b0100: last_grant <= 2'd2;
          4'b1000: last_grant <= 2'd3;
        endcase
      end
    end
  end
endmodule
Verilog-2001 / SV Saved
Font: |
// Click Run Tests (or press Ctrl+Enter) to compile your RTL and simulate against hidden testbenches.
Simulation Timing Diagram (VCD Waveform)
100%
No simulation waveform yet. Run tests to simulate and generate VCD traces.
No compilation run yet. Syntax warnings and elaboration messages will appear here.
No simulation output yet. Raw stdout from vvp will appear here.

RTL Problems / Level 3 · Arbitration & Interconnect

What You Will Learn

By solving Round-Robin Arbiter — Request Arbitration, you will acquire core industry skills:

  • Synthesizable hardware modeling in standard Verilog-2001 / SystemVerilog.
  • Correct handling of interface port contracts, edge-triggered clocks, and active-low/high resets.
  • Simulation waveform interpretation and debugging using timing diagrams (VCD traces).
  • Architectural avoidance of timing violations, glitching hazards, and synthesis warnings.

Problem Statement & Requirements

Implement a 4-client round-robin arbiter. When multiple clients assert req[3:0], grant rotates fairly to prevent client starvation.

Hardware design teams at leading semiconductor firms evaluate these exact port contracts, race-condition assertions, and corner cases during technical design reviews and ASIC engineer interviews.

Objective: Understand rotating priority masks, fair arbitration, and avoiding resource starvation.

Prerequisites: Fixed priority arbiters, one-hot priority masking.

Port List & Interface Timing

The hidden testbench instantiates top_module. Module port names and bit-widths must match the interface contract exactly:

NameDirWidthDescription
clkinput1Master clock
areset_ninput1Active-low asynchronous reset
reqinput44-bit request vector from clients
grantoutput44-bit one-hot grant vector

Timing Constraints & Synthesizable RTL Rules

⚡ Synthesizable Implementation Guidelines

Timing Contract: Grant updates on `posedge clk`. Exactly one active grant output `grant[3:0]` is asserted when at least one request is active.

Synthesis Constraints: Priority rotates circularly to the client immediately following the client that was just granted.

Architectural Deep Dive & Implementation Walkthrough

In a fixed-priority arbiter, high-priority clients can completely starve low-priority clients. A round-robin arbiter ensures 100% fairness by advancing the highest-priority token to $(k+1) \pmod 4$ whenever client $k$ is serviced. This guarantees an upper bound on waiting latency for all bus masters.

Common RTL Designer Pitfalls

⚠️ Common Mistakes to Avoid

['Granting multiple clients simultaneously when requests overlap.', 'Advancing priority when no client is requesting, breaking fair cycle order.']

Silicon & Hardware Engineering Notes

🛠️ ASIC vs FPGA Hardware Considerations

In wide arbiters (8 to 64 ports), round-robin logic is synthesized using dual priority-encoder chains ($req \& \sim mask$ and $req$) to eliminate $O(N)$ sequential case branches.

Starter RTL Code

module top_module(
  input        clk,
  input        areset_n,
  input  [3:0] req,
  output reg [3:0] grant
);

  // 4-client round-robin arbiter

endmodule

Verified Reference Solution

🔒 Reveal Verified Reference RTL Solution
module top_module(
  input        clk,
  input        areset_n,
  input  [3:0] req,
  output reg [3:0] grant
);
  reg [1:0] last_grant;

  function [3:0] get_grant;
    input [1:0] last;
    input [3:0] r;
    reg [3:0] g;
    begin
      g = 4'b0000;
      case (last)
        2'd0: begin
          if (r[1]) g = 4'b0010;
          else if (r[2]) g = 4'b0100;
          else if (r[3]) g = 4'b1000;
          else if (r[0]) g = 4'b0001;
        end
        2'd1: begin
          if (r[2]) g = 4'b0100;
          else if (r[3]) g = 4'b1000;
          else if (r[0]) g = 4'b0001;
          else if (r[1]) g = 4'b0010;
        end
        2'd2: begin
          if (r[3]) g = 4'b1000;
          else if (r[0]) g = 4'b0001;
          else if (r[1]) g = 4'b0010;
          else if (r[2]) g = 4'b0100;
        end
        default: begin // 2'd3
          if (r[0]) g = 4'b0001;
          else if (r[1]) g = 4'b0010;
          else if (r[2]) g = 4'b0100;
          else if (r[3]) g = 4'b1000;
        end
      endcase
      get_grant = g;
    end
  endfunction

  always @(posedge clk or negedge areset_n) begin
    if (!areset_n) begin
      grant      <= 4'b0000;
      last_grant <= 2'd3;
    end else begin
      grant <= get_grant(last_grant, req);
      if (get_grant(last_grant, req) != 4'b0000) begin
        case (get_grant(last_grant, req))
          4'b0001: last_grant <= 2'd0;
          4'b0010: last_grant <= 2'd1;
          4'b0100: last_grant <= 2'd2;
          4'b1000: last_grant <= 2'd3;
        endcase
      end
    end
  end
endmodule
Advertisement

Related RTL Problems in Level 3

Frequently Asked Questions

What does Round-Robin Arbiter — Request Arbitration require?

Implement a 4-client round-robin arbiter. When multiple clients assert req[3:0], grant rotates fairly to prevent client starvation. Implement it as Verilog module top_module matching the listed ports.

Is this design combinational or sequential?

Tags: memory, fifo, protocols, apb, uart, hard, fair-arbitration. If a clock signal is present in the port table, implement it as sequential logic; otherwise, use continuous assignments or combinational blocks.

How is my solution graded?

A hidden SystemVerilog testbench simulates your module in the cloud judge. You pass when all directed corner cases match the golden model and the VCD timing waveform matches the contract.

How does this challenge help with semiconductor interviews?

Technical interviewers at NVIDIA, Qualcomm, Apple, and Intel routinely ask candidates to code, debug, and explain the timing waveforms of Round-Robin Arbiter — Request Arbitration to assess real-world synthesizability and race-condition awareness.

Advertisement