OpenCores
URL https://opencores.org/ocsvn/wb2axip/wb2axip/trunk

Subversion Repositories wb2axip

[/] [wb2axip/] [trunk/] [rtl/] [wbm2axisp.v] - Diff between revs 4 and 5

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 4 Rev 5
Line 62... Line 62...
        ) (
        ) (
        input                           i_clk,  // System clock
        input                           i_clk,  // System clock
        input                           i_reset,// Wishbone reset signal
        input                           i_reset,// Wishbone reset signal
 
 
// AXI write address channel signals
// AXI write address channel signals
        input                           i_axi_wready, // Slave is ready to accept
        input                           i_axi_awready, // Slave is ready to accept
        output  wire    [C_AXI_ID_WIDTH-1:0]     o_axi_wid,      // Write ID
        output  wire    [C_AXI_ID_WIDTH-1:0]     o_axi_awid,     // Write ID
        output  reg     [AW-1:0] o_axi_waddr,    // Write address
        output  reg     [AW-1:0] o_axi_awaddr,   // Write address
        output  wire    [7:0]            o_axi_wlen,     // Write Burst Length
        output  wire    [7:0]            o_axi_awlen,    // Write Burst Length
        output  wire    [2:0]            o_axi_wsize,    // Write Burst size
        output  wire    [2:0]            o_axi_awsize,   // Write Burst size
        output  wire    [1:0]            o_axi_wburst,   // Write Burst type
        output  wire    [1:0]            o_axi_awburst,  // Write Burst type
        output  wire    [1:0]            o_axi_wlock,    // Write lock type
        output  wire    [1:0]            o_axi_awlock,   // Write lock type
        output  wire    [3:0]            o_axi_wcache,   // Write Cache type
        output  wire    [3:0]            o_axi_awcache,  // Write Cache type
        output  wire    [2:0]            o_axi_wprot,    // Write Protection type
        output  wire    [2:0]            o_axi_awprot,   // Write Protection type
        output  reg                     o_axi_wvalid,   // Write address valid
        output  wire    [3:0]            o_axi_awqos,    // Write Quality of Svc
 
        output  reg                     o_axi_awvalid,  // Write address valid
 
 
// AXI write data channel signals
// AXI write data channel signals
        input                           i_axi_wd_wready,  // Write data ready
        input                           i_axi_wready,  // Write data ready
        output  wire    [C_AXI_ID_WIDTH-1:0]     o_axi_wd_wid,   // Write ID tag
        output  reg     [C_AXI_DATA_WIDTH-1:0]   o_axi_wdata,    // Write data
        output  reg     [C_AXI_DATA_WIDTH-1:0]   o_axi_wd_data,  // Write data
        output  reg     [C_AXI_DATA_WIDTH/8-1:0] o_axi_wstrb,    // Write strobes
        output  reg     [C_AXI_DATA_WIDTH/8-1:0] o_axi_wd_strb,  // Write strobes
        output  wire                    o_axi_wlast,    // Last write transaction   
        output  wire                    o_axi_wd_last,  // Last write transaction   
        output  reg                     o_axi_wvalid,   // Write valid
        output  reg                     o_axi_wd_valid, // Write valid
 
 
 
// AXI write response channel signals
// AXI write response channel signals
        input   [C_AXI_ID_WIDTH-1:0]     i_axi_wd_bid,   // Response ID
        input   [C_AXI_ID_WIDTH-1:0]     i_axi_bid,      // Response ID
        input   [1:0]                    i_axi_wd_bresp, // Write response
        input   [1:0]                    i_axi_bresp,    // Write response
        input                           i_axi_wd_bvalid,  // Write reponse valid
        input                           i_axi_bvalid,  // Write reponse valid
        output  wire                    o_axi_wd_bready,  // Response ready
        output  wire                    o_axi_bready,  // Response ready
 
 
// AXI read address channel signals
// AXI read address channel signals
        input                           i_axi_rready,   // Read address ready
        input                           i_axi_arready,  // Read address ready
        output  wire    [C_AXI_ID_WIDTH-1:0]     o_axi_rid,      // Read ID
        output  wire    [C_AXI_ID_WIDTH-1:0]     o_axi_arid,     // Read ID
        output  wire    [AW-1:0] o_axi_raddr,    // Read address
        output  wire    [AW-1:0] o_axi_araddr,   // Read address
        output  wire    [7:0]            o_axi_rlen,     // Read Burst Length
        output  wire    [7:0]            o_axi_arlen,    // Read Burst Length
        output  wire    [2:0]            o_axi_rsize,    // Read Burst size
        output  wire    [2:0]            o_axi_arsize,   // Read Burst size
        output  wire    [1:0]            o_axi_rburst,   // Read Burst type
        output  wire    [1:0]            o_axi_arburst,  // Read Burst type
        output  wire    [1:0]            o_axi_rlock,    // Read lock type
        output  wire    [1:0]            o_axi_arlock,   // Read lock type
        output  wire    [3:0]            o_axi_rcache,   // Read Cache type
        output  wire    [3:0]            o_axi_arcache,  // Read Cache type
        output  wire    [2:0]            o_axi_rprot,    // Read Protection type
        output  wire    [2:0]            o_axi_arprot,   // Read Protection type
        output  reg                     o_axi_rvalid,   // Read address valid
        output  wire    [3:0]            o_axi_arqos,    // Read Protection type
 
        output  reg                     o_axi_arvalid,  // Read address valid
 
 
// AXI read data channel signals   
// AXI read data channel signals   
        input   [C_AXI_ID_WIDTH-1:0]     i_axi_rd_bid,     // Response ID
        input   [C_AXI_ID_WIDTH-1:0]     i_axi_rid,     // Response ID
        input   [1:0]                    i_axi_rd_rresp,   // Read response
        input   [1:0]                    i_axi_rresp,   // Read response
        input                           i_axi_rd_rvalid,  // Read reponse valid
        input                           i_axi_rvalid,  // Read reponse valid
        input   [C_AXI_DATA_WIDTH-1:0]           i_axi_rd_data,    // Read data
        input   [C_AXI_DATA_WIDTH-1:0]   i_axi_rdata,    // Read data
        input                           i_axi_rd_last,    // Read last
        input                           i_axi_rlast,    // Read last
        output  wire                    o_axi_rd_rready,  // Read Response ready
        output  wire                    o_axi_rready,  // Read Response ready
 
 
        // 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,
Line 160... Line 161...
        reg                                     cmptd_one_wr;
        reg                                     cmptd_one_wr;
        reg                                     cmptd_one_rd;
        reg                                     cmptd_one_rd;
 
 
 
 
// Things we're not changing ...
// Things we're not changing ...
        assign o_axi_wlen = 8'h0;       // Burst length is one
        assign o_axi_awlen = 8'h0;      // Burst length is one
        assign o_axi_wsize = 3'b101;    // maximum bytes per burst is 32
        assign o_axi_awsize = 3'b101;   // maximum bytes per burst is 32
        assign o_axi_wburst = 2'b01;    // Incrementing address (ignored)
        assign o_axi_awburst = 2'b01;   // Incrementing address (ignored)
        assign o_axi_rburst = 2'b01;    // Incrementing address (ignored)
        assign o_axi_arburst = 2'b01;   // Incrementing address (ignored)
        assign o_axi_wlock  = 2'b00;    // Normal signaling
        assign o_axi_awlock  = 2'b00;   // Normal signaling
        assign o_axi_rlock  = 2'b00;    // Normal signaling
        assign o_axi_arlock  = 2'b00;   // Normal signaling
        assign o_axi_wcache = 4'h2;     // Normal: no cache, no buffer
        assign o_axi_awcache = 4'h2;    // Normal: no cache, no buffer
        assign o_axi_rcache = 4'h2;     // Normal: no cache, no buffer
        assign o_axi_arcache = 4'h2;    // Normal: no cache, no buffer
        assign o_axi_wprot  = 3'h010;   // Unpriviledged, unsecure, data access
        assign o_axi_awprot  = 3'h010;  // Unpriviledged, unsecure, data access
        assign o_axi_rprot  = 3'h010;   // Unpriviledged, unsecure, data access
        assign o_axi_arprot  = 3'h010;  // Unpriviledged, unsecure, data access
 
        assign o_axi_awqos  = 4'h0;     // Lowest quality of service (unused)
 
        assign o_axi_arqos  = 4'h0;     // Lowest quality of service (unused)
 
 
// Command logic
// Command logic
        assign  o_wb_stall = (i_wb_we)&&(~i_axi_wready)
 
                        ||(~i_wb_we)&&(!i_axi_rready);
 
// Write address logic
// Write address logic
 
 
        always @(posedge i_clk)
        always @(posedge i_clk)
                o_axi_wvalid <= (!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_wvalid)&&(!i_axi_wready);
                        ||(o_wb_stall)&&(o_axi_awvalid)&&(!i_axi_awready);
        always @(posedge i_clk)
        always @(posedge i_clk)
                if (!o_wb_stall)
                if (!o_wb_stall)
                        o_axi_waddr <= { i_wb_addr[AW-1:2], 2'b00 }; // 28 bits
                        o_axi_awaddr <= { i_wb_addr[AW-1:2], 2'b00 }; // 28 bits
 
 
        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_wid = transaction_id;
        assign  o_axi_awid = transaction_id;
 
 
// Read address logic
// Read address logic
        assign  o_axi_rid = transaction_id;
        assign  o_axi_arid = transaction_id;
        assign  o_axi_raddr = o_axi_waddr;
        assign  o_axi_araddr = o_axi_awaddr;
        assign  o_axi_rlen  = o_axi_wlen;
        assign  o_axi_arlen  = o_axi_awlen;
        assign  o_axi_rsize = 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_rvalid <= (!o_wb_stall)&&(i_wb_stb)&&(!i_wb_we)
                o_axi_arvalid <= (!o_wb_stall)&&(i_wb_stb)&&(!i_wb_we)
                        ||(o_wb_stall)&&(o_axi_rvalid)&&(!i_axi_rready);
                        ||(o_wb_stall)&&(o_axi_arvalid)&&(!i_axi_arready);
 
 
 
 
// Write data logic
// Write data logic
        assign  o_axi_wd_wid = transaction_id;
 
 
 
        generate
        generate
        if (DW == 32)
        if (DW == 32)
        begin
        begin
                always @(posedge i_clk)
                always @(posedge i_clk)
                        if (!o_wb_stall)
                        if (!o_wb_stall)
                                o_axi_wd_data <= { i_wb_data, i_wb_data, i_wb_data, i_wb_data };
                                o_axi_wdata <= { i_wb_data, i_wb_data, i_wb_data, i_wb_data };
                always @(posedge i_clk)
                always @(posedge i_clk)
                        if (!o_wb_stall)
                        if (!o_wb_stall)
                        case(i_wb_addr[1:0])
                        case(i_wb_addr[1:0])
                        2'b00:o_axi_wd_strb<={     4'h0,     4'h0,     4'h0, i_wb_sel };
                        2'b00:o_axi_wstrb<={     4'h0,     4'h0,     4'h0, i_wb_sel };
                        2'b01:o_axi_wd_strb<={     4'h0,     4'h0, i_wb_sel,     4'h0 };
                        2'b01:o_axi_wstrb<={     4'h0,     4'h0, i_wb_sel,     4'h0 };
                        2'b10:o_axi_wd_strb<={     4'h0, i_wb_sel,     4'h0,     4'h0 };
                        2'b10:o_axi_wstrb<={     4'h0, i_wb_sel,     4'h0,     4'h0 };
                        2'b11:o_axi_wd_strb<={ i_wb_sel,     4'h0,     4'h0,     4'h0 };
                        2'b11:o_axi_wstrb<={ i_wb_sel,     4'h0,     4'h0,     4'h0 };
                        endcase
                        endcase
        end else if (DW == 128)
        end else if (DW == 128)
        begin
        begin
                always @(posedge i_clk)
                always @(posedge i_clk)
                        if (!o_wb_stall)
                        if (!o_wb_stall)
                                o_axi_wd_data <= i_wb_data;
                                o_axi_wdata <= i_wb_data;
                always @(posedge i_clk)
                always @(posedge i_clk)
                        if (!o_wb_stall)
                        if (!o_wb_stall)
                                o_axi_wd_strb <= i_wb_sel;
                                o_axi_wstrb <= i_wb_sel;
        end endgenerate
        end endgenerate
 
 
        assign  o_axi_wd_last = 1'b1;
        assign  o_axi_wlast = 1'b1;
        always @(posedge i_clk)
        always @(posedge i_clk)
                o_axi_wd_valid <= ((!o_wb_stall)&&(i_wb_stb)&&(i_wb_we))
                o_axi_wvalid <= ((!o_wb_stall)&&(i_wb_stb)&&(i_wb_we))
                        ||(o_wb_stall)&&(o_axi_wd_valid)&&(!i_axi_wd_wready);
                        ||(o_wb_stall)&&(o_axi_wvalid)&&(!i_axi_wready);
 
 
