Skip to content
GATEiit

GATE EC · Digital Circuits

Code converters

Designing combinational code converters between Binary and unit-distance Gray codes via XOR networks, exploiting unused don't-care minterms for BCD-to-Excess-3 self-complementing logic, BCD adder +6 corrections, and 7-segment display/parity circuits.

Before you start

This topic comes before: Minimization of functions using Boolean identities and Karnaugh map

Concept notes

1. Binary ↔ Gray Code Converters (Zero-Glitch Unit-Distance Code)

A Gray code orders integers so adjacent codewords differ in exactly ONE bit (and wraps smoothly from 2n−1 back to 0!). Unlike weighted Binary (where transitioning 0111→1000 flips 4 bits simultaneously and causes race glitches on asynchronous clock-domain crossings or optical shaft encoders), Gray eliminates multi-bit transition skew completely.

  • Binary to Gray (Bn−1…B0→Gn−1…G0) — Parallel 1-Gate-Delay: Gn−1=Bn−1,Gk=Bk+1⊕Bk(k=n−2,…,0).
  • Gray to Binary — Cascaded Prefix XOR: Bn−1=Gn−1,Bk=Bk+1⊕Gk=Gn−1⊕Gn−2⊕⋯⊕Gk. (Note: Binary → Gray computes all bits in parallel with 1 XOR delay, whereas Gray → Binary ripples through n−1 XOR delays unless tree-parallelized!)
Code Converter Architectures: Parallel Binary→Gray XOR vs Cascaded Gray→Binary XOR 4-Bit Binary → Gray (Parallel, 1 Gate Delay) B₃ G₃ = B₃ B₂ B₁ B₀ ⊕ G₂=B₃⊕B₂ ⊕ G₁=B₂⊕B₁ ⊕ G₀=B₁⊕B₀ Gray → Binary (Cascaded Output-to-Input) G₃ B₃ = G₃ G₂ ⊕ B₂=B₃⊕G₂ G₁ ⊕ B₁=B₂⊕G₁ G₀ ⊕ B₀ Delay = (n − 1) XOR stages
4-bit Binary-to-Gray operates in 1 parallel XOR stage, while Gray-to-Binary ripples decoded MSBs downward through (n−1) XOR gates.

2. BCD (8421) ↔ Excess-3 (XS-3) and Self-Complementing Codes

Decimal Digit 8421 BCD (B3B2B1B0) Excess-3 (E3E2E1E0=BCD+3) 2421 (Self-Comp.) Key Property
0 0000 0011 0000 Bitwise inverse gives 9! (1100 in XS-3)
1 0001 0100 0001 Inverse gives 8 (1011)
4 0100 0111 0100 Inverse gives 5 (1000)
9 1001 1100 1111 Excess-3 is unweighted & self-complementing

Why Excess-3 Simplifies Decimal Subtraction: Taking the bitwise 1's complement of any Excess-3 digit automatically gives its 9's complement (9−d↔(15−(d+3))=(9−d)+3)! Furthermore, because BCD inputs 1010–1111 (10–15) never legally occur, placing 6 don't-cares (X) in the 4-variable K-map minimizes BCD → Excess-3 to just: E0=B0‾,E1=B1⊙B0,E2=B2⊕(B1+B0),E3=B3+B2(B1+B0).

BCD (B₃ B₂ B₁ B₀) to Excess-3 Conversion: Don't-Cares (10–15) Shrink E₃ to B₃ + B₂(B₁ + B₀) B₃B₂ / B₁B₀ 00 01 11 10 00 01 11 10 0 0 0 0 0 1 1 1 × × × × 1 1 × × Minimized BCD → Excess-3 Logic E₀ = B₀' (inverts LSB cleanly) E₁ = B₁ ⊙ B₀ = B₁B₀ + B₁'B₀' E₂ = B₂ ⊕ (B₁ + B₀) E₃ = B₃ + B₂(B₁ + B₀)
Using BCD invalid codes (minterms 10–15) as don't-cares collapses the K-map for E₃ cleanly to B₃ + B₂(B₁ + B₀).

3. BCD Addition Correction (+6) and Binary ↔ BCD Conversion

