1 -------------------------------------------------------------------------------     3 -- Company    : SLAC National Accelerator Laboratory     4 -- Created    : 2015-08-09     5 -- Last update: 2016-05-13     6 -------------------------------------------------------------------------------     7 -- Description: The module is based upon RUDP (Cisco implementation) RFC-908, RFC-1151, draft-ietf-sigtran-reliable-udp-00.     8 --              The specifications in the drafts are modified by internal simplifications and improvements.    10 --              Interfaces to transport and application side through AxiStream ports    11 --              The AxiStream IO port widths can be adjusted (AxiStream FIFOs added to IO)    12 --              Optional AxiLite Register interface. More info on registers is in RssiAxiLiteRegItf.vhd    13 --              The module can act as Server or Client:    14 --                 - Server: - Passively listens for connection request from client,    15 --                           - Monitors connection activity NULL segment timeouts    16 --                 - Client: - Actively requests connection    17 --                           - Sends NULL packages if there is no incoming data    19 --    statusReg_o(0) : Connection Active              20 --    statusReg_o(1) : Maximum retransmissions exceeded r.retransMax and    21 --    statusReg_o(2) : Null timeout reached (server) r.nullTout;    22 --    statusReg_o(3) : Error in acknowledgment mechanism       23 --    statusReg_o(4) : SSI Frame length too long    24 --    statusReg_o(5) : Connection to peer timed out    25 --    statusReg_o(6) : Client rejected the connection (parameters out of range)    26 --                     Server proposed new parameters (parameters out of range)                   27 -------------------------------------------------------------------------------    28 -- This file is part of 'SLAC Firmware Standard Library'.    29 -- It is subject to the license terms in the LICENSE.txt file found in the     30 -- top-level directory of this distribution and at:     31 --    https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.     32 -- No part of 'SLAC Firmware Standard Library', including this file,     33 -- may be copied, modified, propagated, or distributed except according to     34 -- the terms contained in the LICENSE.txt file.    35 -------------------------------------------------------------------------------    38 use ieee.std_logic_1164.
all;
    39 use ieee.std_logic_unsigned.
all;
    40 use ieee.std_logic_arith.
all;
    50  --! @ingroup protocols_rssi    57       SERVER_G :  := true;
       -- Module is server or client     61       WINDOW_ADDR_SIZE_G  : positive range 1 to 10 := 3;
  -- 2^WINDOW_ADDR_SIZE_G  = Max number of segments in buffer    66       -- AXIS Configurations    70       -- Generic RSSI parameters    72       -- Version and connection ID    78       -- Window parameters of receiver module    80       MAX_SEG_SIZE_G     : positive := 1024;
  -- <= (2**SEGMENT_ADDR_SIZE_G)*8 Number of bytes    83       ACK_TOUT_G     : positive := 25;
   -- unit depends on TIMEOUT_UNIT_G       84       RETRANS_TOUT_G : positive := 50;
   -- unit depends on TIMEOUT_UNIT_G  (Recommended >= MAX_NUM_OUTS_SEG_G*Data segment transmission time)    85       NULL_TOUT_G    : positive := 200;
  -- unit depends on TIMEOUT_UNIT_G  (Recommended >= 4*RETRANS_TOUT_G)    95       -- High level  Application side interface   100       -- SSI Application side   103       mAppAxisMaster_o : 
out AxiStreamMasterType;
   104       mAppAxisSlave_i  : 
