Advanced Physics‹›⌂ 0:00 studied

Module 21 · 8 min read · Free chapter

Digital electronics: number systems, Boolean algebra and identities, De Morgan's theorems, logic gates and truth tables, Karnaugh maps, adders, flip-flops and counters

What are you preparing for? We show the practice and previous year questions of your exam.

Start from zero: thinking in ones and zeros

A light switch is on or off. A transistor driven hard is either saturated or cut off (transistor as switch). Digital electronics builds everything from such two-state elements, labelled 1 and 0. Two levels are easy to tell apart even with noise, so digital signals can be copied, stored and transmitted without degrading.

In 1854 George Boole published an algebra of logic in which variables take only the values true and false. In 1937 Claude Shannon, then a master's student at MIT, showed that Boole's algebra describes circuits of relays and switches exactly. That insight turned logic into hardware, and every computer, phone and digital camera runs on it.

Number systems and codes

A number in base b is N=∑idi biN = \sum_i d_i\,b^i.

  • Binary (base 2): 10112=8+0+2+1=11101011_2 = 8 + 0 + 2 + 1 = 11_{10}.
  • Octal (base 8) groups binary digits in threes: 101 1102=568101\,110_2 = 56_8.
  • Hexadecimal (base 16, digits 0 to 9 and A to F) groups them in fours: 1010 11112=AF16=175101010\,1111_2 = \text{AF}_{16} = 175_{10}.

Decimal to binary: divide repeatedly by 2 and read the remainders upwards. For 25: 25 → 12 r1 → 6 r0 → 3 r0 → 1 r1 → 0 r1, so 2510=11001225_{10} = 11001_2. For fractions multiply by 2 and read the integer parts downwards: 0.625=0.10120.625 = 0.101_2.

Binary arithmetic. 0 + 0 = 0, 0 + 1 = 1, 1 + 1 = 10 (sum 0, carry 1).

Negative numbers: 2's complement. Invert every bit (1's complement) and add 1. In 8 bits, +5=0000 0101+5 = 0000\,0101 and −5=1111 1011-5 = 1111\,1011. Adding them gives 1 0000 00001\,0000\,0000; dropping the carry out leaves 0.

