1 -------------------------------------------------------------------------------     2 -- File       : JesdRxLane.vhd     3 -- Company    : SLAC National Accelerator Laboratory     4 -- Created    : 2015-04-14     5 -- Last update: 2017-06-22     6 -------------------------------------------------------------------------------     7 -- Description: JesdRx single lane module     8 --              Receiver JESD204b standard.     9 --              Supports sub-class 1 deterministic latency.    10 --              Supports sub-class 0 non deterministic latency    12 --              - Comma synchronization    13 --              - Internal buffer to align the lanes.    14 --              - Sample data alignment (Sample extraction from GT word - barrel shifter).    15 --              - Alignment character replacement.    16 --              - Scrambling support    17 --             Status register encoding:    18 --                bit 0: GT Reset done    19 --                bit 1: Received data valid    20 --                bit 2: Received data is misaligned    21 --                bit 3: Synchronization output status     22 --                bit 4: Rx buffer overflow    23 --                bit 5: Rx buffer underflow    24 --                bit 6: Comma position not as expected during alignment    25 --                bit 7: RX module enabled status    26 --                bit 8: SysRef detected (active only when the lane is enabled)    27 --                bit 9: Comma (K28.5) detected    28 --                bit 10-13: Disparity error    29 --                bit 14-17: Not in table Error    30 --                bit 18-25: 8-bit buffer latency    31 --                bit 26: CDR Status of the GTH (Not used in yaml)    33 --          Note: sampleData_o is little endian and not byte swapped    34 --                First sample in time:  sampleData_o(15 downto 0)     35 --                Second sample in time: sampleData_o(31 downto 16)    37 --          Note: The output ADC sample data can be inverted.    38 --                     inv_i:     '1' Inverted,      '0' Normal    39 --                If inverted the mode can be chosen:    40 --                     invMode_i: '1' Offset binary, '0' Twos complement     41 -------------------------------------------------------------------------------    42 -- This file is part of 'SLAC Firmware Standard Library'.    43 -- It is subject to the license terms in the LICENSE.txt file found in the     44 -- top-level directory of this distribution and at:     45 --    https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.     46 -- No part of 'SLAC Firmware Standard Library', including this file,     47 -- may be copied, modified, propagated, or distributed except according to     48 -- the terms contained in the LICENSE.txt file.    49 -------------------------------------------------------------------------------    52 use ieee.std_logic_1164.
all;
    53 use ieee.std_logic_arith.
all;
    54 use ieee.std_logic_unsigned.
