AMC13
Firmwares for the different applications of the AMC13 uTCA board made at Boston University
 All Classes Variables
s6link_rx_startup_fsm.vhd
1 --////////////////////////////////////////////////////////////////////////////////
2 --// ____ ____
3 --// / /\/ /
4 --// /___/ \ / Vendor: Xilinx
5 --// \ \ \/ Version : 2.5
6 --// \ \ Application : 7 Series FPGAs Transceivers Wizard
7 --// / / Filename : s6link_rx_startup_fsm.vhd
8 --// /___/ /\
9 --// \ \ / \
10 --// \___\/\___\
11 --//
12 --//
13 -- Description : This module performs RX reset and initialization.
14 --
15 --
16 --
17 -- Module S6Link_rx_startup_fsm
18 -- Generated by Xilinx 7 Series FPGAs Transceivers Wizard
19 --
20 --
21 -- (c) Copyright 2010-2012 Xilinx, Inc. All rights reserved.
22 --
23 -- This file contains confidential and proprietary information
24 -- of Xilinx, Inc. and is protected under U.S. and
25 -- international copyright and other intellectual property
26 -- laws.
27 --
28 -- DISCLAIMER
29 -- This disclaimer is not a license and does not grant any
30 -- rights to the materials distributed herewith. Except as
31 -- otherwise provided in a valid license issued to you by
32 -- Xilinx, and to the maximum extent permitted by applicable
33 -- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
34 -- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
35 -- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
36 -- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
37 -- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
38 -- (2) Xilinx shall not be liable (whether in contract or tort,
39 -- including negligence, or under any other theory of
40 -- liability) for any loss or damage of any kind or nature
41 -- related to, arising under or in connection with these
42 -- materials, including for any direct, or any indirect,
43 -- special, incidental, or consequential loss or damage
44 -- (including loss of data, profits, goodwill, or any type of
45 -- loss or damage suffered as a result of any action brought
46 -- by a third party) even if such damage or loss was
47 -- reasonably foreseeable or Xilinx had been advised of the
48 -- possibility of the same.
49 --
50 -- CRITICAL APPLICATIONS
51 -- Xilinx products are not designed or intended to be fail-
52 -- safe, or for use in any application requiring fail-safe
53 -- performance, such as life-support or safety devices or
54 -- systems, Class III medical devices, nuclear facilities,
55 -- applications related to the deployment of airbags, or any
56 -- other applications that could lead to death, personal
57 -- injury, or severe property or environmental damage
58 -- (individually and collectively, "Critical
59 -- Applications"). Customer assumes the sole risk and
60 -- liability of any use of Xilinx products in Critical
61 -- Applications, subject only to applicable laws and
62 -- regulations governing limitations on product liability.
63 --
64 -- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
65 -- PART OF THIS FILE AT ALL TIMES.
66 
67 
68 --*****************************************************************************
69 
70 library IEEE;
71 use IEEE.STD_LOGIC_1164.ALL;
72 use IEEE.NUMERIC_STD.ALL;
73 
75  Generic( EXAMPLE_SIMULATION : integer := 0;
76  GT_TYPE : string := "GTX";
77  EQ_MODE : string := "DFE"; --RX Equalisation Mode; set to DFE or LPM
78  STABLE_CLOCK_PERIOD : integer range 4 to 20 := 8; --Period of the stable clock driving this state-machine, unit is [ns]
79  RETRY_COUNTER_BITWIDTH : integer range 2 to 8 := 8;
80  TX_QPLL_USED : boolean := False; -- the TX and RX Reset FSMs must
81  RX_QPLL_USED : boolean := False; -- share these two generic values
82  PHASE_ALIGNMENT_MANUAL : boolean := True -- Decision if a manual phase-alignment is necessary or the automatic
83  -- is enough. For single-lane applications the automatic alignment is
84  -- sufficient
85  );
86  Port ( STABLE_CLOCK : in STD_LOGIC; --Stable Clock, either a stable clock from the PCB
87  --or reference-clock present at startup.
88  RXUSERCLK : in STD_LOGIC; --RXUSERCLK as used in the design
89  SOFT_RESET : in STD_LOGIC; --User Reset, can be pulled any time
90  QPLLREFCLKLOST : in STD_LOGIC; --QPLL Reference-clock for the GT is lost
91  CPLLREFCLKLOST : in STD_LOGIC; --CPLL Reference-clock for the GT is lost
92  QPLLLOCK : in STD_LOGIC; --Lock Detect from the QPLL of the GT
93  CPLLLOCK : in STD_LOGIC; --Lock Detect from the CPLL of the GT
94  RXRESETDONE : in STD_LOGIC;
95  MMCM_LOCK : in STD_LOGIC;
96  RECCLK_STABLE : in STD_LOGIC;
97  RECCLK_MONITOR_RESTART : in STD_LOGIC:='0';
98  DATA_VALID : in STD_LOGIC;
99  TXUSERRDY : in STD_LOGIC; --TXUSERRDY from GT
100  GTRXRESET : out STD_LOGIC:='0';
101  MMCM_RESET : out STD_LOGIC:='1';
102  QPLL_RESET : out STD_LOGIC:='0'; --Reset QPLL (only if RX uses QPLL)
103  CPLL_RESET : out STD_LOGIC:='0'; --Reset CPLL (only if RX uses CPLL)
104  RX_FSM_RESET_DONE : out STD_LOGIC; --Reset-sequence has sucessfully been finished.
105  RXUSERRDY : out STD_LOGIC:='0';
106  RUN_PHALIGNMENT : out STD_LOGIC;
107  PHALIGNMENT_DONE : in STD_LOGIC;
108  RESET_PHALIGNMENT : out STD_LOGIC:='0';
109  RXDFEAGCHOLD : out STD_LOGIC;
110  RXDFELFHOLD : out STD_LOGIC;
111  RXLPMLFHOLD : out STD_LOGIC;
112  RXLPMHFHOLD : out STD_LOGIC;
113  RETRY_COUNTER : out STD_LOGIC_VECTOR (RETRY_COUNTER_BITWIDTH-1 downto 0):=(others=>'0')-- Number of
114  -- Retries it took to get the transceiver up and running
115  );
116 end S6Link_RX_STARTUP_FSM;
117 
118 --Interdependencies:
119 -- * Timing depends on the frequency of the stable clock. Hence counters-sizes
120 -- are calculated at design-time based on the Generics
121 --
122 -- * if either of the PLLs is reset during TX-startup, it does not need to be reset again by RX
123 -- => signal which PLL has been reset
124 -- *
125 
126 
127 
128 architecture RTL of S6Link_RX_STARTUP_FSM is
129  type rx_rst_fsm_type is(
130  INIT, ASSERT_ALL_RESETS, RELEASE_PLL_RESET, VERIFY_RECCLK_STABLE,
131  RELEASE_MMCM_RESET, WAIT_RESET_DONE, DO_PHASE_ALIGNMENT,
132  MONITOR_DATA_VALID, FSM_DONE);
133 
134  signal rx_state : rx_rst_fsm_type := INIT;
135 
136  constant MMCM_LOCK_CNT_MAX : integer := 1024;
137  constant STARTUP_DELAY : integer := 500;--AR43482: Transceiver needs to wait for 500 ns after configuration
138  constant WAIT_CYCLES : integer := STARTUP_DELAY / STABLE_CLOCK_PERIOD; -- Number of Clock-Cycles to wait after configuration
139  constant WAIT_MAX : integer := WAIT_CYCLES + 10; -- 500 ns plus some additional margin
140 
141  constant WAIT_TIMEOUT_2ms : integer := 2000000 / STABLE_CLOCK_PERIOD;-- 2 ms time-out
142  constant WAIT_TLOCK_MAX : integer := 100000 / STABLE_CLOCK_PERIOD;--100 us time-out
143  constant WAIT_TIMEOUT_500us : integer := 500000 / STABLE_CLOCK_PERIOD;--500 us time-out
144  constant WAIT_TIMEOUT_1us : integer := 1000 / STABLE_CLOCK_PERIOD; --1 us time-out
145  constant WAIT_TIMEOUT_100us : integer := 100000 / STABLE_CLOCK_PERIOD; --100 us time-out
146  constant WAIT_TIME_ADAPT : integer := (37000000 /integer(2.5))/STABLE_CLOCK_PERIOD;
147 
148  signal init_wait_count : integer range 0 to WAIT_MAX:=0;
149  signal init_wait_done : std_logic := '0';
150  signal pll_reset_asserted : std_logic := '0';
151  signal rx_fsm_reset_done_int : std_logic := '0';
152  signal rx_fsm_reset_done_int_s1 : std_logic := '0';
153  signal rx_fsm_reset_done_int_s2 : std_logic := '0';
154  signal rx_fsm_reset_done_int_s3 : std_logic := '0';
155 
156  signal rxresetdone_s1 : std_logic := '0';
157  signal rxresetdone_s2 : std_logic := '0';
158  signal rxresetdone_s3 : std_logic := '0';
159 
160  constant MAX_RETRIES : integer := 2**RETRY_COUNTER_BITWIDTH-1;
161  signal retry_counter_int : integer range 0 to MAX_RETRIES := 0;
162  signal time_out_counter : integer range 0 to WAIT_TIMEOUT_2ms := 0;
163  signal recclk_mon_restart_count : integer range 0 to 3:= 0;
164  signal recclk_mon_count_reset : std_logic := '0';
165 
166  signal reset_time_out : std_logic := '0';
167  signal time_out_2ms : std_logic := '0';--\Flags that the various time-out points
168  signal time_tlock_max : std_logic := '0';--|have been reached.
169  signal time_out_500us : std_logic := '0';--|
170  signal time_out_1us : std_logic := '0';--/
171  signal time_out_100us : std_logic := '0';--/
172  signal check_tlock_max : std_logic := '0';
173 
174  signal mmcm_lock_count : integer range 0 to MMCM_LOCK_CNT_MAX-1:=0;
175  signal mmcm_lock_int : std_logic := '0';
176  signal mmcm_lock_reclocked : std_logic_vector(3 downto 0) := (others=>'0');
177 
178  signal run_phase_alignment_int: std_logic := '0';
179  signal run_phase_alignment_int_s1 : std_logic := '0';
180  signal run_phase_alignment_int_s2 : std_logic := '0';
181  signal run_phase_alignment_int_s3 : std_logic := '0';
182 
183  constant MAX_WAIT_BYPASS : integer := 5000;--5000 RXUSRCLK cycles is the max time for Multi lanes designs
184  signal wait_bypass_count : integer range 0 to MAX_WAIT_BYPASS-1;
185  signal time_out_wait_bypass : std_logic := '0';
186  signal time_out_wait_bypass_s1 : std_logic := '0';
187  signal time_out_wait_bypass_s2 : std_logic := '0';
188  signal time_out_wait_bypass_s3 : std_logic := '0';
189 
190  signal refclk_lost : std_logic;
191 
192  signal time_out_adapt : std_logic := '0';
193  signal adapt_count_reset : std_logic := '0';
194  signal adapt_count : integer range 0 to WAIT_TIME_ADAPT-1;
195 
196 begin
197  --Alias section, signals used within this module mapped to output ports:
198  RETRY_COUNTER <= STD_LOGIC_VECTOR(TO_UNSIGNED(retry_counter_int,RETRY_COUNTER_BITWIDTH));
199  RUN_PHALIGNMENT <= run_phase_alignment_int;
200  RX_FSM_RESET_DONE <= rx_fsm_reset_done_int;
201 
202  process(STABLE_CLOCK)
203  begin
204  if rising_edge(STABLE_CLOCK) then
205  -- The counter starts running when configuration has finished and
206  -- the clock is stable. When its maximum count-value has been reached,
207  -- the 500 ns from Answer Record 43482 have been passed.
208  if init_wait_count = WAIT_MAX then
209  init_wait_done <= '1';
210  else
211  init_wait_count <= init_wait_count + 1;
212  end if;
213  end if;
214  end process;
215 
216 
217  adapt_wait_sim:if(EXAMPLE_SIMULATION = 1) generate
218  time_out_adapt <= '1';
219  end generate;
220 
221  adapt_wait_hw:if(EXAMPLE_SIMULATION = 0) generate
222  process(STABLE_CLOCK)
223  begin
224  if rising_edge(STABLE_CLOCK) then
225  if(adapt_count_reset = '1') then
226  adapt_count <= 0;
227  time_out_adapt <= '0';
228  elsif(adapt_count >= WAIT_TIME_ADAPT) then
229  time_out_adapt <= '1';
230  else
231  adapt_count <= adapt_count + 1;
232  end if;
233  end if;
234  end process;
235  end generate;
236 
237  retries_recclk_monitor:process(STABLE_CLOCK)
238  begin
239  --This counter monitors, how many retries the RECCLK monitor
240  --runs. If during startup too many retries are necessary, the whole
241  --initialisation-process of the transceivers gets restarted.
242  if rising_edge(STABLE_CLOCK) then
243  if recclk_mon_count_reset = '1' then
244  recclk_mon_restart_count <= 0;
245  elsif RECCLK_MONITOR_RESTART = '1' then
246  if recclk_mon_restart_count = 3 then
247  recclk_mon_restart_count <= 0;
248  else
249  recclk_mon_restart_count <= recclk_mon_restart_count + 1;
250  end if;
251  end if;
252  end if;
253  end process;
254 
255  timeouts:process(STABLE_CLOCK)
256  begin
257  if rising_edge(STABLE_CLOCK) then
258  -- One common large counter for generating three time-out signals.
259  -- Intermediate time-outs are derived from calculated values, based
260  -- on the period of the provided clock.
261  if reset_time_out = '1' then
262  time_out_counter <= 0;
263  time_out_2ms <= '0';
264  time_tlock_max <= '0';
265  time_out_500us <= '0';
266  time_out_1us <= '0';
267  time_out_100us <= '0';
268  else
269  if time_out_counter = WAIT_TIMEOUT_2ms then
270  time_out_2ms <= '1';
271  else
272  time_out_counter <= time_out_counter + 1;
273  end if;
274 
275  if (time_out_counter > WAIT_TLOCK_MAX) and (check_tlock_max='1') then
276  time_tlock_max <= '1';
277  end if;
278 
279  if time_out_counter = WAIT_TIMEOUT_500us then
280  time_out_500us <= '1';
281  end if;
282 
283  if time_out_counter = WAIT_TIMEOUT_1us then
284  time_out_1us <= '1';
285  end if;
286 
287  if time_out_counter = WAIT_TIMEOUT_100us then
288  time_out_100us <= '1';
289  end if;
290 
291  end if;
292  end if;
293  end process;
294 
295 
296  mmcm_lock_wait:process(RXUSERCLK)
297  begin
298  --The lock-signal from the MMCM is not immediately used but
299  --enabling a counter. Only when the counter hits its maximum,
300  --the MMCM is considered as "really" locked.
301  --The counter avoids that the FSM already starts on only a
302  --coarse lock of the MMCM (=toggling of the LOCK-signal).
303  if rising_edge(RXUSERCLK) then
304  if MMCM_LOCK = '0' then
305  mmcm_lock_count <= 0;
306  mmcm_lock_int <= '0';
307  else
308  if mmcm_lock_count < MMCM_LOCK_CNT_MAX - 1 then
309  mmcm_lock_count <= mmcm_lock_count + 1;
310  else
311  mmcm_lock_int <= '1';
312  end if;
313  end if;
314  end if;
315  end process;
316 
317  reclocking:process(STABLE_CLOCK)
318  --Reclocking onto the FSM-clock.
319  begin
320  if rising_edge(STABLE_CLOCK) then
321  if MMCM_LOCK = '0' then
322  --The reset-signal is here on purpose. This avoids
323  --getting the shift-register targetted to an SRL.
324  --The reason for this is that an SRL will not help
325  --on the cross-clock domain but "real" Flip-flops will.
326 
327  mmcm_lock_reclocked <= (others => '0');
328  else
329  mmcm_lock_reclocked(3) <= mmcm_lock_int;
330  mmcm_lock_reclocked(2 downto 0) <= mmcm_lock_reclocked(3 downto 1);
331  end if;
332  end if;
333  end process;
334 
335  -- Clock Domain Crossing
336  process(RXUSERCLK)
337  begin
338  if rising_edge(RXUSERCLK) then
339  run_phase_alignment_int_s1 <= run_phase_alignment_int;
340  run_phase_alignment_int_s2 <= run_phase_alignment_int_s1;
341  run_phase_alignment_int_s3 <= run_phase_alignment_int_s2;
342 
343  rx_fsm_reset_done_int_s1 <= rx_fsm_reset_done_int;
344  rx_fsm_reset_done_int_s2 <= rx_fsm_reset_done_int_s1;
345  rx_fsm_reset_done_int_s3 <= rx_fsm_reset_done_int_s2;
346  end if;
347  end process;
348 
349  process(STABLE_CLOCK)
350  begin
351  if rising_edge(STABLE_CLOCK) then
352  rxresetdone_s1 <= RXRESETDONE;
353  rxresetdone_s2 <= rxresetdone_s1;
354  rxresetdone_s3 <= rxresetdone_s2;
355 
356  time_out_wait_bypass_s1 <= time_out_wait_bypass;
357  time_out_wait_bypass_s2 <= time_out_wait_bypass_s1;
358  time_out_wait_bypass_s3 <= time_out_wait_bypass_s2;
359  end if;
360  end process;
361 
362 
363  timeout_buffer_bypass:process(RXUSERCLK)
364  begin
365  if rising_edge(RXUSERCLK) then
366  if run_phase_alignment_int_s3 = '0' then
367  wait_bypass_count <= 0;
368  time_out_wait_bypass <= '0';
369  elsif (run_phase_alignment_int_s3 = '1') and (rx_fsm_reset_done_int_s3 = '0') then
370  if wait_bypass_count = MAX_WAIT_BYPASS - 1 then
371  time_out_wait_bypass <= '1';
372  else
373  wait_bypass_count <= wait_bypass_count + 1;
374  end if;
375  end if;
376  end if;
377  end process;
378 
379  refclk_lost <= '1' when ((RX_QPLL_USED and QPLLREFCLKLOST='1') or (not RX_QPLL_USED and CPLLREFCLKLOST='1')) else '0';
380 
381 
382 
383  --FSM for resetting the GTX/GTH/GTP in the 7-series.
384  --~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
385  --
386  -- Following steps are performed:
387  -- 1) After configuration wait for approximately 500 ns as specified in
388  -- answer-record 43482
389  -- 2) Assert all resets on the GT and on an MMCM potentially connected.
390  -- After that wait until a reference-clock has been detected.
391  -- 3) Release the reset to the GT and wait until the GT-PLL has locked.
392  -- 4) Release the MMCM-reset and wait until the MMCM has signalled lock.
393  -- Also get info from the TX-side which PLL has been reset.
394  -- 5) Wait for the RESET_DONE-signal from the GT.
395  -- 6) Signal to start the phase-alignment procedure and wait for it to
396  -- finish.
397  -- 7) Reset-sequence has successfully run through. Signal this to the
398  -- rest of the design by asserting RX_FSM_RESET_DONE.
399 
400  reset_fsm:process(STABLE_CLOCK)
401  begin
402  if rising_edge(STABLE_CLOCK) then
403  if (SOFT_RESET = '1' or (not(rx_state = INIT) and not(rx_state = ASSERT_ALL_RESETS) and refclk_lost = '1')) then
404  rx_state <= INIT;
405  RXUSERRDY <= '0';
406  GTRXRESET <= '0';
407  MMCM_RESET <= '1';
408  rx_fsm_reset_done_int <= '0';
409  QPLL_RESET <= '0';
410  CPLL_RESET <= '0';
411  pll_reset_asserted <= '0';
412  reset_time_out <= '1';
413  retry_counter_int <= 0;
414  run_phase_alignment_int <= '0';
415  check_tlock_max <= '0';
416  RESET_PHALIGNMENT <= '1';
417  recclk_mon_count_reset <= '1';
418  adapt_count_reset <= '1';
419  RXDFEAGCHOLD <= '0';
420  RXDFELFHOLD <= '0';
421  RXLPMLFHOLD <= '0';
422  RXLPMHFHOLD <= '0';
423 
424  else
425 
426  case rx_state is
427  when INIT =>
428  --Initial state after configuration. This state will be left after
429  --approx. 500 ns and not be re-entered.
430  if init_wait_done = '1' then
431  rx_state <= ASSERT_ALL_RESETS;
432  end if;
433 
434  when ASSERT_ALL_RESETS =>
435  --This is the state into which the FSM will always jump back if any
436  --time-outs will occur.
437  --The number of retries is reported on the output RETRY_COUNTER. In
438  --case the transceiver never comes up for some reason, this machine
439  --will still continue its best and rerun until the FPGA is turned off
440  --or the transceivers come up correctly.
441  if RX_QPLL_USED and not TX_QPLL_USED then
442  if pll_reset_asserted = '0' then
443  QPLL_RESET <= '1';
444  pll_reset_asserted <= '1';
445  else
446  QPLL_RESET <= '0';
447  end if;
448  elsif not RX_QPLL_USED and TX_QPLL_USED then
449  if pll_reset_asserted = '0' then
450  CPLL_RESET <= '1';
451  pll_reset_asserted <= '1';
452  else
453  CPLL_RESET <= '0';
454  end if;
455  end if;
456 
457  RXUSERRDY <= '0';
458  GTRXRESET <= '1';
459  MMCM_RESET <= '1';
460  run_phase_alignment_int <= '0';
461  RESET_PHALIGNMENT <= '1';
462  check_tlock_max <= '0';
463  recclk_mon_count_reset <= '1';
464  adapt_count_reset <= '1';
465 
466 
467  if (RX_QPLL_USED and (QPLLREFCLKLOST = '0') and pll_reset_asserted = '1') or
468  (not RX_QPLL_USED and TX_QPLL_USED and (CPLLREFCLKLOST = '0') and pll_reset_asserted = '1') or
469  (not RX_QPLL_USED and not TX_QPLL_USED and (CPLLREFCLKLOST = '0') ) or
470  (RX_QPLL_USED and TX_QPLL_USED and (QPLLREFCLKLOST = '0') ) then
471  rx_state <= RELEASE_PLL_RESET;
472  reset_time_out <= '1';
473  end if;
474 
475  when RELEASE_PLL_RESET =>
476  --PLL-Reset of the GTX gets released and the time-out counter
477  --starts running.
478  pll_reset_asserted <= '0';
479  reset_time_out <= '0';
480 
481 
482  if (RX_QPLL_USED and (QPLLLOCK = '1')) or
483  (not RX_QPLL_USED and (CPLLLOCK = '1')) then
484  rx_state <= VERIFY_RECCLK_STABLE;
485  reset_time_out <= '1';
486  recclk_mon_count_reset <= '0';
487  adapt_count_reset <= '0';
488  end if;
489 
490  if time_out_2ms = '1' then
491  if retry_counter_int = MAX_RETRIES then
492  -- If too many retries are performed compared to what is specified in
493  -- the generic, the counter simply wraps around.
494  retry_counter_int <= 0;
495  else
496  retry_counter_int <= retry_counter_int + 1;
497  end if;
498  rx_state <= ASSERT_ALL_RESETS;
499  end if;
500 
501  when VERIFY_RECCLK_STABLE =>
502  --reset_time_out <= '0';
503  --Time-out counter is not released in this state as here the FSM
504  --does not wait for a certain period of time but checks on the number
505  --of retries in the RECCLK monitor
506  GTRXRESET <= '0';
507  if RECCLK_STABLE = '1' then
508  rx_state <= RELEASE_MMCM_RESET;
509  reset_time_out <= '1';
510 
511  end if;
512 
513  if recclk_mon_restart_count = 2 then
514  --If two retries are performed in the RECCLK monitor
515  --the whole initialisation-sequence gets restarted.
516  if retry_counter_int = MAX_RETRIES then
517  -- If too many retries are performed compared to what is specified in
518  -- the generic, the counter simply wraps around.
519  retry_counter_int <= 0;
520  else
521  retry_counter_int <= retry_counter_int + 1;
522  end if;
523  rx_state <= ASSERT_ALL_RESETS;
524  end if;
525 
526  when RELEASE_MMCM_RESET =>
527  --Release of the MMCM-reset. Waiting for the MMCM to lock.
528  reset_time_out <= '0';
529  check_tlock_max <= '1';
530 
531  MMCM_RESET <= '0';
532  if mmcm_lock_reclocked(0) = '1' then
533  rx_state <= WAIT_RESET_DONE;
534  reset_time_out <= '1';
535  end if;
536 
537  if time_tlock_max = '1' then
538  if retry_counter_int = MAX_RETRIES then
539  -- If too many retries are performed compared to what is specified in
540  -- the generic, the counter simply wraps around.
541  retry_counter_int <= 0;
542  else
543  retry_counter_int <= retry_counter_int + 1;
544  end if;
545  rx_state <= ASSERT_ALL_RESETS;
546  end if;
547 
548  when WAIT_RESET_DONE =>
549  --When TXOUTCLK is the source for RXUSRCLK, RXUSERRDY depends on TXUSERRDY
550  --If RXOUTCLK is the source for RXUSRCLK, TXUSERRDY can be tied to '1'
551  if TXUSERRDY = '1' then
552  RXUSERRDY <= '1';
553  end if;
554  reset_time_out <= '0';
555  if rxresetdone_s3 = '1' then
556  rx_state <= DO_PHASE_ALIGNMENT;
557  reset_time_out <= '1';
558  end if;
559 
560  if time_out_2ms = '1' then
561  if retry_counter_int = MAX_RETRIES then
562  -- If too many retries are performed compared to what is specified in
563  -- the generic, the counter simply wraps around.
564  retry_counter_int <= 0;
565  else
566  retry_counter_int <= retry_counter_int + 1;
567  end if;
568  rx_state <= ASSERT_ALL_RESETS;
569  end if;
570 
571  when DO_PHASE_ALIGNMENT =>
572  --The direct handling of the signals for the Phase Alignment is done outside
573  --this state-machine.
574  RESET_PHALIGNMENT <= '0';
575  run_phase_alignment_int <= '1';
576  reset_time_out <= '0';
577 
578  if PHALIGNMENT_DONE = '1' then
579  rx_state <= MONITOR_DATA_VALID;
580  reset_time_out <= '1';
581  end if;
582 
583  if time_out_wait_bypass_s3 = '1' then
584  if retry_counter_int = MAX_RETRIES then
585  -- If too many retries are performed compared to what is specified in
586  -- the generic, the counter simply wraps around.
587  retry_counter_int <= 0;
588  else
589  retry_counter_int <= retry_counter_int + 1;
590  end if;
591  rx_state <= ASSERT_ALL_RESETS;
592  end if;
593 
594  when MONITOR_DATA_VALID =>
595  reset_time_out <= '0';
596 
597  if(time_out_100us = '1' and DATA_VALID ='0') then
598  rx_state <= ASSERT_ALL_RESETS;
599  rx_fsm_reset_done_int <= '0';
600  elsif (DATA_VALID = '1') then
601  rx_state <= FSM_DONE;
602  rx_fsm_reset_done_int <= '0';
603  reset_time_out <= '1';
604  end if;
605 
606  when FSM_DONE =>
607  reset_time_out <= '0';
608  if DATA_VALID = '0' then
609  rx_fsm_reset_done_int <= '0';
610  reset_time_out <= '1';
611  rx_state <= MONITOR_DATA_VALID;
612  elsif(time_out_1us = '1') then
613  rx_fsm_reset_done_int <= '1';
614  end if;
615 
616  if(time_out_adapt = '1') then
617  if((GT_TYPE = "GTX" or GT_TYPE = "GTH") and EQ_MODE = "DFE") then
618  RXDFEAGCHOLD <= '1';
619  RXDFELFHOLD <= '1';
620  elsif(GT_TYPE = "GTH" and EQ_MODE = "LPM") then
621  RXLPMHFHOLD <= '1';
622  RXLPMLFHOLD <= '1';
623  end if;
624  end if;
625 
626  end case;
627  end if;
628  end if;
629  end process;
630 
631 end RTL;
632 
633