rtl: rib: arbitrated by logic instead of clock

Signed-off-by: liangkangnan <liangkangnan@163.com>
pull/1/head
Blue Liang 2020-08-13 08:56:01 +08:00
parent 4b5904df81
commit fa958a6153
1 changed files with 15 additions and 80 deletions

View File

@ -122,103 +122,38 @@ module rib(
parameter [1:0]grant2 = 2'h2;
parameter [1:0]grant3 = 2'h3;
wire[3:0] req;
reg[1:0] grant;
reg[1:0] next_grant;
//
assign req = {m3_req_i, m2_req_i, m1_req_i, m0_req_i};
//
always @ (posedge clk) begin
if (rst == `RstEnable) begin
grant <= grant1;
end else begin
grant <= next_grant;
end
end
//
//
// 021
always @ (*) begin
if (rst == `RstEnable) begin
next_grant = grant1;
grant = grant1;
hold_flag_o = `HoldDisable;
end else begin
case (grant)
grant0: begin
if (req[3]) begin
next_grant = grant3;
grant = grant3;
hold_flag_o = `HoldEnable;
end else if (req[0]) begin
next_grant = grant0;
grant = grant0;
hold_flag_o = `HoldEnable;
end else if (req[2]) begin
next_grant = grant2;
grant = grant2;
hold_flag_o = `HoldEnable;
end else begin
next_grant = grant1;
grant = grant1;
hold_flag_o = `HoldDisable;
end
end
grant1: begin
if (req[3]) begin
next_grant = grant3;
hold_flag_o = `HoldEnable;
end else if (req[0]) begin
next_grant = grant0;
hold_flag_o = `HoldEnable;
end else if (req[2]) begin
next_grant = grant2;
hold_flag_o = `HoldEnable;
end else begin
next_grant = grant1;
hold_flag_o = `HoldDisable;
end
end
grant2: begin
if (req[3]) begin
next_grant = grant3;
hold_flag_o = `HoldEnable;
end else if (req[0]) begin
next_grant = grant0;
hold_flag_o = `HoldEnable;
end else if (req[2]) begin
next_grant = grant2;
hold_flag_o = `HoldEnable;
end else begin
next_grant = grant1;
hold_flag_o = `HoldDisable;
end
end
grant3: begin
if (req[3]) begin
next_grant = grant3;
hold_flag_o = `HoldEnable;
end else if (req[0]) begin
next_grant = grant0;
hold_flag_o = `HoldEnable;
end else if (req[2]) begin
next_grant = grant2;
hold_flag_o = `HoldEnable;
end else begin
next_grant = grant1;
hold_flag_o = `HoldDisable;
end
end
default: begin
next_grant = grant1;
hold_flag_o = `HoldDisable;
end
endcase
end
end
// (访)
// (访)
always @ (*) begin
if (rst == `RstEnable) begin
m0_ack_o = `RIB_NACK;