<##//////////////////////////////////////////////////////////////////
|
<##//////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// 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 ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////##>
|
//////////////////////////////////////////////////////////////////##>
|
|
|
INCLUDE def_axi2apb.txt
|
INCLUDE def_axi2apb.txt
|
OUTFILE PREFIX_mux.v
|
OUTFILE PREFIX_mux.v
|
|
|
ITER SX
|
ITER SX
|
module PREFIX_mux (PORTS);
|
module PREFIX_mux (PORTS);
|
|
|
|
|
input clk;
|
input clk;
|
input reset;
|
input reset;
|
|
|
input [ADDR_BITS-1:0] cmd_addr;
|
input [ADDR_BITS-1:0] cmd_addr;
|
|
|
input psel;
|
input psel;
|
output [31:0] prdata;
|
output [31:0] prdata;
|
output pready;
|
output pready;
|
output pslverr;
|
output pslverr;
|
|
|
output pselSX;
|
output pselSX;
|
|
|
input preadySX;
|
input preadySX;
|
|
|
input pslverrSX;
|
input pslverrSX;
|
|
|
input [31:0] prdataSX;
|
input [31:0] prdataSX;
|
|
|
|
|
|
|
parameter ADDR_MSB = EXPR(ADDR_BITS-1);
|
parameter ADDR_MSB = EXPR(ADDR_BITS-1);
|
parameter ADDR_LSB = EXPR(ADDR_BITS-DEC_BITS);
|
parameter ADDR_LSB = EXPR(ADDR_BITS-DEC_BITS);
|
|
|
reg pready;
|
reg pready;
|
reg pslverr_pre;
|
reg pslverr_pre;
|
reg pslverr;
|
reg pslverr;
|
reg [31:0] prdata_pre;
|
reg [31:0] prdata_pre;
|
reg [31:0] prdata;
|
reg [31:0] prdata;
|
|
|
reg [SLV_BITS-1:0] slave_num;
|
reg [SLV_BITS-1:0] slave_num;
|
|
|
always @(*)
|
always @(*)
|
begin
|
begin
|
casex (cmd_addr[ADDR_MSB:ADDR_LSB])
|
casex (cmd_addr[ADDR_MSB:ADDR_LSB])
|
DEC_BITSDEC_ADDRSX : slave_num = SLV_BITS'dSX;
|
DEC_BITSDEC_ADDRSX : slave_num = SLV_BITS'dSX;
|
|
|
default : slave_num = SLV_BITS'dSLAVE_NUM; //decode error
|
default : slave_num = SLV_BITS'dSLAVE_NUM; //decode error
|
endcase
|
endcase
|
end
|
end
|
|
|
assign pselSX = psel & (slave_num == SLV_BITS'dSX);
|
assign pselSX = psel & (slave_num == SLV_BITS'dSX);
|
|
|
always @(*)
|
always @(*)
|
begin
|
begin
|
case (slave_num)
|
case (slave_num)
|
SLV_BITS'dSX: pready = preadySX;
|
SLV_BITS'dSX: pready = preadySX;
|
default : pready = 1'b1; //decode error
|
default : pready = 1'b1; //decode error
|
endcase
|
endcase
|
end
|
end
|
|
|
always @(*)
|
always @(*)
|
begin
|
begin
|
case (slave_num)
|
case (slave_num)
|
SLV_BITS'dSX: pslverr_pre = pslverrSX;
|
SLV_BITS'dSX: pslverr_pre = pslverrSX;
|
default : pslverr_pre = 1'b1; //decode error
|
default : pslverr_pre = 1'b1; //decode error
|
endcase
|
endcase
|
end
|
end
|
|
|
always @(*)
|
always @(*)
|
begin
|
begin
|
case (slave_num)
|
case (slave_num)
|
SLV_BITS'dSX: prdata_pre = prdataSX;
|
SLV_BITS'dSX: prdata_pre = prdataSX;
|
default : prdata_pre = {32{1'b0}};
|
default : prdata_pre = {32{1'b0}};
|
endcase
|
endcase
|
end
|
end
|
|
|
|
|
always @(posedge clk or posedge reset)
|
always @(posedge clk or posedge reset)
|
if (reset)
|
if (reset)
|
begin
|
begin
|
prdata <= #FFD {32{1'b0}};
|
prdata <= #FFD {32{1'b0}};
|
pslverr <= #FFD 1'b0;
|
pslverr <= #FFD 1'b0;
|
end
|
end
|
else if (psel & pready)
|
else if (psel & pready)
|
begin
|
begin
|
prdata <= #FFD prdata_pre;
|
prdata <= #FFD prdata_pre;
|
pslverr <= #FFD pslverr_pre;
|
pslverr <= #FFD pslverr_pre;
|
end
|
end
|
else if (~psel)
|
else if (~psel)
|
begin
|
begin
|
prdata <= #FFD {32{1'b0}};
|
prdata <= #FFD {32{1'b0}};
|
pslverr <= #FFD 1'b0;
|
pslverr <= #FFD 1'b0;
|
end
|
end
|
|
|
endmodule
|
endmodule
|
|
|
|
|
|
|