Line 54... |
Line 54... |
//
|
//
|
module wbm2axisp #(
|
module wbm2axisp #(
|
parameter C_AXI_ID_WIDTH = 6, // The AXI id width used for R&W
|
parameter C_AXI_ID_WIDTH = 6, // The AXI id width used for R&W
|
// This is an int between 1-16
|
// This is an int between 1-16
|
parameter C_AXI_DATA_WIDTH = 128,// Width of the AXI R&W data
|
parameter C_AXI_DATA_WIDTH = 128,// Width of the AXI R&W data
|
parameter AW = 28, // Wishbone address width
|
parameter C_AXI_ADDR_WIDTH = 28, // AXI Address width
|
parameter DW = 128, // Wishbone data width
|
parameter DW = 32, // Wishbone data width
|
|
parameter AW = 26, // Wishbone address width
|
parameter STRICT_ORDER = 0 // Reorder, or not? 0 -> Reorder
|
parameter STRICT_ORDER = 0 // Reorder, or not? 0 -> Reorder
|
) (
|
) (
|
input i_clk, // System clock
|
input i_clk, // System clock
|
input i_reset,// Wishbone reset signal
|
// input i_reset,// Wishbone reset signal--unused
|
|
|
// AXI write address channel signals
|
// AXI write address channel signals
|
input i_axi_awready, // Slave is ready to accept
|
input i_axi_awready, // Slave is ready to accept
|
output wire [C_AXI_ID_WIDTH-1:0] o_axi_awid, // Write ID
|
output reg [C_AXI_ID_WIDTH-1:0] o_axi_awid, // Write ID
|
output reg [AW-1:0] o_axi_awaddr, // Write address
|
output reg [C_AXI_ADDR_WIDTH-1:0] o_axi_awaddr, // Write address
|
output wire [7:0] o_axi_awlen, // Write Burst Length
|
output wire [7:0] o_axi_awlen, // Write Burst Length
|
output wire [2:0] o_axi_awsize, // Write Burst size
|
output wire [2:0] o_axi_awsize, // Write Burst size
|
output wire [1:0] o_axi_awburst, // Write Burst type
|
output wire [1:0] o_axi_awburst, // Write Burst type
|
output wire [1:0] o_axi_awlock, // Write lock type
|
output wire [0:0] o_axi_awlock, // Write lock type
|
output wire [3:0] o_axi_awcache, // Write Cache type
|
output wire [3:0] o_axi_awcache, // Write Cache type
|
output wire [2:0] o_axi_awprot, // Write Protection type
|
output wire [2:0] o_axi_awprot, // Write Protection type
|
output wire [3:0] o_axi_awqos, // Write Quality of Svc
|
output wire [3:0] o_axi_awqos, // Write Quality of Svc
|
output reg o_axi_awvalid, // Write address valid
|
output reg o_axi_awvalid, // Write address valid
|
|
|
Line 90... |
Line 91... |
output wire o_axi_bready, // Response ready
|
output wire o_axi_bready, // Response ready
|
|
|
// AXI read address channel signals
|
// AXI read address channel signals
|
input i_axi_arready, // Read address ready
|
input i_axi_arready, // Read address ready
|
output wire [C_AXI_ID_WIDTH-1:0] o_axi_arid, // Read ID
|
output wire [C_AXI_ID_WIDTH-1:0] o_axi_arid, // Read ID
|
output wire [AW-1:0] o_axi_araddr, // Read address
|
output wire [C_AXI_ADDR_WIDTH-1:0] o_axi_araddr, // Read address
|
output wire [7:0] o_axi_arlen, // Read Burst Length
|
output wire [7:0] o_axi_arlen, // Read Burst Length
|
output wire [2:0] o_axi_arsize, // Read Burst size
|
output wire [2:0] o_axi_arsize, // Read Burst size
|
output wire [1:0] o_axi_arburst, // Read Burst type
|
output wire [1:0] o_axi_arburst, // Read Burst type
|
output wire [1:0] o_axi_arlock, // Read lock type
|
output wire [0:0] o_axi_arlock, // Read lock type
|
output wire [3:0] o_axi_arcache, // Read Cache type
|
output wire [3:0] o_axi_arcache, // Read Cache type
|
output wire [2:0] o_axi_arprot, // Read Protection type
|
output wire [2:0] o_axi_arprot, // Read Protection type
|
output wire [3:0] o_axi_arqos, // Read Protection type
|
output wire [3:0] o_axi_arqos, // Read Protection type
|
output reg o_axi_arvalid, // Read address valid
|
output reg o_axi_arvalid, // Read address valid
|
|
|
Line 112... |
Line 113... |
|
|
// We'll share the clock and the reset
|
// We'll share the clock and the reset
|
input i_wb_cyc,
|
input i_wb_cyc,
|
input i_wb_stb,
|
input i_wb_stb,
|
input i_wb_we,
|
input i_wb_we,
|
input [AW-1:0] i_wb_addr,
|
input [(AW-1):0] i_wb_addr,
|
input [DW-1:0] i_wb_data,
|
input [(DW-1):0] i_wb_data,
|
input [(DW/8-1):0] i_wb_sel,
|
input [(DW/8-1):0] i_wb_sel,
|
output reg o_wb_ack,
|
output reg o_wb_ack,
|
output wire o_wb_stall,
|
output wire o_wb_stall,
|
output reg [DW-1:0] o_wb_data,
|
output reg [(DW-1):0] o_wb_data,
|
output reg o_wb_err
|
output reg o_wb_err
|
);
|
);
|
|
|
//*****************************************************************************
|
//*****************************************************************************
|
// Parameter declarations
|
// Parameter declarations
|
Line 133... |
Line 134... |
|
|
//*****************************************************************************
|
//*****************************************************************************
|
// Internal register and wire declarations
|
// Internal register and wire declarations
|
//*****************************************************************************
|
//*****************************************************************************
|
|
|
wire cmd_en;
|
|
wire [2:0] cmd;
|
|
wire [7:0] blen;
|
|
wire [31:0] addr;
|
|
wire [CTL_SIG_WIDTH-1:0] ctl;
|
|
wire cmd_ack;
|
|
|
|
// User interface write ports
|
|
wire wrdata_vld;
|
|
wire [C_AXI_DATA_WIDTH-1:0] wrdata;
|
|
wire [C_AXI_DATA_WIDTH/8-1:0] wrdata_bvld;
|
|
wire wrdata_cmptd;
|
|
wire wrdata_rdy;
|
|
wire wrdata_sts_vld;
|
|
wire [WR_STS_WIDTH-1:0] wrdata_sts;
|
|
|
|
// User interface read ports
|
|
wire rddata_rdy;
|
|
wire rddata_vld;
|
|
wire [C_AXI_DATA_WIDTH-1:0] rddata;
|
|
wire [C_AXI_DATA_WIDTH/8-1:0] rddata_bvld;
|
|
wire rddata_cmptd;
|
|
wire [RD_STS_WIDTH-1:0] rddata_sts;
|
|
reg cmptd_one_wr;
|
|
reg cmptd_one_rd;
|
|
|
|
|
|
// Things we're not changing ...
|
// Things we're not changing ...
|
assign o_axi_awlen = 8'h0; // Burst length is one
|
assign o_axi_awlen = 8'h0; // Burst length is one
|
assign o_axi_awsize = 3'b101; // maximum bytes per burst is 32
|
assign o_axi_awsize = 3'b101; // maximum bytes per burst is 32
|
assign o_axi_awburst = 2'b01; // Incrementing address (ignored)
|
assign o_axi_awburst = 2'b01; // Incrementing address (ignored)
|
assign o_axi_arburst = 2'b01; // Incrementing address (ignored)
|
assign o_axi_arburst = 2'b01; // Incrementing address (ignored)
|
assign o_axi_awlock = 2'b00; // Normal signaling
|
assign o_axi_awlock = 1'b0; // Normal signaling
|
assign o_axi_arlock = 2'b00; // Normal signaling
|
assign o_axi_arlock = 1'b0; // Normal signaling
|
assign o_axi_awcache = 4'h2; // Normal: no cache, no buffer
|
assign o_axi_awcache = 4'h2; // Normal: no cache, no buffer
|
assign o_axi_arcache = 4'h2; // Normal: no cache, no buffer
|
assign o_axi_arcache = 4'h2; // Normal: no cache, no buffer
|
assign o_axi_awprot = 3'h010; // Unpriviledged, unsecure, data access
|
assign o_axi_awprot = 3'b010; // Unpriviledged, unsecure, data access
|
assign o_axi_arprot = 3'h010; // Unpriviledged, unsecure, data access
|
assign o_axi_arprot = 3'b010; // Unpriviledged, unsecure, data access
|
assign o_axi_awqos = 4'h0; // Lowest quality of service (unused)
|
assign o_axi_awqos = 4'h0; // Lowest quality of service (unused)
|
assign o_axi_arqos = 4'h0; // Lowest quality of service (unused)
|
assign o_axi_arqos = 4'h0; // Lowest quality of service (unused)
|
|
|
// Command logic
|
// Command logic
|
// Write address logic
|
// Write address logic
|
|
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|
o_axi_awvalid <= (!o_wb_stall)&&(i_wb_stb)&&(i_wb_we)
|
o_axi_awvalid <= (!o_wb_stall)&&(i_wb_stb)&&(i_wb_we)
|
||(o_wb_stall)&&(o_axi_awvalid)&&(!i_axi_awready);
|
||(o_wb_stall)&&(o_axi_awvalid)&&(!i_axi_awready);
|
|
|
|
generate
|
|
if (DW == 32)
|
|
begin
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|
if (!o_wb_stall)
|
if (!o_wb_stall) // 26 bit address becomes 28 bit ...
|
o_axi_awaddr <= { i_wb_addr[AW-1:2], 2'b00 }; // 28 bits
|
o_axi_awaddr <= { i_wb_addr[AW-1:2], 4'b00 };
|
|
end else if (DW == 128)
|
|
begin
|
|
always @(posedge i_clk)
|
|
if (!o_wb_stall) // 28 bit address ...
|
|
o_axi_awaddr <= { i_wb_addr[AW-1:0], 4'b00 };
|
|
end endgenerate
|
|
|
reg [5:0] transaction_id;
|
reg [5:0] transaction_id;
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|
if (!i_wb_cyc)
|
if (!i_wb_cyc)
|
transaction_id <= 6'h00;
|
transaction_id <= 6'h00;
|
else if ((i_wb_stb)&&(~o_wb_stall))
|
else if ((i_wb_stb)&&(~o_wb_stall))
|
transaction_id <= transaction_id + 6'h01;
|
transaction_id <= transaction_id + 6'h01;
|
assign o_axi_awid = transaction_id;
|
always @(posedge i_clk)
|
|
if ((i_wb_stb)&&(~o_wb_stall))
|
|
o_axi_awid <= transaction_id;
|
|
|
// Read address logic
|
// Read address logic
|
assign o_axi_arid = transaction_id;
|
assign o_axi_arid = o_axi_awid;
|
assign o_axi_araddr = o_axi_awaddr;
|
assign o_axi_araddr = o_axi_awaddr;
|
assign o_axi_arlen = o_axi_awlen;
|
assign o_axi_arlen = o_axi_awlen;
|
assign o_axi_arsize = 3'b101; // maximum bytes per burst is 32
|
assign o_axi_arsize = 3'b101; // maximum bytes per burst is 32
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|
o_axi_arvalid <= (!o_wb_stall)&&(i_wb_stb)&&(!i_wb_we)
|
o_axi_arvalid <= (!o_wb_stall)&&(i_wb_stb)&&(!i_wb_we)
|
Line 250... |
Line 236... |
reg [(LGFIFOLN-1):0] fifo_tail;
|
reg [(LGFIFOLN-1):0] fifo_tail;
|
reg [(C_AXI_DATA_WIDTH-1):0] reorder_fifo_data [0:(FIFOLN-1)];
|
reg [(C_AXI_DATA_WIDTH-1):0] reorder_fifo_data [0:(FIFOLN-1)];
|
reg [(FIFOLN-1):0] reorder_fifo_valid;
|
reg [(FIFOLN-1):0] reorder_fifo_valid;
|
reg [(FIFOLN-1):0] reorder_fifo_err;
|
reg [(FIFOLN-1):0] reorder_fifo_err;
|
|
|
|
initial reorder_fifo_valid = 0;
|
|
initial reorder_fifo_err = 0;
|
|
|
if (DW == 32)
|
if (DW == 32)
|
begin
|
begin
|
reg [1:0] reorder_fifo_addr [0:(FIFOLN-1)];
|
reg [1:0] reorder_fifo_addr [0:(FIFOLN-1)];
|
|
|
|
|
Line 264... |
Line 253... |
always @(posedge i_clk)
|
always @(posedge i_clk)
|
if ((o_axi_arvalid)&&(i_axi_arready))
|
if ((o_axi_arvalid)&&(i_axi_arready))
|
reorder_fifo_addr[o_axi_arid] <= low_addr;
|
reorder_fifo_addr[o_axi_arid] <= low_addr;
|
|
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|
case(reorder_fifo_addr[1:0])
|
case(reorder_fifo_addr[fifo_tail][1:0])
|
2'b00: o_wb_data <=reorder_fifo_data[fifo_tail][ 31: 0];
|
2'b00: o_wb_data <=reorder_fifo_data[fifo_tail][ 31: 0];
|
2'b01: o_wb_data <=reorder_fifo_data[fifo_tail][ 63:32];
|
2'b01: o_wb_data <=reorder_fifo_data[fifo_tail][ 63:32];
|
2'b10: o_wb_data <=reorder_fifo_data[fifo_tail][ 95:64];
|
2'b10: o_wb_data <=reorder_fifo_data[fifo_tail][ 95:64];
|
2'b11: o_wb_data <=reorder_fifo_data[fifo_tail][127:96];
|
2'b11: o_wb_data <=reorder_fifo_data[fifo_tail][127:96];
|
endcase
|
endcase
|
Line 287... |
Line 276... |
// point to next, but let's also insist that it be LGFIFOLN
|
// point to next, but let's also insist that it be LGFIFOLN
|
// bits in size as well. This'll be part of the fifo_full
|
// bits in size as well. This'll be part of the fifo_full
|
// calculation below.
|
// calculation below.
|
wire [(LGFIFOLN-1):0] n_fifo_head, nn_fifo_head;
|
wire [(LGFIFOLN-1):0] n_fifo_head, nn_fifo_head;
|
assign n_fifo_head = fifo_head+1'b1;
|
assign n_fifo_head = fifo_head+1'b1;
|
|
assign nn_fifo_head = { fifo_head[(LGFIFOLN-1):1]+1'b1, fifo_head[0] };
|
|
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|
begin
|
begin
|
if ((i_axi_rvalid)&&(o_axi_rready))
|
if ((i_axi_rvalid)&&(o_axi_rready))
|
reorder_fifo_data[i_axi_rid]<= i_axi_rdata;
|
reorder_fifo_data[i_axi_rid]<= i_axi_rdata;
|
Line 342... |
Line 332... |
else
|
else
|
r_fifo_full <= (fifo_tail==n_fifo_head);
|
r_fifo_full <= (fifo_tail==n_fifo_head);
|
end
|
end
|
assign w_fifo_full = r_fifo_full;
|
assign w_fifo_full = r_fifo_full;
|
end else begin
|
end else begin
|
|
//
|
|
// Strict ordering, but can only read every fourth addresses
|
|
//
|
assign w_fifo_full = 1'b0;
|
assign w_fifo_full = 1'b0;
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|
o_wb_data <= i_axi_rdata;
|
o_wb_data <= i_axi_rdata[31:0];
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|
o_wb_ack <= ((i_axi_rvalid)&&(o_axi_rready))
|
o_wb_ack <= (i_wb_cyc)&&(
|
||((i_axi_bvalid)&&(o_axi_bready));
|
((i_axi_rvalid)&&(o_axi_rready))
|
|
||((i_axi_bvalid)&&(o_axi_bready)));
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|
o_wb_err <= (!i_wb_cyc)&&((o_wb_err)
|
o_wb_err <= (i_wb_cyc)&&((o_wb_err)
|
||((i_axi_rvalid)&&(i_axi_rresp[1]))
|
||((i_axi_rvalid)&&(i_axi_rresp[1]))
|
||((i_axi_bvalid)&&(i_axi_bresp[1])));
|
||((i_axi_bvalid)&&(i_axi_bresp[1])));
|
end endgenerate
|
end endgenerate
|
|
|
|
|