Round Robin Arbiter
Round Robin Arbiter
ID No. Name
2023H1400128H V. Sahat Monal
Verilog Design Code for Round Robin Arbiter
module arbiter#(parameter N = 4) (clk,rst,req,gnt3);
// PORT DECLARATION
input clk; //CLOCK
input rst; //RESET
input [N-1:0] req; //REQUEST SIGNALS
output [N-1:0] gnt3; //GRANT SIGNALS
//INTERNAL REGISTERS
wire [$clog2(N)-1:0] gnt;
wire comreq;
wire beg; // BEGIN SIGNAL
wire [$clog2(N)-1:0] llgnt; // LATCHED ENCODED GRANT
wire lcomreq ; // BUS STATUS
reg [N-1:0] lgnt; // LATCHED GRANTS
reg mask_enable ;
reg lmask0;
reg lmask1 ;
reg ledge ;
//--//
else
begin
lgnt[0] <=(~lcomreq & ~lmask1 & ~lmask0 & ~req[3] & ~req[2] & ~req[1] &
req[0])
| (~lcomreq & ~lmask1 & lmask0 & ~req[3] & ~req[2] & req[0])
| (~lcomreq & lmask1 & ~lmask0 & ~req[3] & req[0])
| (~lcomreq & lmask1 & lmask0 & req[0] )
| ( lcomreq & lgnt[0]);
lgnt[2] <=(~lcomreq & ~lmask1 & ~lmask0 & req[2] & ~req[1])
| (~lcomreq & ~lmask1 & lmask0 & req[2])
| (~lcomreq & lmask1 & ~lmask0 & ~req[3] & req[2] & ~req[1] &
~req[0])
| (~lcomreq & lmask1 & lmask0 & req[2] & ~req[1] & ~req[0])
| ( lcomreq & lgnt[2]);
lgnt[3] <=(~lcomreq & ~lmask1 & ~lmask0 & req[3] & ~req[2] & ~req[1])
| (~lcomreq & ~lmask1 & lmask0 & req[3] & ~req[2])
| (~lcomreq & lmask1 & ~lmask0 & req[3])
| (~lcomreq & lmask1 & lmask0 & req[3] & ~req[2] & ~req[1] & ~req[0])
| ( lcomreq & lgnt[3]);
end
//BEGIN SIGNAL
// Encoder logic
// lmask register.
endmodule
initial begin
$dumpfile ("arbiter.vcd");
$dumpvars();
clk = 0;
rst = 1;
req = 4'b0;
#10 rst = 0;
repeat (1) @ (posedge clk);
req[0] <= 1;
repeat (1) @ (posedge clk);
req[0] <= 0;
repeat (1) @ (posedge clk);
req[0] <= 1;
req[1] <= 1;
repeat (1) @ (posedge clk);
req[2] <= 1;
req[1] <= 0;
repeat (1) @ (posedge clk);
req[3] <= 1;
req[2] <= 0;
repeat (1) @ (posedge clk);
req[3] <= 0;
repeat (1) @ (posedge clk);
req[0] <= 0;
repeat (1) @ (posedge clk)
#10 $finish;
end
// Connect the DUT
arbiter U (
clk,
rst,
req,
gnt3
);
endmodule