// ---------------------------------------------------------------------- // Copyright (c) 2016, The Regents of the University of California All // rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following // disclaimer in the documentation and/or other materials provided // with the distribution. // // * Neither the name of The Regents of the University of California // nor the names of its contributors may be used to endorse or // promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL REGENTS OF THE // UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. // ---------------------------------------------------------------------- `include "trellis.vh" `include "riffa.vh" module registers #(parameter C_PCI_DATA_WIDTH = 128, parameter C_NUM_CHNL = 12, parameter C_MAX_READ_REQ_BYTES = 512, // Max size of read requests (in bytes) parameter C_VENDOR = "ALTERA", parameter C_NUM_VECTORS = 2, parameter C_VECTOR_WIDTH = 32, parameter C_FPGA_NAME = "FPGA", parameter C_PIPELINE_OUTPUT= 1, parameter C_PIPELINE_INPUT= 1) ( // Interface: Clocks input CLK, // Interface: Resets input RST_IN, // Interface: RXR Engine input [C_PCI_DATA_WIDTH-1:0] RXR_DATA, input RXR_DATA_VALID, input RXR_DATA_START_FLAG, input [`clog2s(C_PCI_DATA_WIDTH/32)-1:0] RXR_DATA_START_OFFSET, input [`SIG_FBE_W-1:0] RXR_META_FDWBE, input RXR_DATA_END_FLAG, input [`clog2s(C_PCI_DATA_WIDTH/32)-1:0] RXR_DATA_END_OFFSET, input [`SIG_LBE_W-1:0] RXR_META_LDWBE, input [`SIG_TC_W-1:0] RXR_META_TC, input [`SIG_ATTR_W-1:0] RXR_META_ATTR, input [`SIG_TAG_W-1:0] RXR_META_TAG, input [`SIG_TYPE_W-1:0] RXR_META_TYPE, input [`SIG_ADDR_W-1:0] RXR_META_ADDR, input [`SIG_BARDECODE_W-1:0] RXR_META_BAR_DECODED, input [`SIG_REQID_W-1:0] RXR_META_REQUESTER_ID, input [`SIG_LEN_W-1:0] RXR_META_LENGTH, // Interface: TXC Engine output TXC_DATA_VALID, output [C_PCI_DATA_WIDTH-1:0] TXC_DATA, output TXC_DATA_START_FLAG, output [`clog2s(C_PCI_DATA_WIDTH/32)-1:0] TXC_DATA_START_OFFSET, output TXC_DATA_END_FLAG, output [`clog2s(C_PCI_DATA_WIDTH/32)-1:0] TXC_DATA_END_OFFSET, input TXC_DATA_READY, output TXC_META_VALID, output [`SIG_FBE_W-1:0] TXC_META_FDWBE, output [`SIG_LBE_W-1:0] TXC_META_LDWBE, output [`SIG_LOWADDR_W-1:0] TXC_META_ADDR, output [`SIG_TYPE_W-1:0] TXC_META_TYPE, output [`SIG_LEN_W-1:0] TXC_META_LENGTH, output [`SIG_BYTECNT_W-1:0] TXC_META_BYTE_COUNT, output [`SIG_TAG_W-1:0] TXC_META_TAG, output [`SIG_REQID_W-1:0] TXC_META_REQUESTER_ID, output [`SIG_TC_W-1:0] TXC_META_TC, output [`SIG_ATTR_W-1:0] TXC_META_ATTR, output TXC_META_EP, input TXC_META_READY, // Interface: Channel - WR output [31:0] CHNL_REQ_DATA, output [C_NUM_CHNL-1:0] CHNL_SGRX_LEN_VALID, output [C_NUM_CHNL-1:0] CHNL_SGRX_ADDRLO_VALID, output [C_NUM_CHNL-1:0] CHNL_SGRX_ADDRHI_VALID, output [C_NUM_CHNL-1:0] CHNL_SGTX_LEN_VALID, output [C_NUM_CHNL-1:0] CHNL_SGTX_ADDRLO_VALID, output [C_NUM_CHNL-1:0] CHNL_SGTX_ADDRHI_VALID, output [C_NUM_CHNL-1:0] CHNL_RX_LEN_VALID, output [C_NUM_CHNL-1:0] CHNL_RX_OFFLAST_VALID, // Interface: Channel - RD input [(`SIG_TXRLEN_W*C_NUM_CHNL)-1:0] CHNL_TX_REQLEN, input [(`SIG_OFFLAST_W*C_NUM_CHNL)-1:0] CHNL_TX_OFFLAST, input [(`SIG_TXDONELEN_W*C_NUM_CHNL)-1:0] CHNL_TX_DONELEN, input [(`SIG_RXDONELEN_W*C_NUM_CHNL)-1:0] CHNL_RX_DONELEN, input [`SIG_CORESETTINGS_W-1:0] CORE_SETTINGS, output [C_NUM_CHNL-1:0] CHNL_TX_LEN_READY, output [C_NUM_CHNL-1:0] CHNL_TX_OFFLAST_READY, output CORE_SETTINGS_READY, output [C_NUM_VECTORS-1:0] INTR_VECTOR_READY, output [C_NUM_CHNL-1:0] CHNL_TX_DONE_READY, output [C_NUM_CHNL-1:0] CHNL_RX_DONE_READY, output CHNL_NAME_READY, // Interface: Interrupt Vectors input [C_NUM_VECTORS*C_VECTOR_WIDTH-1:0] INTR_VECTOR ); localparam C_ADDR_RANGE = 256; localparam C_ARRAY_LENGTH = (32*C_ADDR_RANGE)/C_PCI_DATA_WIDTH; localparam C_NAME_WIDTH = 32; localparam C_FIELDS_WIDTH = 4; localparam C_OUTPUT_STAGES = C_PIPELINE_OUTPUT > 0 ? 1:0; localparam C_INPUT_STAGES = C_PIPELINE_INPUT > 0 ? 1:0; localparam C_TXC_REGISTER_WIDTH = C_PCI_DATA_WIDTH + 2*(1 + `clog2(C_PCI_DATA_WIDTH/32) + `SIG_FBE_W) + `SIG_LOWADDR_W + `SIG_TYPE_W + `SIG_LEN_W + `SIG_BYTECNT_W + `SIG_TAG_W + `SIG_REQID_W + `SIG_TC_W + `SIG_ATTR_W + 1; localparam C_RXR_REGISTER_WIDTH = C_PCI_DATA_WIDTH + 2*(1 + `clog2(C_PCI_DATA_WIDTH/32) + `SIG_FBE_W) + `SIG_ADDR_W + `SIG_TYPE_W + `SIG_LEN_W + `SIG_TAG_W + `SIG_REQID_W + `SIG_TC_W + `SIG_ATTR_W; // The Mem/IO read/write address space should be at least 8 bits wide. This // means we'll need at least 10 bits of BAR 0, at least 1024 bytes. The bottom // two bits must always be zero (i.e. all addresses are 4 byte word aligned). // The Mem/IO read/write address space is partitioned as illustrated below. // {CHANNEL_NUM} {DATA_OFFSETS} {ZERO} // ------4-------------4-----------2-- // The lower 2 bits are always zero. The middle 4 bits are used according to // the listing below. The top 4 bits differentiate between channels for values // defined in the table below. // 0000 = Length of SG buffer for RX transaction (Write only) // 0001 = PC low address of SG buffer for RX transaction (Write only) // 0010 = PC high address of SG buffer for RX transaction (Write only) // 0011 = Transfer length for RX transaction (Write only) // 0100 = Offset/Last for RX transaction (Write only) // 0101 = Length of SG buffer for TX transaction (Write only) // 0110 = PC low address of SG buffer for TX transaction (Write only) // 0111 = PC high address of SG buffer for TX transaction (Write only) // 1000 = Transfer length for TX transaction (Read only) (ACK'd on read) // 1001 = Offset/Last for TX transaction (Read only) // 1010 = Link rate, link width, bus master enabled, number of channels (Read only) // 1011 = Interrupt vector 1 (Read only) (Reset on read) // 1100 = Interrupt vector 2 (Read only) (Reset on read) // 1101 = Transferred length for RX transaction (Read only) (ACK'd on read) // 1110 = Transferred length for TX transaction (Read only) (ACK'd on read) // 1111 = Name of FPGA (Read only) wire [31:0] __wRdMemory[C_ADDR_RANGE-1:0]; wire [32*C_ADDR_RANGE-1:0] _wRdMemory; wire [C_PCI_DATA_WIDTH-1:0] wRdMemory[C_ARRAY_LENGTH-1:0]; wire [C_PCI_DATA_WIDTH-1:0] wRxrData; wire wRxrDataValid; wire wRxrDataStartFlag; wire [`clog2s(C_PCI_DATA_WIDTH/32)-1:0] wRxrDataStartOffset; wire [`SIG_FBE_W-1:0] wRxrMetaFdwbe; wire wRxrDataEndFlag; wire [`clog2s(C_PCI_DATA_WIDTH/32)-1:0] wRxrDataEndOffset; wire [`SIG_LBE_W-1:0] wRxrMetaLdwbe; wire [`SIG_TC_W-1:0] wRxrMetaTc; wire [`SIG_ATTR_W-1:0] wRxrMetaAttr; wire [`SIG_TAG_W-1:0] wRxrMetaTag; wire [`SIG_TYPE_W-1:0] wRxrMetaType; wire [`SIG_ADDR_W-1:0] wRxrMetaAddr; wire [`SIG_REQID_W-1:0] wRxrMetaRequesterId; wire [`SIG_LEN_W-1:0] wRxrMetaLength; wire [C_PCI_DATA_WIDTH-1:0] wTxcData; wire wTxcDataValid; wire wTxcDataStartFlag; wire [`clog2s(C_PCI_DATA_WIDTH/32)-1:0] wTxcDataStartOffset; wire [`SIG_FBE_W-1:0] wTxcMetaFdwbe; wire wTxcDataEndFlag; wire [`clog2s(C_PCI_DATA_WIDTH/32)-1:0] wTxcDataEndOffset; wire [`SIG_LBE_W-1:0] wTxcMetaLdwbe; wire [`SIG_LOWADDR_W-1:0] wTxcMetaAddr; wire [`SIG_TYPE_W-1:0] wTxcMetaType; wire [`SIG_LEN_W-1:0] wTxcMetaLength; wire [`SIG_BYTECNT_W-1:0] wTxcMetaByteCount; wire [`SIG_TAG_W-1:0] wTxcMetaTag; wire [`SIG_REQID_W-1:0] wTxcMetaRequesterId; wire [`SIG_TC_W-1:0] wTxcMetaTc; wire [`SIG_ATTR_W-1:0] wTxcMetaAttr; wire wTxcMetaEp; wire wTxcDataReady; wire [`clog2s(C_NUM_CHNL)-1:0] wReqChnl; wire [C_FIELDS_WIDTH-1:0] wReqField; wire [(1<