/////////////////////////////////////////////////////////////////////
|
<##//////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// 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_axi2ahb.txt
|
INCLUDE def_axi2ahb.txt
|
OUTFILE PREFIX_wr_fifo.v
|
OUTFILE PREFIX_wr_fifo.v
|
|
|
module PREFIX_wr_fifo (PORTS);
|
module PREFIX_wr_fifo (PORTS);
|
|
|
parameter FIFO_LINES = EXPR(2 * 16); //double buffer of max burst
|
parameter FIFO_LINES = EXPR(2 * 16); //double buffer of max burst
|
parameter RESP_SLVERR = 2'b10;
|
parameter RESP_SLVERR = 2'b10;
|
|
|
input clk;
|
input clk;
|
input reset;
|
input reset;
|
|
|
port WGROUP_AXI_W;
|
port WGROUP_AXI_W;
|
port BGROUP_AXI_B;
|
port BGROUP_AXI_B;
|
output [DATA_BITS-1:0] HWDATA;
|
output [DATA_BITS-1:0] HWDATA;
|
input HREADY;
|
input HREADY;
|
input [1:0] HTRANS;
|
input [1:0] HTRANS;
|
input HRESP;
|
input HRESP;
|
|
|
input cmd_err;
|
input cmd_err;
|
input wdata_phase;
|
input wdata_phase;
|
output wdata_ready;
|
output wdata_ready;
|
input data_last;
|
input data_last;
|
|
|
|
|
wire data_push;
|
wire data_push;
|
wire data_pop;
|
wire data_pop;
|
wire data_empty;
|
wire data_empty;
|
wire data_full;
|
wire data_full;
|
|
|
wire resp_push;
|
wire resp_push;
|
wire resp_pop;
|
wire resp_pop;
|
wire resp_empty;
|
wire resp_empty;
|
wire resp_full;
|
wire resp_full;
|
|
|
reg [LOG2(CMD_DEPTH):0] burst_cnt;
|
reg [LOG2(CMD_DEPTH):0] burst_cnt;
|
wire burst_full;
|
wire burst_full;
|
|
|
wire axi_last;
|
wire axi_last;
|
wire ahb_last;
|
wire ahb_last;
|
wire [1:0] cmd_resp;
|
wire [1:0] cmd_resp;
|
|
|
assign cmd_resp = cmd_err | HRESP ? RESP_SLVERR : 2'b00;
|
assign cmd_resp = cmd_err | HRESP ? RESP_SLVERR : 2'b00;
|
|
|
assign wdata_ready = burst_cnt > 'd0;
|
assign wdata_ready = burst_cnt > 'd0;
|
|
|
assign WREADY = (~data_full) & (~burst_full);
|
assign WREADY = (~data_full) & (~burst_full);
|
|
|
|
|
assign data_push = WVALID & WREADY;
|
assign data_push = WVALID & WREADY;
|
assign data_pop = wdata_phase & HREADY;
|
assign data_pop = wdata_phase & HREADY;
|
|
|
assign axi_last = WVALID & WREADY & WLAST;
|
assign axi_last = WVALID & WREADY & WLAST;
|
assign ahb_last = wdata_phase & data_last;
|
assign ahb_last = wdata_phase & data_last;
|
|
|
assign burst_full = burst_cnt == {EXPR(LOG2(CMD_DEPTH)+1){1'b1}};
|
assign burst_full = burst_cnt == {EXPR(LOG2(CMD_DEPTH)+1){1'b1}};
|
|
|
always @(posedge clk or posedge reset)
|
always @(posedge clk or posedge reset)
|
if (reset)
|
if (reset)
|
burst_cnt <= #FFD 'd0;
|
burst_cnt <= #FFD 'd0;
|
else if (axi_last | ahb_last)
|
else if (axi_last | ahb_last)
|
burst_cnt <= #FFD burst_cnt + axi_last - ahb_last;
|
burst_cnt <= #FFD burst_cnt + axi_last - ahb_last;
|
|
|
prgen_fifo #(DATA_BITS, FIFO_LINES)
|
prgen_fifo #(DATA_BITS, FIFO_LINES)
|
data_fifo(
|
data_fifo(
|
.clk(clk),
|
.clk(clk),
|
.reset(reset),
|
.reset(reset),
|
.push(data_push),
|
.push(data_push),
|
.pop(data_pop),
|
.pop(data_pop),
|
.din({WDATA
|
.din({WDATA
|
}
|
}
|
),
|
),
|
.dout({HWDATA
|
.dout({HWDATA
|
}
|
}
|
),
|
),
|
.empty(data_empty),
|
.empty(data_empty),
|
.full(data_full)
|
.full(data_full)
|
);
|
);
|
|
|
|
|
assign resp_push = ahb_last;
|
assign resp_push = ahb_last;
|
assign resp_pop = BVALID & BREADY;
|
assign resp_pop = BVALID & BREADY;
|
|
|
assign BVALID = (~resp_empty);
|
assign BVALID = (~resp_empty);
|
|
|
prgen_fifo #(2+ID_BITS, CMD_DEPTH)
|
prgen_fifo #(2+ID_BITS, CMD_DEPTH)
|
resp_fifo(
|
resp_fifo(
|
.clk(clk),
|
.clk(clk),
|
.reset(reset),
|
.reset(reset),
|
.push(resp_push),
|
.push(resp_push),
|
.pop(resp_pop),
|
.pop(resp_pop),
|
.din({cmd_resp,
|
.din({cmd_resp,
|
WID
|
WID
|
}
|
}
|
),
|
),
|
.dout({BRESP,
|
.dout({BRESP,
|
BID
|
BID
|
}
|
}
|
),
|
),
|
.empty(resp_empty),
|
.empty(resp_empty),
|
.full(resp_full)
|
.full(resp_full)
|
);
|
);
|
|
|
|
|
|
|
endmodule
|
endmodule
|
|
|
|
|
|
|