A single master talking to a few slaves is the easy case. Real chips have processors, DMA engines, graphics and network controllers all reaching for the same memory at the same time. This chapter covers the ideas that make that work: arbitration between masters, pipelining and outstanding transactions, interconnect structures, and bridges between buses and clock domains. AHB and AXI are built on exactly these ideas.

When two masters share a bus, only one can drive it at a time. An arbiter decides who. Its rules matter more than they seem: a badly chosen policy lets one master take the bus forever while another starves. This article explains bus arbitration, compares fixed priority and round robin in a simulation, and shows where arbiters sit in real buses.

8 min read | Beginner to Intermediate

What You'll Learn

  • Explain why a shared bus needs an arbiter
  • Compare fixed-priority and round-robin arbitration
  • Recognize starvation and how to prevent it
  • Implement a two-master arbiter in Verilog

Who Owns the Bus?

A shared bus has one set of address and data wires. If two masters drive them at the same time, the values collide. So each master raises a request, an arbiter grants the bus to one of them, and a multiplexer connects only the granted master to the bus. The other master keeps its request up and waits.

Fixed Priority

The simplest policy gives every master a fixed rank. When several request, the highest-ranked one wins. It is small and predictable, and it suits masters with real-time deadlines, such as a display controller that must never miss a pixel.

Its weakness is starvation: a high-priority master that requests all the time keeps the bus, and the lower-priority masters never get it.

Round Robin

A round-robin arbiter remembers who was granted last and gives the next conflict to the other master. Every master gets a turn, so none can starve. Here is a two-master arbiter that does either, selected by a parameter:


module bus_arbiter #(
  parameter ROUND_ROBIN = 0              // 0 = fixed priority (master 0 wins), 1 = round robin
) (
  input            clk,
  input            rst,
  input      [1:0] req,
  output reg [1:0] gnt
);
  reg last;                              // the master granted last time

  always @(posedge clk) begin
    if (rst) begin
      gnt  <= 2'b00;
      last <= 1'b1;
    end
    else begin
      if (req == 2'b11) begin
        if (ROUND_ROBIN) begin
          gnt  <= last ? 2'b01 : 2'b10;  // the other master gets the next turn
          last <= ~last;
        end
        else begin
          gnt <= 2'b01;                  // master 0 always wins
        end
      end
      else begin
        gnt <= req;                      // only one or no request: grant it
        if (req == 2'b01)
          last <= 1'b0;
        else if (req == 2'b10)
          last <= 1'b1;
      end
    end
  end
endmodule

Each grant lasts one cycle, enough for one transfer to a slave that is always ready.

Quick Check

Q: Both masters request continuously. With round robin, how many of every four transfers does each master get?

Show Answer

Two each. The arbiter alternates on every conflict, so the grants go 0, 1, 0, 1.

The Two Policies Side by Side

The testbench drives both arbiters with the same requests: both masters want the bus for eight cycles.

Output
fixed priority: master 0 got 8 transfers, master 1 got 0
round robin:    master 0 got 4 transfers, master 1 got 4

Fixed priority starved master 1 completely. In a real system, master 1 could be a DMA engine moving audio data, and the audio would stop. Round robin split the bus evenly.

Arbitration in Real Buses

  • AHB with several masters uses an arbiter with HBUSREQ and HGRANT signals in the classic AMBA 2 form. AHB-Lite has a single master; multi-master systems put an arbiter in the interconnect instead.
  • AXI has no arbitration signals at all. Each master has its own port into the interconnect, and arbiters inside the interconnect decide, per slave, which request goes next.
  • Real arbiters often combine policies: priority classes with round robin inside each class, or weights so that a master gets a guaranteed share of the bandwidth.

Quick Check

Q: A system has a display controller that must get the bus within 2 cycles, and three DMA engines. Which policy would you choose?

Show Answer

A combination: the display controller in a higher priority class, so it always wins, and round robin among the three DMA engines, so none of them starves. The display must not request all the time, or the DMA engines would still starve.

Running It in ChipVerify Lab

The example contains the arbiter, a shared bus built around it, and the testbench that compares both policies. Run it and compare the two grant patterns in the waveform.

Common Mistakes

Mistake #1: Fixed priority for masters that request all the time

A greedy high-priority master starves everyone else. Use round robin, or make sure the high-priority master only requests occasionally.

Mistake #2: Changing the grant in the middle of a transfer

If the grant moves while a slave is still answering with wait states, the response goes to the wrong master. Re-arbitrate only when the current transfer completes.

Mistake #3: A master that drops its request while waiting

A master that gives up and requests again later may be unlucky every time. Keep the request up until the grant arrives.

Practice Exercise

Challenge: A Master That Stops Early

Open the example. Change the testbench so that both masters request for four cycles, and then only master 1 requests for four more. Predict the counts for both policies, then run it.

Hint

When only one master requests, both arbiters simply grant it.

Solution

req = 2'b11;                     // both masters request ...
repeat (4) @(negedge clk);
req = 2'b10;                     // ... then only master 1
repeat (4) @(negedge clk);
req = 2'b00;

Fixed priority: master 0 gets 4 (the first four cycles), master 1 gets 4 (the last four). Round robin: master 0 gets 2 and master 1 gets 6, two during the shared phase and four after. With fixed priority, master 1 only got the bus because master 0 stopped asking.

Open the ready-made example in the lab and run the simulation.

Summary

  • A shared bus needs an arbiter so that only one master drives it at a time.
  • Fixed priority is simple and predictable but lets a busy high-priority master starve the others.
  • Round robin gives every requesting master a turn; in the simulation it split eight transfers 4 to 4, where fixed priority gave 8 to 0.
  • AHB multi-master systems and AXI interconnects arbitrate per slave, often with combined policies.
Did you find what you were looking for?

Quiz

No quiz questions available for this article.