Chapter 2: Digital Codes & Error Detection - Complete Study Notes

NotebookLM Ingestion Compilation

This merged document contains all 4 study notes for Chapter 2: Digital Codes & Error Detection from ECE 2103 Digital Electronics (Sharif Sir).


2.01 BCD & Weighted Digital Codes

What is a Digital Code?

A Digital Code is a system of rules that assigns a unique pattern of binary bits (0s and 1s) to represent numbers, letters, symbols, or control commands.

Unlike pure binary number systems used for arithmetic, binary codes are engineered for specialized digital tasks such as decimal displays, error detection, data transmission, and mechanical position sensing.

graph TD
    Codes[Binary Digital Codes] --> Weighted[Weighted Positional Codes]
    Codes --> NonWeighted[Non-Weighted Codes]
    
    Weighted --> BCD8421[BCD / 8421 Code]
    Weighted --> W2421[2421 Self-Comp Code]
    Weighted --> W5211[5211 Code]
    Weighted --> W8421N[84-2-1 Negative Weight Code]
    
    NonWeighted --> XS3[Excess-3 Self-Comp Code]
    NonWeighted --> Gray[Gray Code / Single-Bit Change]
    NonWeighted --> ErrorCtrl[Parity / Error Control Codes]

1. What is BCD (Binary Coded Decimal)?

Concept: BCD Definition

Binary Coded Decimal (BCD) is a class of binary encodings where each decimal digit of a number is represented by a fixed number of bits (usually four).

In standard 8421 BCD, each decimal digit (0 through 9) is directly replaced by its equivalent 4-bit binary nibble.

  • Decimal:
  • BCD:

Why do we use BCD?

  1. Decimal Display Drivers: Devices like calculators and digital clocks use 7-segment displays. Directly mapping 4-bit BCD nibbles to display segment controllers is much simpler than converting a pure binary number into decimal components.
  2. Financial Precision: In binary floating-point representations, decimal fractions like cannot be represented exactly (leading to rounding errors: ). BCD represents each decimal digit exactly, preventing precision loss in financial transactions.

2. BCD Addition Mechanics

Because a 4-bit binary group can represent 16 states ( to ), but BCD only permits 10 states ( to ), standard binary addition can yield invalid states.

The BCD Addition Rule:

  1. Add the two BCD digits using standard binary addition.
  2. Check the sum of each 4-bit nibble:
    • Case A: Sum and no carry generated The sum is a valid BCD digit.
    • Case B: Sum OR an intermediate carry is generated The sum is invalid. Add to that nibble to skip the 6 invalid states, and add the resulting carry to the next higher-order nibble.

Step-by-Step Addition Examples:

Example 1: BCD Addition with Sum (Valid)

Add and :

4_{10} \to & 0100 & (\text{BCD}) \\ +3_{10} \to & 0011 & (\text{BCD}) \\ \hline & 0111 & (\text{Binary Sum} = 7_{10} \le 9) \end{array}$$ Since the sum is $\le 9$ and no carry was generated, the result is valid: **$0111_{\text{BCD}} = 7_{10}$**.

Example 2: BCD Addition with Sum (Correction Needed)

Add and :

6_{10} \to & 0110 & (\text{BCD}) \\ +7_{10} \to & 0111 & (\text{BCD}) \\ \hline \text{Binary Sum} \to & 1101 & (\text{Equal to } 13_{10} > 9 \implies \text{Invalid}) \\ \text{Add } 6 \to & +0110 & (\text{Correction Factor}) \\ \hline \text{Result} \to & \mathbf{1 \ 0011} & (\text{Carry generated to next nibble}) \end{array}$$ Expressed as 4-bit groups: $\mathbf{0001\ 0011_{\text{BCD}}} = 13_{10}$.

3. Distinction Between a Number System and a Code

Major Exam Theory Question (2018 - 4 Marks)

Question: Explain the fundamental differences between a Number System and a Code.

