8b/10b Encoder & Decoder
Use this 8b/10b Encoder & Decoder to encode hexadecimal data bytes, D.x.y data symbols and legal K control symbols into 10-bit code groups. Decode received 10-bit symbols while checking running disparity, invalid code groups and control-character status.
| # | Symbol | Byte | RD In | 6b | 4b | 10b Code | RD Out | Status |
|---|
-
-
What Is 8b/10b Encoding?
8b/10b is a line-coding system that converts each eight-bit input symbol into a ten-bit transmission code group. The additional encoded bits provide useful signal properties such as controlled disparity, sufficient transitions for clock recovery and special control symbols that cannot simply be treated as ordinary payload bytes.
The classic IBM implementation divides each byte into a five-bit portion and a three-bit portion. These are encoded through 5b/6b and 3b/4b coding tables, producing the final ten-bit code group.
A correct encoder cannot simply use a fixed lookup from each byte to one ten-bit value because the selected code group also depends on the current running disparity.
8b/10b D.x.y Symbol Notation
An ordinary data symbol is conventionally written as D.x.y. The five least significant input bits determine x, from 0 through 31, and the three most significant input bits determine y, from 0 through 7.
5b/6b and 3b/4b Encoding
The lower five data bits are transformed into a six-bit sub-block. The upper three bits are transformed into a four-bit sub-block.
Running disparity is evaluated during this process because the first sub-block can change the disparity state used to choose the second sub-block.
What Is Running Disparity?
Disparity is the difference between the number of transmitted ones and zeros. 8b/10b tracks a running state commonly represented as RD− or RD+.
RD−
The encoder is in the negative running-disparity state before the next code selection.
RD+
The encoder is in the positive running-disparity state before the next code selection.
When a sub-block has non-zero disparity, its selected version normally drives the running state toward the opposite sign. Balanced sub-blocks leave the state unchanged.
8b/10b Encoding Example: D31.1
D31.1 is a useful test of the encoder.
With initial RD+, the 5b/6b portion changes:
This illustrates why running disparity must be part of an 8b/10b encoder.
8b/10b K Control Symbols
8b/10b reserves several legal control characters known as K symbols. They are not ordinary data bytes even though each can be associated with an eight-bit value.
This calculator accepts the standard control set:
| Control Group | Legal Symbols |
|---|---|
| K28.y | K28.0 through K28.7 |
| Additional .7 controls | K23.7, K27.7, K29.7, K30.7 |
K28.5 8b/10b Encoding
K28.5 is one of the best-known 8b/10b control characters and is commonly used as a comma-related synchronization symbol by protocols built on 8b/10b.
The decoder recognizes both forms and checks whether the selected one is legal for the running disparity entering that code group.
What Is an 8b/10b Disparity Error?
A received ten-bit pattern may be a legitimate 8b/10b code group but still be wrong for the receiver’s current running disparity.
That situation is different from receiving a pattern that is not a legal 8b/10b symbol at all.
Code Error
The received 10-bit value does not correspond to a legal generated data or control symbol.
Disparity Error
The 10-bit value is recognizable, but it is not the legal version for the expected incoming RD state.
Why the Decoder Tracks Running Disparity
Suppose a code group is valid only when entering the symbol with RD+. If the receiver is currently in RD− and receives that RD+ form, simply looking up the ten bits would identify the underlying symbol but miss an important line-code violation.
This decoder therefore builds both the legal code map and the expected-RD map. It can report a recognizable symbol as a disparity error rather than treating every recognizable ten-bit pattern as valid.
8b/10b Expansion Ratio
Eight application bits become ten transmitted bits:
The physical encoded bit count is therefore 25% larger than the original eight-bit symbol count before considering any higher-level protocol framing.
Why 8b/10b Uses Alternative Encodings
Many symbols have different legal code groups for negative and positive running disparity. These choices allow the transmitter to keep the long-term difference between ones and zeros bounded instead of allowing a large DC imbalance to accumulate.
Some balanced sub-blocks use the same pattern for both running states, while others have special alternate representations selected for run-length and coding constraints.
Special Alternate .7 Encoding
The three-bit value 7 has primary and alternate 3b/4b representations in specific circumstances. Correct handling of those alternatives helps prevent undesirable long runs and is one reason a simple independent lookup of the 5b and 3b fields is not sufficient for a complete encoder.
The JavaScript implementation on this page applies the standard alternate D.x.A7 conditions and uses the appropriate alternate code for legal K.x.7 control symbols.
Bit Order Used by This Calculator
The calculator displays the conventional 8b/10b code-group notation:
The six-bit 5b/6b group is shown first, followed by the four-bit 3b/4b group. This is the representation commonly used in published 8b/10b tables.
Encoding Multiple 8b/10b Symbols
When several bytes are encoded, running disparity is not reset for each byte. The RD output from one symbol becomes the RD input to the next symbol.
This is why the tool supports complete sequences rather than calculating every byte independently.
Hexadecimal to 8b/10b Encoding
Hex mode interprets every two hexadecimal digits as one ordinary eight-bit data symbol. For each byte, the tool derives x from the low five bits and y from the upper three bits.
Note that ordinary hexadecimal input always means a D data character. If you specifically require the control character having the same underlying byte value, enter the appropriate K.x.y notation in Symbol mode.
D Symbol vs K Symbol
A byte value alone is not sufficient to say that a character is a K control character. The transmitter must intentionally request a legal K code.
Their 8b/10b code groups are not generally interchangeable, so this calculator keeps the two cases explicit.
Invalid K Codes
Only the defined K symbol set can be encoded. For example, a user cannot arbitrarily request K1.2 simply because x and y fall within the numerical D.x.y ranges.
When an illegal K symbol is entered, the encoder rejects it instead of silently treating it as ordinary data.
Common 8b/10b Encoding Mistakes
Ignoring Running Disparity
Many source symbols have different code groups for RD− and RD+.
Resetting RD Every Byte
Running disparity must normally continue across the complete encoded stream.
Treating Every Byte as a K Code
Only a specific set of K.x.y control symbols is legal.
Ignoring .7 Alternatives
Some y=7 data symbols require alternate 3b/4b code groups.
Confusing Code and Disparity Errors
A known 10-bit pattern can still violate the expected running disparity.
Reversing Display Bit Order
Serializer and analyzer displays may visually order code-group bits differently.
8b/10b Encoder & Decoder FAQs
What does 8b/10b mean?
What is running disparity in 8b/10b?
What does D31.1 mean?
What is D31.1 with RD−?
What is K28.5?
What is K28.5 with RD−?
What is K28.5 with RD+?
How many K control symbols are legal?
What is an 8b/10b code error?
What is an 8b/10b disparity error?
Does running disparity reset for every byte?
Does 8b/10b add overhead?
Can every byte be encoded as data?
Can every x.y value be used as a K symbol?
Why does one byte sometimes have two 10-bit codes?
What are 5b/6b and 3b/4b?
Can this decoder identify K characters?
Can I decode a continuous stream?
Encode and Decode 8b/10b With Running Disparity
Enter hexadecimal data, D.x.y symbols or legal K control characters to generate 10-bit code groups, or decode received groups while tracking RD state and detecting invalid or disparity-inconsistent symbols.