上篇讲了固定优先级仲裁器的设计,并给出了指定最高优先级的实现方法
Verilog固定优先级仲裁器——Fixed Priority Arbiter_weixin_42330305的博客-CSDN博客
轮询仲裁就是在固定优先级仲裁器的基础上,所有的request轮流当最高优先级。
一、原理
当N个source同时发出请求时,默认source 0的优先级最高,当source 0 被响应后,它的优先级变为最低,source 1的优先级转为最高,以此类推。
二、实现方法
在固定优先级仲裁器的那一篇,讲了指定最高优先级的固定优先级仲裁器的实现方法。那么轮询仲裁器就是在固定优先级的基础上,最高优先级依次变化。
即初始情况下,最高优先级为source 0,然后是source 1、source 2、……直到source N
RTL如下:
module appoint_first_priority_arb
(
input [5:0] req,
input [5:0] first_priority,
output [5:0] grant
);
wire [6*2-1:0] double_req = {req,req};
wire [6*2-1:0] req_sub_first_priority = double_req - first_priority;
wire [6*2-1:0] double_grant = double_req & (~req_sub_first_priority);
assign grant = double_grant[5:0] | double_grant[11:6];
endmodule
若想实现轮询,需要将first_priority由input信号改为自己产生(first_priority为独热码)
module round_arb
(
input clk,
input reset_n,
input [5:0] req,
output [5:0] grant
);
reg [5:0] round_priority;
always @(posedge clk or negedge reset_n)
begin
if(!reset_n)
round_priority <= 6'b1;
else if(|grant)
round_priority <= {grant[4:0],grant[5]};
end
wire [6*2-1:0] double_req = {req,req};
wire [6*2-1:0] req_sub_round_priority = double_req - round_priority;
wire [6*2-1:0] double_grant = double_req & (~req_sub_round_priority);
assign grant = double_grant[5:0] | double_grant[11:6];
endmodule
仲裁器进阶:
Verilog权重轮询仲裁器设计——Weighted Round Robin Arbiter_weixin_42330305的博客-CSDN博客