1 ------------------------------------------------------------------------------- 2 -- File : Pgp2bRxPhy.vhd 3 -- Company : SLAC National Accelerator Laboratory 4 -- Created : 2009-05-27 5 -- Last update: 2017-03-28 6 ------------------------------------------------------------------------------- 8 -- Physical interface receive module for the Pretty Good Protocol version 2 core. 9 ------------------------------------------------------------------------------- 10 -- This file is part of 'SLAC Firmware Standard Library'. 11 -- It is subject to the license terms in the LICENSE.txt file found in the 12 -- top-level directory of this distribution and at: 13 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. 14 -- No part of 'SLAC Firmware Standard Library', including this file, 15 -- may be copied, modified, propagated, or distributed except according to 16 -- the terms contained in the LICENSE.txt file. 17 ------------------------------------------------------------------------------- 20 use ieee.std_logic_1164.
all;
21 use ieee.std_logic_arith.
all;
22 use ieee.std_logic_unsigned.
all;
27 --! @ingroup protocols_pgp_pgp2b_core 31 RX_LANE_CNT_G : range 1 to 2 := 1 -- Number of receive lanes, 1-2 35 -- System clock, reset & control 43 -- Error Flags, one pulse per event 47 -- Opcode Receive Interface 53 pgpRemData : out slv(7 downto 0) := (others => '0');
-- Far end side User Data 55 -- Cell Receive Interfac e 64 -- Physical Interface Signals 77 -- Define architecture 123 -- Physical Link State 140 -- Opcode Receive Interface 144 -- Cell Receive Interface 153 -- Drive active polarity control signals 158 -- State transition sync logic. 188 -- Link down edge detection 192 -- Link error generation 199 -- Link error edge detection 230 -- Link control state machine 236 -- Hold in rx reset for 8 clocks 244 -- Hold reset for 255 clocks 253 -- Wait for lock state 266 -- Terminal count without lock 275 -- Wait for training pattern 288 -- Decode or disparity error, clear lts count 296 -- Training pattern seen 305 -- ID & Lane Count Ok 322 -- Run after we have seen 256 non-inverted training sequences 323 -- without any disparity or decode errors. 331 -- Terminal count without seeing a valid LTS 339 -- Count cycles without LTS 348 -- Wait a few clocks after inverting receive interface 378 -- Training sequence seen 381 -- Link is inverted or bad lts, reset and relink 392 -- Link is down after long period without seeing a LTS 393 -- Min spacing of LTS is 2 Cells = 2 * 256 = 512 394 -- Timeout set at 4096 = 8 cells 395 elsif stateCnt(11 downto 0) = x"FFF" then 399 -- Count cycles without LTS 418 -- Receive data pipeline 446 -- Link init ordered set detect 463 -- LTS is detected when phy is ready 466 -- Detect link init ordered sets 472 -- Lane count and ID must match 493 -- The remaining opcodes are only detected when the link is up 496 -- Detect opCode ordered set 504 -- Detect SOC ordered set 509 -- Detect SOF ordered set 518 -- Detect EOC ordered set 524 -- Detect EOF ordered set 530 -- Detect EOFE ordered set 555 -- Ordered Set Detection 559 -- Skip errored decodes 565 -- Link init ordered set 572 -- Detect Link Inversion 637 -- Generate Loop for unused lanes slv( 1 downto 0) rxDetectOpCodeEnRaw
out pgpRxLinkErrorsl := '0'
slv( 2 downto 0) := "011" ST_WAIT_C
slv( 2 downto 0) := "001" ST_RESET_C
slv( RX_LANE_CNT_G* 2- 1 downto 0) :=( others => '0') dly0RxDataK
slv( RX_LANE_CNT_G- 1 downto 0) :=( others => '0') intRxPolarity
out pgpRemLinkReadysl := '0'
slv( RX_LANE_CNT_G* 16- 1 downto 0) :=( others => '0') dly1RxData
slv( 1 downto 0) rxDetectEOFRaw
slv( 7 downto 0) := "11111011" K_SOC_C
out pgpRxLinkDownsl := '0'
slv( 7 downto 0) := "11111101" K_EOF_C
slv( 1 downto 0) rxDetectSOFRaw
slv( RX_LANE_CNT_G* 2- 1 downto 0) :=( others => '0') dly0RxDecErr
slv( RX_LANE_CNT_G* 2- 1 downto 0) :=( others => '0') dly0RxDispErr
slv( 7 downto 0) := "01011100" K_EOC_C
slv( 7 downto 0) :=( others => '0') ltsCnt
slv( 2 downto 0) := "010" ST_LOCK_C
RX_LANE_CNT_Ginteger range 1 to 2:= 1
slv( RX_LANE_CNT_G* 2- 1 downto 0) :=( others => '0') dly1RxDecErr
slv( RX_LANE_CNT_G* 16- 1 downto 0) :=( others => '0') dly0RxData
slv( RX_LANE_CNT_G* 2- 1 downto 0) :=( others => '0') dly1RxDataK
slv( 7 downto 0) := "00111100" K_LTS_C
slv( 1 downto 0) rxDetectSOCRaw
slv( 7 downto 0) := "01111100" K_OTS_C
slv( 1 downto 0) rxDetectEOCRaw
slv( 7 downto 0) := "11110111" K_SOF_C
in phyRxDecErrslv( RX_LANE_CNT_G* 2- 1 downto 0)
slv( 7 downto 0) := "11111110" K_EOFE_C
out phyRxPolarityslv( RX_LANE_CNT_G- 1 downto 0)
sl := '0' rxDetectOpCodeEn
slv( RX_LANE_CNT_G- 1 downto 0) :=( others => '0') rxDetectInvert
slv( 2 downto 0) := "101" ST_READY_C
slv( 2 downto 0) nxtState
slv( 2 downto 0) := ST_LOCK_C curState
slv( RX_LANE_CNT_G* 2- 1 downto 0) :=( others => '0') dly1RxDispErr
slv( 7 downto 0) := "10110101" D_215_C
slv( 7 downto 0) := "01001010" D_102_C
slv( 1 downto 0) rxDetectEOFERaw
slv( RX_LANE_CNT_G- 1 downto 0) rxDetectInvertRaw
slv( RX_LANE_CNT_G- 1 downto 0) nxtRxPolarity
out pgpRxOpCodeslv( 7 downto 0)
slv( 2 downto 0) := "100" ST_INVRT_C
in phyRxDataslv( RX_LANE_CNT_G* 16- 1 downto 0)
sl := '0' rxDetectRemLink
in phyRxDataKslv( RX_LANE_CNT_G* 2- 1 downto 0)
slv( 1 downto 0) rxDetectLtsRaw
in phyRxDispErrslv( RX_LANE_CNT_G* 2- 1 downto 0)
slv( 19 downto 0) :=( others => '0') stateCnt
out cellRxDataslv( RX_LANE_CNT_G* 16- 1 downto 0)
slv( 3 downto 0) := "0101" PGP2B_ID_C
slv( 7 downto 0) :=( others => '0') rxDetectRemData
out pgpRemDataslv( 7 downto 0) :=( others => '0')