本文主要分享【】,技术文章【三 仲裁器的设计】为【luuuugang】投稿,如果你遇到相关问题,请看以下文章。
固定优先级 -- Fixed Priority思路:假设最低位优先级最高,从低位到高位依次去判断,借助一个pre_req来记录低位是否已经有了request,如果第i位有了request,那么第i+1位一直到最高位的pre_req都是1。
实现方式一//Fixed Priority Arbiter
module fixed_prior_arb #(
parameter REQ_WIDTH=3)(
input[REQ_WIDTH-1:0] req,
output[REQ_WIDTH-1:0] grant
);
wire[REQ_WIDTH-1:0] pre_req;
assign pre_req[0]=1'b0;
assign pre_req[REQ_WIDTH-1:1]=req[REQ_WIDTH-2:0] | pre_req[REQ_WIDTH-2:0];
assign grant=req&~pre_req;
endmodule
上述思想本质上时找到req从低到高的第一个1。那么利用补码的思想,将req-1,得到的结果进行取反,将取反后的结果与req原来的值按位与。结果就会得到grant。
实现方式二//Fixed Priority Arbiter
module fixed_prior_arb #(
parameter REQ_WIDTH=3)(
input[REQ_WIDTH-1:0] req,
output[REQ_WIDTH-1:0] grant
);
assign grant=req&~(req-1);
endmodule
Round Robin
思路一:
优先级变化,输入request正常。
利用上述fixed的实现方式二的思想,设计一个指定第x位优先级最高(最低位优先级最低)的固定优先级仲裁器。
module arbiter_base
#(parameter NUM_REQ=4)(
input[NUM_REQ-1:0] req,
input[NUM_REQ-1:0] base,
output[NUM_REQ-1:0] gnt
);
wire[2*NUM_REQ-1:0] double_req={req,req};
wire[2*NUM_REQ-1:0] double_gnt=double_req&~double_req-base);
assign gnt=double_gnt[NUM_REQ-1:0] | double_gnt[2*NUM_REQ-1:NUM_REQ];
endmodule
在此基础上,设置一个pre_grant,base为上一个grant左移一位的结果,由此实现优先级的轮换。
module round_robin_arbiter
#(parameter NUM_REQ=4)(
input clk,
input rst_n,
input[NUM_REQ-1:0] req,
output[NUM_REQ-1:0] gnt
);
reg[NUM_REQ-1:0] pre_gnt;
arbiter_base u1(.req(req),.gnt(gnt),.base(pre_gnt));
always@(posedge clk or negedge rst_n)begin
if(!rst_n)
pre_gnt
本文地址:https://www.ufidawhy.com/gjp/120183.html
版权声明:本文来源于网络,如有侵权请E-mail联系 ufidawhy 站长 ufidawhy@vip.qq.com!
版权声明:本文来源于网络,如有侵权请E-mail联系 ufidawhy 站长 ufidawhy@vip.qq.com!