How to Generate and Check 4-Bit Odd Parity Generator Codes In digital communication and data storage, errors can occur when data is transmitted from a sender to a receiver. Noise, interference, or hardware flaws can flip bits from 0 to 1 or vice versa. To ensure data integrity, error detection methods are used. One of the simplest and most common methods is parity checking.
This article explains how to design, generate, and check 4-bit odd parity codes, covering the underlying logic, truth tables, Boolean expressions, and logic circuit implementations. What is Odd Parity?
A parity bit is an extra bit added to a binary code to ensure that the total number of 1-s in the message meets a specific condition.
In even parity, the total number of 1-s (including the parity bit) must be an even number.
In odd parity, the total number of 1-s (including the parity bit) must be an odd number.
For a 4-bit message (A₃A₂A₁A₀), a 5th bit—the parity bit (P)—is generated and appended. If the 4-bit message already contains an odd number of 1-s, the odd parity bit is set to 0. If the message contains an even number of 1-s (including zero 1-s), the odd parity bit is set to 1 to make the total count odd. Part 1: 4-Bit Odd Parity Generator
The parity generator resides at the transmitter end. It takes the 4-bit user data as input and generates the required odd parity bit. Truth Table
Let the 4-bit input message be represented by A, B, C, D and the odd parity bit by Poddcap P sub o d d end-sub Number of 1s Odd Parity Bit ( Poddcap P sub o d d end-sub Transmitted Code ( ABCDPoddcap A cap B cap C cap D cap P sub o d d end-sub 1 0 0 1 0 1 1 0 0 1 1 0 1 0 0 1 Boolean Expression
An Exclusive-OR (XOR) gate outputs a 1 when the number of 1-s at its input is odd. Conversely, an Exclusive-NOR (XNOR) gate outputs a 1 when the number of 1-s at its input is even.
Because the odd parity bit needs to be 1 when the input message has an even number of 1-s, we use the XNOR function.
The simplified Boolean expression for the 4-bit odd parity generator is:
Podd=(A⊕B⊕C⊕D)′cap P sub o d d end-sub equals open paren cap A circled plus cap B circled plus cap C circled plus cap D close paren prime
Alternatively, using standard gate properties, this can be written as:
Podd=A⊕B⊕C⊙Dcap P sub o d d end-sub equals cap A circled plus cap B circled plus cap C circled dot cap D Logic Circuit Implementation To build this circuit using logic gates: Pass inputs A and B through a first XOR gate: Pass inputs C and D through a second XOR gate:
Pass the outputs X₁ and X₂ through an XNOR gate (or an XOR gate followed by a NOT gate) to get the final output: Part 2: 4-Bit Odd Parity Checker
The parity checker resides at the receiver end. Its job is to verify the integrity of the incoming 5-bit code word (the 4-bit message plus the parity bit). We will denote the received bits as A, B, C, D, and P.
The checker counts the number of 1-s across all 5 bits. If the total number of 1-s is odd, no error is detected. If the total number of 1-s is even, a transmission error has occurred. Truth Table and Error Detection Logic
The parity checker generates an error check bit, often called the Error Bit (E) or Parity Error Check (PEC). E = 0: No error detected (Total number of 1-s is odd). E = 1: Error detected (Total number of 1-s is even). Boolean Expression
Since we want the error bit (E) to be 1 when the total number of 1-s across all five received bits is even, we check the combined parity of all bits using an XNOR function:
E=(A⊕B⊕C⊕D⊕P)′cap E equals open paren cap A circled plus cap B circled plus cap C circled plus cap D circled plus cap P close paren prime Alternatively, since we know from the generator that
, we can compare the newly calculated expected odd parity bit with the received parity bit using an XOR gate:
E=(A⊕B⊕C⊕D)′⊕Pcap E equals open paren cap A circled plus cap B circled plus cap C circled plus cap D close paren prime circled plus cap P
If the received parity bit P does not match the generated calculation from A, B, C, D, the XOR gate outputs a 1, signaling an error. Logic Circuit Implementation To implement the 4-bit odd parity checker:
Group the received data bits \(A, B\) into one XOR gate and C, D into another XOR gate.
Combine their outputs using a third XOR gate to obtain the message’s core parity matrix:
Pass M through an inverter (NOT gate) to find what the odd parity should have been:
Feed M’ and the received parity bit P into a final XOR gate. If they mismatch, the output E switches to 1. Limitations of Parity Checking
While 4-bit odd parity generation and checking is an inexpensive, simple way to secure digital networks, it has one major limitation: it can only detect single-bit errors (or any odd number of bit errors).
If a severe burst of noise flips exactly two bits simultaneously (e.g., changing 00001 into 11001), the total number of 1-s remains odd. The receiver’s parity checker will return an E = 0 output, completely missing the double-bit corruption. For multi-bit error detection and correction, advanced techniques like Cyclic Redundancy Checks (CRC) or Hamming Codes must be utilized instead.
Propose specific ways to proceed by asking if the user needs help with Verilog/VHDL implementations, Logisim circuit designs, or converting the logic to even parity.
Leave a Reply