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

Subversion Repositories wb2axip

[/] [wb2axip/] [trunk/] [rtl/] [wbm2axisp.v] - Diff between revs 2 and 3

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

Rev 2 Rev 3
Line 26... Line 26...
// Creator:     Dan Gisselquist, Ph.D.
// Creator:     Dan Gisselquist, Ph.D.
//              Gisselquist Technology, LLC
//              Gisselquist Technology, LLC
//
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
//
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
// Copyright (C) 2016, Gisselquist Technology, LLC
//
//
// This program is free software (firmware): you can redistribute it and/or
// This program is free software (firmware): you can redistribute it and/or
// modify it under the terms of  the GNU General Public License as published
// modify it under the terms of  the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License, or (at
// by the Free Software Foundation, either version 3 of the License, or (at
// your option) any later version.
// your option) any later version.
Line 55... Line 55...
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 AW                    = 28,   // Wishbone address width
        parameter DW                    = 128   // Wishbone data width
        parameter DW                    = 32,   // Wishbone data width
 
        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
 
 
// AXI write address channel signals
// AXI write address channel signals
Line 75... Line 76...
        output  reg                     o_axi_wvalid,   // Write address valid
        output  reg                     o_axi_wvalid,   // Write address valid
 
 
// AXI write data channel signals
// AXI write data channel signals
        input                           i_axi_wd_wready,  // Write data ready
        input                           i_axi_wd_wready,  // Write data ready
        output  wire    [C_AXI_ID_WIDTH-1:0]     o_axi_wd_wid,   // Write ID tag
        output  wire    [C_AXI_ID_WIDTH-1:0]     o_axi_wd_wid,   // Write ID tag
        output  reg     [DW-1:0] o_axi_wd_data,  // Write data
        output  reg     [C_AXI_DATA_WIDTH-1:0]   o_axi_wd_data,  // Write data
        output  reg     [DW/8-1:0]       o_axi_wd_strb,  // Write strobes
        output  reg     [C_AXI_DATA_WIDTH/8-1:0] o_axi_wd_strb,  // Write strobes
        output  wire                    o_axi_wd_last,  // Last write transaction   
        output  wire                    o_axi_wd_last,  // Last write transaction   
        output  reg                     o_axi_wd_valid, // 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_wd_bid,   // Response ID
