Purpose of Line Coding
In digital systems, information is represented as a sequence of bits, namely 0s and 1s. To send it over a physical medium such as copper wire or optical fiber, the bits must be mapped to a physical signal, for example a changing voltage or a light pulse. This process is called line coding. Channel coding is a separate operation that adds redundant symbols for error detection or correction.
Using a fixed high level for '1' and a low or zero level for '0' describes the unipolar NRZ case and can limit transmission performance. The issues concern the DC component, clock recovery, and matching the spectrum to the channel. Line codes are selected with these requirements in mind.
Desirable Properties of Line Codes
A line code should support correct and efficient data transmission by meeting several requirements:
- DC Component Minimization: The signal should have a zero or near-zero average voltage, known as being DC-balanced. Many networks use transformers or AC-coupling, which block a persistent , leading to signal distortion.
- Self-Synchronization: A self-synchronizing code provides frequent transitions, meaning changes in signal level, even for difficult data patterns. The receiver uses them to extract a and stay synchronized with the transmitter. This limits sampling errors.
- Bandwidth Efficiency: The code should occupy the minimum possible bandwidth for a given data rate. Some codes, while offering good synchronization, require double the bandwidth of simpler codes.
- Error Detection Capability: Some codes have inherent rules where certain signal sequences are invalid. If the receiver detects an invalid sequence, it knows a transmission error has occurred.
- Transparency: A transparent code can represent any sequence of bits, including long strings of all 0s or all 1s. Its synchronization and DC behavior still depend on the selected code and channel.
Common Line Codes
The examples below compare how the codes address these requirements.
Polar and Unipolar NRZ (Non-Return-to-Zero)
In NRZ, the signal level remains constant throughout the bit period.
- Polar NRZ: Logical '1' is represented by a positive voltage (), and '0' is represented by a negative voltage ().
- Unipolar NRZ: Logical '1' is a positive voltage (), and '0' is zero voltage ().
Evaluation: With rectangular pulses, the continuous part of the main spectral lobe extends to , so the code occupies a narrow band. The DC component depends on the signal levels and bit statistics, especially for the unipolar version. Long sequences of identical bits make clock recovery difficult.
RZ (Return-to-Zero)
In unipolar RZ, a '1' is represented by a pulse lasting half of the bit period, followed by a return to zero. A '0' is represented by no pulse (0V).
Evaluation: For unipolar RZ, when the stream contains a nonzero fraction of ones, the spectral line at the clock frequency () helps synchronization. With a rectangular 50% duty-cycle pulse, the first null occurs at , so the required band is wider than for NRZ. The DC component still depends on the data, and long zero runs contain no transitions.
AMI (Alternate Mark Inversion)
AMI is a three-level (ternary) code that limits the DC component by alternating the polarity of mark pulses.
- Logical '0' is represented by 0V.
- Logical '1' symbols (marks) are represented by alternating positive () and negative () pulses.
Evaluation: Consecutive mark pulses have opposite polarity, so their average DC component approaches zero over a long stream. Like NRZ, AMI produces a constant 0V level during a long sequence of '0's, which makes clock recovery difficult.
HDB3 (High-Density Bipolar of order 3)
A modification of AMI used in E1 digital telephony systems, including the European PCM hierarchy. It limits zero runs so that the receiver continues to obtain transitions for synchronization.
- It follows the same rules as AMI.
- Substitution: When a sequence of four consecutive zeros () occurs, it is replaced with a pattern containing a "violation" pulse (), which breaks AMI's alternating rule.
- The choice of pattern ( or ) depends on the parity of the number of pulses since the previous violation: is used for an odd count and for an even count. The rule gives consecutive pulses alternating polarity and limits the DC imbalance. is a regular bipolar pulse that follows the alternating rule.
Evaluation: HDB3 limits intervals without pulses while retaining AMI alternation apart from controlled violations. Its substitution rule limits the DC imbalance, and the inserted pulses provide transitions for synchronization.
Manchester Code
Manchester code is a two-phase code. Every bit period contains a transition in the middle, so timing information is present in the data stream.
- In the IEEE 802.3 convention, a logical '0' is a high-to-low transition.
- In the IEEE 802.3 convention, a logical '1' is a low-to-high transition.
Evaluation: A transition in every bit assists synchronization, while equal dwell times at positive and negative levels cancel the DC component in an ideal waveform. With rectangular pulses, the first null occurs at twice the frequency of polar NRZ, so Manchester requires a wider band.