CMX
CMX firmware code in-line documentation
 All Classes Namespaces Files Functions Variables
rx_sync.vhd
Go to the documentation of this file.
1 
3 
4 ------------------------------------------------------------------------------
5 -- ____ ____
6 -- / /\/ /
7 -- /___/ \ / Vendor: Xilinx
8 -- \ \ \/ Version : 1.12
9 -- \ \ Application : Virtex-6 FPGA GTX Transceiver Wizard
10 -- / / Filename : rx_sync.vhd
11 -- /___/ /\
12 -- \ \ / \
13 -- \___\/\___\
14 --
15 --
16 -- Module gtx_txrx_rx_sync
17 -- Generated by Xilinx Virtex-6 FPGA GTX Transceiver Wizard
18 --
19 --
20 -- (c) Copyright 2009-2011 Xilinx, Inc. All rights reserved.
21 --
22 -- This file contains confidential and proprietary information
23 -- of Xilinx, Inc. and is protected under U.S. and
24 -- international copyright and other intellectual property
25 -- laws.
26 --
27 -- DISCLAIMER
28 -- This disclaimer is not a license and does not grant any
29 -- rights to the materials distributed herewith. Except as
30 -- otherwise provided in a valid license issued to you by
31 -- Xilinx, and to the maximum extent permitted by applicable
32 -- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
33 -- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
34 -- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
35 -- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
36 -- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
37 -- (2) Xilinx shall not be liable (whether in contract or tort,
38 -- including negligence, or under any other theory of
39 -- liability) for any loss or damage of any kind or nature
40 -- related to, arising under or in connection with these
41 -- materials, including for any direct, or any indirect,
42 -- special, incidental, or consequential loss or damage
43 -- (including loss of data, profits, goodwill, or any type of
44 -- loss or damage suffered as a result of any action brought
45 -- by a third party) even if such damage or loss was
46 -- reasonably foreseeable or Xilinx had been advised of the
47 -- possibility of the same.
48 --
49 -- CRITICAL APPLICATIONS
50 -- Xilinx products are not designed or intended to be fail-
51 -- safe, or for use in any application requiring fail-safe
52 -- performance, such as life-support or safety devices or
53 -- systems, Class III medical devices, nuclear facilities,
54 -- applications related to the deployment of airbags, or any
55 -- other applications that could lead to death, personal
56 -- injury, or severe property or environmental damage
57 -- (individually and collectively, "Critical
58 -- Applications"). Customer assumes the sole risk and
59 -- liability of any use of Xilinx products in Critical
60 -- Applications, subject only to applicable laws and
61 -- regulations governing limitations on product liability.
62 --
63 -- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
64 -- PART OF THIS FILE AT ALL TIMES.
65 
66 
67 library ieee;
68 use ieee.std_logic_1164.all;
69 use ieee.numeric_std.all;
70 library UNISIM;
71 use UNISIM.VCOMPONENTS.ALL;
72 
73 entity rx_sync is
74 port
75 (
76  RXENPMAPHASEALIGN : out std_logic;
77  RXPMASETPHASE : out std_logic;
78  RXDLYALIGNDISABLE : out std_logic;
79  RXDLYALIGNOVERRIDE : out std_logic;
80  RXDLYALIGNRESET : out std_logic;
81  SYNC_DONE : out std_logic;
82  USER_CLK : in std_logic;
83  RESET : in std_logic
84 );
85 
86 
87 end rx_sync;
88 
89 architecture RTL of rx_sync is
90 --***********************************Parameter Declarations********************
91 
92  constant DLY : time := 1 ns;
93 
94 --*******************************Register Declarations************************
95 
96  signal begin_r : std_logic;
97  signal phase_align_r : std_logic;
98  signal ready_r : std_logic;
99  signal sync_counter_r : unsigned(5 downto 0);
100  signal sync_done_count_r : unsigned(5 downto 0);
101  signal align_reset_counter_r : unsigned(4 downto 0);
102  signal wait_after_sync_r : std_logic;
103  signal wait_before_setphase_counter_r : unsigned(5 downto 0);
104  signal wait_before_setphase_r : std_logic;
105  signal align_reset_r : std_logic;
106 
107 --*******************************Wire Declarations****************************
108 
109  signal count_32_setphase_complete_r : std_logic;
110  signal count_32_wait_complete_r : std_logic;
111  signal count_align_reset_complete_r : std_logic;
112  signal next_phase_align_c : std_logic;
113  signal next_align_reset_c : std_logic;
114  signal next_ready_c : std_logic;
115  signal next_wait_after_sync_c : std_logic;
116  signal next_wait_before_setphase_c : std_logic;
117  signal sync_32_times_done_r : std_logic;
118 
119  attribute max_fanout:string;
120  attribute max_fanout of ready_r : signal is "2";
121 
122 begin
123 --*******************************Main Body of Code****************************
124 
125  --________________________________ State machine __________________________
126  -- This state machine manages the phase alingment procedure of the GTX on the
127  -- receive side. The module is held in reset till the usrclk source is stable
128  -- and RXRESETDONE is asserted. In the case that a MMCM is used to generate
129  -- rxusrclk, the mmcm_locked signal is used to indicate a stable usrclk source.
130  -- Once RXRESETDONE and mmcm_locked are asserted, the state machine goes
131  -- into the align_reset_r state where RXDLYALIGNRESET is asserted for 20 cycles.
132  -- After this, it goes into the wait_before_setphase_r state for 32 cycles.
133  -- After asserting RXENPMAPHASEALIGN and waiting 32 cycles, it enters the
134  -- phase_align_r state where RXPMASETPHASE is asserted for 32 clock cycles.
135  -- After the port is deasserted, the state machine goes into a wait state for
136  -- 32 cycles. This procedure is repeated 32 times.
137 
138  -- State registers
139  process( USER_CLK )
140  begin
141  if(USER_CLK'event and USER_CLK = '1') then
142  if(RESET='1') then
143  begin_r <= '1' after DLY;
144  align_reset_r <= '0' after DLY;
145  wait_before_setphase_r <= '0' after DLY;
146  phase_align_r <= '0' after DLY;
147  wait_after_sync_r <= '0' after DLY;
148  ready_r <= '0' after DLY;
149  else
150  begin_r <= '0' after DLY;
155  ready_r <= next_ready_c after DLY;
156  end if;
157  end if;
158  end process;
159 
160  -- Next state logic
163 
166 
170 
173 
175  ready_r;
176 
177  --______ Counter for holding RXDLYALIGNRESET for 20 RXUSRCLK2 cycles ______
178  process( USER_CLK )
179  begin
180  if(USER_CLK'event and USER_CLK = '1') then
181  if (align_reset_r='0') then
182  align_reset_counter_r <= (others=>'0') after DLY;
183  else
185  end if;
186  end if ;
187  end process;
188 
190  and align_reset_counter_r(2);
191 
192  --_______Counter for waiting 32 clock cycles before RXPMASETPHASE _________
193  process( USER_CLK )
194  begin
195  if(USER_CLK'event and USER_CLK = '1') then
196  if ((wait_before_setphase_r='0') and (wait_after_sync_r='0')) then
197  wait_before_setphase_counter_r <= (others=>'0') after DLY;
198  else
200  end if;
201  end if;
202  end process;
203 
205 
206  --_______________ Counter for holding SYNC for SYNC_CYCLES ________________
207  process( USER_CLK )
208  begin
209  if(USER_CLK'event and USER_CLK = '1') then
210  if (phase_align_r='0') then
211  sync_counter_r <= (others=>'0') after DLY;
212  else
213  sync_counter_r <= sync_counter_r + 1 after DLY;
214  end if;
215  end if;
216  end process;
217 
219 
220  --__________ Counter for counting number of times sync is done ____________
221  process( USER_CLK )
222  begin
223  if(USER_CLK'event and USER_CLK = '1') then
224  if (RESET='1') then
225  sync_done_count_r <= (others=>'0') after DLY;
226  elsif((count_32_wait_complete_r ='1') and (phase_align_r = '1')) then
228  end if;
229  end if;
230  end process;
231 
233 
234  --_______________ Assign the phase align ports into the GTX _______________
235 
237  RXENPMAPHASEALIGN <= (not begin_r) and (not align_reset_r);
239  RXDLYALIGNDISABLE <= '1';
240  RXDLYALIGNOVERRIDE <= '1';
241 
242  --_______________________ Assign the sync_done port _______________________
243 
244  SYNC_DONE <= ready_r;
245 
246 
247 end RTL;
std_logic phase_align_r
Definition: rx_sync.vhd:97
std_logic next_phase_align_c
Definition: rx_sync.vhd:112
in USER_CLKstd_logic
Definition: rx_sync.vhd:82
out RXPMASETPHASEstd_logic
Definition: rx_sync.vhd:77
out SYNC_DONEstd_logic
Definition: rx_sync.vhd:81
std_logic count_32_setphase_complete_r
Definition: rx_sync.vhd:109
std_logic count_32_wait_complete_r
Definition: rx_sync.vhd:110
in RESETstd_logic
Definition: rx_sync.vhd:83
out RXDLYALIGNDISABLEstd_logic
Definition: rx_sync.vhd:78
std_logic count_align_reset_complete_r
Definition: rx_sync.vhd:111
unsigned (4 downto 0) align_reset_counter_r
Definition: rx_sync.vhd:101
unsigned (5 downto 0) sync_done_count_r
Definition: rx_sync.vhd:100
_library_ ieeeieee
Definition: Readout_FIFO.vhd:6
std_logic next_wait_before_setphase_c
Definition: rx_sync.vhd:116
std_logic wait_before_setphase_r
Definition: rx_sync.vhd:104
time :=1 ns DLY
Definition: rx_sync.vhd:92
std_logic next_wait_after_sync_c
Definition: rx_sync.vhd:115
out RXENPMAPHASEALIGNstd_logic
Definition: rx_sync.vhd:76
std_logic ready_r
Definition: rx_sync.vhd:98
out RXDLYALIGNOVERRIDEstd_logic
Definition: rx_sync.vhd:79
std_logic sync_32_times_done_r
Definition: rx_sync.vhd:117
std_logic begin_r
Definition: rx_sync.vhd:96
unsigned (5 downto 0) wait_before_setphase_counter_r
Definition: rx_sync.vhd:103
std_logic align_reset_r
Definition: rx_sync.vhd:105
unsigned (5 downto 0) sync_counter_r
Definition: rx_sync.vhd:99
std_logic next_ready_c
Definition: rx_sync.vhd:114
std_logic next_align_reset_c
Definition: rx_sync.vhd:113
string max_fanout
Definition: rx_sync.vhd:119
out RXDLYALIGNRESETstd_logic
Definition: rx_sync.vhd:80
std_logic wait_after_sync_r
Definition: rx_sync.vhd:102