AspectBinary Number SystemBinary Code
Fundamental PurposeDesigned for mathematical computation and quantitative representation.Designed for human interface, data transmission, and hardware control.
Bit Position WeightingBit positions follow strict powers of 2 ().Bit positions may have non-standard weights () or no weights at all.
Arithmetic SuitabilityDirectly supports standard addition, subtraction, and multiplication.Unsuitable for direct arithmetic without specialized hardware conversion.
Bit EfficiencyHighly efficient; utilizes all binary combinations continuously.Contains invalid/unused states {e.g., BCD skips 6 states out of 16}.
Representation Example

4. Weighted Positional Codes

A digital code is classified as Weighted if each bit position in a 4-bit group is assigned a fixed numerical weight (). The represented decimal digit is calculated as:

Comparison Table of Major 4-Bit Weighted Codes:

Decimal Digit8421 (Standard BCD)2421 Code5211 Code84-2-1 Code
00000000000000000
10001000100010111
20010001000110110
30011001101000101
40100010001010100
50101101110001011
60110110010011010
70111110110111001
81000111011001000
91001111111111111

Terminology & Concept Breakdown

  • 8421 (BCD): The standard Binary Coded Decimal system. Uses standard binary weights for digits 0 to 9. States 1010 to 1111 ( to ) are invalid.
  • 2421 Code: A weighted self-complementing code where the sum of bit weights equals .
  • 5211 Code: A weighted code where the MSB carries a weight of .
  • 84-2-1 Code: A negative-weight code where the last two bits carry negative weights ( and ).

4.2 Differences between Weighted and Non-Weighted Codes

FeatureWeighted CodesNon-Weighted Codes
Bit Value WeightingEach bit position is assigned a specific numerical weight ().Bits have no position weights; the value depends strictly on pattern rules.
Mathematical Evaluation.Cannot be converted to decimal via standard sum of products.
Examples8421 (BCD), 2421, 5211, 84-2-1.Excess-3, Gray Code.
Arithmetic LogicSimple arithmetic correction rules can be applied (e.g. in BCD).Complex arithmetic correction rules; Gray code is not suitable for direct addition.
Primary ApplicationsDisplay drivers, calculators, and ALU input interfaces.Rotary encoders (Gray) and self-complementing math simplifications (Excess-3).

5. Alphanumeric Codes: The ASCII Standard

Foundational Concept (Outside Direct PYQ Scope)

Alphanumeric representation via standard ASCII is a foundational computer organization topic that is rarely tested directly as calculation problems in ECE 2103 examinations, but is required context for digital systems.

Digital computers must process text, punctuation, and control symbols in addition to numbers. Alphanumeric Codes assign binary codes to represent characters. The most popular standard is ASCII (American Standard Code for Information Interchange).

5.1 Standard ASCII (7-Bit Code)

  • Bit Count: Dedicated 7-bit word format ().
  • State Space: Represents distinct characters (from decimal to ).
  • Encoding Split:
    • Printable Characters (): Includes digits 0-9, letters a-z and A-Z, punctuation, and mathematical symbols.
    • Non-Printable Control Characters ( and ): Used for physical device control (e.g., Carriage Return CR, Line Feed LF, Backspace BS, Null NUL).

5.2 Extended ASCII (8-Bit Code)

  • Bit Count: 8-bit word format.
  • State Space: Represents characters. The upper 128 characters (decimal ) represent special graphic characters, symbols, and foreign alphabet characters.

5.3 Hardware Storage & Parity Integration

In physical computer memory, data is organized in 8-bit bytes. Standard 7-bit ASCII characters are stored in 8-bit bytes by setting the most significant bit (MSB) to either:

  • 0 (default padding).
  • A Parity Bit (for simple error detection during transmission).

6. PYQ Numerical Solution: 5211 Code Conversion [PYQ 2018]

Major Exam Problem: Convert into 5211 Weighted Code (2018 - 8 Marks)

Solution:

To convert a multi-digit decimal number into 5211 code, convert each decimal digit independently into its corresponding 4-bit 5211 code group from the lookup table:

  1. Digit 6:
  2. Digit 0:
  3. Digit 5:


