1 | |
---|
2 | -- |
---|
3 | -- Project: Aurora Module Generator version 2.4 |
---|
4 | -- |
---|
5 | -- Date: $Date: 2005/11/07 21:30:55 $ |
---|
6 | -- Tag: $Name: i+IP+98818 $ |
---|
7 | -- File: $RCSfile: standard_cc_module_vhd.ejava,v $ |
---|
8 | -- Rev: $Revision: 1.1.2.4 $ |
---|
9 | -- |
---|
10 | -- Company: Xilinx |
---|
11 | -- Contributors: R. K. Awalt, B. L. Woodard, N. Gulstone |
---|
12 | -- |
---|
13 | -- Disclaimer: XILINX IS PROVIDING THIS DESIGN, CODE, OR |
---|
14 | -- INFORMATION "AS IS" SOLELY FOR USE IN DEVELOPING |
---|
15 | -- PROGRAMS AND SOLUTIONS FOR XILINX DEVICES. BY |
---|
16 | -- PROVIDING THIS DESIGN, CODE, OR INFORMATION AS |
---|
17 | -- ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, |
---|
18 | -- APPLICATION OR STANDARD, XILINX IS MAKING NO |
---|
19 | -- REPRESENTATION THAT THIS IMPLEMENTATION IS FREE |
---|
20 | -- FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE |
---|
21 | -- RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY |
---|
22 | -- REQUIRE FOR YOUR IMPLEMENTATION. XILINX |
---|
23 | -- EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH |
---|
24 | -- RESPECT TO THE ADEQUACY OF THE IMPLEMENTATION, |
---|
25 | -- INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR |
---|
26 | -- REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE |
---|
27 | -- FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES |
---|
28 | -- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
---|
29 | -- PURPOSE. |
---|
30 | -- |
---|
31 | -- (c) Copyright 2004 Xilinx, Inc. |
---|
32 | -- All rights reserved. |
---|
33 | -- |
---|
34 | |
---|
35 | -- |
---|
36 | -- STANDARD_CC_MODULE |
---|
37 | -- |
---|
38 | -- Author: Nigel Gulstone |
---|
39 | -- Xilinx - Embedded Networking System Engeneering Group |
---|
40 | -- |
---|
41 | -- Description: This module drives the Aurora module's Clock Compensation |
---|
42 | -- interface. Clock Compensation sequences are generated according |
---|
43 | -- to the requirements in the Aurora Protocol specification. |
---|
44 | -- |
---|
45 | -- This module supports Aurora Modules with any number of |
---|
46 | -- 2-byte lanes and no User Flow Control. |
---|
47 | -- |
---|
48 | |
---|
49 | library IEEE; |
---|
50 | use IEEE.STD_LOGIC_1164.all; |
---|
51 | |
---|
52 | -- synthesis translate_off |
---|
53 | library UNISIM; |
---|
54 | use UNISIM.all; |
---|
55 | -- synthesis translate_on |
---|
56 | |
---|
57 | |
---|
58 | entity STANDARD_CC_MODULE is |
---|
59 | port |
---|
60 | ( |
---|
61 | -- Clock Compensation Control Interface |
---|
62 | WARN_CC : out std_logic; |
---|
63 | DO_CC : out std_logic; |
---|
64 | |
---|
65 | |
---|
66 | -- System Interface |
---|
67 | DCM_NOT_LOCKED : in std_logic; |
---|
68 | USER_CLK : in std_logic; |
---|
69 | CHANNEL_UP : in std_logic |
---|
70 | |
---|
71 | ); |
---|
72 | end STANDARD_CC_MODULE; |
---|
73 | |
---|
74 | architecture RTL of STANDARD_CC_MODULE is |
---|
75 | |
---|
76 | |
---|
77 | --******************************Parameter Declarations******************************* |
---|
78 | |
---|
79 | constant DLY : time := 1 ns; |
---|
80 | |
---|
81 | |
---|
82 | |
---|
83 | --************************** Internal Register Declarations ************************** |
---|
84 | |
---|
85 | signal prepare_count_r : std_logic_vector(0 to 9) := "0000000000"; |
---|
86 | signal cc_count_r : std_logic_vector(0 to 5) := "000000"; |
---|
87 | signal reset_r : std_logic; |
---|
88 | |
---|
89 | signal count_13d_srl_r : std_logic_vector(0 to 11); |
---|
90 | signal count_13d_flop_r : std_logic; |
---|
91 | signal count_16d_srl_r : std_logic_vector(0 to 14); |
---|
92 | signal count_16d_flop_r : std_logic; |
---|
93 | signal count_24d_srl_r : std_logic_vector(0 to 22); |
---|
94 | signal count_24d_flop_r : std_logic; |
---|
95 | |
---|
96 | |
---|
97 | --*********************************Wire Declarations********************************** |
---|
98 | |
---|
99 | signal start_cc_c : std_logic; |
---|
100 | signal inner_count_done_r : std_logic; |
---|
101 | signal middle_count_done_c : std_logic; |
---|
102 | signal cc_idle_count_done_c : std_logic; |
---|
103 | |
---|
104 | |
---|
105 | --*********************************Main Body of Code********************************** |
---|
106 | begin |
---|
107 | |
---|
108 | |
---|
109 | --________________________Clock Correction State Machine__________________________ |
---|
110 | |
---|
111 | |
---|
112 | |
---|
113 | -- The clock correction state machine is a counter with three sections. The first |
---|
114 | -- section counts out the idle period before a clock correction occurs. The second |
---|
115 | -- section counts out a period when NFC and UFC operations should not be attempted |
---|
116 | -- because they will not be completed. The last section counts out the cycles of |
---|
117 | -- the clock correction sequence. |
---|
118 | |
---|
119 | |
---|
120 | |
---|
121 | |
---|
122 | -- The inner count for the CC counter counts to 13. It is implemented using |
---|
123 | -- an SRL16 and a flop |
---|
124 | |
---|
125 | -- The SRL counts 12 bits of the count |
---|
126 | process(USER_CLK) |
---|
127 | begin |
---|
128 | if(USER_CLK'event and USER_CLK = '1') then |
---|
129 | count_13d_srl_r <= (count_13d_flop_r & count_13d_srl_r(0 to 10)) after DLY; |
---|
130 | end if; |
---|
131 | end process; |
---|
132 | |
---|
133 | |
---|
134 | |
---|
135 | -- The inner count is done when a 1 reaches the end of the SRL |
---|
136 | inner_count_done_r <= count_13d_srl_r(11); |
---|
137 | |
---|
138 | |
---|
139 | -- The flop extends the shift register to 13 bits for counting. It is held at |
---|
140 | -- zero while channel up is low to clear the register, and is seeded with a |
---|
141 | -- single 1 when channel up transitions from 0 to 1 |
---|
142 | process(USER_CLK) |
---|
143 | begin |
---|
144 | if(USER_CLK'event and USER_CLK = '1') then |
---|
145 | if(CHANNEL_UP = '0') then |
---|
146 | count_13d_flop_r <= '0' after DLY; |
---|
147 | elsif( (CHANNEL_UP and reset_r)= '1') then |
---|
148 | count_13d_flop_r <= '1' after DLY; |
---|
149 | else |
---|
150 | count_13d_flop_r <= inner_count_done_r after DLY; |
---|
151 | end if; |
---|
152 | end if; |
---|
153 | end process; |
---|
154 | |
---|
155 | |
---|
156 | |
---|
157 | -- The middle count for the CC counter counts to 16. Its count increments only |
---|
158 | -- when the inner count is done. It is implemented using an SRL16 and a flop |
---|
159 | |
---|
160 | |
---|
161 | -- The SRL counts 15 bits of the count. It is enabled only when the inner count |
---|
162 | -- is done |
---|
163 | process(USER_CLK) |
---|
164 | begin |
---|
165 | if(USER_CLK'event and USER_CLK = '1') then |
---|
166 | if((inner_count_done_r or not CHANNEL_UP) = '1') then |
---|
167 | count_16d_srl_r <= ( count_16d_flop_r & count_16d_srl_r(0 to 13) ) after DLY; |
---|
168 | end if; |
---|
169 | end if; |
---|
170 | end process; |
---|
171 | |
---|
172 | |
---|
173 | |
---|
174 | -- The middle count is done when a 1 reaches the end of the SRL and the inner |
---|
175 | -- count finishes |
---|
176 | middle_count_done_c <= inner_count_done_r and count_16d_srl_r(14); |
---|
177 | |
---|
178 | |
---|
179 | |
---|
180 | -- The flop extends the shift register to 16 bits for counting. It is held at |
---|
181 | -- zero while channel up is low to clear the register, and is seeded with a |
---|
182 | -- single 1 when channel up transitions from 0 to 1 |
---|
183 | process(USER_CLK) |
---|
184 | begin |
---|
185 | if(USER_CLK'event and USER_CLK = '1') then |
---|
186 | if(CHANNEL_UP = '0') then |
---|
187 | count_16d_flop_r <= '0' after DLY; |
---|
188 | elsif((CHANNEL_UP and reset_r)='1') then |
---|
189 | count_16d_flop_r <= '1' after DLY; |
---|
190 | elsif(inner_count_done_r = '1') then |
---|
191 | count_16d_flop_r <= middle_count_done_c after DLY; |
---|
192 | end if; |
---|
193 | end if; |
---|
194 | end process; |
---|
195 | |
---|
196 | |
---|
197 | |
---|
198 | |
---|
199 | -- The outer count (aka the cc idle count) is done when it reaches 24. Its count |
---|
200 | -- increments only when the middle count is done. It is implemented with 2 |
---|
201 | -- SRL16Es. |
---|
202 | |
---|
203 | |
---|
204 | -- The SRL counts 23 bits of the count. It is enabled only when the middle count is |
---|
205 | -- done |
---|
206 | process(USER_CLK) |
---|
207 | begin |
---|
208 | if(USER_CLK'event and USER_CLK = '1') then |
---|
209 | if((middle_count_done_c or not CHANNEL_UP) = '1') then |
---|
210 | count_24d_srl_r <= (count_24d_flop_r & count_24d_srl_r(0 to 21)) after DLY; |
---|
211 | end if; |
---|
212 | end if; |
---|
213 | end process; |
---|
214 | |
---|
215 | |
---|
216 | |
---|
217 | -- The cc idle count is done when a 1 reaches the end of the SRL and the middle count finishes |
---|
218 | cc_idle_count_done_c <= middle_count_done_c and count_24d_srl_r(22); |
---|
219 | |
---|
220 | |
---|
221 | |
---|
222 | -- The flop extends the shift register to 24 bits for counting. It is held at |
---|
223 | -- zero while channel up is low to clear the register, and is seeded with a single |
---|
224 | -- 1 when channel up transitions from 0 to 1 |
---|
225 | process(USER_CLK) |
---|
226 | begin |
---|
227 | if(USER_CLK'event and USER_CLK = '1') then |
---|
228 | if(CHANNEL_UP = '0') then |
---|
229 | count_24d_flop_r <= '0' after DLY; |
---|
230 | elsif( (CHANNEL_UP and reset_r) = '1') then |
---|
231 | count_24d_flop_r <= '1' after DLY; |
---|
232 | elsif( middle_count_done_c = '1') then |
---|
233 | count_24d_flop_r <= cc_idle_count_done_c after DLY; |
---|
234 | end if; |
---|
235 | end if; |
---|
236 | end process; |
---|
237 | |
---|
238 | |
---|
239 | |
---|
240 | |
---|
241 | -- Because UFC and CC sequences are not allowed to preempt one another, there |
---|
242 | -- there is a warning signal to indicate an impending CC sequence. This signal |
---|
243 | -- is used to prevent UFC messages from starting. |
---|
244 | |
---|
245 | -- For 1 lane, we need an 10-cycle count. |
---|
246 | process(USER_CLK) |
---|
247 | begin |
---|
248 | if(USER_CLK'event and USER_CLK = '1') then |
---|
249 | prepare_count_r <= (cc_idle_count_done_c & prepare_count_r(0 to 8)) after DLY; |
---|
250 | end if; |
---|
251 | end process; |
---|
252 | |
---|
253 | |
---|
254 | |
---|
255 | -- The state machine stays in the prepare_cc state from when the cc idle |
---|
256 | -- count finishes, to when the prepare count has finished. While in this |
---|
257 | -- state, UFC operations cannot start, which prevents them from having to |
---|
258 | -- be pre-empted by CC sequences. |
---|
259 | process(USER_CLK) |
---|
260 | begin |
---|
261 | if(USER_CLK'event and USER_CLK = '1') then |
---|
262 | if(CHANNEL_UP = '0') then |
---|
263 | WARN_CC <= '0' after DLY; |
---|
264 | elsif(cc_idle_count_done_c = '1') then |
---|
265 | WARN_CC <= '1' after DLY; |
---|
266 | elsif(prepare_count_r(9) = '1') then |
---|
267 | WARN_CC <= '0' after DLY; |
---|
268 | end if; |
---|
269 | end if; |
---|
270 | end process; |
---|
271 | |
---|
272 | |
---|
273 | |
---|
274 | |
---|
275 | |
---|
276 | -- Track the state of channel up on the previous cycle. We use this signal to determine |
---|
277 | -- when to seed the shift register counters with ones |
---|
278 | process(USER_CLK) |
---|
279 | begin |
---|
280 | if(USER_CLK'event and USER_CLK = '1') then |
---|
281 | reset_r <= not CHANNEL_UP after DLY; |
---|
282 | end if; |
---|
283 | end process; |
---|
284 | |
---|
285 | |
---|
286 | |
---|
287 | --Do a CC after CHANNEL_UP is asserted or CC_warning is complete. |
---|
288 | start_cc_c <= prepare_count_r(9) or (CHANNEL_UP and reset_r); |
---|
289 | |
---|
290 | |
---|
291 | |
---|
292 | |
---|
293 | -- This SRL counter keeps track of the number of cycles spent in the CC |
---|
294 | -- sequence. It starts counting when the prepare_cc state ends, and |
---|
295 | -- finishes counting after 6 cycles have passed. |
---|
296 | process(USER_CLK) |
---|
297 | begin |
---|
298 | if(USER_CLK'event and USER_CLK = '1') then |
---|
299 | cc_count_r <= ( (not CHANNEL_UP or prepare_count_r(9)) & cc_count_r(0 to 4) ) after DLY; |
---|
300 | end if; |
---|
301 | end process; |
---|
302 | |
---|
303 | |
---|
304 | |
---|
305 | -- The TX_LL module stays in the do_cc state for 6 cycles. It starts |
---|
306 | -- when the prepare_cc state ends. |
---|
307 | process(USER_CLK) |
---|
308 | begin |
---|
309 | if(USER_CLK'event and USER_CLK = '1') then |
---|
310 | if(CHANNEL_UP = '0') then |
---|
311 | DO_CC <= '0' after DLY; |
---|
312 | elsif(start_cc_c = '1') then |
---|
313 | DO_CC <= '1' after DLY; |
---|
314 | elsif(cc_count_r(5) = '1') then |
---|
315 | DO_CC <= '0' after DLY; |
---|
316 | end if; |
---|
317 | end if; |
---|
318 | end process; |
---|
319 | |
---|
320 | |
---|
321 | end RTL; |
---|
322 | |
---|
323 | |
---|