Verilog轮询仲裁器设计——Round Robin Arbiter

上篇讲了固定优先级仲裁器的设计,并给出了指定最高优先级的实现方法

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博客

verilog多因素影响仲裁器设计_weixin_42330305的博客-CSDN博客

  • 6
    点赞
  • 58
    收藏
    觉得还不错? 一键收藏
  • 10
    评论
四源轮询仲裁器是一种常见的硬件电路,可以用于多个设备之间的资源共享。在verilog中实现四源轮询仲裁器,需要按照以下步骤进行: 1. 定义输入输出端口:根据四源轮询仲裁器的功能,需要定义4个设备的请求信号输入端口和一个仲裁结果输出端口。例如: ``` module arbiter(input req1, input req2, input req3, input req4, output arb); ``` 2. 定义内部变量:需要定义一个轮询计数器变量,用于记录当前轮询到哪个请求信号。例如: ``` reg [1:0] count = 2'b00; ``` 3. 实现轮询逻辑:将请求信号和计数器变量结合,实现轮询逻辑。例如: ``` always @ (req1 or req2 or req3 or req4) begin case (count) 2'b00: if (req1) begin count <= 2'b01; arb <= 1'b1; end 2'b01: if (req2) begin count <= 2'b10; arb <= 1'b1; end 2'b10: if (req3) begin count <= 2'b11; arb <= 1'b1; end 2'b11: if (req4) begin count <= 2'b00; arb <= 1'b1; end default: arb <= 1'b0; endcase end ``` 4. 编写完整的模块代码:将以上步骤合并,编写完整的四源轮询仲裁器模块代码。例如: ``` module arbiter(input req1, input req2, input req3, input req4, output arb); reg [1:0] count = 2'b00; always @ (req1 or req2 or req3 or req4) begin case (count) 2'b00: if (req1) begin count <= 2'b01; arb <= 1'b1; end 2'b01: if (req2) begin count <= 2'b10; arb <= 1'b1; end 2'b10: if (req3) begin count <= 2'b11; arb <= 1'b1; end 2'b11: if (req4) begin count <= 2'b00; arb <= 1'b1; end default: arb <= 1'b0; endcase end endmodule ``` 需要注意的是,以上代码仅为示例,具体实现可能因为不同的系统需求而有所不同。在实际使用时,需要根据实际情况进行适当修改和调整。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值