7. PYQ Master Puzzle: The 12-Bit Register Decoder [PYQ 2022]

PYQ Master Puzzle (2022): The 12-Bit Register Decoder

Question: The state of a 12-bit register is 100010010111. What is its content if it represents: (i) Three decimal digits in BCD? (ii) Three decimal digits in the excess-3 code? (iii) Three decimal digits in the 8-4-2-1 code? (iv) A binary number?

Solution Methodology: First, divide the 12-bit string into three 4-bit nibbles: 1000, 1001, 0111.

(i) As BCD (Standard 8421): Evaluate each 4-bit block directly into decimal.

  • 1000 = 8
  • 1001 = 9
  • 0111 = 7
  • Answer: 897

(ii) As Excess-3 Code: Excess-3 is generated by adding 3 (0011) to the decimal digit. To decode it, subtract 3 from each nibble.

  • 1000 (8) - 3 = 5
  • 1001 (9) - 3 = 6
  • 0111 (7) - 3 = 4
  • Answer: 564

(iii) As 8, 4, -2, -1 Code: Apply the specific mathematical weights to each bit in the nibble: .

  • 1000 = 8
  • 1001 = 7
  • 0111 = 1
  • Answer: 871

(iv) As a pure Binary Number: Evaluate the entire 12-bit string as a single base-2 integer.

  • Answer: 2199

Past Year Questions (PYQs)

  • [PYQ 2018]: Explain the difference between a Number System and a Code. (04 Marks)
  • [PYQ 2018]: Convert decimal numbers into 5211 weighted code (e.g., ). (08 Marks)
  • [PYQ 2019]: Conversions for BCD, 2421, 5211, and 84-2-1 codes. (08 Marks)
  • [PYQ 2022]: 12-Bit Register Decoder puzzle (100010010111 in BCD, Excess-3, 8-4-2-1, Binary). (10 Marks)

Related Concepts: 01 BCD & Weighted Digital Codes | 03 Gray Code & Code Conversions | 04 Error Control, Parity Generators & Checkers

2.02 Excess-3 Code & Self-Complementing Logic

What is a Self-Complementing Code?

A 4-bit binary code is defined as Self-Complementing if the 1’s complement {bitwise inversion: } of any decimal digit’s code word yields the exact code word of its 9’s decimal complement ().

