1 ---------------------------------------------------------------------------
3 -- Module : encode_8b10b_lut_base.vhd
7 -- Last Update : 2008-10-31
9 -- Project : 8b/10b Encoder Reference Design
11 -- Description : LUT-based Single-port Base Encoder
13 -- Company : Xilinx, Inc.
15 -- DISCLAIMER OF LIABILITY
17 -- This file contains proprietary and confidential information of
18 -- Xilinx, Inc. ("Xilinx"), that
is distributed under a license
19 -- from Xilinx, and may be used, copied and/or disclosed only
20 -- pursuant to the terms of a valid license agreement with Xilinx.
22 -- XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION
23 -- ("MATERIALS") "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER
24 -- EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING WITHOUT
25 -- LIMITATION, ANY WARRANTY WITH RESPECT TO NONINFRINGEMENT,
26 -- MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE. Xilinx
27 -- does not warrant that functions included in the Materials will
28 -- meet the requirements of Licensee, or that the operation of the
29 -- Materials will be uninterrupted or error-free, or that defects
30 -- in the Materials will be corrected. Furthermore, Xilinx does
31 -- not warrant or make any representations regarding use, or the
32 -- results of the use, of the Materials in terms of correctness,
33 -- accuracy, reliability or otherwise.
35 -- Xilinx products are not designed or intended to be fail-safe,
36 -- or for use in any application requiring fail-safe performance,
37 -- such as life-support or safety devices or systems, Class III
38 -- medical devices, nuclear facilities, applications related to
39 -- the deployment of airbags, or any other applications that could
40 -- lead to death, personal injury or severe property or
41 -- environmental damage (individually and collectively, "critical
42 -- applications"). Customer assumes the sole risk and liability
43 -- of any use of Xilinx products in critical applications,
44 -- subject only to applicable laws and regulations governing
45 -- limitations on product liability.
47 -- Copyright 2000,
2001,
2002,
2003,
2004,
2008 Xilinx, Inc.
48 -- All rights reserved.
50 -- This disclaimer and copyright notice must be retained as part
51 -- of this file at all times.
53 ---------------------------------------------------------------------------
57 -- Date Version Description
59 -- 10/31/2008 1.
1 Initial
release
61 -------------------------------------------------------------------------------
64 USE IEEE.std_logic_1164.
ALL;
71 C_HAS_FORCE_CODE : :=0 ;
72 C_FORCE_CODE_VAL : :="1010101010" ;
73 C_FORCE_CODE_DISP : :=0 ;
78 DIN : IN (7 DOWNTO 0) :=(OTHERS => '0');
81 DOUT : OUT (9 DOWNTO 0) :=
82 str_to_slv(C_FORCE_CODE_VAL, 10) ;
84 FORCE_CODE : IN :='0' ;
85 FORCE_DISP : IN :='0' ;
88 bint_2_sl(C_FORCE_CODE_DISP);
92 END encode_8b10b_lut_base;
94 -----------------------------------------------------------------
96 -----------------------------------------------------------------
99 -----------------------------------------------------------------
100 -- Constant Declarations
101 -----------------------------------------------------------------
102 CONSTANT POS : := '1' ;
103 CONSTANT NEG : := '0' ;
105 ------------------------------------------------------------------
106 -- Signal Declarations
107 ------------------------------------------------------------------
108 SIGNAL b6 : (5 DOWNTO 0) :=(OTHERS => '0');
109 SIGNAL b4 : (3 DOWNTO 0) :=(OTHERS => '0');
110 SIGNAL pdes6 : :='0';
111 SIGNAL pdes4 : :='0';
116 SIGNAL disp_in_i : :='0';
117 SIGNAL disp_run : :=bint_2_sl(C_FORCE_CODE_DISP);
118 SIGNAL kerr_i : :='0' ;
120 ALIAS a : IS DIN(0) ;
121 ALIAS b : IS DIN(1) ;
122 ALIAS c : IS DIN(2) ;
123 ALIAS d : IS DIN(3) ;
124 ALIAS e : IS DIN(4) ;
125 ALIAS b5 : (4 DOWNTO 0) IS DIN(4 DOWNTO 0) ;
126 ALIAS b3 : (2 DOWNTO 0) IS DIN(7 DOWNTO 5) ;
128 -----------------------------------------------------------------
129 -- Begin Architecture
130 -----------------------------------------------------------------
133 -----------------------------------------------------------------
134 -- Map internal signals to proper port names
135 -----------------------------------------------------------------
136 DISP_OUT <= disp_run ;
139 -------------------------------------------------------------------------------
140 -- Calculate intermediate terms using notation and logic from 8b/10b spec
141 -------------------------------------------------------------------------------
142 k28 <= boolean_to_std_logic((KIN = '1') AND (b5 = "11100")) ;
143 l13 <= (((a XOR b) AND NOT(c OR d)) OR ((c XOR d) AND NOT(a OR b)));
144 l31 <= (((a XOR b) AND (c AND d)) OR ((c XOR d) AND (a AND b)));
145 a7 <= (KIN OR ((l31 AND D AND NOT(e) AND disp_in_i) OR
146 (l13 AND NOT(d) AND e AND NOT(disp_in_i))));
148 ------------------------------------------------------
149 -- Check for invalid K codes
150 ------------------------------------------------------
151 gke : IF (C_HAS_KERR = 1) GENERATE
154 IF (CLK'event AND CLK = '1') THEN
156 IF (FORCE_CODE='1') THEN
157 kerr_i <= NEG AFTER TFF;
158 ELSIF (b5 = "11100") THEN
159 kerr_i <= NEG AFTER TFF;
160 ELSIF (b3 /= "111") THEN
161 kerr_i <= KIN AFTER TFF;
162 ELSIF ((b5 /= "10111") AND (b5 /= "11011") AND (b5 /= "11101")
163 AND (b5 /= "11110")) THEN
164 kerr_i <= KIN AFTER TFF;
166 kerr_i <= NEG AFTER TFF;
173 ngke : IF (C_HAS_KERR /= 1) GENERATE
177 -------------------------------------------------------
178 --Do the 5B/6B conversion (calculate the 6b symbol)
179 -------------------------------------------------------
180 PROCESS (b5, k28, disp_in_i)
182 IF (k28='1') THEN --K.28
183 IF (disp_in_i = NEG) THEN
190 WHEN "00000" => --D.0
192 THEN b6 <= "000110" ;
193 ELSE b6 <= "111001" ;
195 WHEN "00001" => --D.1
197 THEN b6 <= "010001" ;
198 ELSE b6 <= "101110" ;
200 WHEN "00010" => --D.2
202 THEN b6 <= "010010" ;
203 ELSE b6 <= "101101" ;
205 WHEN "00011" => b6 <= "100011" ;
--D.3
206 WHEN "00100" => --D.4
208 THEN b6 <= "010100" ;
209 ELSE b6 <= "101011" ;
211 WHEN "00101" => b6 <= "100101" ;
--D.5
212 WHEN "00110" => b6 <= "100110" ;
--D.6
213 WHEN "00111" => --D.7
215 THEN b6 <= "000111" ;
216 ELSE b6 <= "111000" ;
218 WHEN "01000" => --D.8
220 THEN b6 <= "011000" ;
221 ELSE b6 <= "100111" ;
223 WHEN "01001" => b6 <= "101001" ;
--D.9
224 WHEN "01010" => b6 <= "101010" ;
--D.10
225 WHEN "01011" => b6 <= "001011" ;
--D.11
226 WHEN "01100" => b6 <= "101100" ;
--D.12
227 WHEN "01101" => b6 <= "001101" ;
--D.13
228 WHEN "01110" => b6 <= "001110" ;
--D.14
229 WHEN "01111" => --D.15
231 THEN b6 <= "000101" ;
232 ELSE b6 <= "111010" ;
235 WHEN "10000" => --D.16
237 THEN b6 <= "110110" ;
238 ELSE b6 <= "001001" ;
240 WHEN "10001" => b6 <= "110001" ;
--D.17
241 WHEN "10010" => b6 <= "110010" ;
--D.18
242 WHEN "10011" => b6 <= "010011" ;
--D.19
243 WHEN "10100" => b6 <= "110100" ;
--D.20
244 WHEN "10101" => b6 <= "010101" ;
--D.21
245 WHEN "10110" => b6 <= "010110" ;
--D.22
246 WHEN "10111" => --D/K.23
248 THEN b6 <= "010111" ;
249 ELSE b6 <= "101000" ;
251 WHEN "11000" => --D.24
253 THEN b6 <= "001100" ;
254 ELSE b6 <= "110011" ;
256 WHEN "11001" => b6 <= "011001" ;
--D.25
257 WHEN "11010" => b6 <= "011010" ;
--D.26
258 WHEN "11011" => --D/K.27
260 THEN b6 <= "011011" ;
261 ELSE b6 <= "100100" ;
263 WHEN "11100" => b6 <= "011100" ;
--D.28
264 WHEN "11101" => --D/K.29
266 THEN b6 <= "011101" ;
267 ELSE b6 <= "100010" ;
269 WHEN "11110" => --D/K.30
271 THEN b6 <= "011110" ;
272 ELSE b6 <= "100001" ;
274 WHEN "11111" => --D.31
276 THEN b6 <= "110101" ;
277 ELSE b6 <= "001010" ;
284 -------------------------------------------------------
285 -- Calculate the running disparity -after- the 6B symbol
286 -------------------------------------------------------
287 PROCESS (b5, k28, disp_in_i)
290 pdes6 <= NOT(disp_in_i) ;
293 WHEN "00000" => pdes6 <= NOT(disp_in_i) ;
294 WHEN "00001" => pdes6 <= NOT(disp_in_i) ;
295 WHEN "00010" => pdes6 <= NOT(disp_in_i) ;
296 WHEN "00011" => pdes6 <= disp_in_i ;
297 WHEN "00100" => pdes6 <= NOT(disp_in_i) ;
298 WHEN "00101" => pdes6 <= disp_in_i ;
299 WHEN "00110" => pdes6 <= disp_in_i ;
300 WHEN "00111" => pdes6 <= disp_in_i ;
302 WHEN "01000" => pdes6 <= NOT(disp_in_i) ;
303 WHEN "01001" => pdes6 <= disp_in_i ;
304 WHEN "01010" => pdes6 <= disp_in_i ;
305 WHEN "01011" => pdes6 <= disp_in_i ;
306 WHEN "01100" => pdes6 <= disp_in_i ;
307 WHEN "01101" => pdes6 <= disp_in_i ;
308 WHEN "01110" => pdes6 <= disp_in_i ;
309 WHEN "01111" => pdes6 <= NOT(disp_in_i) ;
311 WHEN "10000" => pdes6 <= NOT(disp_in_i) ;
312 WHEN "10001" => pdes6 <= disp_in_i ;
313 WHEN "10010" => pdes6 <= disp_in_i ;
314 WHEN "10011" => pdes6 <= disp_in_i ;
315 WHEN "10100" => pdes6 <= disp_in_i ;
316 WHEN "10101" => pdes6 <= disp_in_i ;
317 WHEN "10110" => pdes6 <= disp_in_i ;
318 WHEN "10111" => pdes6 <= NOT(disp_in_i) ;
320 WHEN "11000" => pdes6 <= NOT(disp_in_i) ;
321 WHEN "11001" => pdes6 <= disp_in_i ;
322 WHEN "11010" => pdes6 <= disp_in_i ;
323 WHEN "11011" => pdes6 <= NOT(disp_in_i) ;
324 WHEN "11100" => pdes6 <= disp_in_i ;
325 WHEN "11101" => pdes6 <= NOT(disp_in_i) ;
326 WHEN "11110" => pdes6 <= NOT(disp_in_i) ;
327 WHEN "11111" => pdes6 <= NOT(disp_in_i) ;
328 WHEN OTHERS => pdes6 <= disp_in_i;
333 ------------------------------------------------------
334 -- Do the 3B/4B conversion (calculate the 4b symbol)
335 ------------------------------------------------------
336 PROCESS (b3, k28, pdes6, a7)
339 WHEN "000" => --D/K.x.0
344 WHEN "001" => --D/K.x.1
345 IF ((k28='1') AND (pdes6 = NEG))
349 WHEN "010" => --D/K.x.2
350 IF ((k28='1') AND (pdes6 = NEG))
354 WHEN "011" => --D/K.x.3
359 WHEN "100" => --D/K.x.4
364 WHEN "101" => --D/K.x.5
365 IF ((k28='1') AND (pdes6 = NEG))
369 WHEN "110" => --D/K.x.6
370 IF ((k28='1') AND (pdes6 = NEG))
374 WHEN "111" => --D.x.P7
391 -------------------------------------------------------
392 -- Calculate the running disparity -after- the 4B symbol
393 -------------------------------------------------------
397 WHEN "000" => pdes4 <= NOT(pdes6) ;
398 WHEN "001" => pdes4 <= pdes6 ;
399 WHEN "010" => pdes4 <= pdes6 ;
400 WHEN "011" => pdes4 <= pdes6 ;
401 WHEN "100" => pdes4 <= NOT(pdes6) ;
402 WHEN "101" => pdes4 <= pdes6 ;
403 WHEN "110" => pdes4 <= pdes6 ;
404 WHEN "111" => pdes4 <= NOT(pdes6) ;
405 WHEN OTHERS => pdes4 <= pdes6;
409 -------------------------------------------------------
410 -- Update the running disparity on the clock
411 -------------------------------------------------------
412 gdr: IF ((C_HAS_FORCE_CODE = 1) AND (C_FORCE_CODE_DISP = 1)) GENERATE
415 IF (CLK'event AND CLK = '1') THEN
417 IF (FORCE_CODE = '1') THEN
418 disp_run <= '1' AFTER TFF;
420 disp_run <= pdes4 AFTER TFF;
427 gdc: IF ((C_HAS_FORCE_CODE = 1) AND (C_FORCE_CODE_DISP = 0)) GENERATE
430 IF (CLK'event AND CLK = '1') THEN
432 IF (FORCE_CODE = '1') THEN
433 disp_run <= '0' AFTER TFF;
435 disp_run <= pdes4 AFTER TFF;
442 ngdb: IF (C_HAS_FORCE_CODE = 0) GENERATE
445 IF (CLK'event AND CLK = '1') THEN
447 disp_run <= pdes4 AFTER TFF;
453 --------------------------------------------------------
454 -- Override the internal running disparity if FORCE_DISP=1
455 --------------------------------------------------------
456 gpd: IF (C_HAS_DISP_IN = 1) GENERATE
457 PROCESS (FORCE_DISP, DISP_IN, disp_run)
459 IF (FORCE_DISP = '1') THEN
460 disp_in_i <= DISP_IN ;
462 disp_in_i <= disp_run ;
467 ngpd: IF (C_HAS_DISP_IN=0) GENERATE
468 disp_in_i <= disp_run;
471 --------------------------------------------------------
472 -- Update the data output on the clock
473 --------------------------------------------------------
476 IF (CLK'event AND CLK = '1') THEN
478 IF (FORCE_CODE = '1') THEN
479 DOUT <= str_to_slv(C_FORCE_CODE_VAL, 10) AFTER TFF;
481 DOUT <= (b4 & b6) AFTER TFF ;
487 -------------------------------------------------------
488 -- Update the ND output on the clock
489 -------------------------------------------------------
490 gnd: IF (C_HAS_ND=1) GENERATE
493 IF (CLK'event AND CLK = '1') THEN
494 IF (FORCE_CODE = '1') THEN