Because 4 bits hold 16 values while decimal holds 10, adding two BCD digits yields an illegal code whenever the 4-bit binary sum exceeds 9 (10012): Correction Needed (K)=Cout+S3S2+S3S1. Whenever K=1, a second 4-bit adder adds 01102=+6 to skip past invalid states 1010–1111 and pass decimal carry K=1 to the next digit! Similarly, multi-bit Binary-to-BCD (Double-Dabble algorithm) shifts MSB-first and adds +3 to any BCD nibble ≥5 before shifting left (2(x+3)=2x+6 auto-skips 10–15!).

4. 7-Segment Display Decoders and Parity Code Generators

A 7-segment display drives LED segments a–g clockwise from top (g center bar) for BCD 0–9 (with 10–15 typically blanked or don't-cared). Watch polarity in hardware questions: Common-Cathode LEDs require active-HIGH (1) decoder outputs, whereas Common-Anode requires active-LOW (0)! Finally, an (n+1)-bit Parity Converter appends Peven=d0⊕d1⊕⋯⊕dn−1 (or inverted for odd parity) to guarantee single-bit error detection across buses.

Formulas to remember

Binary to Gray conversion (bitwise)
Gn−1=Bn−1,Gk=Bk+1⊕Bk(0≤k≤n−2)
Gray to Binary conversion (prefix XOR)
Bn−1=Gn−1,Bk=Bk+1⊕Gk=⨁i=kn−1Gi
BCD-to-Excess-3 minimized equations
E0=B0‾,E1=B1⊙B0,E2=B2⊕(B1+B0),E3=B3+B2(B1+B0)
Single-digit BCD adder +6 correction flag
K=C4+Z3Z2+Z3Z1(add 01102 iff K=1)
Self-complementing weight-sum necessity
∑wi=9(for weighted self-complementing 4-bit BCD codes like 2421,  5211,  842ˉ1ˉ)

Common mistakes

  • Reversing Binary → Gray vs Gray → Binary XOR chains: Binary → Gray XORs input bits (G_k = B_{k+1} ⊕ B_k); Gray → Binary XORs the previously decoded output bit (B_k = B_{k+1} ⊕ G_k)!
  • Forgetting +6 (01102) correction when 9<Sum≤15: Carry-out C4 only catches sums ≥16; you MUST also check Z3Z2+Z3Z1 for sums 10–15.
  • Assuming Excess-3 addition automatically preserves Excess-3 bias: Summing two Excess-3 digits creates (A+B+6), requiring −3 when no decimal carry occurs and +3 when a carry occurs!
  • Confusing Common-Cathode vs Common-Anode 7-segment polarity: Common-cathode lights segments on logic 1, whereas common-anode lights segments on logic 0.
  • Treating all self-complementing codes as weighted: Excess-3 is self-complementing (9's complement = bitwise NOT) even though it has NO fixed positional weights.

Worked examples

Try each step yourself, then reveal the working.

Example 1: Converting Between 5-Bit Binary and Reflected Gray Code

numerical

(a) Convert binary B=101102 to Gray code G. (b) Convert Gray code G′=11011G back to Binary B′.

  1. Step 1: Compute Binary → Gray via adjacent XOR (keep MSB)

    Try it on paper first.

Example 2: Self-Complementing Property Verification in Excess-3 Subtraction

numerical

Demonstrate decimal 9's-complementing of decimal 2 (0010BCD) using its Excess-3 representation.

  1. Step 1: Encode digit 2 into Excess-3

    Try it on paper first.

Example 3: Minimizing an Excess-3 to BCD Detector Using Valid-Range Don't-Cares

numerical

For a BCD → 7-segment display (active-HIGH, common cathode), find the minimized SOP expression for the middle horizontal bar g (lit for digits 2,3,4,5,6,8,9; OFF for 0,1,7; don't-care for 10–15).

  1. Step 1: List OFF-minterms (maxterms) inside 0..9

    Try it on paper first.

Example 4: Two-Digit BCD Addition Requiring +6 Correction

numerical

Explain hardware steps when adding 0111BCD (7) and 0101BCD (5) using a 4-bit binary adder + BCD correction unit.

  1. Step 1: Perform raw 4-bit binary sum

    Try it on paper first.

Previous year questions

No official GATE EC question is tagged with this topic yet. The topic test below uses practice questions.

Topic test

8 questions: original practice questions, with GATE marking (MCQ wrong answers lose marks). Score 60% or more to pass. A new set is drawn each time.

Mark as mastered

Loading your progress…

My revision notes

Notes written by the GATEiit team against the official GATE EC syllabus; being checked by a reviewer. Updated 2026-11-29. Spotted a mistake? Use Report an issue on any question, or contact us.