in  AxiStreamSlaveType;
   106       -- SSI Transport side   112       -- AXI-Lite Register Interface   127    constant FIFO_PAUSE_THRESH_C : positive := ((2**FIFO_ADDR_WIDTH_C)-1) - 16;
  -- FIFO_FULL - padding (128 bytes)   134    -- Tx Segment requests    135    signal s_sndResend : sl;
   136    signal s_sndSyn    : sl;
   137    signal s_sndAck    : sl;
   138    signal s_sndAckMon : sl;
   139    signal s_sndAckCon : sl;
   141    signal s_sndRst  : sl;
   142    signal s_sndNull : sl;
   145    signal s_synHeadSt  : sl;
   146    signal s_rstHeadSt  : sl;
   147    signal s_dataHeadSt : sl;
   148    signal s_nullHeadSt : sl;
   149    signal s_ackHeadSt  : sl;
   151    -- Current transmitted or received SeqN and AckN      152    signal s_txSeqN : slv(7 downto 0);
   153    signal s_txAckN : slv(7 downto 0);
   155    signal s_rxSeqN     : slv(7 downto 0);
   156    signal s_rxLastSeqN : slv(7 downto 0);
   157    signal s_rxAckN     : slv(7 downto 0);
   158    signal s_rxLastAckN : slv(7 downto 0);
   161    signal s_headerAddr : slv(7 downto 0);
   163    signal s_headerRdy  : sl;
   166    signal s_txChkEnable : sl;
   167    signal s_txChkValid  : sl;
   168    signal s_txChkStrobe : sl;
   169    signal s_txChkLength : positive;
   170    signal s_txChksum    : slv(15 downto 0);
   173    signal s_rxChkEnable : sl;
   174    signal s_rxChkValid  : sl;
   175    signal s_rxChkCheck  : sl;
   176    signal s_rxChkStrobe : sl;
   177    signal s_rxChkLength : positive;
   180    signal s_rxValidSeg : sl;
   181    signal s_rxDropSeg  : sl;
   189    signal s_rxWrBuffWe   : sl;
   190    signal s_rxRdBuffRe   : sl;
   199    signal s_txWrBuffWe   : sl;
   200    signal s_txRdBuffRe   : sl;
   204    -- Acknowledge pulse when valid segment    205    -- with acknowledge flag received   208    -- Application Fifo reset when connection is closed   209    signal s_rstFifo : sl;
   211    -- AXIS Application side   218    -- SSI Application side   224    -- AXIS Transport side   231    -- SSI Transport side         237    -- Monitor input signals   238    signal s_txBufferEmpty : sl;
   239    signal s_lenErr        : sl;
   240    signal s_ackErr        : sl;
   241    signal s_peerConnTout  : sl;
   242    signal s_paramReject   : sl;
   244    -- Connection control and parameters   245    signal s_initSeqN   : slv(7 downto 0);
   246    signal s_connActive : sl;
   247    signal s_closeRq    : sl;
   248    signal s_closed     : sl;
   249    signal s_openRq     : sl;
   250    signal s_intCloseRq : sl;
   251    signal s_txAckF     : sl;
   254    signal s_injectFaultReg : sl;
   255    signal s_injectFault    : sl;
   257    -- Axi Lite registers   258    signal s_openRqReg       : sl;
   259    signal s_closeRqReg      : sl;
   260    signal s_modeReg         : sl;
       -- '0': Use internal parameters from generics    261    -- '1': Use parameters from Axil      262    signal s_initSeqNReg     : slv(7 downto 0);
   266    signal s_dropCntReg  : slv(31 downto 0);
   267    signal s_validCntReg : slv(31 downto 0);
   268    signal s_reconCntReg  : slv(31 downto 0);
   269    signal s_resendCntReg : slv(31 downto 0);
   276    -- attribute dont_touch                   : string;   277    -- attribute dont_touch of bandwidth      : signal is "TRUE";        278    -- attribute dont_touch of s_mAppAxisCtrl : signal is "TRUE";        279    -- attribute dont_touch of s_mTspAxisCtrl : signal is "TRUE";      281 ----------------------------------------------------------------------   283    -- Assertions to check generics   288    -- /////////////////////////////////////////////////////////   289    ------------------------------------------------------------   290    -- Register interface   291    ------------------------------------------------------------   292    -- /////////////////////////////////////////////////////////   341    s_injectFault <= s_injectFaultReg or inject_i;
   343    -- /////////////////////////////////////////////////////////   344    ------------------------------------------------------------   345    -- Parameter assignment   346    ------------------------------------------------------------   347    -- /////////////////////////////////////////////////////////   348    combParamAssign : 
process (
closeRq_i, 
openRq_i, s_appRssiParamReg, s_closeRqReg, s_initSeqNReg,
   349                               s_intCloseRq, s_modeReg, s_openRqReg) 
