【仲裁器】轮询仲裁round-robin,rr

  • 起因:在多主单从的设计中,当多个源端同时发起传输请求时,需要仲裁器根据优先级来判断响应哪一个源端。
  • 轮询仲裁:各个源端优先级相同,当其同时发起请求时,依次进行响应。

电路图

在这里插入图片描述

代码

module rr_arb(
  input  clk,
  input  rst_n,

  input  req1,
  input  req2,
  input  req3,
  input  req4,

  input  busy,
  output reg [3:0] nx_arb_gnt
);
localparam  S1=4'b0001,
      S2=4'b0010,
      S3=4'b0100,
      S4=4'b1000;
reg [3:0] cur_arb_gnt_r;
wire [3:0] cur_arb_gnt;
always @(posedge clk or negedge rst_n) begin
  if (~rst_n) begin
    cur_arb_gnt_r <= S1; // S1
  end
  else if (~busy) begin
    cur_arb_gnt_r <= nx_arb_gnt;
  end
end
assign cur_arb_gnt = cur_arb_gnt_r;
always @(*) begin
  if (~busy) begin
    case(cur_arb_gnt)    //循环仲裁
      S1:begin 
        case(1'b1)
          req2:nx_arb_gnt = S2;
          req3:nx_arb_gnt = S3;
          req4:nx_arb_gnt  = S4;
          req1:nx_arb_gnt = S1;
          default:nx_arb_gnt = S1;
        endcase
      end
      S2:begin 
        case(1'b1)
          req3:nx_arb_gnt = S3;
          req4:nx_arb_gnt = S4;
          req1:nx_arb_gnt = S1;
          req2:nx_arb_gnt = S2;
          default:nx_arb_gnt = S2;
        endcase
      end
      S3:begin 
        case(1'b1)
          req4:nx_arb_gnt = S4;
          req1:nx_arb_gnt = S1;
          req2:nx_arb_gnt = S2;
          req3:nx_arb_gnt = S3;
          default:nx_arb_gnt = S3;
        endcase
      end
      S4:begin
        case(1'b1)
          req1:nx_arb_gnt = S1;
          req2:nx_arb_gnt = S2;
          req3:nx_arb_gnt = S3;
          req4:nx_arb_gnt = S4;
          default:nx_arb_gnt   = S4;
      endcase
    end
    default: nx_arb_gnt = S1;
    endcase
  end
  else begin
    nx_arb_gnt = cur_arb_gnt;
  end
end
endmodule
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值