So subtraction A−BA - B is done as A+(2’s complement of B)A + (\text{2's complement of } B), and one adder circuit handles both. An n-bit 2's-complement number ranges from −2n−1-2^{n-1} to 2n−1−12^{n-1} - 1.

Codes. BCD (binary-coded decimal) writes each decimal digit in 4 bits: 5910=0101 1001BCD59_{10} = 0101\,1001_{\text{BCD}}, used in displays and calculators. Gray code changes only one bit between successive numbers, avoiding glitches in shaft encoders. ASCII uses 7 bits per character ('A' = 65).

Boolean algebra and logic gates

Operations. NOT (complement) Aˉ\bar{A}, AND A⋅BA \cdot B, OR A+BA + B.

Basic identities.

Law OR form AND form
identity A + 0 = A A · 1 = A
null A + 1 = 1 A · 0 = 0
idempotent A + A = A A · A = A
complement A + Ā = 1 A · Ā = 0
commutative A + B = B + A AB = BA
distributive A + BC = (A + B)(A + C) A(B + C) = AB + AC
absorption A + AB = A A(A + B) = A
involution double complement of A = A —

A useful extra rule: A+AˉB=A+BA + \bar{A}B = A + B. Proof: A+AˉB=(A+Aˉ)(A+B)=A+BA + \bar{A}B = (A + \bar{A})(A + B) = A + B by the distributive law.

De Morgan's theorems.

A+B‾=Aˉ⋅Bˉ,A⋅B‾=Aˉ+Bˉ\overline{A + B} = \bar{A}\cdot\bar{B}, \qquad \overline{A \cdot B} = \bar{A} + \bar{B}

In words: to complement an expression, complement each variable and swap AND with OR. Proof by truth table: both sides of the first are 1 only when A = B = 0.

Logic gates.

Inputs A B AND OR NAND NOR XOR XNOR
0 0 0 0 1 1 0 1
0 1 0 1 1 0 1 0
1 0 0 1 1 0 1 0
1 1 1 1 0 0 0 1

XOR is A⊕B=ABˉ+AˉBA \oplus B = A\bar{B} + \bar{A}B, 1 when inputs differ; XNOR is its complement, an equality detector.

Universal gates. With NAND alone:

  • NOT: tie both inputs, A⋅A‾=Aˉ\overline{A \cdot A} = \bar{A}.
  • AND: NAND followed by NOT.
  • OR: invert each input, then NAND: Aˉ⋅Bˉ‾=A+B\overline{\bar{A}\cdot\bar{B}} = A + B (De Morgan).

NOR is universal in the same way. Integrated circuits are often built entirely from NAND gates because a CMOS NAND is the simplest and fastest gate (CMOS).

Simplification and combinational circuits

Sum of products (SOP). From a truth table, write one AND term (minterm) for each row with output 1 and OR them together. Example: output 1 for rows ABC = 011, 101, 110, 111 (a majority voter):

Y=AˉBC+ABˉC+ABCˉ+ABCY = \bar{A}BC + A\bar{B}C + AB\bar{C} + ABC

Algebraic simplification. Adding ABC twice more (idempotent law) and grouping:

Y=BC(Aˉ+A)+AC(Bˉ+B)+AB(Cˉ+C)=AB+BC+CAY = BC(\bar{A} + A) + AC(\bar{B} + B) + AB(\bar{C} + C) = AB + BC + CA

Karnaugh map. The truth table is drawn as a grid in Gray-code order so that adjacent cells differ in one variable. Groups of 1, 2, 4 or 8 adjacent 1s (wrapping round the edges) each give one simplified product term, with the variables that change inside the group dropped. For the majority function the map gives three pairs, AB, BC and CA, the same result faster. K-maps are practical up to four or five variables.

Half adder. Adds two bits A and B:

S=A⊕B,C=A⋅BS = A \oplus B, \qquad C = A \cdot B

one XOR gate and one AND gate.

Full adder. Adds A, B and a carry-in CinC_{in}:

S=A⊕B⊕Cin,Cout=AB+Cin(A⊕B)S = A \oplus B \oplus C_{in}, \qquad C_{out} = AB + C_{in}(A \oplus B)

built from two half adders and an OR gate. Chaining n full adders gives an n-bit ripple-carry adder; with XOR gates on B controlled by a subtract line, it also subtracts using 2's complement.

Other combinational blocks. Multiplexers (select one of many inputs), demultiplexers, decoders (such as BCD to seven-segment display drivers), encoders and comparators. Logic families implement gates with BJTs (TTL, 74-series) or MOSFETs (CMOS, 4000-series and all modern chips).

Flip-flops, registers and counters

Combinational outputs depend only on present inputs. Sequential circuits also depend on past inputs: they have memory, built from feedback.

SR latch. Two cross-coupled NOR gates. S = 1 sets Q = 1; R = 1 resets Q = 0; S = R = 0 holds the last state; S = R = 1 is forbidden (both outputs 0, unpredictable when released).

Clocked flip-flops change only at a clock edge, so that all parts of a system update together.

Flip-flop Inputs Behaviour at clock edge Use
SR S, R set, reset, hold; S = R = 1 not allowed basic memory
D (data) D Q takes the value of D registers, memory
JK J, K as SR, but J = K = 1 toggles Q counters
T (toggle) T T = 1 toggles, T = 0 holds frequency division

The JK flip-flop removes the forbidden state of SR. If the clock pulse is long, a JK with J = K = 1 can toggle several times (race-around); the master-slave or edge-triggered design prevents this.

Registers. A row of n D flip-flops sharing a clock stores an n-bit word. A shift register connects each Q to the next D, moving the data one place per clock pulse: used for serial-to-parallel conversion, delay lines and multiplying by 2.

Counters. In a ripple (asynchronous) counter, each JK (J = K = 1) or T flip-flop toggles on the falling output of the previous one. Each stage halves the frequency, so n stages count from 0 to 2n−12^n - 1 and divide the clock by 2n2^n. Four stages give a 4-bit (mod-16) counter; resetting at 1010 gives a decade (mod-10) counter for decimal displays. A synchronous counter clocks all stages together, avoiding the cumulative delay of ripple counters.

Memory and processors. Static RAM cells are flip-flops; registers, counters and adders together form the arithmetic-logic unit and control unit of a microprocessor (microprocessors).

Mains lens: how UPSC asks this

The syllabus explicitly names "Boolean identities, De Morgan's laws, logic gates and truth tables, simple logic circuits", so short, reliable questions come almost every year.

Expect:

  • Number conversions and 2's complement (5 to 10 marks).
  • Prove De Morgan's theorems (10 marks) by truth table; simplify an expression.
  • Universal gates (10 marks): build NOT, AND, OR from NAND or NOR.
  • Simplify and realise (10 marks): a Boolean expression with minimum gates; K-map.
  • Half and full adder (10 marks): truth table, expressions, circuit.
  • Flip-flops (10 marks): SR, JK, D; race-around; counters.

Model answer plan: "State and prove De Morgan's theorems. Show that the NAND gate is a universal gate." (10 marks).

  1. Statements of both theorems.
  2. Truth-table proof with four rows each.
  3. NOT, AND, OR from NAND, with expressions using De Morgan.
  4. One-line note: NOR is also universal; NAND dominates CMOS design.

Quick revision

  • Binary, octal (3 bits), hex (4 bits), BCD; 2's complement = invert + 1; range −2n−1-2^{n-1} to 2n−1−12^{n-1} - 1.
  • Identities: A+A=AA + A = A, AAˉ=0A\bar{A} = 0, A+AB=AA + AB = A, A+AˉB=A+BA + \bar{A}B = A + B.
  • De Morgan: A+B‾=AˉBˉ\overline{A + B} = \bar{A}\bar{B}, AB‾=Aˉ+Bˉ\overline{AB} = \bar{A} + \bar{B}.
  • Gates: AND, OR, NOT, NAND, NOR, XOR (ABˉ+AˉBA\bar{B} + \bar{A}B), XNOR; NAND and NOR universal.
  • Majority =AB+BC+CA= AB + BC + CA; K-maps in Gray order.
  • Half adder S=A⊕BS = A \oplus B, C=ABC = AB; full adder Cout=AB+Cin(A⊕B)C_{out} = AB + C_{in}(A \oplus B).
  • Flip-flops SR, D, JK (toggle at J = K = 1), T; ripple counter divides by 2n2^n.

Mains answer practice

Write your answer first, then open the points a good answer should cover.

  1. Convert 25.625 (decimal) to binary, and 175 (decimal) to hexadecimal. Represent −5 in 8-bit 2's complement form.

    Show answer points
    • 25 by repeated division: 11001
    • 0.625 by repeated multiplication: 0.101; so 11001.101
    • 175 = 1010 1111 = AF (hex)
    • +5 = 0000 0101; invert 1111 1010; add 1: 1111 1011
    • check: 5 + (−5) gives 0 after dropping carry
  2. State and prove De Morgan's theorems using truth tables. Use them to simplify the complement of (A + B̄C).

    Show answer points
    • NOT(A + B) = Ā·B̄; NOT(AB) = Ā + B̄
    • four-row truth tables for each side
    • complement each variable and swap AND and OR
    • NOT(A + B̄C) = Ā · NOT(B̄C)
    • = Ā(B + C̄)
  3. What are universal gates? Show how NOT, AND and OR gates can be realised using only NAND gates.

    Show answer points
    • NAND and NOR are universal
    • NOT: inputs tied, NOT(A·A) = Ā
    • AND: NAND followed by NAND-inverter
    • OR: invert inputs then NAND: NOT(Ā·B̄) = A + B
    • CMOS NAND simplest; whole ICs from NAND
  4. Design a half adder and a full adder. Write their truth tables and Boolean expressions and draw the logic circuits.

    Show answer points
    • half adder: S = A ⊕ B, C = AB
    • truth table for two inputs
    • full adder: S = A ⊕ B ⊕ C_in
    • C_out = AB + C_in(A ⊕ B)
    • two half adders plus OR; ripple-carry n-bit adder
  5. Explain the working of a JK flip-flop with its truth table. What is the race-around condition and how is it avoided? How are JK flip-flops used in a ripple counter?

    Show answer points
    • J K = 00 hold, 01 reset, 10 set, 11 toggle
    • removes SR forbidden state
    • race-around: repeated toggling during a long clock pulse
    • master-slave or edge-triggering prevents it
    • ripple counter: J = K = 1 stages, each halves frequency; n stages count to 2ⁿ − 1

Previous year questions

Previous year questions for UPSC CSE will appear here once each one is checked word for word against the official question paper.

Learn with AI

A tutor that asks instead of telling, a partner that argues the other side, and this chapter told through your own district.

Tell the tutor what you are stuck on. It will guide you with questions and give the answer after a few tries.

🙋 Raise a doubt or feedback

Stuck somewhere, or spotted a mistake? Write to the ExamHike team. We usually reply within a day, and you will see the reply on My progress.

Log in to ask a doubt or send feedback →

More in this module: Devices and electronics

Official sources

Facts in this chapter were checked against these official sources.

  1. IGNOU PHE-10 Electrical Circuits and Electronics: Digital electronics (number systems, Boolean algebra, flip-flops, registers)
  2. NPTEL Digital Circuits (IIT): Boolean algebra and combinational logic