CMX
CMX firmware code in-line documentation
 All Classes Namespaces Files Functions Variables
tx_sync.vhd
Go to the documentation of this file.
1 
3 -------------------------------------------------------------------------------
4 -- ____ ____
5 -- / /\/ /
6 -- /___/ \ / Vendor: Xilinx
7 -- \ \ \/ Version : 1.12
8 -- \ \ Application : Virtex-6 FPGA GTX Transceiver Wizard
9 -- / / Filename : tx_sync.vhd
10 -- /___/ /\
11 -- \ \ / \
12 -- \___\/\___\
13 --
14 --
15 -- Module tx_sync
16 -- Generated by Xilinx Virtex-6 FPGA GTX Transceiver Wizard
17 --
18 --
19 -- (c) Copyright 2009-2011 Xilinx, Inc. All rights reserved.
20 --
21 -- This file contains confidential and proprietary information
22 -- of Xilinx, Inc. and is protected under U.S. and
23 -- international copyright and other intellectual property
24 -- laws.
25 --
26 -- DISCLAIMER
27 -- This disclaimer is not a license and does not grant any
28 -- rights to the materials distributed herewith. Except as
29 -- otherwise provided in a valid license issued to you by
30 -- Xilinx, and to the maximum extent permitted by applicable
31 -- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
32 -- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
33 -- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
34 -- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
35 -- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
36 -- (2) Xilinx shall not be liable (whether in contract or tort,
37 -- including negligence, or under any other theory of
38 -- liability) for any loss or damage of any kind or nature
39 -- related to, arising under or in connection with these
40 -- materials, including for any direct, or any indirect,
41 -- special, incidental, or consequential loss or damage
42 -- (including loss of data, profits, goodwill, or any type of
43 -- loss or damage suffered as a result of any action brought
44 -- by a third party) even if such damage or loss was
45 -- reasonably foreseeable or Xilinx had been advised of the
46 -- possibility of the same.
47 --
48 -- CRITICAL APPLICATIONS
49 -- Xilinx products are not designed or intended to be fail-
50 -- safe, or for use in any application requiring fail-safe
51 -- performance, such as life-support or safety devices or
52 -- systems, Class III medical devices, nuclear facilities,
53 -- applications related to the deployment of airbags, or any
54 -- other applications that could lead to death, personal
55 -- injury, or severe property or environmental damage
56 -- (individually and collectively, "Critical
57 -- Applications"). Customer assumes the sole risk and
58 -- liability of any use of Xilinx products in Critical
59 -- Applications, subject only to applicable laws and
60 -- regulations governing limitations on product liability.
61 --
62 -- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
63 -- PART OF THIS FILE AT ALL TIMES.
64 
65 
66 library ieee;
67 use ieee.std_logic_1164.all;
68 use ieee.numeric_std.all;
69 library UNISIM;
70 use UNISIM.VCOMPONENTS.ALL;
71 
72 entity tx_sync is
73 generic
74 (
76 );
77 port
78 (
79  TXENPMAPHASEALIGN : out std_logic;
80  TXPMASETPHASE : out std_logic;
81  TXDLYALIGNDISABLE : out std_logic;
82  TXDLYALIGNRESET : out std_logic;
83  SYNC_DONE : out std_logic;
84  USER_CLK : in std_logic;
85  RESET : in std_logic
86 );
87 
88 
89 end tx_sync;
90 
91 architecture RTL of tx_sync is
92 --***********************************Parameter Declarations********************
93 
94  constant DLY : time := 1 ns;
95 
96 --*******************************Register Declarations************************
97 
98  signal begin_r : std_logic;
99  signal phase_align_r : std_logic;
100  signal ready_r : std_logic;
101  signal sync_counter_r : unsigned(13 downto 0);--(15 downto 0);
102  signal wait_before_setphase_counter_r : unsigned(5 downto 0);
103  signal align_reset_counter_r : unsigned(4 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_setphase_complete_r : std_logic;
110  signal count_32_complete_r : std_logic;
111  signal count_align_reset_complete_r : std_logic;
112  signal next_phase_align_c : std_logic;
113  signal next_ready_c : std_logic;
114  signal next_wait_before_setphase_c : std_logic;
115  signal next_align_reset_c : std_logic;
116 
117 begin
118 --*******************************Main Body of Code****************************
119 
120  --________________________________ State machine __________________________
121  -- This state machine manages the TX phase alignment procedure of the GTX.
122  -- The module is held in reset till TXRESETDONE is asserted. Once TXRESETDONE
123  -- is asserted, the state machine goes into the align_reset_r state, asserting
124  -- TXDLYALIGNRESET for 20 TXUSRCLK2 cycles. After this, it goes into the
125  -- wait_before_setphase_r state for 32 cycles. After asserting TXENPMAPHASEALIGN and
126  -- waiting 32 cycles, it goes into the phase_align_r state where the last
127  -- part of the alignment procedure is completed. This involves asserting
128  -- TXPMASETPHASE for 8192 (TXPLL_DIVSEL_OUT=1), 16384 (TXPLL_DIVSEL_OUT=2),
129  -- or 32768 (TXPLL_DIVSEL_OUT=4) clock cycles. After completion of the phase
130  -- alignment procedure, TXDLYALIGNDISABLE is deasserted.
131 
132  -- State registers
133  process( USER_CLK )
134  begin
135  if(USER_CLK'event and USER_CLK = '1') then
136  if(RESET='1') then
137  begin_r <= '1' after DLY;
138  align_reset_r <= '0' after DLY;
139  wait_before_setphase_r <= '0' after DLY;
140  phase_align_r <= '0' after DLY;
141  ready_r <= '0' after DLY;
142  else
143  begin_r <= '0' after DLY;
147  ready_r <= next_ready_c after DLY;
148  end if;
149  end if;
150  end process;
151 
152  -- Next state logic
155 
158 
161 
163  ready_r;
164 
165  --______ Counter for holding TXDLYALIGNRESET for 20 TXUSRCLK2 cycles ______
166  process( USER_CLK )
167  begin
168  if(USER_CLK'event and USER_CLK = '1') then
169  if (align_reset_r='0') then
170  align_reset_counter_r <= (others=>'0') after DLY;
171  else
173  end if;
174  end if;
175  end process;
176 
178  and align_reset_counter_r(2);
179 
180  --______ Counter for waiting 32 clock cycles before TXPMASETPHASE _________
181  process( USER_CLK )
182  begin
183  if(USER_CLK'event and USER_CLK = '1') then
184  if (wait_before_setphase_r='0') then
185  wait_before_setphase_counter_r <= (others=>'0') after DLY;
186  else
188  end if;
189  end if;
190  end process;
191 
193 
194  --_______________ Counter for holding SYNC for SYNC_CYCLES ________________
195  process( USER_CLK )
196  begin
197  if(USER_CLK'event and USER_CLK = '1') then
198  if (phase_align_r='0') then
199  sync_counter_r <= (others=>'0') after DLY;
200  else
201  sync_counter_r <= sync_counter_r + 1 after DLY;
202  end if;
203  end if;
204  end process;
205 
206 fast_simulation: if(SIM_TXPMASETPHASE_SPEEDUP=1) generate
207  -- 64 cycles of setphase for simulation
209 end generate fast_simulation;
210 
211 no_fast_simulation: if(SIM_TXPMASETPHASE_SPEEDUP=0) generate
212  -- 8192 cycles of setphase for output divider of 1
214 end generate no_fast_simulation;
215 
216  --_______________ Assign the phase align ports into the GTX _______________
217 
218  TXDLYALIGNRESET <= '0';
219  TXENPMAPHASEALIGN <= (not begin_r) and (not align_reset_r);
221  TXDLYALIGNDISABLE <= '1';
222 
223  --_______________________ Assign the sync_done port _______________________
224 
225  SYNC_DONE <= ready_r;
226 
227 
228 end RTL;
std_logic phase_align_r
Definition: tx_sync.vhd:99
out TXDLYALIGNRESETstd_logic
Definition: tx_sync.vhd:82
out SYNC_DONEstd_logic
Definition: tx_sync.vhd:83
std_logic next_phase_align_c
Definition: tx_sync.vhd:112
in USER_CLKstd_logic
Definition: tx_sync.vhd:84
out TXENPMAPHASEALIGNstd_logic
Definition: tx_sync.vhd:79
unsigned (4 downto 0) align_reset_counter_r
Definition: tx_sync.vhd:103
out TXPMASETPHASEstd_logic
Definition: tx_sync.vhd:80
std_logic count_align_reset_complete_r
Definition: tx_sync.vhd:111
std_logic next_wait_before_setphase_c
Definition: tx_sync.vhd:114
in RESETstd_logic
Definition: tx_sync.vhd:85
_library_ UNISIMUNISIM
time :=1 ns DLY
Definition: tx_sync.vhd:94
std_logic count_32_complete_r
Definition: tx_sync.vhd:110
SIM_TXPMASETPHASE_SPEEDUPinteger :=0
Definition: tx_sync.vhd:75
_library_ ieeeieee
Definition: Topo_Data_TX.vhd:9
std_logic begin_r
Definition: tx_sync.vhd:98
unsigned (5 downto 0) wait_before_setphase_counter_r
Definition: tx_sync.vhd:102
std_logic align_reset_r
Definition: tx_sync.vhd:105
std_logic wait_before_setphase_r
Definition: tx_sync.vhd:104
std_logic ready_r
Definition: tx_sync.vhd:100
std_logic next_align_reset_c
Definition: tx_sync.vhd:115
std_logic next_ready_c
Definition: tx_sync.vhd:113
std_logic count_setphase_complete_r
Definition: tx_sync.vhd:109
out TXDLYALIGNDISABLEstd_logic
Definition: tx_sync.vhd:81
unsigned (13 downto 0) sync_counter_r
Definition: tx_sync.vhd:101