1 ------------------------------------------------------------------------------- 2 -- File : JesdSyncFsmRx.vhd 3 -- Company : SLAC National Accelerator Laboratory 4 -- Created : 2015-04-14 5 -- Last update: 2015-04-14 6 ------------------------------------------------------------------------------- 7 -- Description: Synchronizer Finite state machine 8 -- Finite state machine for sub-class 1 deterministic latency 9 -- lane synchronization. 10 -- It also supports sub-class 0 non deterministic mode. 11 ------------------------------------------------------------------------------- 12 -- This file is part of 'SLAC Firmware Standard Library'. 13 -- It is subject to the license terms in the LICENSE.txt file found in the 14 -- top-level directory of this distribution and at: 15 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. 16 -- No part of 'SLAC Firmware Standard Library', including this file, 17 -- may be copied, modified, propagated, or distributed except according to 18 -- the terms contained in the LICENSE.txt file. 19 ------------------------------------------------------------------------------- 22 use ieee.std_logic_1164.
all;
23 use ieee.std_logic_arith.
all;
24 use ieee.std_logic_unsigned.
all;
30 --! @ingroup protocols_jesd204b 35 -- Number of bytes in a frame 38 -- Number of frames in a multi frame 41 -- Number of multi-frames in ILA sequence (4-255) 53 -- JESD subclass selection: '0' or '1'(default) 56 -- SYSREF for subcalss 1 fixed latency 59 -- Data and character inputs from GT (transceivers) 63 -- Local multi frame clock 66 -- One or more RX modules requested synchronization 70 -- Combined link errors 73 -- Synchronous FSM control outputs 75 -- Synchronization request 78 -- Elastic buffer latency in clock cycles 81 -- Read enable for Rx Buffer. 82 -- Holds buffers between first data and LMFC 85 -- First non comma (K) character detected. 86 -- To indicate when to realign sample within the dataRx. 89 -- Ila frames are being received 98 -- Synchronisation process is complete and data is valid 116 type RegType is record 117 -- Synchronous FSM control outputs 129 cnt : slv(7 downto 0);
130 cntLatency : slv(7 downto 0);
136 constant REG_INIT_C : RegType := ( 148 cnt => (others => '0'), 149 cntLatency => (others => '0'), 155 signal r : RegType := REG_INIT_C;
156 signal rin : RegType;
158 signal s_kDetected : sl;
159 signal s_kStable : sl;
164 -- Comma detected if detected in three consecutive clock cycles 165 s_kStable <= s_kDetected and r.kDetectRegD1 and r.kDetectRegD2 and r.kDetectRegD3;
168 comb :
process (
rst, r,
enable_i,
sysRef_i,
dataRx_i,
subClass_i,
chariskRx_i,
lmfc_i,
nSyncAnyD1_i,
nSyncAny_i,
linkErr_i,
gtReady_i, s_kDetected, s_kStable)
is 169 variable v : RegType;
171 -- Latch the current value 174 -- Comma detected pipeline 176 v.kDetectRegD2 := r.kDetectRegD1;
177 v.kDetectRegD3 := r.kDetectRegD2;
183 ---------------------------------------------------------------------- 193 v.cntLatency := (others => '0');
195 -- Next state condition (depending on subclass) 205 ---------------------------------------------------------------------- 215 v.cntLatency := (others => '0');
217 -- Next state condition 218 if s_kDetected = '1' and lmfc_i = '1' then 223 ---------------------------------------------------------------------- 233 v.cntLatency := (others => '0');
235 -- Next state condition 236 if s_kDetected = '0' then 238 -- v.readBuff := '0'; -- TODO this signal has to be applied one c-c earlier for simulation 239 -- But in hardware that is not the case. This should be investigated. 243 ---------------------------------------------------------------------- 253 v.cntLatency := r.cntLatency + 1;
255 -- Next state condition 262 ---------------------------------------------------------------------- 272 v.cntLatency := r.cntLatency;
274 -- Put ILA Sequence counter to 0 275 v.cnt := (others => '0');
277 -- Next state condition 280 ---------------------------------------------------------------------- 289 v.cntLatency := r.cntLatency;
291 -- Increase lmfc counter. 296 -- Next state condition 297 -- After NUM_ILAS_MF_G LMFC clocks the ILA sequence ends and relevant ADC data is being received. 300 elsif enable_i = '0' or s_kStable = '1' then 303 ---------------------------------------------------------------------- 312 v.cntLatency := r.cntLatency;
314 -- Next state condition 318 ---------------------------------------------------------------------- 327 v.cntLatency := (others => '0');
329 -- Next state condition 331 ---------------------------------------------------------------------- 339 -- Register the variable for next clock cycle 344 seq :
process (
clk)
is 346 if rising_edge(clk) then 347 r <= rin after TPD_G;
out buffLatency_oslv( 7 downto 0)
in dataRx_islv(( GT_WORD_SIZE_C* 8)- 1 downto 0)
NUM_ILAS_MF_Gpositive := 4
positive := 4 GT_WORD_SIZE_C
in chariskRx_islv( GT_WORD_SIZE_C- 1 downto 0)