An arbiter is a digital circuit that controls access to a shared resource by many devices. Each device must request the use of the resource, and the arbiter decides which device gets it, outputting a “grant” signal.
Implementation
module arbiter(r, g, clock, resetn);
input [3:1] r;
output [3:1] g;
input clock, reset;
reg [3:0] y; // current state
reg [3:0] Y; // next state
parameter [3:0] s_idle = 4'b0001, s_g1 = 4'b0010, s_g2 = 4'b0100, s_g3 = 4'b1000;
// encodes so we can use the symbolic name and don't have to type out the full bits
always@(y, r) begin // next-state logic
case(y)
s_idle: begin
if (r[1])
Y = s_g1;
else if (r[2])
Y = s_g2;
else if (r[3])
Y = s_g3;
else
Y = s_idle;
end
s_g1: begin
if (r[1])
Y = s_g1;
else
Y = s_idle;
end
s_g2: begin
if (r[2])
Y = s_g2;
else
Y = s_idle;
end
s_g3: begin
if (r[3])
Y =
default: Y = s_idle;
endcase
end
// not finished above, below
always@(posedge clock)
endmodule