| 1 |
2 |
kboyette |
-------------------------------------------------------------------------------
|
| 2 |
|
|
--
|
| 3 |
|
|
-- Title : 8b/10b Decoder
|
| 4 |
|
|
-- Design : 10-bit to 8-bit Decoder
|
| 5 |
|
|
-- Project : 8000 - 8b10b_encdec
|
| 6 |
|
|
-- Author : Ken Boyette
|
| 7 |
|
|
-- Company : Critia Computer, Inc.
|
| 8 |
|
|
--
|
| 9 |
|
|
-------------------------------------------------------------------------------
|
| 10 |
|
|
--
|
| 11 |
|
|
-- File : 8b10b_dec.vhd
|
| 12 |
|
|
-- Version : 1.0
|
| 13 |
|
|
-- Generated : 09.27.2006
|
| 14 |
|
|
-- By : Itf2Vhdl ver. 1.20
|
| 15 |
|
|
--
|
| 16 |
|
|
-------------------------------------------------------------------------------
|
| 17 |
|
|
--
|
| 18 |
|
|
-- Description :
|
| 19 |
|
|
-- This module provides 10-bit to 9-bit encoding.
|
| 20 |
|
|
-- It accepts 10-bit encoded parallel data input and generates 8-bit decoded
|
| 21 |
|
|
-- data output in accordance with the 8b/10b standard method. This method was
|
| 22 |
|
|
-- described in the 1983 IBM publication "A DC-Balanced, Partitioned-Block,
|
| 23 |
|
|
-- 8B/10B Transmission Code" by A.X. Widmer and P.A. Franaszek. The method
|
| 24 |
|
|
-- WAS granted a U.S. Patent #4,486,739 in 1984; now expired.
|
| 25 |
|
|
--
|
| 26 |
|
|
-- The parallel 10-bit Binary input represent 1024 possible values, called
|
| 27 |
|
|
-- characters - only 268 of which are valid.
|
| 28 |
|
|
--
|
| 29 |
|
|
-- The input is a 10-bit encoded character whose bits are identified as:
|
| 30 |
|
|
-- AI, BI, CI, DI, EI, II, FI, GI, HI, JI (Least Significant to Most)
|
| 31 |
|
|
--
|
| 32 |
|
|
-- In addition to 256 data output characters, there are 12 special control
|
| 33 |
|
|
-- or K, characters defined for command and synchronization use.
|
| 34 |
|
|
--
|
| 35 |
|
|
-- The eight data output bits are identified as:
|
| 36 |
|
|
-- HI, GI, FI, EI, DI, CI, BI, AI (Most Significant to Least)
|
| 37 |
|
|
--
|
| 38 |
|
|
-- The output, KO, is used to indicate the output value is one of the
|
| 39 |
|
|
-- control characters.
|
| 40 |
|
|
--
|
| 41 |
|
|
-- All inputs and outputs are synchronous with an externally supplied
|
| 42 |
|
|
-- byte rate clock BYTECLK.
|
| 43 |
|
|
-- The encoded output is valid one clock after the input.
|
| 44 |
|
|
-- There is a reset input, RESET, to reset the logic. The next rising
|
| 45 |
|
|
-- BYTECLK after RESET is deasserted latches valid input data.
|
| 46 |
|
|
--
|
| 47 |
|
|
-- Note: This VHDL structure closely follows the discrete logic defined
|
| 48 |
|
|
-- in the original article and the subsequent patent. The Figures
|
| 49 |
|
|
-- referenced are those in the patent.
|
| 50 |
|
|
-------------------------------------------------------------------------------
|
| 51 |
|
|
-- This program is licensed under the GPL
|
| 52 |
|
|
-------------------------------------------------------------------------------
|
| 53 |
|
|
|
| 54 |
|
|
library IEEE;
|
| 55 |
|
|
use IEEE.STD_LOGIC_1164.all;
|
| 56 |
|
|
|
| 57 |
|
|
entity dec_8b10b is
|
| 58 |
|
|
port(
|
| 59 |
|
|
RESET : in std_logic ; -- Global asynchronous reset (AH)
|
| 60 |
|
|
RBYTECLK : in std_logic ; -- Master synchronous receive byte clock
|
| 61 |
|
|
AI, BI, CI, DI, EI, II : in std_logic ;
|
| 62 |
|
|
FI, GI, HI, JI : in std_logic ; -- Encoded input (LS..MS)
|
| 63 |
|
|
KO : out std_logic ; -- Control (K) character indicator (AH)
|
| 64 |
|
|
HO, GO, FO, EO, DO, CO, BO, AO : out std_logic -- Decoded out (MS..LS)
|
| 65 |
|
|
);
|
| 66 |
|
|
end dec_8b10b;
|
| 67 |
|
|
|
| 68 |
|
|
architecture behavioral of dec_8b10b is
|
| 69 |
|
|
|
| 70 |
|
|
-- Signals to tie things together
|
| 71 |
|
|
signal ANEB, CNED, EEI, P13, P22, P31 : std_logic ; -- Figure 10 Signals
|
| 72 |
|
|
signal IKA, IKB, IKC : std_logic ; -- Figure 11 Signals
|
| 73 |
|
|
signal XA, XB, XC, XD, XE : std_logic ; -- Figure 12 Signals
|
| 74 |
|
|
signal OR121, OR122, OR123, OR124, OR125, OR126, OR127 : std_logic ;
|
| 75 |
|
|
signal XF, XG, XH : std_logic ; -- Figure 13 Signals
|
| 76 |
|
|
signal OR131, OR132, OR133, OR134, IOR134 : std_logic ;
|
| 77 |
|
|
|
| 78 |
|
|
begin
|
| 79 |
|
|
|
| 80 |
|
|
--
|
| 81 |
|
|
-- 6b Input Function (Reference: Figure 10)
|
| 82 |
|
|
--
|
| 83 |
|
|
|
| 84 |
|
|
-- One 1 and three 0's
|
| 85 |
|
|
P13 <= (ANEB and (not CI and not DI))
|
| 86 |
|
|
or (CNED and (not AI and not BI)) ;
|
| 87 |
|
|
-- Three 1's and one 0
|
| 88 |
|
|
P31 <= (ANEB and CI and DI)
|
| 89 |
|
|
or (CNED and AI and BI) ;
|
| 90 |
|
|
-- Two 1's and two 0's
|
| 91 |
|
|
P22 <= (AI and BI and (not CI and not DI))
|
| 92 |
|
|
or (CI and DI and (not AI and not BI))
|
| 93 |
|
|
or (ANEB and CNED) ;
|
| 94 |
|
|
|
| 95 |
|
|
-- Intermediate term for "AI is Not Equal to BI"
|
| 96 |
|
|
ANEB <= AI xor BI ;
|
| 97 |
|
|
|
| 98 |
|
|
-- Intermediate term for "CI is Not Equal to DI"
|
| 99 |
|
|
CNED <= CI xor DI ;
|
| 100 |
|
|
|
| 101 |
|
|
-- Intermediate term for "E is Equal to I"
|
| 102 |
|
|
EEI <= EI xnor II ;
|
| 103 |
|
|
|
| 104 |
|
|
--
|
| 105 |
|
|
-- K Decoder - Figure 11
|
| 106 |
|
|
--
|
| 107 |
|
|
|
| 108 |
|
|
-- Intermediate terms
|
| 109 |
|
|
IKA <= (CI and DI and EI and II)
|
| 110 |
|
|
or (not CI and not DI and not EI and not II) ;
|
| 111 |
|
|
IKB <= P13 and (not EI and II and GI and HI and JI) ;
|
| 112 |
|
|
IKC <= P31 and (EI and not II and not GI and not HI and not JI) ;
|
| 113 |
|
|
|
| 114 |
|
|
-- PROCESS: KFN; Determine K output
|
| 115 |
|
|
KFN: process (RESET, RBYTECLK, IKA, IKB, IKC)
|
| 116 |
|
|
begin
|
| 117 |
|
|
if RESET = '1' then
|
| 118 |
|
|
KO <= '0';
|
| 119 |
|
|
elsif RBYTECLK'event and RBYTECLK = '0' then
|
| 120 |
|
|
KO <= IKA or IKB or IKC;
|
| 121 |
|
|
end if;
|
| 122 |
|
|
end process KFN;
|
| 123 |
|
|
|
| 124 |
|
|
--
|
| 125 |
|
|
-- 5b Decoder Figure 12
|
| 126 |
|
|
--
|
| 127 |
|
|
|
| 128 |
|
|
-- Logic to determine complimenting A,B,C,D,E,I inputs
|
| 129 |
|
|
OR121 <= (P22 and (not AI and not CI and EEI))
|
| 130 |
|
|
or (P13 and not EI) ;
|
| 131 |
|
|
OR122 <= (AI and BI and EI and II)
|
| 132 |
|
|
or (not CI and not DI and not EI and not II)
|
| 133 |
|
|
or (P31 and II) ;
|
| 134 |
|
|
OR123 <= (P31 and II)
|
| 135 |
|
|
or (P22 and BI and CI and EEI)
|
| 136 |
|
|
or (P13 and DI and EI and II) ;
|
| 137 |
|
|
OR124 <= (P22 and AI and CI and EEI)
|
| 138 |
|
|
or (P13 and not EI) ;
|
| 139 |
|
|
OR125 <= (P13 and not EI)
|
| 140 |
|
|
or (not CI and not DI and not EI and not II)
|
| 141 |
|
|
or (not AI and not BI and not EI and not II) ;
|
| 142 |
|
|
OR126 <= (P22 and not AI and not CI and EEI)
|
| 143 |
|
|
or (P13 and not II) ;
|
| 144 |
|
|
OR127 <= (P13 and DI and EI and II)
|
| 145 |
|
|
or (P22 and not BI and not CI and EEI) ;
|
| 146 |
|
|
|
| 147 |
|
|
XA <= OR127
|
| 148 |
|
|
or OR121
|
| 149 |
|
|
or OR122 ;
|
| 150 |
|
|
XB <= OR122
|
| 151 |
|
|
or OR123
|
| 152 |
|
|
or OR124 ;
|
| 153 |
|
|
XC <= OR121
|
| 154 |
|
|
or OR123
|
| 155 |
|
|
or OR125 ;
|
| 156 |
|
|
XD <= OR122
|
| 157 |
|
|
or OR124
|
| 158 |
|
|
or OR127 ;
|
| 159 |
|
|
XE <= OR125
|
| 160 |
|
|
or OR126
|
| 161 |
|
|
or OR127 ;
|
| 162 |
|
|
|
| 163 |
|
|
-- PROCESS: DEC5B; Generate and latch LS 5 decoded bits
|
| 164 |
|
|
DEC5B: process (RESET, RBYTECLK, XA, XB, XC, XD, XE, AI, BI, CI, DI, EI)
|
| 165 |
|
|
begin
|
| 166 |
|
|
if RESET = '1' then
|
| 167 |
|
|
AO <= '0' ;
|
| 168 |
|
|
BO <= '0' ;
|
| 169 |
|
|
CO <= '0' ;
|
| 170 |
|
|
DO <= '0' ;
|
| 171 |
|
|
EO <= '0' ;
|
| 172 |
|
|
elsif RBYTECLK'event and RBYTECLK = '0' then
|
| 173 |
|
|
AO <= XA XOR AI ; -- Least significant bit 0
|
| 174 |
|
|
BO <= XB XOR BI ;
|
| 175 |
|
|
CO <= XC XOR CI ;
|
| 176 |
|
|
DO <= XD XOR DI ;
|
| 177 |
|
|
EO <= XE XOR EI ; -- Most significant bit 6
|
| 178 |
|
|
end if;
|
| 179 |
|
|
end process DEC5B;
|
| 180 |
|
|
|
| 181 |
|
|
--
|
| 182 |
|
|
-- 3b Decoder - Figure 13
|
| 183 |
|
|
--
|
| 184 |
|
|
|
| 185 |
|
|
-- Logic for complimenting F,G,H outputs
|
| 186 |
|
|
OR131 <= (GI and HI and JI)
|
| 187 |
|
|
or (FI and HI and JI)
|
| 188 |
|
|
or (IOR134);
|
| 189 |
|
|
OR132 <= (FI and GI and JI)
|
| 190 |
|
|
or (not FI and not GI and not HI)
|
| 191 |
|
|
or (not FI and not GI and HI and JI);
|
| 192 |
|
|
OR133 <= (not FI and not HI and not JI)
|
| 193 |
|
|
or (IOR134)
|
| 194 |
|
|
or (not GI and not HI and not JI) ;
|
| 195 |
|
|
OR134 <= (not GI and not HI and not JI)
|
| 196 |
|
|
or (FI and HI and JI)
|
| 197 |
|
|
or (IOR134) ;
|
| 198 |
|
|
IOR134 <= (not (HI and JI))
|
| 199 |
|
|
and (not (not HI and not JI))
|
| 200 |
|
|
and (not CI and not DI and not EI and not II) ;
|
| 201 |
|
|
|
| 202 |
|
|
XF <= OR131
|
| 203 |
|
|
or OR132 ;
|
| 204 |
|
|
XG <= OR132
|
| 205 |
|
|
or OR133 ;
|
| 206 |
|
|
XH <= OR132
|
| 207 |
|
|
or OR134 ;
|
| 208 |
|
|
|
| 209 |
|
|
-- PROCESS: DEC3B; Generate and latch MS 3 decoded bits
|
| 210 |
|
|
DEC3B: process (RESET, RBYTECLK, XF, XG, XH, FI, GI, HI)
|
| 211 |
|
|
begin
|
| 212 |
|
|
if RESET = '1' then
|
| 213 |
|
|
FO <= '0' ;
|
| 214 |
|
|
GO <= '0' ;
|
| 215 |
|
|
HO <= '0' ;
|
| 216 |
|
|
elsif RBYTECLK'event and RBYTECLK ='0' then
|
| 217 |
|
|
FO <= XF XOR FI ; -- Least significant bit 7
|
| 218 |
|
|
GO <= XG XOR GI ;
|
| 219 |
|
|
HO <= XH XOR HI ; -- Most significant bit 10
|
| 220 |
|
|
end if;
|
| 221 |
|
|
end process DEC3B ;
|
| 222 |
|
|
|
| 223 |
|
|
end behavioral;
|
| 224 |
|
|
|