graph LR
    subgraph Self-Complementing Symmetry
        D2[Decimal Digit 2: 0101] -->|Bitwise Inversion| InvD2[1's Comp: 1010]
        InvD2 -->|Equals| D7[Decimal Digit 7 = 9 - 2: 1010]
    end


1. What is Excess-3 Code?

[concept] Concept: Excess-3 Definition Excess-3 (XS-3) is a non-weighted binary code. Each decimal digit (0 through 9) is represented by the 4-bit binary value of .

  • Decimal:
  • Excess-3 representation:

1.1 Differences: Standard BCD (8421) vs. Excess-3 (XS-3)

FeatureStandard BCD (8421)Excess-3 (XS-3)
WeightingWeighted positional code (weights: ).Non-weighted code (each representation is ).
Self-ComplementingNo (e.g. 1’s complement of BCD 1 [0001] is 1110, which is invalid, not BCD 8).Yes (bitwise inversion of XS-3 yields XS-3 ).
Zero Representation0000 (equal to electrical zero/disconnected state).0011 (prevents false line fault detection).
Arithmetic Carry RuleAdd 0110 () if sum or carry is generated.Add 0011 () if carry is generated; subtract 0011 () if no carry is generated.
Unused StatesStates 1010 to 1111 () are invalid.States 0000 to 0010 () and 1101 to 1111 () are invalid.

Why do we use Excess-3?

  1. Simplified Subtraction (Self-Complementing): The primary advantage of Excess-3 is that the 1’s complement of an Excess-3 digit is the Excess-3 representation of its 9’s complement (e.g. 1’s complement of 0100 [1] is 1011 [8]). This makes subtraction circuits in early decimal calculators incredibly simple to design.
  2. Transmission Reliability: Unlike standard BCD where is represented by 0000 (which is indistinguishable from a line disconnection or fault), the smallest valid Excess-3 code word is 0011 (decimal 0). This prevents signal transmission line faults from being misread as valid data.

2. Excess-3 Addition Mechanics

Because Excess-3 values always have an extra offset of built-in, adding two Excess-3 digits yields:

To restore the correct Excess-3 bias of :

  • Case A: A carry is generated (Sum ) Add 0011 () to correct the sum nibble.
  • Case B: No carry is generated (Sum ) Subtract 0011 () (or add 1101) to correct the sum nibble.

Step-by-Step Addition Examples:

Example 1: Excess-3 Addition with Sum (No Carry)

Add and in Excess-3:

0101 & (2 + 3 = 5) \\ +0110 & (3 + 3 = 6) \\ \hline 1011 & (\text{Raw Binary Sum} = 11_{10} \to \text{No Carry}) \\ -0011 & (\text{No Carry} \implies \text{Subtract } 3) \\ \hline \mathbf{1000} & (\text{Corrected Sum} = 8_{10} \implies 5_{\text{decimal}} \text{ in XS-3}) \end{array}$$ **Final Answer:** **$1000_{\text{XS-3}}$** (corresponds to $5_{10}$).

Example 2: Excess-3 Addition with Sum (Carry Generated)

Add and in Excess-3:

1001 & (6 + 3 = 9) \\ +1000 & (5 + 3 = 8) \\ \hline \mathbf{1} \ 0001 & (\text{Raw Binary Sum} \to \text{Carry generated!}) \\ +0011 & (\text{Carry generated} \implies \text{Add } 3 \text{ to sum nibble}) \\ \hline \mathbf{1} \ 0100 & (\text{Carry is pushed to next nibble}) \end{array}$$ Grouped into 4-bit nibbles: $\mathbf{0100\ 0100_{\text{XS-3}}}$ (corresponds to $11_{10}$ in decimal).

3. Mathematical Proof: Excess-3 is a Self-Complementing Code

Major Exam Proof (2021, 2023, 2025 - 8 to 10 Marks)

Question: Prove mathematically that Excess-3 (XS-3) code is a self-complementing code.

Step-by-Step Proof:

  1. Definition of Excess-3 Code: The Excess-3 code word for any decimal digit () is constructed by adding to its standard 4-bit binary equivalent:

  2. Evaluating the 9’s Complement of (): The Excess-3 code word for the 9’s complement of is:

  3. Evaluating the 1’s Complement of : Taking the bitwise 1’s complement of a 4-bit number is mathematically equivalent to subtracting it from (): Substituting :

  4. Comparing Results:


4. The Mathematics of Self-Complementing Weighted Codes

Unlike Excess-3 (which is non-weighted), many weighted 4-bit codes (like , ) are also self-complementing. There is a strict mathematical constraint on the weights of such codes.

The Self-Complementing Weight Theorem

For a weighted 4-bit binary code with weights to be self-complementing, the sum of its individual weights must equal exactly 9:

Algebraic Proof:

  1. Let the code representation of a decimal digit be . Its value is:
  2. For the code to be self-complementing, the 9’s complement () must be represented by the bitwise inverted word :
  3. Add the two equations together:
  4. Since (as one bit is always 0 and the other is 1):

Verification of Common Codes:

  • Code: Self-complementing.
  • Code: Self-complementing.
  • BCD Code: Not self-complementing.

5. Complete 9’s Complement Symmetry Table

Decimal Digit ()BCD (8421)Excess-3 Code ()1’s Comp of XS-39’s Comp Digit ()XS-3 Code of ()
000000011110091100
100010100101181011
200100101101071010
300110110100161001
401000111100051000
501011000011140111
601101001011030110
701111010010120101
810001011010010100
910011100001100011

5. Design: BCD to Excess-3 Code Converter

Major Exam Design Problem (2018 - 10 Marks)

Question: Design a combinational logic circuit to convert a 4-bit BCD input () to a 4-bit Excess-3 code output ().

Boolean Function Derivation (K-Map Simplification):

  • Inputs: (Don’t care conditions ).
  • Outputs: .
  1. Output (LSB):
  2. Output :
  3. Output :
  4. Output (MSB):

Past Year Questions (PYQs)

  • [PYQ 2017, 2021, 2023, 2025]: Define self-complementary code. (04 Marks)
  • [PYQ 2021, 2023, 2025]: Prove mathematically that Excess-3 code is a self-complementary code. (08-10 Marks)
  • [PYQ 2018]: Design a BCD to Excess-3 code converter circuit. (10 Marks)

Related Concepts: 2.01 BCD & Weighted Digital Codes | 2.02 Excess-3 Code & Self-Complementing Logic | 2.04 Error Control, Parity Generators & Checkers

2.03 Gray Code & Code Conversions

What is Gray Code?

Gray Code (also called Reflected Binary Code) is an -bit non-weighted binary coding system. Its defining property is that only one bit changes state (from 0 to 1 or 1 to 0) between any two consecutive values.


1. Physical Significance: Why Use Gray Code?

Standard binary numbers are ideal for math, but they cause severe glitches when interfacing with the physical world due to simultaneous multi-bit transitions:

A. Rotary Shaft Encoders (Position Sensing)

Optical sensors read angular position from coded disks:

  • The Binary Problem: Transitioning from decimal 3 (011) to 4 (100) requires three bits to flip at once. Due to microscopic mechanical misalignments, the sensors will not trigger at the exact same instant. For a fraction of a millisecond, the processor might read an erroneous state like 111 (decimal 7) or 010 (decimal 2), leading to positioning errors.
  • The Gray Code Solution: Transitioning from 3 (010 in Gray) to 4 (110 in Gray) flips only the MSB. The sensor is physically guaranteed to read either 3 or 4, with no intermediate erroneous states.

B. Low-Power VLSI Design

In high-speed integrated circuits, flipping bus lines charges/discharges parasitic capacitances, consuming dynamic power. By using Gray code, the average number of bit transitions (switching activity) is minimized, lowering power consumption.


2. 4-Bit Gray Code Lookup Table

Notice how the codes reflect. The second half is the mirror image of the first half (excluding the MSB).

Decimal ValueStandard BinaryGray Code
000000000
100010001
200100011
300110010
401000110
501010111
601100101
701110100
810001100
910011101
1010101111
1110111110
1211001010
1311011011
1411101001
1511111000

3. Conversion Algorithms and Flows

Conversions between pure binary and Gray code are performed using the Exclusive-OR (XOR, ) operator.

3.1 Binary-to-Gray Conversion

Binary-to-Gray Conversion Flow:
Binary:  B3 -------> B2 -------> B1 -------> B0
         |           |           |           |
         |           XOR         XOR         XOR
         v           v           v           v
Gray:    G3          G2          G1          G0
  1. The MSB of the Gray code is identical to the MSB of the binary number:
  2. Each subsequent Gray bit is found by XORing the corresponding binary bit with the binary bit to its left:

Binary-to-Gray Conversion: Convert Binary to Gray

Result:


3.2 Gray-to-Binary Conversion

Gray-to-Binary Conversion Flow:
Gray:    G3          G2          G1          G0
         |           ^           ^           ^
         |           |           |           |
         v           XOR         XOR         XOR
Binary:  B3 -------> B2 -------> B1 -------> B0
  1. The MSB of the binary number is identical to the MSB of the Gray code:
  2. Each subsequent binary bit is found by XORing the previously calculated binary bit with the next Gray code bit:

Gray-to-Binary Conversion: Convert Gray to Binary

Result:


4. Hardware Implementation

To design a combinational circuit that converts a 4-bit Gray code input () to a 4-bit Binary output (), we map the Gray-to-Binary recurrence relations:

This maps directly to a cascade of three XOR gates:

graph LR
    G3[Input G3] --> B3[Output B3]
    G3 --> XOR1[XOR Gate 1]
    G2[Input G2] --> XOR1
    XOR1 --> B2[Output B2]
    
    B2 --> XOR2[XOR Gate 2]
    G1[Input G1] --> XOR2
    XOR2 --> B1[Output B1]
    
    B1 --> XOR3[XOR Gate 3]
    G0[Input G0] --> XOR3
    XOR3 --> B0[Output B0]

Past Year Questions (PYQs)

  • [PYQ 2017]: Define Reflected code. (04 Marks)
  • [PYQ 2018]: Convert into Gray code. (12 Marks)
    • Solution: Convert to binary: . Perform binary-to-gray:
      • Gray Code:
  • [PYQ 2024]: Design a 4-bit reflected code to binary converter circuit using XOR gates. (10 Marks)

Related Concepts: 01 BCD & Weighted Digital Codes | 02 Excess-3 Code & Self-Complementing Logic | 03 Gray Code & Code Conversions

2.04 Error Control, Parity Generators & Checkers

Error Control Concepts

During serial data transmission over noisy communication channels, electromagnetic interference can cause bit inversion errors { or }.

To safeguard data integrity, systems employ Error Control Codes by appending redundant check bits to transmitted data packets.


1. Error Detecting vs. Error Correcting Codes [PYQ 2017, 2018]

Major Exam Theory Question (2017, 2018 - 4 Marks)

Question: Explain the fundamental differences between Error Detecting codes and Error Correcting codes.

ParameterError Detecting CodesError Correcting Codes
Primary FunctionDetects the presence of errors during transmission.Detects the error AND automatically determines its bit location to correct it.
Action on ErrorFlags error to receiver; requires retransmission.Automatically corrects error without requesting retransmission.
Redundancy OverheadLow overhead; requires few redundant bits {e.g., 1 parity bit}.High overhead; requires multiple redundant check bits {e.g., Hamming distance}.
Implementation ComplexitySimple hardware {cascaded XOR gates}.Complex logic {syndrome decoders & bit-flipping networks}.
Standard ExamplesParity bits, Checksums, CRC.Hamming Code, Reed-Solomon Code, BCH Code.

2. Parity Architecture & Operation

graph LR
    subgraph Transmitter End
        DataTx[Data Bits: x y z] --> GenXOR[Parity Generator Logic]
        GenXOR --> Packet[Transmitted Packet: x y z P]
    end
    
    Packet -->|Serial Channel| RxPacket[Received Packet: x' y' z' P']
    
    subgraph Receiver End
        RxPacket --> CheckXOR[Parity Checker Logic]
        CheckXOR -->|C = 0| NoError[No Error Detected]
        CheckXOR -->|C = 1| ErrorDet[Bit Error Flagged!]
    end

3. Even Parity Generator & Checker

  • Even Parity Rule: The parity bit is generated so that the total count of 1s in is always EVEN.
  • 3-Bit Generator (Transmitter):
  • 4-Bit Checker (Receiver):

4. Design: 3-Bit Odd Parity Generator & 4-Bit Checker [PYQ 2022, 2025]

Major Exam Design Problem (2022 - 8 Marks, 2025 - 10 Marks)

Question: Design a 3-bit parity generator and 4-bit parity checker circuit using an odd parity bit.

Part A: 3-Bit Odd Parity Generator (Transmitter)

  • Logic Rule: Generates such that total 1s in is ODD. If has an even number of 1s, must be 1.

Truth Table:

Input Message ()Generated Odd Parity Bit ()
0 0 01
0 0 10
0 1 00
0 1 11
1 0 00
1 0 11
1 1 01
1 1 10

Boolean Function:

The minterms for are , which is the exact inverse of a 3-input XOR function {an XNOR function}:


Part B: 4-Bit Odd Parity Checker (Receiver)

  • Logic Rule: Evaluates received bits . If total 1s is EVEN, an error has occurred Error output .

Boolean Function:

Implemented by cascading three 2-input XNOR gates.


5. Critical Limitations of Parity Error Checking [PYQ 2018]

Limitations of Simple Parity

  1. Odd-Bit Error Detection Only: Parity can ONLY detect an odd number of bit errors {1, 3, 5 flipped bits}.
  2. Fails on Even-Bit Errors: If an even number of bits flip {e.g., 2 bits change state}, total parity remains unchanged, and remains {error undetected}.
  3. No Correction Capability: Parity indicates that an error occurred, but cannot identify which bit flipped.

5.1 Differences: Parity Codes vs. Hamming Codes

FeatureSimple Parity CodesHamming Codes (e.g., 7-bit)
Primary CapabilityError detection only.Single-bit error detection AND correction.
Error Detection LimitDetects only odd numbers of bit errors (). Fails on even errors.Detects up to 2-bit errors (with SEC-DED), corrects 1-bit errors.
Error Correction LimitZero (requires retransmission).Corrects exactly one flipped bit.
Bit OverheadMinimal (exactly 1 parity bit added, regardless of data size).Higher ( parity bits for data bits, for data bits).
Syndrome Decoder ComplexityVery low (cascaded XOR/XNOR gates).Medium (decoder logic to calculate error position syndrome).
Typical Use CasesShort-distance transmission, memory buses.ECC memory, satellite communications, network packets.

6. Master Tutorial: 7-Bit Hamming Code Error Control

To overcome the limitations of simple parity, Richard Hamming developed a method to locate and correct a single-bit error by using overlapping parity sets.

6.1 Bit Allocation Schema

A 7-bit Hamming code contains 4 data bits () and 3 redundant parity bits (). The parity bits are positioned at indices that are powers of 2.

7-Bit Codeword Positions:
    1      2      3      4      5      6      7
+------+------+------+------+------+------+------+
|  P1  |  P2  |  D3  |  P4  |  D5  |  D6  |  D7  |
+------+------+------+------+------+------+------+
  2^0    2^1    Data   2^2    Data   Data   Data

The binary weight of each position determines which parity bits check it:

  • Position 3 () is checked by (LSB=1) and (middle=1).
  • Position 5 () is checked by (LSB=1) and (MSB=1).
  • Position 6 () is checked by (middle=1) and (MSB=1).
  • Position 7 () is checked by , , and .

6.2 Parity Generator (Transmitter End)

Assuming even parity, each parity bit is calculated by XORing the data bits in its check set:

  • checks positions with LSB = 1 ():
  • checks positions with middle bit = 1 ():
  • checks positions with MSB = 1 ():

Worked Example: Encode Data 1100 ()

Given data bits: .

  1. Calculate Parities:
  2. Construct Codeword:
    • (Bit 1)
    • (Bit 2)
    • (Bit 3)
    • (Bit 4)
    • (Bit 5)
    • (Bit 6)
    • (Bit 7)
    Codeword: 1100001

6.3 Parity Checker & Error Correction (Receiver End)

Upon receiving the 7-bit codeword, the receiver computes three check bits ():

The check bits form the Syndrome Word ():

  • Syndrome (Decimal 0): No error occurred during transmission.
  • Syndrome (Decimal ): A single-bit error occurred at bit position . To correct the error, simply invert bit .

Worked Example: Correcting a Bit Error

Suppose the received codeword is 1110001 (the 3rd bit flipped from 0 to 1 during transmission).

  1. Extract received bits:
    • .
  2. Calculate Check Bits:
  3. Evaluate Syndrome:
  4. Correction: Bit position 3 is incorrect. Flip Bit 3 () from 1 to 0. The corrected codeword is 1100001, and the recovered data is 1100.

7. Past Year Questions (PYQs)

  • [PYQ 2017]: Define Error Detection Code. (04 Marks)
  • [PYQ 2018]: Differences between Error Detecting and Error Correcting codes. (04 Marks)
  • [PYQ 2015, 2020, 2023, 2024]: 4-bit even parity checker design. (08 Marks)
  • [PYQ 2022, 2025]: Design 3-bit generator & 4-bit checker using odd parity bit. (08 to 10 Marks)