all;
    60  --! @ingroup protocols_jesd204b    65       -- Number of bytes in a frame    68       -- Number of frames in a multi frame    78       -- JESD subclass selection: '0' or '1'(default)         81       -- SYSREF for subclass 1 fixed latency    84       -- Clear registered errors         93       -- Data and character inputs from GT (transceivers)    96       -- Local multi frame clock   102       -- One or more RX modules requested synchronization   109       -- Synchronization request output    112       -- Synchronization process is complete and data is valid   124    type RegType is record   126       errReg          : slv(ERR_REG_WIDTH_C-1 downto 0);
   128       sampleDataValid : sl;
   132    constant REG_INIT_C : RegType := (   134       errReg          => (others => '0'),   135       sampleData      => (others => '0'),   136       sampleDataValid => '0',   140    signal r   : RegType := REG_INIT_C;
   141    signal rin : RegType;
   145    -- Control signals from FSM   147    signal s_readBuff   : sl;
   148    signal s_alignFrame : sl;
   150    signal s_dataValid  : sl;
   153    signal s_bufRst : sl;
   159    signal s_charAndDataBuff : slv(s_charAndData'range);
   161    signal s_sampleDataValid : sl;
   164    signal s_bufOvf      : sl;
   165    signal s_bufUnf      : sl;
   166    signal s_bufFull     : sl;
   167    signal s_alignErr    : sl;
   168    signal s_positionErr : sl;
   169    signal s_linkErrVec  : slv(5 downto 0);
   170    signal s_linkErr     : sl;
   171    signal s_kDetected   : sl;
   172    signal s_refDetected : sl;
   173    signal s_errComb     : slv(ERR_REG_WIDTH_C-1 downto 0);
   174    signal s_buffLatency : slv(7 downto 0);
   178    s_charAndData <= r.jesdGtRx.dataK & r.jesdGtRx.data;
   182    s_bufWe  <= not s_bufRst and not s_bufFull;
   183    s_bufRe  <= r.bufWeD1 and s_readBuff;
   185    -- Buffer samples between first data and LMFC   186    -- Min size one LMFC period   187    RX_buffer_fifo_INST : 
entity work.
FifoSync   199          -- ADDR_WIDTH_G   => bitSize((K_G * F_G)/GT_WORD_SIZE_C),   207          wr_en        => s_bufWe,
       -- Always write when enabled   208          rd_en        => s_bufRe,
  -- Hold read while sync not in sync with LMFC   209          din          => s_charAndData,
   210          dout         => s_charAndDataBuff,
   225    -- Synchronization FSM   245          -- buffLatency_o => s_buffLatency,   254    -- Align the rx data within the GT word and replace the characters.    266          dataRx_i          => s_charAndDataBuff
((GT_WORD_SIZE_C*8
)-
1 downto 0),
   267          chariskRx_i       => s_charAndDataBuff
(((GT_WORD_SIZE_C*8
)+GT_WORD_SIZE_C
)-
1 downto (GT_WORD_SIZE_C*8
)),
   278          -- Link error masked by the mask from register and ORed   279          s_linkErrVec <= s_positionErr & s_bufOvf & s_bufUnf & uOr(r.jesdGtRx.dispErr) & uOr(r.jesdGtRx.decErr) & s_alignErr after TPD_G;
   282          -- Combine errors that need registering   283          s_errComb <= r.jesdGtRx.decErr & r.jesdGtRx.dispErr & s_alignErr & s_positionErr & s_bufOvf & s_bufUnf after TPD_G;
   288    -- Synchronous process function:   289    -- - Registering of errors   290    -- - Delay the s_bufWe to use it for s_bufRe   291    -- - Inverting ADC data   292    -------------------------------------------------------------------------------   293    -------------------------------------------------------------------------------   295                    s_bufWe, s_errComb, s_nSync, s_sampleData,
   296                    s_sampleDataValid) 
is   297       variable v : RegType;
   302       v.bufWeD1  := s_bufWe;
   304       -- Register errors (store until reset)   305       if (r.jesdGtRx.rstDone = '1' and s_nSync = '1') then   306          for I in 0 to(ERR_REG_WIDTH_C-1) loop   307             if (s_errComb(I) = '1') and (enable_i = '1') then   313       -- Clear registered errors if module is disabled   315          v.errReg := REG_INIT_C.errReg;
   318       -- Invert sample data   319       v.sampleDataValid := s_sampleDataValid;
   321       if (inv_i = '1') then   322          -- Invert sample data         325          v.sampleData := s_sampleData;
   339          r <= rin after TPD_G;
   347    status_o     <= r.jesdGtRx.cdrStable & s_buffLatency & r.errReg(r.errReg'high downto 4) & s_kDetected & s_refDetected & enable_i & r.errReg(2 downto 0) & s_nSync & r.errReg(3) & s_dataValid & r.jesdGtRx.rstDone;
   348 ----------------------------------------------------------------------------------------- ADDR_WIDTH_Ginteger   range  4 to  48:= 4
 
USE_DSP48_Gstring  :=   "no"
 
in chariskRx_islv(   GT_WORD_SIZE_C- 1 downto  0)  
 
in rstsl  :=not    RST_POLARITY_G
 
slv(   GT_WORD_SIZE_C- 1 downto  0)   dataK
 
positive  := 19+ 2*   GT_WORD_SIZE_C RX_STAT_WIDTH_C
 
out data_countslv(   ADDR_WIDTH_G- 1 downto  0)  
 
PIPE_STAGES_Gnatural   range  0 to  16:= 0
 
in dataRx_islv((   GT_WORD_SIZE_C* 8)- 1 downto  0)  
 
in r_jesdGtRxjesdGtRxLaneType  
 
out sampleData_oslv((   GT_WORD_SIZE_C* 8)- 1 downto  0)  
 
ALTERA_RAM_Gstring  :=   "M9K"
 
DATA_WIDTH_Ginteger   range  1 to ( 2** 24):= 16
 
in dinslv(   DATA_WIDTH_G- 1 downto  0)  
 
FULL_THRES_Ginteger   range  1 to ( 2** 24):= 1
 
slv(   GT_WORD_SIZE_C- 1 downto  0)   dispErr
 
positive  := 4 GT_WORD_SIZE_C
 
out doutslv(   DATA_WIDTH_G- 1 downto  0)  
 
in dataRx_islv((   GT_WORD_SIZE_C* 8)- 1 downto  0)  
 
ALTERA_SYN_Gboolean  :=   false
 
out sampleData_oslv((   GT_WORD_SIZE_C* 8)- 1 downto  0)  
 
RST_ASYNC_Gboolean  :=   false
 
out status_oslv((   RX_STAT_WIDTH_C)- 1 downto  0)  
 
jesdGtRxLaneType  :=(data  =>( others => '0'),dataK  =>( others => '0'),dispErr  =>( others => '0'),decErr  =>( others => '0'),rstDone  => '0',cdrStable  => '0') JESD_GT_RX_LANE_INIT_C
 
in linkErrMask_islv( 5 downto  0)  :=( others => '1')
 
FWFT_EN_Gboolean  :=   false
 
slv(   GT_WORD_SIZE_C- 1 downto  0)   decErr
 
EMPTY_THRES_Ginteger   range  1 to ( 2** 24):= 1
 
slv((   GT_WORD_SIZE_C* 8)- 1 downto  0)   data
 
in chariskRx_islv(   GT_WORD_SIZE_C- 1 downto  0)