<##//////////////////////////////////////////////////////////////////
|
<##//////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// Author: Eyal Hochberg ////
|
//// Author: Eyal Hochberg ////
|
//// eyal@provartec.com ////
|
//// eyal@provartec.com ////
|
//// ////
|
//// ////
|
//// Downloaded from: http://www.opencores.org ////
|
//// Downloaded from: http://www.opencores.org ////
|
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// Copyright (C) 2010 Provartec LTD ////
|
//// Copyright (C) 2010 Provartec LTD ////
|
//// www.provartec.com ////
|
//// www.provartec.com ////
|
//// info@provartec.com ////
|
//// info@provartec.com ////
|
//// ////
|
//// ////
|
//// This source file may be used and distributed without ////
|
//// This source file may be used and distributed without ////
|
//// restriction provided that this copyright statement is not ////
|
//// restriction provided that this copyright statement is not ////
|
//// removed from the file and that any derivative work contains ////
|
//// removed from the file and that any derivative work contains ////
|
//// the original copyright notice and the associated disclaimer.////
|
//// the original copyright notice and the associated disclaimer.////
|
//// ////
|
//// ////
|
//// This source file is free software; you can redistribute it ////
|
//// This source file is free software; you can redistribute it ////
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
//// Public License as published by the Free Software Foundation.////
|
//// Public License as published by the Free Software Foundation.////
|
//// ////
|
//// ////
|
//// This source is distributed in the hope that it will be ////
|
//// This source is distributed in the hope that it will be ////
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
//// PURPOSE. See the GNU Lesser General Public License for more////
|
//// PURPOSE. See the GNU Lesser General Public License for more////
|
//// details. http://www.gnu.org/licenses/lgpl.html ////
|
//// details. http://www.gnu.org/licenses/lgpl.html ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////##>
|
//////////////////////////////////////////////////////////////////##>
|
|
|
OUTFILE PREFIX_ic_MSTR_SLV_arbiter.v
|
OUTFILE PREFIX_ic_MSTR_SLV_arbiter.v
|
|
|
ITER MX MSTRNUM
|
ITER MX MSTRNUM
|
ITER SX SLVNUM
|
ITER SX SLVNUM
|
|
|
module PREFIX_ic_MSTR_SLV_arbiter(PORTS);
|
module PREFIX_ic_MSTR_SLV_arbiter(PORTS);
|
|
|
input clk;
|
input clk;
|
input reset;
|
input reset;
|
|
|
input [MSTRNUM-1:0] M_last;
|
input [MSTRNUM-1:0] M_last;
|
input [MSTRNUM-1:0] M_req;
|
input [MSTRNUM-1:0] M_req;
|
input [MSTRNUM-1:0] M_grant;
|
input [MSTRNUM-1:0] M_grant;
|
|
|
input [LOG2(SLVNUM)-1:0] MMX_slave;
|
input [LOG2(SLVNUM)-1:0] MMX_slave;
|
|
|
output [MSTRNUM-1:0] SSX_master;
|
output [MSTRNUM-1:0] SSX_master;
|
|
|
|
|
|
|
reg [MSTRNUM:0] SSX_master_prio_reg;
|
reg [MSTRNUM:0] SSX_master_prio_reg;
|
wire [MSTRNUM-1:0] SSX_master_prio;
|
wire [MSTRNUM-1:0] SSX_master_prio;
|
reg [MSTRNUM-1:0] SSX_master_d;
|
reg [MSTRNUM-1:0] SSX_master_d;
|
|
|
wire [MSTRNUM-1:0] M_SSX;
|
wire [MSTRNUM-1:0] M_SSX;
|
wire [MSTRNUM-1:0] M_SSX_valid;
|
wire [MSTRNUM-1:0] M_SSX_valid;
|
wire [MSTRNUM-1:0] M_SSX_prio;
|
wire [MSTRNUM-1:0] M_SSX_prio;
|
reg [MSTRNUM-1:0] M_SSX_burst;
|
reg [MSTRNUM-1:0] M_SSX_burst;
|
|
|
|
|
|
|
|
|
parameter MASTER_NONE = BIN(0 MSTRNUM);
|
parameter MASTER_NONE = BIN(0 MSTRNUM);
|
parameter MASTERMX = BIN(EXPR(2^MX) MSTRNUM);
|
parameter MASTERMX = BIN(EXPR(2^MX) MSTRNUM);
|
|
|
|
|
|
|
|
|
IFDEF DEF_PRIO
|
IFDEF DEF_PRIO
|
always @(posedge clk or posedge reset)
|
always @(posedge clk or posedge reset)
|
if (reset)
|
if (reset)
|
begin
|
begin
|
SSX_master_prio_reg[MSTRNUM:1] <= #FFD {MSTRNUM{1'b0}};
|
SSX_master_prio_reg[MSTRNUM:1] <= #FFD {MSTRNUM{1'b0}};
|
SSX_master_prio_reg[0] <= #FFD 1'b1;
|
SSX_master_prio_reg[0] <= #FFD 1'b1;
|
end
|
end
|
else if (|(M_req & M_grant & M_last))
|
else if (|(M_req & M_grant & M_last))
|
begin
|
begin
|
SSX_master_prio_reg[MSTRNUM:1] <= #FFD SSX_master_prio_reg[MSTRNUM-1:0];
|
SSX_master_prio_reg[MSTRNUM:1] <= #FFD SSX_master_prio_reg[MSTRNUM-1:0];
|
SSX_master_prio_reg[0] <= #FFD SSX_master_prio_reg[MSTRNUM-1];
|
SSX_master_prio_reg[0] <= #FFD SSX_master_prio_reg[MSTRNUM-1];
|
end
|
end
|
|
|
assign SSX_master_prio = SSX_master_prio_reg[MSTRNUM-1:0];
|
assign SSX_master_prio = SSX_master_prio_reg[MSTRNUM-1:0];
|
|
|
assign M_SSX_prio = M_SSX_valid & SSX_master_prio;
|
assign M_SSX_prio = M_SSX_valid & SSX_master_prio;
|
ENDIF DEF_PRIO
|
ENDIF DEF_PRIO
|
|
|
|
|
|
|
always @(posedge clk or posedge reset)
|
always @(posedge clk or posedge reset)
|
if (reset)
|
if (reset)
|
begin
|
begin
|
SSX_master_d <= #FFD {MSTRNUM{1'b0}};
|
SSX_master_d <= #FFD {MSTRNUM{1'b0}};
|
end
|
end
|
else
|
else
|
begin
|
begin
|
SSX_master_d <= #FFD SSX_master;
|
SSX_master_d <= #FFD SSX_master;
|
end
|
end
|
|
|
LOOP MX MSTRNUM
|
LOOP MX MSTRNUM
|
always @(posedge clk or posedge reset)
|
always @(posedge clk or posedge reset)
|
if (reset)
|
if (reset)
|
begin
|
begin
|
M_SSX_burst[MX] <= #FFD 1'b0;
|
M_SSX_burst[MX] <= #FFD 1'b0;
|
end
|
end
|
else if (M_req[MX])
|
else if (M_req[MX])
|
begin
|
begin
|
M_SSX_burst[MX] <= #FFD SSX_master[MX] & (M_grant[MX] ? (~M_last[MX]) : 1'b1);
|
M_SSX_burst[MX] <= #FFD SSX_master[MX] & (M_grant[MX] ? (~M_last[MX]) : 1'b1);
|
end
|
end
|
|
|
ENDLOOP MX
|
ENDLOOP MX
|
|
|
assign M_SSX = {CONCAT(MMX_slave == 'dSX ,)};
|
assign M_SSX = {CONCAT(MMX_slave == 'dSX ,)};
|
|
|
assign M_SSX_valid = M_SSX & M_req;
|
assign M_SSX_valid = M_SSX & M_req;
|
|
|
|
|
LOOP SX SLVNUM
|
LOOP SX SLVNUM
|
assign SSX_master =
|
assign SSX_master =
|
M_SSX_burst[MX] ? SSX_master_d :
|
M_SSX_burst[MX] ? SSX_master_d :
|
IF DEF_PRIO M_SSX_prio[MX] ? MASTERMX :
|
IF DEF_PRIO M_SSX_prio[MX] ? MASTERMX :
|
M_SSX_valid[MX] ? MASTERMX :
|
M_SSX_valid[MX] ? MASTERMX :
|
MASTER_NONE;
|
MASTER_NONE;
|
|
|
ENDLOOP SX
|
ENDLOOP SX
|
|
|
endmodule
|
endmodule
|
|
|
|
|