is   351       if (s_modeReg = '0') then   352          -- Use external requests   353          s_closeRq <= s_closeRqReg or closeRq_i or s_intCloseRq;
   354          s_openRq  <= s_openRqReg or openRq_i;
   356          -- Assign application side Rssi parameters from generics   372          -- Use axil register requests   373          s_closeRq <= s_closeRqReg or s_intCloseRq;
   374          s_openRq  <= s_openRqReg;
   376          -- Assign application side Rssi parameters from Axilite registers   377          s_appRssiParam <= s_appRssiParamReg;
   379          s_initSeqN     <= s_initSeqNReg;
   381    end process combParamAssign;
   383    -- /////////////////////////////////////////////////////////   384    ------------------------------------------------------------   386    ------------------------------------------------------------   387    -- /////////////////////////////////////////////////////////   389    -- Application Fifo reset when connection is closed   390    s_rstFifo <= rst_i or not s_connActive;
   447    -- /////////////////////////////////////////////////////////   448    ------------------------------------------------------------   449    -- Input AXIS conversion to SSI    450    ------------------------------------------------------------   451    -- /////////////////////////////////////////////////////////   455    s_sAppAxisSlave <= ssi2AxisSlave(s_sAppSsiSlave);
   459    s_sTspAxisSlave <= ssi2AxisSlave(s_sTspSsiSlave);
   461    -- /////////////////////////////////////////////////////////   462    ------------------------------------------------------------   463    -- Connection and monitoring part   464    ------------------------------------------------------------    465    ConnFSM_INST : 
entity work.
ConnFSM   501    Monitor_INST : 
entity work.
Monitor   540    -- /////////////////////////////////////////////////////////   541    ------------------------------------------------------------   543    ------------------------------------------------------------   544    -- /////////////////////////////////////////////////////////          546    -- Header decoder module   566          ack_i          => s_txAckF,
    -- Connected to ConnectFSM   576    -----------------------------------------   577    -- Group all ack requests   578    s_sndAck <= s_sndAckCon or s_sndAckMon;
   581    TxFSM_INST : 
entity work.
TxFSM   632          dataSt_o     => 
open,
          -- may be used in the future otherwise remove   650    -----------------------------------------------      656          ADDR_WIDTH_G => 
(SEGMENT_ADDR_SIZE_G+WINDOW_ADDR_SIZE_G
)   659          -- Port A - Write only   662          addra => s_txWrBuffAddr,
   663          dina  => s_txWrBuffData,
   665          -- Port B - Read only   668          addrb => s_txRdBuffAddr,
   669          doutb => s_txRdBuffData
);
   671    tx_Chksum_INST : 
entity work.
Chksum   684          data_i   => endianSwap64
(s_mTspSsiMaster.
data(RSSI_WORD_WIDTH_C*8-
1 downto 0)),
   689    -- /////////////////////////////////////////////////////////   690    ------------------------------------------------------------   692    ------------------------------------------------------------      693    -- /////////////////////////////////////////////////////////     694    RxFSM_INST : 
entity work.
RxFSM   735          ADDR_WIDTH_G => 
(SEGMENT_ADDR_SIZE_G+WINDOW_ADDR_SIZE_G
)   738          -- Port A - Write only   741          addra => s_rxWrBuffAddr,
   742          dina  => s_rxWrBuffData,
   744          -- Port B - Read only   747          addrb => s_rxRdBuffAddr,
   748          doutb => s_rxRdBuffData
);
   750    -- Acknowledge valid packet   751    s_rxAck <= s_rxValidSeg and s_rxFlags.ack and s_connActive;
   753    rx_Chksum_INST : 
entity work.
Chksum   771    -- /////////////////////////////////////////////////////////   772    ------------------------------------------------------------   773    -- Output SSI conversion to AXIS   774    ------------------------------------------------------------   775    -- /////////////////////////////////////////////////////////   777    -- SSI Application side      780    -- SSI Transport side   784    -- /////////////////////////////////////////////////////////   785    ------------------------------------------------------------   787    ------------------------------------------------------------   788    -- /////////////////////////////////////////////////////////   820    mAppAxisMaster_o <= monMasters(
1);
   852 ----------------------------------------   857    for i in 1 downto 0 generate   864             -- AXIS Stream Interface   874    end generate PACKET_RATE;         
   876 end architecture rtl;
 
out appSsiMaster_oSsiMasterType  
 
in axisSlaveAxiStreamSlaveType  
 
in chksum_islv( 15 downto  0)  
 
FIFO_ADDR_WIDTH_Ginteger   range  4 to  48:= 9
 
out tspSsiMaster_oSsiMasterType  
 
array(natural range <> ) of AxiStreamSlaveType   AxiStreamSlaveArray
 
out sAxisCtrlAxiStreamCtrlType  
 
array(natural range <> ) of slv( 31 downto  0)   Slv32Array
 
ACK_HEADER_SIZE_Gnatural  := 8
 
CSUM_WIDTH_Gpositive  := 16
 