// Read data channel / response logic
// Read data channel / response logic
        assign  o_axi_rd_rready = 1'b1;
        assign  o_axi_rready = 1'b1;
        assign  o_axi_wd_bready = 1'b1;
        assign  o_axi_bready = 1'b1;
 
 
        wire    w_fifo_full;
        wire    w_fifo_full;
        generate
        generate
        if (STRICT_ORDER == 0)
        if (STRICT_ORDER == 0)
        begin
        begin
Line 261... Line 260...
                        reg     [1:0]    low_addr;
                        reg     [1:0]    low_addr;
                        always @(posedge i_clk)
                        always @(posedge i_clk)
                                if ((i_wb_stb)&&(!o_wb_stall))
                                if ((i_wb_stb)&&(!o_wb_stall))
                                        low_addr <= i_wb_addr[1:0];
                                        low_addr <= i_wb_addr[1:0];
                        always @(posedge i_clk)
                        always @(posedge i_clk)
                                if ((o_axi_rvalid)&&(i_axi_rready))
                                if ((o_axi_arvalid)&&(i_axi_arready))
                                        reorder_fifo_addr[o_axi_rid] <= 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[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];
Line 291... Line 290...
                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;
 
 
                always @(posedge i_clk)
                always @(posedge i_clk)
                begin
                begin
                        if ((i_axi_rd_rvalid)&&(o_axi_rd_rready))
                        if ((i_axi_rvalid)&&(o_axi_rready))
                                reorder_fifo_data[i_axi_rd_bid]<= i_axi_rd_data;
                                reorder_fifo_data[i_axi_rid]<= i_axi_rdata;
                        if ((i_axi_rd_rvalid)&&(o_axi_rd_rready))
                        if ((i_axi_rvalid)&&(o_axi_rready))
                        begin
                        begin
                                reorder_fifo_valid[i_axi_rd_bid] <= 1'b1;
                                reorder_fifo_valid[i_axi_rid] <= 1'b1;
                                reorder_fifo_err[i_axi_rd_bid] <= i_axi_rd_rresp[1];
                                reorder_fifo_err[i_axi_rid] <= i_axi_rresp[1];
                        end
                        end
                        if ((i_axi_wd_bvalid)&&(o_axi_wd_bready))
                        if ((i_axi_bvalid)&&(o_axi_bready))
                        begin
                        begin
                                reorder_fifo_valid[i_axi_wd_bid] <= 1'b1;
                                reorder_fifo_valid[i_axi_bid] <= 1'b1;
                                reorder_fifo_err[i_axi_wd_bid] <= i_axi_wd_bresp[1];
                                reorder_fifo_err[i_axi_bid] <= i_axi_bresp[1];
                        end
                        end
 
 
                        if (reorder_fifo_valid[fifo_tail])
                        if (reorder_fifo_valid[fifo_tail])
                        begin
                        begin
                                o_wb_ack <= 1'b1;
                                o_wb_ack <= 1'b1;
