1 ------------------------------------------------------------------------------- 2 -- File : GLinkGtx7RxRst.vhd 3 -- Company : SLAC National Accelerator Laboratory 4 -- Created : 2012-12-17 5 -- Last update: 2014-11-10 6 ------------------------------------------------------------------------------- 7 -- Description: G-Link GTX7 Reset module 8 ------------------------------------------------------------------------------- 9 -- This file is part of 'SLAC Firmware Standard Library'. 10 -- It is subject to the license terms in the LICENSE.txt file found in the 11 -- top-level directory of this distribution and at: 12 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. 13 -- No part of 'SLAC Firmware Standard Library', including this file, 14 -- may be copied, modified, propagated, or distributed except according to 15 -- the terms contained in the LICENSE.txt file. 16 ------------------------------------------------------------------------------- 19 use ieee.std_logic_1164.
all;
21 use ieee.std_logic_unsigned.
all;
22 use ieee.std_logic_arith.
all;
25 --! @ingroup protocols_glink_gtx7 31 STABLE_CLOCK_PERIOD : range 4 to 20 := 8;
--Period of the stable clock driving this state-machine, unit is [ns] 36 STABLE_CLOCK : in ;
--Stable Clock, either a stable clock from the PCB 37 --or reference-clock present at startup. 41 PLLLOCK : in ;
--Lock Detect from the PLL of the GT 62 -- Retries it took to get the transceiver up and running 67 -- * Timing depends on the frequency of the stable clock. Hence counters-sizes 68 -- are calculated at design-time based on the Generics 70 -- * if either of the PLLs is reset during TX-startup, it does not need to be reset again by RX 71 -- => signal which PLL has been reset 78 INIT, ASSERT_ALL_RESETS, RELEASE_PLL_RESET, VERIFY_RECCLK_STABLE, 79 RELEASE_MMCM_RESET, WAIT_RESET_DONE, DO_PHASE_ALIGNMENT, 80 MONITOR_DATA_VALID, FSM_DONE);
85 constant STARTUP_DELAY : := 500;
--AR43482: Transceiver needs to wait for 500 ns after configuration 116 signal time_out_2ms : := '0';
--\Flags that the various time-out points 130 constant MAX_WAIT_BYPASS : := 5000;
--5000 RXUSRCLK cycles is the max time for Multi lanes designs 149 Synchronizer_run_phase_alignment, 150 Synchronizer_fsm_reset_done, 151 Synchronizer_SOFT_RESET, 152 Synchronizer_RXRESETDONE, 153 Synchronizer_time_out_wait_bypass, 154 Synchronizer_mmcm_lock_reclocked, 155 Synchronizer_data_valid, 156 Synchronizer_PLLLOCK, 157 Synchronizer_PHALIGNMENT_DONE : label is "TRUE";
161 --Alias section, signals used within this module mapped to output ports: 169 -- The counter starts running when configuration has finished and 170 -- the clock is stable. When its maximum count-value has been reached, 171 -- the 500 ns from Answer Record 43482 have been passed. 203 --This counter monitors, how many retries the RECCLK monitor 204 --runs. If during startup too many retries are necessary, the whole 205 --initialisation-process of the transceivers gets restarted. 222 -- One common large counter for generating three time-out signals. 223 -- Intermediate time-outs are derived from calculated values, based 224 -- on the period of the provided clock. 262 --The lock-signal from the MMCM is not immediately used but 263 --enabling a counter. Only when the counter hits its maximum, 264 --the MMCM is considered as "really" locked. 265 --The counter avoids that the FSM already starts on only a 266 --coarse lock of the MMCM (=toggling of the LOCK-signal). 280 -- Clock Domain Crossing 281 Synchronizer_run_phase_alignment :
entity work.
Synchronizer 321 Synchronizer_time_out_wait_bypass :
entity work.
Synchronizer 331 Synchronizer_mmcm_lock_reclocked :
entity work.
Synchronizer 356 -- Phase aligner might run on rxusrclk in some cases 357 -- Synchronizer it just in case 358 Synchronizer_PHALIGNMENT_DONE :
entity work.
Synchronizer 383 -- Lock Detect Clock should be driven by STABLE_CLOCK, no need to synchronize 388 --FSM for resetting the GTX/GTH/GTP in the 7-series. 389 --~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 391 -- Following steps are performed: 392 -- 1) After configuration wait for approximately 500 ns as specified in 393 -- answer-record 43482 394 -- 2) Assert all resets on the GT and on an MMCM potentially connected. 395 -- After that wait until a reference-clock has been detected. 396 -- 3) Release the reset to the GT and wait until the GT-PLL has locked. 397 -- 4) Release the MMCM-reset and wait until the MMCM has signalled lock. 398 -- Also get info from the TX-side which PLL has been reset. 399 -- 5) Wait for the RESET_DONE-signal from the GT. 400 -- 6) Signal to start the phase-alignment procedure and wait for it to 402 -- 7) Reset-sequence has successfully run through. Signal this to the 403 -- rest of the design by asserting RX_FSM_RESET_DONE. 434 --Initial state after configuration. This state will be left after 435 --approx. 500 ns and not be re-entered. 440 when ASSERT_ALL_RESETS => 441 --This is the state into which the FSM will always jump back if any 442 --time-outs will occur. 443 --The number of retries is reported on the output RETRY_COUNTER. In 444 --case the transceiver never comes up for some reason, this machine 445 --will still continue its best and rerun until the FPGA is turned off 446 --or the transceivers come up correctly. 469 when RELEASE_PLL_RESET => 470 --PLL-Reset of the GTX gets released and the time-out counter 485 -- If too many retries are performed compared to what is specified in 486 -- the generic, the counter simply wraps around. 494 when VERIFY_RECCLK_STABLE => 495 --reset_time_out <= '0'; 496 --Time-out counter is not released in this state as here the FSM 497 --does not wait for a certain period of time but checks on the number 498 --of retries in the RECCLK monitor 507 --If two retries are performed in the RECCLK monitor 508 --the whole initialisation-sequence gets restarted. 510 -- If too many retries are performed compared to what is specified in 511 -- the generic, the counter simply wraps around. 519 when RELEASE_MMCM_RESET => 520 --Release of the MMCM-reset. Waiting for the MMCM to lock. 532 -- If too many retries are performed compared to what is specified in 533 -- the generic, the counter simply wraps around. 541 when WAIT_RESET_DONE => 542 --When TXOUTCLK is the source for RXUSRCLK, RXUSERRDY depends on TXUSERRDY 543 --If RXOUTCLK is the source for RXUSRCLK, TXUSERRDY can be tied to '1' 555 -- If too many retries are performed compared to what is specified in 556 -- the generic, the counter simply wraps around. 564 when DO_PHASE_ALIGNMENT => 565 --The direct handling of the signals for the Phase Alignment is done outside 566 --this state-machine. 578 -- If too many retries are performed compared to what is specified in 579 -- the generic, the counter simply wraps around. 587 when MONITOR_DATA_VALID => 594 elsif fsmCnt = x"FFFF" then integer range 0 to WAIT_TIMEOUT_2ms:= 0 time_out_counter
out RESET_PHALIGNMENTstd_logic := '0'
out RXDFEAGCHOLDstd_logic
std_logic := '0' data_valid_sync
rx_rst_fsm_type := INIT rx_state
integer range 0 to MAX_RETRIES:= 0 retry_counter_int
integer := 100000/ STABLE_CLOCK_PERIOD WAIT_TLOCK_MAX
integer range 0 to WAIT_MAX:= 0 init_wait_count
integer := 5000 MAX_WAIT_BYPASS
std_logic := '0' adapt_count_reset
EXAMPLE_SIMULATIONinteger := 0
in PLLREFCLKLOSTstd_logic
integer := 2** RETRY_COUNTER_BITWIDTH- 1 MAX_RETRIES
in RECCLK_STABLEstd_logic
integer := WAIT_CYCLES+ 10 WAIT_MAX
std_logic_vector( 15 downto 0) fsmCnt
std_logic := '0' rx_fsm_reset_done_int_s3
STABLE_CLOCK_PERIODinteger range 4 to 20:= 8
integer range 0 to WAIT_TIME_ADAPT- 1 adapt_count
std_logic := '0' time_out_adapt
std_logic_vector( 3 downto 0) :=( others => '0') mmcm_lock_reclocked
std_logic := '0' time_out_500us
std_logic := '0' time_out_100us
RETRY_COUNTER_BITWIDTHinteger range 2 to 8:= 8
std_logic := '0' reset_time_out
std_logic soft_reset_rise
std_logic := '0' check_tlock_max
integer := 1024 MMCM_LOCK_CNT_MAX
std_logic := '0' time_tlock_max
in RECCLK_MONITOR_RESTARTstd_logic := '0'
in PHALIGNMENT_DONEstd_logic
std_logic := '0' run_phase_alignment_int_s3
integer := 1000/ STABLE_CLOCK_PERIOD WAIT_TIMEOUT_1us
integer := 100000/ STABLE_CLOCK_PERIOD WAIT_TIMEOUT_100us
integer range 0 to MMCM_LOCK_CNT_MAX- 1:= 0 mmcm_lock_count
std_logic := '0' pll_reset_asserted
std_logic := '0' mmcm_lock_int
std_logic soft_reset_sync
integer := STARTUP_DELAY/ STABLE_CLOCK_PERIOD WAIT_CYCLES
std_logic := '0' time_out_wait_bypass_s3
(INIT,ASSERT_ALL_RESETS,RELEASE_PLL_RESET,VERIFY_RECCLK_STABLE,RELEASE_MMCM_RESET,WAIT_RESET_DONE,DO_PHASE_ALIGNMENT,MONITOR_DATA_VALID,FSM_DONE) rx_rst_fsm_type
integer range 0 to 3:= 0 recclk_mon_restart_count
std_logic := '0' run_phase_alignment_int
out RX_FSM_RESET_DONEstd_logic
std_logic soft_reset_fall
std_logic := '0' time_out_2ms
out PLL_RESETstd_logic := '0'
integer := 500 STARTUP_DELAY
out MMCM_RESETstd_logic := '1'
std_logic := '0' time_out_1us
integer := 500000/ STABLE_CLOCK_PERIOD WAIT_TIMEOUT_500us
out GTRXRESETstd_logic := '0'
integer := 3000000/ STABLE_CLOCK_PERIOD WAIT_TIMEOUT_2ms
std_logic := '0' phalignment_done_sync
out RXUSERRDYstd_logic := '0'
integer :=( 37000000/ integer( 3.125))/ STABLE_CLOCK_PERIOD WAIT_TIME_ADAPT
std_logic := '0' recclk_mon_count_reset
std_logic := '0' init_wait_done
out RUN_PHALIGNMENTstd_logic
std_logic := '0' rx_fsm_reset_done_int
std_logic := '0' plllock_sync
out RETRY_COUNTERstd_logic_vector( RETRY_COUNTER_BITWIDTH- 1 downto 0) :=( others => '0')
std_logic := '0' time_out_wait_bypass
integer range 0 to MAX_WAIT_BYPASS- 1 wait_bypass_count
std_logic := '0' rxresetdone_s3