in addrbslv(   ADDR_WIDTH_G- 1 downto  0)  :=( others => '0')
 
in appSsiSlave_iSsiSlaveType  
 
AXIS_CONFIG_GAxiStreamConfigType  :=   AXI_STREAM_CONFIG_INIT_C
 
out rssiParam_oRssiParamType  
 
in rdHeaderData_islv(   RSSI_WORD_WIDTH_C* 8- 1 downto  0)  
 
out rxBufferSize_ointeger   range  1 to  2**(   SEGMENT_ADDR_SIZE_G)
 
in rstbsl  :=not (   RST_POLARITY_G)
 
out doutbslv(   DATA_WIDTH_G- 1 downto  0)  
 
PIPE_STAGES_Gnatural   range  0 to  16:= 1
 
DATA_WIDTH_Ginteger   range  1 to ( 2** 24):= 16
 
out wrBuffData_oslv(   RSSI_WORD_WIDTH_C* 8- 1 downto  0)  
 
out wrBuffData_oslv(   RSSI_WORD_WIDTH_C* 8- 1 downto  0)  
 
CLK_FREQUENCY_Greal  := 100.0E6
 
out rxSeqN_oslv( 7 downto  0)  
 
in lastAckN_islv( 7 downto  0)  
 
out chksumLength_opositive  
 
out rdHeaderAddr_oslv( 7 downto  0)  
 
out chksum_oslv(   CSUM_WIDTH_G- 1 downto  0)  
 
out txSeqN_oslv( 7 downto  0)  
 
in appRssiParam_iRssiParamType  
 
SLAVE_AXI_CONFIG_GAxiStreamConfigType  :=   AXI_STREAM_CONFIG_INIT_C
 
TIMEOUT_UNIT_Greal  := 1.0E-6
 
in txWindowSize_iinteger   range  1 to  2**(   WINDOW_ADDR_SIZE_G)
 
array(natural range <> ) of slv( 63 downto  0)   Slv64Array
 
WINDOW_ADDR_SIZE_Gpositive  := 7
 
SLAVE_READY_EN_Gboolean  :=   true
 
FIFO_FIXED_THRESH_Gboolean  :=   true
 
out frameRateslv( 31 downto  0)  
 
out txWindowSize_ointeger   range  1 to  2**(   WINDOW_ADDR_SIZE_G)
 
GEN_SYNC_FIFO_Gboolean  :=   false
 
out dropCnt_oslv(   CNT_WIDTH_G- 1 downto  0)  
 
in rxWindowSize_iinteger   range  1 to  2**(   WINDOW_ADDR_SIZE_G)
 
out reconCnt_oslv(   CNT_WIDTH_G- 1 downto  0)  
 
out rxLastSeqN_oslv( 7 downto  0)  
 
DATA_HEADER_SIZE_Gnatural  := 8
 
WINDOW_ADDR_SIZE_Gpositive  := 3
 
in rdBuffData_islv(   RSSI_WORD_WIDTH_C* 8- 1 downto  0)  
 
in rdBuffData_islv(   RSSI_WORD_WIDTH_C* 8- 1 downto  0)  
 
slv( 1 downto  0)  :=   "11" AXI_RESP_DECERR_C
 
RST_HEADER_SIZE_Gnatural  := 8
 
in rxLastSeqN_islv( 7 downto  0)  
 
out rxWindowSize_ointeger   range  1 to  2**(   WINDOW_ADDR_SIZE_G)
 
ADDR_WIDTH_Ginteger   range  1 to ( 2** 24):= 4
 
in rxRssiParam_iRssiParamType  
 
HEADER_CHKSUM_EN_Gboolean  :=   true
 
DATA_WIDTH_Gpositive  := 64
 
INT_PIPE_STAGES_Gnatural   range  0 to  16:= 0
 
HEADER_CHKSUM_EN_Gboolean  :=   true
 
out rdBuffAddr_oslv((   SEGMENT_ADDR_SIZE_G+   WINDOW_ADDR_SIZE_G)- 1 downto  0)  
 
in data_islv(   DATA_WIDTH_G- 1 downto  0)  
 
out rdBuffAddr_oslv((   SEGMENT_ADDR_SIZE_G+   WINDOW_ADDR_SIZE_G)- 1 downto  0)  
 
SEGMENT_ADDR_SIZE_Gpositive  := 7
 