Line 345... Line 344...
                end
                end
                assign w_fifo_full = r_fifo_full;
                assign w_fifo_full = r_fifo_full;
        end else begin
        end else begin
                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_rd_data;
                        o_wb_data <= i_axi_rdata;
                always @(posedge i_clk)
                always @(posedge i_clk)
                        o_wb_ack <= ((i_axi_rd_rvalid)&&(o_axi_rd_rready))
                        o_wb_ack <= ((i_axi_rvalid)&&(o_axi_rready))
                                  ||((i_axi_wd_bvalid)&&(o_axi_wd_bready));
                                  ||((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_rd_rvalid)&&(i_axi_rd_rresp[1]))
                                ||((i_axi_rvalid)&&(i_axi_rresp[1]))
                                ||((i_axi_wd_bvalid)&&(i_axi_wd_bresp[1])));
                                ||((i_axi_bvalid)&&(i_axi_bresp[1])));
        end endgenerate
        end endgenerate
 
 
 
 
        // Now, the difficult signal ... the stall signal
        // Now, the difficult signal ... the stall signal
        // Let's build for a single cycle input ... and only stall if something
        // Let's build for a single cycle input ... and only stall if something
        // outgoing is valid and nothing is ready.
        // outgoing is valid and nothing is ready.
        assign  o_wb_stall = (i_wb_cyc)&&(
        assign  o_wb_stall = (i_wb_cyc)&&(
                                (w_fifo_full)
                                (w_fifo_full)
 
                                ||((o_axi_awvalid)&&(!i_axi_awready))
                                ||((o_axi_wvalid)&&(!i_axi_wready))
                                ||((o_axi_wvalid)&&(!i_axi_wready))
                                ||((o_axi_wd_valid)&&(!i_axi_wd_wready))
                                ||((o_axi_arvalid)&&(!i_axi_arready)));
                                ||((o_axi_rvalid)&&(!i_axi_rready)));
 
endmodule
endmodule
 
 
 No newline at end of file
 No newline at end of file
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.