1 -------------------------------------------------------------------------------     2 -- File       : Jesd204bRx.vhd     3 -- Company    : SLAC National Accelerator Laboratory     4 -- Created    : 2015-04-14     5 -- Last update: 2016-02-12     6 -------------------------------------------------------------------------------     7 -- Description: JESD204b multi-lane receiver module     8 --              Receiver JESD204b module.     9 --              Supports a subset of features from JESD204b standard.    10 --              Supports sub-class 1 deterministic latency.    11 --              Supports sub-class 0 non deterministic latency.    13 --              - Synchronization of LMFC to SYSREF    14 --              - Multi-lane operation (L_G: 1-16)    15 --              - Lane alignment using RX buffers    16 --              - Serial lane error check    17 --              - Alignment character replacement and alignment check    19 --          Note: sampleDataArr_o is little endian and not byte-swapped    20 --                First sample in time:  sampleData_o(15 downto 0)     21 --                Second sample in time: sampleData_o(31 downto 16)    22 -------------------------------------------------------------------------------    23 -- This file is part of 'SLAC Firmware Standard Library'.    24 -- It is subject to the license terms in the LICENSE.txt file found in the     25 -- top-level directory of this distribution and at:     26 --    https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.     27 -- No part of 'SLAC Firmware Standard Library', including this file,     28 -- may be copied, modified, propagated, or distributed except according to     29 -- the terms contained in the LICENSE.txt file.    30 -------------------------------------------------------------------------------    33 use ieee.std_logic_1164.
all;
    34 use ieee.std_logic_arith.
all;
    35 use ieee.std_logic_unsigned.