in init_islv(   CSUM_WIDTH_G- 1 downto  0)  
 
in addraslv(   ADDR_WIDTH_G- 1 downto  0)  :=( others => '0')
 
CLK_FREQUENCY_Greal  := 100.0E6
 
out tspSsiSlave_oSsiSlaveType  
 
in appSsiMaster_iSsiMasterType  
 
RETRANSMIT_ENABLE_Gboolean  :=   true
 
SEGMENT_ADDR_SIZE_Gpositive  := 7
 
NULL_HEADER_SIZE_Gnatural  := 8
 
out bandwidthslv( 63 downto  0)  
 
SEGMENT_ADDR_SIZE_Gpositive  := 3
 
in tspSsiMaster_iSsiMasterType  
 
in windowSize_iinteger   range  1 to  2**(   WINDOW_ADDR_SIZE_G)
 
AXIS_CLK_FREQ_Greal  := 156.25E+6
 
out appSsiSlave_oSsiSlaveType  
 
WINDOW_ADDR_SIZE_Gpositive  := 3
 
array(natural range <> ) of AxiStreamMasterType   AxiStreamMasterArray
 
in initSeqN_islv( 7 downto  0)  
 
out sAxisSlaveAxiStreamSlaveType  
 
MAX_RETRANS_CNT_Gpositive  := 2
 
AxiLiteReadMasterType  :=(araddr  =>( others => '0'),arprot  =>( others => '0'),arvalid  => '0',rready  => '1') AXI_LITE_READ_MASTER_INIT_C
 
WINDOW_ADDR_SIZE_Gpositive  := 7
 
in rxBufferSize_iinteger   range  1 to  2**(   SEGMENT_ADDR_SIZE_G)
 
out mTLastTUserslv( 7 downto  0)  
 
AxiLiteWriteMasterType  :=(awaddr  =>( others => '0'),awprot  =>( others => '0'),awvalid  => '0',wdata  =>( others => '0'),wstrb  =>( others => '1'),wvalid  => '0',bready  => '1') AXI_LITE_WRITE_MASTER_INIT_C
 
in sAxisMasterAxiStreamMasterType  
 
in rssiParam_iRssiParamType  
 
in rxWindowSize_iinteger   range  1 to  2**(   WINDOW_ADDR_SIZE_G)
 
out statusReg_oslv(   STATUS_WIDTH_G downto  0)  
 
out mAxisMasterAxiStreamMasterType  
 
in axisMasterAxiStreamMasterType  
 
EACK_HEADER_SIZE_Gnatural  := 8
 
out lastAckN_oslv( 7 downto  0)  
 
out txBufferSize_ointeger   range  1 to  2**(   SEGMENT_ADDR_SIZE_G)
 
SYN_HEADER_SIZE_Gnatural  := 24
 
in mAxisSlaveAxiStreamSlaveType  
 
CASCADE_SIZE_Ginteger   range  1 to ( 2** 24):= 1
 
in ackN_islv( 7 downto  0)  
 
FIFO_PAUSE_THRESH_Ginteger   range  1 to ( 2** 24):= 1
 
VALID_THOLD_Ginteger   range  0 to ( 2** 24):= 1
 
out rxParam_oRssiParamType  
 
out rxAckN_oslv( 7 downto  0)  
 
out resendCnt_oslv(   CNT_WIDTH_G- 1 downto  0)  
 
in headerLength_ipositive  
 
MASTER_AXI_CONFIG_GAxiStreamConfigType  :=   AXI_STREAM_CONFIG_INIT_C
 
in bufferSize_iinteger   range  1 to  2**(   SEGMENT_ADDR_SIZE_G)
 
RETRANS_TOUT_Gpositive  := 50
 
in tspSsiSlave_iSsiSlaveType  
 
TIMEOUT_UNIT_Greal  := 1.0E-6
 
CASCADE_PAUSE_SEL_Ginteger   range  0 to ( 2** 24):= 0
 
out wrBuffAddr_oslv((   SEGMENT_ADDR_SIZE_G+   WINDOW_ADDR_SIZE_G)- 1 downto  0)  
 
out validCnt_oslv(   CNT_WIDTH_G- 1 downto  0)  
 
out wrBuffAddr_oslv((   SEGMENT_ADDR_SIZE_G+   WINDOW_ADDR_SIZE_G)- 1 downto  0)  
 
in dinaslv(   DATA_WIDTH_G- 1 downto  0)  :=( others => '0')