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
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 .
- Binary (base 2): .
- Octal (base 8) groups binary digits in threes: .
- Hexadecimal (base 16, digits 0 to 9 and A to F) groups them in fours: .
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 . For fractions multiply by 2 and read the integer parts downwards: .
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, and . Adding them gives ; dropping the carry out leaves 0.
So subtraction is done as , and one adder circuit handles both. An n-bit 2's-complement number ranges from to .
Codes. BCD (binary-coded decimal) writes each decimal digit in 4 bits: , 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) , AND , OR .
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: . Proof: by the distributive law.
De Morgan's theorems.
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 , 1 when inputs differ; XNOR is its complement, an equality detector.
Universal gates. With NAND alone:
- NOT: tie both inputs, .
- AND: NAND followed by NOT.
- OR: invert each input, then NAND: (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):
Algebraic simplification. Adding ABC twice more (idempotent law) and grouping:
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:
one XOR gate and one AND gate.
Full adder. Adds A, B and a carry-in :
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 and divide the clock by . 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).
- Statements of both theorems.
- Truth-table proof with four rows each.
- NOT, AND, OR from NAND, with expressions using De Morgan.
- 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 to .
- Identities: , , , .
- De Morgan: , .
- Gates: AND, OR, NOT, NAND, NOR, XOR (), XNOR; NAND and NOR universal.
- Majority ; K-maps in Gray order.
- Half adder , ; full adder .
- Flip-flops SR, D, JK (toggle at J = K = 1), T; ripple counter divides by .