all;
    45  --! @ingroup protocols_jesd204b    50       -- Test tx module instead of GTX    53       -- AXI Lite and stream generics    58       -- Number of bytes in a frame (1,2,or 4)    61       -- Number of frames in a multi frame (32)    64       -- Number of RX lanes (1 to 32)    65       L_G : positive range 1 to 32 := 2);
    73       -- AXI-Lite Register Interface    79       -- Legacy Interface that we will remove in the future    83       -- Sample data output (Use if external data acquisition core is attached)    92       -- SYSREF for subclass 1 fixed latency    95       -- SYSREF output for debug    98       -- Data and character inputs from GT (transceivers)   104       -- Synchronization output combined from all receivers    116    type RegType is record   120    constant REG_INIT_C : RegType := (   124    signal r   : RegType := REG_INIT_C;
   125    signal rin : RegType;
   129    -- Local Multi Frame Clock    132    -- Synchronization output generation   133    signal s_nSyncVec     : slv(L_G-1 downto 0);
   134    signal s_nSyncVecEn   : slv(L_G-1 downto 0);
   135    signal s_dataValidVec : slv(L_G-1 downto 0);
   137    signal s_nSyncAll : sl;
   138    signal s_nSyncAny : sl;
   140    -- Control and status from AxiLite   141    ------------------------------------------------------------   143    signal s_enableRx    : slv(L_G-1 downto 0);
   144    signal s_replEnable  : sl;
   145    signal s_scrEnable   : sl;
   146    signal s_invertData  : slv(L_G-1 downto 0); 
   148    -- JESD subclass selection (from AXI lite register)   149    signal s_subClass    : sl;
   150    -- User reset (from AXI lite register)   151    signal s_gtReset     : sl;
   153    signal s_invertSync      : sl;
   154    signal s_clearErr        : sl;
   166    -- Sysref conditioning   167    signal s_sysrefSync : sl;
   168    signal s_sysrefD    : sl;
   169    signal s_sysrefRe   : sl;
   171    -- Record containing GT signals   173    signal s_rawData     : slv32Array(L_G-1 downto 0);
   175    -- Generate pause signal logic OR   176    signal s_linkErrMask : slv(5 downto 0);
   180    -- Check JESD generics   181    assert (((K_G * F_G) mod GT_WORD_SIZE_C) = 0) report "K_G setting is incorrect" severity failure;
   182    assert (F_G = 1 or F_G = 2 or (F_G = 4 and GT_WORD_SIZE_C = 4)) report "F_G setting must be 1,2,or 4*" severity failure;
   184    -- Legacy Interface that we will remove in the future   187    -----------------------------------------------------------   188    -- AXI Lite AXI clock domain crossed   189    -----------------------------------------------------------   191    GEN_rawData : for I in L_G-1 downto 0 generate   192       s_rawData(I) <= s_jesdGtRxArr(I).data;
   193    end generate GEN_rawData;
   195    -- axiLite register interface   230    -----------------------------------------------------------   232    -----------------------------------------------------------     235    -- Generate TX test core if TEST_G=true is selected   236    TEST_GEN : if TEST_G = true generate   237       -----------------------------------------   238       TX_LANES_GEN : for I in L_G-1 downto 0 generate   253       end generate TX_LANES_GEN;
   254    end generate TEST_GEN;
   256    -- ELSE   (not TEST_G) just connect to the input from the MGT   257    GT_OPER_GEN : if TEST_G = false generate   258       -----------------------------------------   259       -- Use input from GTX   261    end generate GT_OPER_GEN;
   262    ----------------------------------------    264    -----------------------------------------------------------   266    -----------------------------------------------------------        267    -- Synchronize SYSREF input to devClk_i   284    -- Delay SYSREF input (for 1 to 32 c-c)   293          dly_i    => s_sysrefDlyRx,
   298    -- LMFC period generator aligned to SYSREF input   307          --nSync_i     => '0', -- r.nSyncAnyD1,        309          sysref_i   => s_sysrefD,
       -- Delayed SYSREF IN   310          sysrefRe_o => s_sysrefRe,
      -- Rising-edge of SYSREF OUT   314    -----------------------------------------------------------   315    -- Receiver modules (L_G)   316    -----------------------------------------------------------    318    -- JESD Receiver modules (one module per Lane)   319    generateRxLanes : for I in L_G-1 downto 0 generate   328             sysRef_i     => s_sysrefRe,
  -- Rising-edge of SYSREF   334             inv_i        => s_invertData
(I
), 
   347    -- Test signal generator   348    generatePulserLanes : for I in L_G-1 downto 0 generate   363    -- Put sync output in 'z' if not enabled   364    syncVectEn : for I in L_G-1 downto 0 generate   365       s_nSyncVecEn(I) <= s_nSyncVec(I) or not s_enableRx(I);
   366    end generate syncVectEn;
   368    -- Combine nSync signals from all receivers   369    s_nSyncAny <= '0' when allBits (s_enableRx, '0') else uAnd(s_nSyncVecEn);
   372    comb : 
process (r, 
devRst_i, s_nSyncAll, s_nSyncAny) 
is   373       variable v : RegType;
   375       v.nSyncAnyD1 := s_nSyncAny;
   387          r <= rin after TPD_G;
   393    -- Invert/or not nSync signal (control from axil)   394    nSync_o         <= r.nSyncAnyD1 when s_invertSync = '0' else not r.nSyncAnyD1;
   396    leds_o          <= uOr(s_dataValidVec) & s_nSyncAny;
   401 ----------------------------------------------------- 
array(natural range <> ) of slv((   GT_WORD_SIZE_C* 8)- 1 downto  0)   sampleDataArray
 
out alignTxArr_oalignTxArray(   L_G- 1 downto  0)  
 
out thresoldLowArr_oSlv16Array(   L_G- 1 downto  0)  
 
out enableRx_oslv(   L_G- 1 downto  0)  
 
L_Gpositive   range  1 to  32:= 2
 
in rstsl  :=not    RST_POLARITY_G
 
out dataValidVec_oslv(   L_G- 1 downto  0)  
 
out rxAxisMasterArr_oAxiStreamMasterArray(   L_G- 1 downto  0)  
 
AxiStreamMasterType  :=(tValid  => '0',tData  =>( others => '0'),tStrb  =>( others => '1'),tKeep  =>( others => '1'),tLast  => '0',tDest  =>( others => '0'),tId  =>( others => '0'),tUser  =>( others => '0')) AXI_STREAM_MASTER_INIT_C
 
BYPASS_SYNC_Gboolean  :=   false
 
out axilWriteSlaveAxiLiteWriteSlaveType  
 
in sampleData_islv((   GT_WORD_SIZE_C* 8)- 1 downto  0)  
 
array(natural range <> ) of slv((   RX_STAT_WIDTH_C)- 1 downto  0)   rxStatuRegisterArray
 
in delay_islv( 3 downto  0)  
 
out linkErrMask_oslv( 5 downto  0)  
 
in rawData_islv32Array(   L_G- 1 downto  0)  
 
out sampleDataArr_osampleDataArray(   L_G- 1 downto  0)  
 
in r_jesdGtRxjesdGtRxLaneType  
 
in dly_islv(   DLY_WIDTH_G- 1 downto  0)  
 
in axilReadMasterAxiLiteReadMasterType  
 
slv( 1 downto  0)  :=   "10" AXI_RESP_SLVERR_C
 
AXI_ERROR_RESP_Gslv( 1 downto  0)  :=   AXI_RESP_SLVERR_C
 
in axilWriteMasterAxiLiteWriteMasterType  :=   AXI_LITE_WRITE_MASTER_INIT_C
 
array(natural range <> ) of slv((   GT_WORD_SIZE_C)- 1 downto  0)   alignTxArray
 
out axilReadSlaveAxiLiteReadSlaveType  
 
in thresoldHigh_islv((   F_G* 8)- 1 downto  0)  
 
out rxPolarityslv(   L_G- 1 downto  0)  
 
positive  := 4 GT_WORD_SIZE_C
 
array(natural range <> ) of AxiStreamCtrlType   AxiStreamCtrlArray
 
out sysrefDlyRx_oslv(   SYSRF_DLY_WIDTH_C- 1 downto  0)  
 
out thresoldHighArr_oSlv16Array(   L_G- 1 downto  0)  
 
out pulse_oslv(   L_G- 1 downto  0)  
 
in axilReadMasterAxiLiteReadMasterType  :=   AXI_LITE_READ_MASTER_INIT_C
 
AXI_ERROR_RESP_Gslv( 1 downto  0)  :=   AXI_RESP_SLVERR_C
 
array(natural range <> ) of AxiStreamMasterType   AxiStreamMasterArray
 
out gtRxReset_oslv(   L_G- 1 downto  0)  
 
out invertData_oslv(   L_G- 1 downto  0)  
 
in axilWriteMasterAxiLiteWriteMasterType  
 
array(natural range <> ) of slv( 15 downto  0)   Slv16Array
 
positive  := 5 SYSRF_DLY_WIDTH_C
 
AxiStreamCtrlType  :=(pause  => '0',overflow  => '0',idle  => '1') AXI_STREAM_CTRL_UNUSED_C
 
out sampleData_oslv((   GT_WORD_SIZE_C* 8)- 1 downto  0)  
 
out status_oslv((   RX_STAT_WIDTH_C)- 1 downto  0)  
 
in r_jesdGtRxArrjesdGtRxLaneTypeArray(   L_G- 1 downto  0)  
 
in linkErrMask_islv( 5 downto  0)  :=( others => '1')
 
out r_jesdGtRxjesdGtRxLaneType  
 
in thresoldLow_islv((   F_G* 8)- 1 downto  0)  
 
RST_ASYNC_Gboolean  :=   false
 
in align_islv(   GT_WORD_SIZE_C- 1 downto  0)  
 
array(natural range <> ) of jesdGtRxLaneType   jesdGtRxLaneTypeArray
 
out dlyTxArr_oSlv4Array(   L_G- 1 downto  0)  
 
out leds_oslv( 1 downto  0)  
 
out rxPolarityslv(   L_G- 1 downto  0)  
 
in rxCtrlArr_iAxiStreamCtrlArray(   L_G- 1 downto  0)  :=( others =>   AXI_STREAM_CTRL_UNUSED_C)
 
in statusRxArr_irxStatuRegisterArray(   L_G- 1 downto  0)  
 
L_Gpositive   range  1 to  32:= 2
 
array(natural range <> ) of slv( 3 downto  0)   Slv4Array
 
out axilWriteSlaveAxiLiteWriteSlaveType  
 
out axilReadSlaveAxiLiteReadSlaveType