8b/10b — Overview, Tables & Implementation Notes
Overview
8b/10b encoding maps each 8‑bit symbol into a 10‑bit code group with controlled disparity and guaranteed transition density. It provides DC balance, bounded run length, control characters, and immediate error detection. It is used in Gigabit Ethernet, PCIe Gen1/2, Fibre Channel, Serial RapidIO, SATA, and early DisplayPort.
This page consolidates the architectural description, encoding/decoding tables, K‑character definitions, and RTL implementation notes.
1. Why 8b/10b Exists
- DC balance through running disparity
- Transition density for stable CDR
- Control characters (K‑codes) for alignment and protocol control
- Error detection via invalid codes and disparity violations
2. Encoder & Decoder Architecture
Encoder
- 8 bits → 5b/6b encoder → 3b/4b encoder → 10 bits
- running disparity determines RD– or RD+ version
- explicit handling of K‑codes
Decoder
- 10 bits → 6b/5b decoder → 4b/3b decoder → 8 bits
- classification (data vs control)
- disparity validation
- error detection
3. Running Disparity (RD)
Running disparity is a single‑bit state:
- RD = +1 → previous symbol had more 1s
- RD = –1 → previous symbol had more 0s
Each symbol has two versions (RD– and RD+).
The encoder selects the version that keeps RD bounded.
4. Control Characters (K‑codes)
K‑characters are special non‑data symbols used for:
- comma alignment
- framing
- training sequences
- protocol control
K28.5 is the canonical comma symbol and the only K‑character that is provably non‑emulable by any D.x.y pattern.
5. 5b/6b Encoding Table
| Input (5b) | RD− Code (6b) | RD+ Code (6b) | Notes |
|---|---|---|---|
| 00000 | 100111 | 011000 | D.0 |
| 00001 | 011101 | 100010 | D.1 |
| 00010 | 101101 | 010010 | D.2 |
| 00011 | 110001 | 110001 | D.3 (neutral) |
| 00100 | 110101 | 001010 | D.4 |
| 00101 | 101001 | 101001 | D.5 (neutral) |
| 00110 | 011001 | 011001 | D.6 (neutral) |
| 00111 | 111000 | 000111 | D.7 |
| 01000 | 111001 | 000110 | D.8 |
| 01001 | 100101 | 100101 | D.9 (neutral) |
| 01010 | 010101 | 010101 | D.10 (neutral) |
| 01011 | 110100 | 001011 | D.11 |
| 01100 | 001101 | 001101 | D.12 (neutral) |
| 01101 | 101100 | 010011 | D.13 |
| 01110 | 011100 | 100011 | D.14 |
| 01111 | 010111 | 101000 | D.15 |
| 10000 | 011011 | 100100 | D.16 |
| 10001 | 100011 | 011100 | D.17 |
| 10010 | 010011 | 101100 | D.18 |
| 10011 | 110010 | 110010 | D.19 (neutral) |
| 10100 | 001011 | 110100 | D.20 |
| 10101 | 101010 | 010101 | D.21 |
| 10110 | 011010 | 100101 | D.22 |
| 10111 | 111010 | 000101 | D.23 |
| 11000 | 110011 | 001100 | D.24 |
| 11001 | 100110 | 011001 | D.25 |
| 11010 | 010110 | 101001 | D.26 |
| 11011 | 110110 | 001001 | D.27 |
| 11100 | 001110 | 110001 | D.28 |
| 11101 | 101110 | 010001 | D.29 |
| 11110 | 011110 | 100001 | D.30 |
| 11111 | 101011 | 010100 | D.31 |
6. 3b/4b Encoding Table
| Input (3b) | RD− Code (4b) | RD+ Code (4b) | Notes |
|---|---|---|---|
| 000 | 0100 | 1011 | D.x.0 |
| 001 | 1001 | 0110 | D.x.1 |
| 010 | 0101 | 1010 | D.x.2 |
| 011 | 1100 | 0011 | D.x.3 |
| 100 | 1101 | 0010 | D.x.4 |
| 101 | 1011 | 0100 | D.x.5 |
| 110 | 0111 | 1000 | D.x.6 |
| 111 | 1110 | 0001 | D.x.7 |
7. K‑Character Tables
K‑Character Table
| K‑code | 5b/6b (RD− / RD+) | 3b/4b (RD− / RD+) | Notes |
|---|---|---|---|
| K28.0 | 001111 / 110000 | 0100 / 1011 | Special |
| K28.1 | 001111 / 110000 | 1001 / 0110 | Special |
| K28.2 | 001111 / 110000 | 0101 / 1010 | Special |
| K28.5 | 001111 / 110000 | 1010 / 0101 | Comma character |
| K28.6 | 001111 / 110000 | 0111 / 1000 | Special |
| K28.7 | 001111 / 110000 | 1110 / 0001 | Special |
Non‑Emulability Notes
- K28.5 has a unique run‑length pattern → cannot be produced by any D‑character
- other K‑characters are reserved but not mathematically unique
Example Table
| K‑code | 10b pattern | Notes |
|---|---|---|
| K.28.5 | 001111 1010 / 110000 0101 | Comma symbol; the only K‑character that is provably non‑emulable by any D.x.y. |
| K.28.0 | 001111 0100 / 110000 1011 | Reserved control symbol; may overlap with D‑patterns depending on disparity. |
| K.28.1 | 001111 1001 / 110000 0110 | Control symbol; not used for comma alignment. |
| K.28.2 | 001111 0101 / 110000 1010 | Reserved control symbol. |
| K.28.3 | 001111 0011 / 110000 1100 | Protocol‑level control; not guaranteed to be non‑emulable. |
| K.28.4 | 001111 0010 / 110000 1101 | Reserved control symbol. |
| K.28.6 | 001111 0110 / 110000 1001 | Control symbol; may share patterns with D‑characters. |
| K.28.7 | 001111 1110 / 110000 0001 | Reserved control symbol; not a comma. |
8. 6b/5b Decoding Table
| 6b code | 5b output | Notes |
|---|---|---|
| 100111 | 00000 | D.0 |
| 011000 | 00000 | D.0 |
| 011101 | 00001 | D.1 |
| 100010 | 00001 | D.1 |
| 101101 | 00010 | D.2 |
| 010010 | 00010 | D.2 |
| 110001 | 00011 | D.3 (also used by D.28, context‑dependent) |
| 110101 | 00100 | D.4 |
| 001010 | 00100 | D.4 |
| 101001 | 00101 | D.5 |
| 011001 | 00110 | D.6 (also used by D.25, context‑dependent) |
| 111000 | 00111 | D.7 |
| 000111 | 00111 | D.7 |
| 111001 | 01000 | D.8 |
| 000110 | 01000 | D.8 |
| 100101 | 01001 | D.9 (also used by D.22, context‑dependent) |
| 010101 | 01010 | D.10 (also used by D.21, context‑dependent) |
| 110100 | 01011 | D.11 (also used by D.20, context‑dependent) |
| 001011 | 01011 | D.11 (also used by D.20, context‑dependent) |
| 001101 | 01100 | D.12 |
| 101100 | 01101 | D.13 (also used by D.18, context‑dependent) |
| 010011 | 01101 | D.13 (also used by D.18, context‑dependent) |
| 011100 | 01110 | D.14 (also used by D.17, context‑dependent) |
| 100011 | 01110 | D.14 (also used by D.17, context‑dependent) |
| 010111 | 01111 | D.15 |
| 101000 | 01111 | D.15 |
| 011011 | 10000 | D.16 |
| 100100 | 10000 | D.16 |
| 100011 | 10001 | D.17 (also used by D.14, context‑dependent) |
| 011100 | 10001 | D.17 (also used by D.14, context‑dependent) |
| 010011 | 10010 | D.18 (also used by D.13, context‑dependent) |
| 101100 | 10010 | D.18 (also used by D.13, context‑dependent) |
| 110010 | 10011 | D.19 |
| 001011 | 10100 | D.20 (also used by D.11, context‑dependent) |
| 110100 | 10100 | D.20 (also used by D.11, context‑dependent) |
| 101010 | 10101 | D.21 (also used by D.10, context‑dependent) |
| 010101 | 10101 | D.21 (also used by D.10, context‑dependent) |
| 011010 | 10110 | D.22 (also used by D.9, context‑dependent) |
| 100101 | 10110 | D.22 (also used by D.9, context‑dependent) |
| 111010 | 10111 | D.23 |
| 000101 | 10111 | D.23 |
| 110011 | 11000 | D.24 |
| 001100 | 11000 | D.24 |
| 100110 | 11001 | D.25 |
| 011001 | 11001 | D.25 (also used by D.6, context‑dependent) |
| 010110 | 11010 | D.26 |
| 101001 | 11010 | D.26 (also used by D.5, context‑dependent) |
| 110110 | 11011 | D.27 |
| 001001 | 11011 | D.27 |
| 001110 | 11100 | D.28 |
| 110001 | 11100 | D.28 (also used by D.3, context‑dependent) |
| 101110 | 11101 | D.29 |
| 010001 | 11101 | D.29 |
| 011110 | 11110 | D.30 |
| 100001 | 11110 | D.30 |
| 101011 | 11111 | D.31 |
| 010100 | 11111 | D.31 |
9. 4b/3b Decoding Table
| 4b code | 3b output | Notes |
|---|---|---|
| 0100 | 000 | D.x.0 (also used by D.x.5, context‑dependent) |
| 1011 | 000 | D.x.0 (also used by D.x.5, context‑dependent) |
| 1001 | 001 | D.x.1 |
| 0110 | 001 | D.x.1 |
| 0101 | 010 | D.x.2 |
| 1010 | 010 | D.x.2 |
| 1100 | 011 | D.x.3 |
| 0011 | 011 | D.x.3 |
| 1101 | 100 | D.x.4 |
| 0010 | 100 | D.x.4 |
| 1011 | 101 | D.x.5 (also used by D.x.0, context‑dependent) |
| 0100 | 101 | D.x.5 (also used by D.x.0, context‑dependent) |
| 0111 | 110 | D.x.6 |
| 1000 | 110 | D.x.6 |
| 1110 | 111 | D.x.7 |
| 0001 | 111 | D.x.7 |
10. RTL Implementation Notes
Encoder
- table‑driven or logic‑driven
- RD stored as a single flip‑flop
- explicit K‑code handling
- optional pipelining
- bit ordering must match serializer
Decoder
- detect invalid 10‑bit codes
- detect disparity errors
- extract K‑flag
- reconstruct 8‑bit symbol
- provide error flags
11. Example VHDL Skeleton
entity encoder_8b10b is
port (
clk : in std_logic;
din : in std_logic_vector(7 downto 0);
kin : in std_logic;
dout : out std_logic_vector(9 downto 0);
rdout : out std_logic
);
end entity;
12. Summary
8b/10b encoding provides:
- DC balance
- transition density
- control characters
- error detection
It is simple, robust, and ideal for medium‑speed serial links with PLL‑based CDR.