Line 102... Line 103...
 
 
// 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_rd_bid,     // Response ID
        input   [1:0]                    i_axi_rd_rresp,   // Read response
        input   [1:0]                    i_axi_rd_rresp,   // Read response
        input                           i_axi_rd_rvalid,  // Read reponse valid
        input                           i_axi_rd_rvalid,  // Read reponse valid
        input   [DW-1:0]         i_axi_rd_data,    // Read data
        input   [C_AXI_DATA_WIDTH-1:0]           i_axi_rd_data,    // Read data
        input                           i_axi_rd_last,    // Read last
        input                           i_axi_rd_last,    // Read last
        output  wire                    o_axi_rd_rready,  // Read Response ready
        output  wire                    o_axi_rd_rready,  // Read Response ready
 
 
        // We'll share the clock and the reset
        // We'll share the clock and the reset
        input                           i_wb_cyc, i_wb_stb, i_wb_we;
        input                           i_wb_cyc,
        input           [AW-1:0] i_wb_addr;
        input                           i_wb_stb,
        input           [DW-1:0] i_wb_data;
        input                           i_wb_we,
        output  reg                     o_wb_ack;
        input           [AW-1:0] i_wb_addr,
        output  wire                    o_wb_stall;
        input           [DW-1:0] i_wb_data,
        output  reg     [DW-1:0] o_wb_data;
        input           [3:0]            i_wb_sel,
        output  reg                     o_wb_err;
        output  reg                     o_wb_ack,
 
        output  wire                    o_wb_stall,
 
        output  reg     [DW-1:0] o_wb_data,
 
        output  reg                     o_wb_err
);
);
 
 
//*****************************************************************************
//*****************************************************************************
// Parameter declarations
// Parameter declarations
//*****************************************************************************
//*****************************************************************************
Line 201... Line 205...
 
 
// Write data logic
// Write data logic
        assign  o_axi_wd_wid = transaction_id;
        assign  o_axi_wd_wid = transaction_id;
        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_wbdata };
                        o_axi_wd_data <= { 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_wd_strb<={     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_wd_strb<={     4'h0,     4'h0, i_wb_sel,     4'h0 };
Line 228... Line 232...
                // Reorder FIFO
                // Reorder FIFO
                //
                //
                localparam      LGFIFOLN = C_AXI_ID_WIDTH;
                localparam      LGFIFOLN = C_AXI_ID_WIDTH;
                localparam      FIFOLN = (1<<LGFIFOLN);
                localparam      FIFOLN = (1<<LGFIFOLN);
                // FIFO reorder buffer
                // FIFO reorder buffer
                reg     [(DW-1):0]       reorder_fifo_data [0:(FIFOLN-1)];
                reg     [(LGFIFOLN-1):0] fifo_tail;
                reg                     reorder_fifo_valid[0:(FIFOLN-1)];
                reg     [(C_AXI_DATA_WIDTH-1):0] reorder_fifo_data [0:(FIFOLN-1)];
                reg                     reorder_fifo_err  [0:(FIFOLN-1)];
                reg     [(FIFOLN-1):0]   reorder_fifo_valid;
 
                reg     [(FIFOLN-1):0]   reorder_fifo_err;
 
                reg     [1:0]            reorder_fifo_addr [0:(FIFOLN-1)];
 
 
 
 
 
                reg     [1:0]    low_addr;
 
                always @(posedge i_clk)
 
                        if ((i_wb_stb)&&(!o_wb_stall))
 
                                low_addr <= i_wb_addr[1:0];
 
                always @(posedge i_clk)
 
                        if ((o_axi_rvalid)&&(i_axi_rready))
 
                                reorder_fifo_addr[o_axi_rid] <= low_addr;
 
 
 
 
 
                wire    [(LGFIFOLN-1):0] fifo_head;
                assign  fifo_head = transaction_id;
                assign  fifo_head = transaction_id;
 
 
                // Let's do some math to figure out where the FIFO head will
                // Let's do some math to figure out where the FIFO head will
                // 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
Line 247... Line 265...
                        if ((i_axi_rd_rvalid)&&(o_axi_rd_rready))
                        if ((i_axi_rd_rvalid)&&(o_axi_rd_rready))
                                reorder_fifo_data[i_axi_rd_bid]<= i_axi_rd_data;
                                reorder_fifo_data[i_axi_rd_bid]<= i_axi_rd_data;
                        if ((i_axi_rd_rvalid)&&(o_axi_rd_rready))
                        if ((i_axi_rd_rvalid)&&(o_axi_rd_rready))
                        begin
                        begin
                                reorder_fifo_valid[i_axi_rd_bid] <= 1'b1;
                                reorder_fifo_valid[i_axi_rd_bid] <= 1'b1;
                                reorder_fifo_err[i_axi_rd_bid] <= i_axi_rd_resp[1];
                                reorder_fifo_err[i_axi_rd_bid] <= i_axi_rd_rresp[1];
                        end
                        end
                        if ((i_axi_wd_bvalid)&&(o_axi_wd_bready))
                        if ((i_axi_wd_bvalid)&&(o_axi_wd_bready))
                        begin
                        begin
                                reorder_fifo_valid[i_axi_wd_bid] = 1'b1;
                                reorder_fifo_valid[i_axi_wd_bid] <= 1'b1;
                                reorder_fifo_err[i_axi_wd_bid] = i_axi_wd_bresp[1];
                                reorder_fifo_err[i_axi_wd_bid] <= i_axi_wd_bresp[1];
                        end
                        end
 
 
                        o_wb_data <= reorder_fifo_data[fifo_tail];
                        case(reorder_fifo_addr[1: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'b10: o_wb_data <=reorder_fifo_data[fifo_tail][ 95:64];
 
                        2'b11: o_wb_data <=reorder_fifo_data[fifo_tail][127:96];
 
                        endcase
 
 
                        if (reorder_fifo_valid[fifo_tail])
                        if (reorder_fifo_valid[fifo_tail])
                        begin
                        begin
                                o_wb_ack <= 1'b1;
                                o_wb_ack <= 1'b1;
                                o_wb_err <= reorder_fifo_err[fifo_tail];
                                o_wb_err <= reorder_fifo_err[fifo_tail];
                                fifo_tail <= fifo_tail + 6'h1;
                                fifo_tail <= fifo_tail + 6'h1;
Line 278... Line 302...
                                o_wb_err <= 1'b0;
                                o_wb_err <= 1'b0;
                                o_wb_ack <= 1'b0;
                                o_wb_ack <= 1'b0;
                        end
                        end
                end
                end
 
 
 
                reg     r_fifo_full;
                always @(posedge i_clk)
                always @(posedge i_clk)
                begin
                begin
                        if (!i_wb_cyc)
                        if (!i_wb_cyc)
                                r_fifo_full <= 1'b0;
                                r_fifo_full <= 1'b0;
                        else if ((i_wb_stb)&&(~o_wb_stall)
                        else if ((i_wb_stb)&&(~o_wb_stall)
Line 294... Line 319...
                        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
                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_rd_data;
                always @(posedge i_clk)
                always @(posedge i_clk)
                        o_wb_ack <= ((i_axi_rd_rvalid)&&(o_axi_rd_rready))
                        o_wb_ack <= ((i_axi_rd_rvalid)&&(o_axi_rd_rready))
                                  ||((i_axi_wd_bvalid)&&(o_axi_wd_bready));
                                  ||((i_axi_wd_bvalid)&&(o_axi_wd_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_resp[1]))
                                ||((i_axi_rd_rvalid)&&(i_axi_rd_rresp[1]))
                                ||((i_axi_wd_bvalid)&&(i_axi_wd_bresp[1])));
                                ||((i_axi_wd_bvalid)&&(i_axi_wd_bresp[1])));
        end
        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_wvalid)&&(!i_axi_wready))
                                ||((o_axi_wvalid)&&(!i_axi_wready))
                                ||((o_axi_wd_valid)&&(!i_axi_wd_bready))
                                ||((o_axi_wd_valid)&&(!i_axi_wd_wready))
                                ||((o_axi_rvalid)&&(!i_axi_rready)));
                                ||((o_axi_rvalid)&&(!i_axi_rready)));
endmodule
endmodule
 
 
 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.