Digital Electronics cover
Interactive book · Semester 3

Digital Electronics

Click bits, wire gates and clock flip-flops to see digital logic work

Twelve chapters, 12 interactives, few words. Every chapter is mapped to the Anna University, VTU, SPPU, Mumbai University and KTU units it covers, from binary numbers and Karnaugh maps to flip-flops, state machines, logic families and Verilog.

  • AUEC3352Digital Systems Design
  • VTUBEC302Digital System Design using Verilog
  • SPPU204182Digital Circuits
  • MUECC303Digital System Design
  • KTUPBECT304Logic Circuit Design

By Skill-Lync · Updated 16 Nov 2026 · 12 chapters · 12 interactives · free, no sign-up

Chapter 1

Number systems and codes

Which syllabus covers thisAU EC3352 Unit IVTU not in syllabusSPPU 204182 Unit II (code converters)MU ECC303 Module 1KTU PBECT304 Module 1

Why do digital circuits count in binary?

A transistor switch is reliable when it only has to be clearly on or clearly off. Two states are easy to tell apart even with noise, temperature drift and cheap parts, so every digital value is stored as a pattern of bits (binary digits). Each bit position is worth twice the one to its right: 1, 2, 4, 8, 16 and so on.

What are hexadecimal and octal for?

They are shorthand for long bit patterns. One hex digit stands for exactly 4 bits (0 to F) and one octal digit for 3 bits, so you convert by grouping bits from the right. 1001 1100 is 9C in hex; regrouped as 10 011 100 it is 234 in octal.

How does a circuit store a negative number?

With two's complement: the most significant bit has a negative weight (−128 in an 8-bit byte), the rest keep their normal weights. To negate a number, invert every bit and add 1. The payoff is that the same adder handles positive and negative numbers, and there is only one zero. One's complement (just invert) also exists but has two zeros, +0 and −0.

Number systems: one pattern of bits read as binary, hex, BCD, Gray and two's complement: interactive loads as you scroll

What are BCD, Excess-3 and Gray code?

BCD stores each decimal digit in its own 4 bits, so 95 is 1001 0101: easy to show on a display, wasteful in storage. Excess-3 adds 3 to each digit before coding it, which makes the 9's complement a simple bit inversion. Gray code changes only one bit between neighbouring numbers, so a rotary encoder never reads a wildly wrong value halfway between two positions. Binary to Gray: each Gray bit is the XOR of a binary bit and the bit to its left.

How can a code detect or even correct an error?

Add redundant bits. A single parity bit makes the count of 1s even, so any single flipped bit is detected but not located. Hamming (7,4) adds three parity bits at positions 1, 2 and 4, each checking a different set of positions. When a bit flips, the failing checks spell out its position in binary (the syndrome), and the receiver flips it back.

Hamming (7,4) code: flip a bit and watch the syndrome find it: interactive loads as you scroll
Predict, then check

In 8-bit two's complement, what is 1000 0000?

Worked examples

Decimal to binary, hex and octal · Convert 156
  1. Repeated division by 2 gives the remainders (read bottom-up) 10011100
  2. Group in fours: 1001 1100 = 9 and C, so hex 9C
  3. Group in threes from the right: 10 011 100 = 2, 3, 4, so octal 234

Answer: 10011100 (binary) = 9C (hex) = 234 (octal)

Two's complement of a negative number · Write -45 as an 8-bit two's complement number
  1. +45 = 00101101
  2. Invert every bit: 11010010
  3. Add 1: 11010011
  4. Check: −128 + 64 + 16 + 2 + 1 = -45

Answer: 11010011

BCD addition with the +6 correction · Add 57 and 38 in BCD
  1. Units: 0111 + 1000 = 1111 (15). That is more than 9, so add 0110: 1 0101 (digit 5, carry 1)
  2. Tens: 0101 + 0011 + carry 1 = 1001 (9), no correction needed
  3. Result 1001 0101

Answer: 1001 0101 = 95

Hamming code: find and fix the error · Data 1101 is sent as Hamming (7,4); bit 6 flips on the way
  1. Parity bits: p1 = d1⊕d2⊕d4 = 0, p2 = d1⊕d3⊕d4 = 1, p4 = d2⊕d3⊕d4 = 0, so the codeword is 1010101
  2. Received 1010111
  3. Checks: p1 group (1,3,5,7) passes, p2 group (2,3,6,7) fails, p4 group (4,5,6,7) fails
  4. Syndrome = p4 p2 p1 = 110 = 6, so flip bit 6 back

Answer: Bit 6 was wrong; corrected codeword 1010101, data 1101

Chapter 2

Boolean algebra and logic gates

Which syllabus covers thisAU EC3352 Unit IVTU BEC302 Module 1SPPU 204182 Unit IIMU ECC303 Module 2KTU PBECT304 Module 1

What does each logic gate do?

AND gives 1 only when all inputs are 1. OR gives 1 when any input is 1. NOT inverts. NAND and NOR are AND and OR followed by NOT. XOR gives 1 when the inputs differ, XNOR when they match. In this book a prime marks a complement: A′ means NOT A.

Logic gate playground, with each gate rebuilt from NAND gates only: interactive loads as you scroll

Why are NAND and NOR called universal gates?

Either one alone can build every other gate. A NAND with its inputs tied together is a NOT; NAND followed by NOT is AND; NANDs on inverted inputs make OR (De Morgan). Chips and standard-cell libraries lean on this: a CMOS NAND needs only four transistors and is faster than an AND, which is really a NAND plus an inverter.

Which Boolean theorems do the real work?

Absorption (A + AB = A), the complement law (A + A′ = 1), distribution in both directions (A + BC = (A + B)(A + C), which has no ordinary-algebra twin) and De Morgan: (AB)′ = A′ + B′ and (A + B)′ = A′B′. De Morgan is how you move a bubble through a gate: a NAND is the same as an OR with inverted inputs.

What are minterms, maxterms, SOP and POS?

A minterm is an AND of every variable that is 1 for exactly one input row; a function is the OR of the minterms where it is 1, written Σm(…). A maxterm is an OR term that is 0 for exactly one row; the function is the AND of its maxterms, ΠM(…). Sum of products (SOP) maps to an AND-OR circuit, product of sums (POS) to OR-AND. Both canonical forms are correct but rarely minimal.

Predict, then check

You only have 2-input NAND gates. How many do you need for one 2-input OR?

Worked examples

Simplify with theorems · Simplify F = AB + AB′ + A′B
  1. AB + AB′ = A(B + B′) = A
  2. F = A + A′B
  3. A + A′B = (A + A′)(A + B) = A + B (distribution)

Answer: F = A + B

Apply De Morgan · Write the complement of F = (A + B′)C
  1. F′ = ((A + B′)C)′ = (A + B′)′ + C′
  2. (A + B′)′ = A′B
  3. F′ = A′B + C′

Answer: F′ = A′B + C′

Canonical SOP from a truth table · F(A, B, C) is 1 for the majority of inputs (two or three 1s)
  1. Rows with two or more 1s: 011, 101, 110, 111
  2. F = Σm(3, 5, 6, 7) = A′BC + AB′C + ABC′ + ABC
  3. Each pair shares two variables with ABC, so ABC can be reused three times (A + A = A)
  4. F = BC + AC + AB

Answer: F = AB + BC + AC (3 two-input ANDs and a 3-input OR)

Chapter 3

Karnaugh maps and minimisation

Which syllabus covers thisAU EC3352 Unit IVTU BEC302 Module 1SPPU 204182 Unit IIMU ECC303 Module 3.1KTU PBECT304 Module 1

Why does a Karnaugh map work?

Its rows and columns are numbered in Gray code (00, 01, 11, 10), so any two side-by-side cells differ in exactly one variable, and so do the cells at opposite edges. Two neighbouring 1s can merge into one term that drops the changing variable (AB′C + ABC = AC). Groups of 2, 4 or 8 cells drop 1, 2 or 3 variables.

Four-variable Karnaugh map that groups and simplifies as you click: interactive loads as you scroll

What are the rules for drawing groups?

Groups are rectangles of 1, 2, 4, 8 or 16 cells, they may wrap around the edges (the four corners are one group), and every 1 must be inside at least one group. Make each group as large as possible and use as few groups as possible. A group that is the only one covering some 1 is an essential prime implicant: it must appear in the answer.

What do don't-care cells mean?

They are input combinations that never happen (a BCD digit above 9) or whose output nobody reads. Marked X, they can be treated as 1 when that makes a group larger and as 0 otherwise. The K-map above lets you set cells to X and watch the answer shrink.

How do you get the minimal product of sums?

Group the 0s instead of the 1s. Each group of 0s gives an OR term with the variables complemented the opposite way (a 0-group where A = 1 and B = 1 gives (A′ + B′)), and the function is the AND of those terms. Pick whichever of SOP and POS needs fewer gates.

What is the Quine-McCluskey method?

The same merging, done as a table, so it works for any number of variables and can be programmed. List minterms by the number of 1s, merge pairs that differ in one bit (marking the dropped bit with a dash), repeat until nothing merges: what is left are the prime implicants. A prime-implicant chart then picks the essential ones and the cheapest cover for the rest. EDA tools use descendants of this idea, such as Espresso.

Predict, then check

On a 4-variable K-map the four corner cells are 1 and nothing else is. How many literals does the minimal SOP have?

Worked examples

K-map with wrap-around groups · F = Σm(0, 2, 5, 7, 8, 10, 13, 15)
  1. Corners 0, 2, 8, 10 form a group of four: B = 0, D = 0, so B′D′
  2. Centre cells 5, 7, 13, 15 form a group of four: B = 1, D = 1, so BD
  3. Every 1 is covered by those two groups

Answer: F = B′D′ + BD (an XNOR of B and D)

Using don't-cares · F = Σm(1, 3, 7, 11, 15) + d(0, 2, 5)
  1. Column CD = 11 (cells 3, 7, 15, 11) is a group of four: CD
  2. Cell 1 still needs a group; with don't-cares 0, 2 and 3 it joins row AB = 00, a group of four: A′B′
  3. Minimal SOP: A′B′ + CD (another minimum also exists: A′D + CD, using don't-care 5)

Answer: F = A′B′ + CD

Minimal POS by grouping zeros · F = Σm(0, 1, 2, 3, 4, 6, 8, 9, 10, 11)
  1. SOP from the 1s: rows AB = 00 and 10 give B′; cells 0, 2, 4, 6 give A′D′, so F = B′ + A′D′
  2. The 0s are 5, 7, 12, 13, 14, 15
  3. Group 12, 13, 14, 15 (A = 1, B = 1) gives (A′ + B′); group 5, 7, 13, 15 (B = 1, D = 1) gives (B′ + D′)
  4. F = (B′ + D′)(A′ + B′)

Answer: SOP B′ + A′D′; POS (B′ + D′)(A′ + B′)

Chapter 4

Adders, subtractors and comparators

Which syllabus covers thisAU EC3352 Unit IIVTU BEC302 Module 2SPPU 204182 Unit IIIMU ECC303 Module 3.2KTU PBECT304 Module 2

How does a full adder work?

It adds three bits, A, B and a carry in. The sum is A ⊕ B ⊕ Cin (1 when an odd number of inputs are 1) and the carry out is AB + Cin(A ⊕ B): either both bits are 1, or one is and a carry arrives. A half adder is the same without Cin: S = A ⊕ B, C = AB.

Why is a ripple-carry adder slow?

Stage i cannot finish until the carry from stage i − 1 arrives, so the worst case (adding 1 to 0111…1) waits for the carry to travel through every stage. With about 2 gate delays per stage, a 4-bit adder settles in about 9 gate delays and a 32-bit one in about 65. The interactive shows the carry travelling and how far it really goes for your numbers.

Four-bit ripple-carry adder and subtractor with the carry travelling: interactive loads as you scroll

How does a carry look-ahead adder remove the wait?

Each stage computes generate G = AB (it makes a carry by itself) and propagate P = A ⊕ B (it passes an incoming carry on). Then every carry can be written straight from the inputs: C1 = G0 + P0C0, C2 = G1 + P1G0 + P1P0C0, and so on. All carries are ready after about 3 gate delays whatever the width, at the cost of wide gates, so real designs look ahead in groups of 4.

How does the same adder subtract?

A − B = A + B′ + 1 in two's complement. Put an XOR gate on each B input, controlled by a mode line M: when M = 1 the XORs invert B and M also feeds the carry in. Overflow (a signed result that does not fit) is the XOR of the carries into and out of the sign bit.

What do a BCD adder and a magnitude comparator add?

A BCD adder is a binary adder plus a correction: if the 4-bit sum is above 9 or produced a carry, add 0110 so the digit wraps to 0 to 9 and a decimal carry goes out. A magnitude comparator decides A > B, A = B or A < B: equality is the AND of bit-wise XNORs, and A > B is found from the most significant bit where they differ.

Predict, then check

4-bit two's complement: 0110 + 0101 (6 + 5). What does the adder output?

Worked examples

4-bit addition · Add 1011 and 0110
  1. Bit 0: 1 + 0 = 1, carry 0
  2. Bit 1: 1 + 1 = 0, carry 1
  3. Bit 2: 0 + 1 + 1 = 0, carry 1
  4. Bit 3: 1 + 0 + 1 = 0, carry 1
  5. Unsigned: 11 + 6 = 17 = 1 0001

Answer: Sum 0001 with carry out 1 (17 needs five bits)

Subtraction with the adder · Compute 5 − 9 in 4 bits
  1. 9 = 1001, inverted 0110
  2. 0101 + 0110 + 1 = 1100, carry out 0
  3. Carry out 0 means a borrow: the result is negative
  4. 1100 in two's complement = −8 + 4 = −4

Answer: 1100 = −4

Ripple delay in nanoseconds · 16-bit ripple adder, every gate 10 ns
  1. with n = 16
  2. (2 × 16 + 1) × 10 = 330 ns
  3. A look-ahead version: about 3 gate delays for the carries = 30 ns (plus wiring for wide gates)

Answer: About 330 ns, so it limits the clock to roughly 3 MHz

Chapter 5

Multiplexers, decoders and encoders

Which syllabus covers thisAU EC3352 Unit IIVTU BEC302 Module 2SPPU 204182 Unit IIIMU ECC303 Module 3.3KTU PBECT304 Module 2

What does a multiplexer do?

It is a digitally controlled switch: n select lines choose one of 2ⁿ data inputs and pass it to the output. A 4:1 mux has output Y = S1′S0′I0 + S1′S0I1 + S1S0′I2 + S1S0I3. Bigger ones are built as trees: two 8:1 muxes and a 2:1 mux make a 16:1.

How can a multiplexer replace a whole logic circuit?

Put the input variables on the select lines and tie each data input to that row's output, 0 or 1: an 8:1 mux realises any 3-variable function with no other gates. A smarter trick uses a 4:1 mux: A and B go to the selects, and each data input becomes 0, 1, C or C′, decided by the two rows that share that AB.

Multiplexer realising a Boolean function: interactive loads as you scroll

What are a demultiplexer and a decoder?

A demultiplexer routes one input to one of 2ⁿ outputs. A decoder is the same idea with the data input held at 1: an n-to-2ⁿ decoder makes exactly one output active for each input code, so its outputs are the minterms. OR a few of them together and you have any function; with an enable input, small decoders combine into bigger ones.

What does a priority encoder solve?

A plain encoder turns a one-hot input (exactly one line active) into its binary number, but gives nonsense when two lines are active. A priority encoder outputs the number of the highest-priority active line and adds a valid output for when none is active; that is how interrupt controllers pick which request to serve.

What are code converters and 7-segment decoders?

Combinational circuits designed straight from a truth table: binary to Gray (an XOR per bit), BCD to Excess-3, BCD to 7-segment (seven outputs a to g, one K-map each, codes 10 to 15 used as don't-cares). Parity generators and checkers are XOR trees that produce or test the parity bit of a word.

Predict, then check

To realise any 4-variable function with one multiplexer and no other gates except an inverter, the smallest mux you need is:

Worked examples

Function on a 4:1 multiplexer · F(A, B, C) = Σm(1, 2, 6, 7) with A, B on the selects
  1. AB = 00: rows 0 and 1 give F = 0, 1, so I0 = C
  2. AB = 01: rows 2 and 3 give F = 1, 0, so I1 = C′
  3. AB = 10: rows 4 and 5 give 0, 0, so I2 = 0
  4. AB = 11: rows 6 and 7 give 1, 1, so I3 = 1

Answer: I0 to I3 = C, C′, 0, 1

Full adder from a decoder · Build a full adder with a 3-to-8 decoder and two OR gates
  1. Sum is 1 for minterms 1, 2, 4, 7
  2. Carry is 1 for minterms 3, 5, 6, 7
  3. OR decoder outputs 1, 2, 4, 7 for S and 3, 5, 6, 7 for Cout

Answer: S = Σm(1, 2, 4, 7), Cout = Σm(3, 5, 6, 7), each a 4-input OR

Priority encoder output · 4-to-2 priority encoder, D3 highest; inputs D3 D2 D1 D0 = 0110
  1. Active lines: D2 and D1
  2. D2 has the higher priority
  3. Output the number 2 and set Valid = 1

Answer: Y1 Y0 = 10, V = 1

Chapter 6

Latches and flip-flops

Which syllabus covers thisAU EC3352 Unit IIIVTU BEC302 Module 3SPPU 204182 Unit IVMU ECC303 Module 4.1KTU PBECT304 Module 3

How can gates remember a bit?

Cross-couple two NOR gates so each output feeds the other's input. With S = R = 0 the loop holds whatever it had: that is one bit of memory. S = 1 sets Q to 1, R = 1 resets it to 0, and S = R = 1 is forbidden because both outputs go to 0 and the final state after releasing them is unpredictable. That is the SR latch.

What is the difference between a latch and a flip-flop?

A gated latch is transparent: while its enable is high the output follows the input. A flip-flop samples its input only at a clock edge (rising or falling) and holds it for the rest of the cycle. Because everything changes together at the edge, a whole system of flip-flops can be designed cycle by cycle without races. Classic master-slave flip-flops get this by putting two latches in series on opposite clock levels.

Flip-flop timing diagram: SR, D, JK and T: interactive loads as you scroll

What do SR, JK, D and T flip-flops do?

D copies its input: Q+ = D. T toggles when T = 1: Q+ = T ⊕ Q. JK is an SR without the forbidden case: J sets, K resets, J = K = 1 toggles, so Q+ = JQ′ + K′Q. SR: Q+ = S + R′Q with SR = 0. Preset and clear inputs force Q regardless of the clock, which is how a circuit starts in a known state.

What is an excitation table and why convert flip-flops?

The characteristic table answers: given the inputs, what is the next state? The excitation table answers the design question: to go from Q to Q+, what inputs do I need? For a JK, 0→1 needs J = 1 (K don't-care) and 1→1 needs K = 0. Converting one flip-flop into another uses exactly this: write the target's behaviour, read the needed inputs from the excitation table, and simplify with a K-map (a JK with J = K = T is a T flip-flop).

What are setup time, hold time and metastability?

The input must be stable for a setup time before the edge and a hold time after it. Break that and the flip-flop can hang between 0 and 1 for an unpredictable time (metastability). Setup sets the speed limit: the clock period must cover clock-to-Q, the logic delay and setup. Signals from another clock domain are passed through two flip-flops in a row (a synchroniser) to make metastability very unlikely.

Predict, then check

A JK flip-flop with J = K = 1 is clocked by a 10 MHz clock. What is at Q?

Worked examples

JK sequence · JK flip-flop starts at Q = 0; inputs (J, K) at five edges: (1,0), (0,0), (1,1), (1,1), (0,1)
  1. (1,0) sets: Q = 1
  2. (0,0) holds: Q = 1
  3. (1,1) toggles: Q = 0
  4. (1,1) toggles: Q = 1
  5. (0,1) resets: Q = 0

Answer: Q = 1, 1, 0, 1, 0

D flip-flop from a JK · Turn a JK into a D flip-flop
  1. D = 1 must give Q+ = 1: from the excitation table J = 1, K = X (if Q = 0) or J = X, K = 0 (if Q = 1)
  2. D = 0 must give Q+ = 0: J = 0, K = X or J = X, K = 1
  3. K-maps give J = D and K = D′

Answer: J = D, K = D′ (one inverter)

Maximum clock frequency · Clock-to-Q 2.0 ns, logic 6.5 ns, setup 1.5 ns
  1. 2.0 + 6.5 + 1.5 = 10.0 ns
  2. f = 1 / 10.0 ns

Answer: 100 MHz

Chapter 7

Shift registers and counters

Which syllabus covers thisAU EC3352 Unit IIIVTU BEC302 Module 3SPPU 204182 Unit IVMU ECC303 Modules 4.1 to 4.3KTU PBECT304 Module 3

What is a shift register?

A row of D flip-flops, each feeding the next, on one clock. Every edge moves the stored word one place. Serial-in parallel-out (SIPO) turns a bit stream into a word, which is what a UART receiver or an SPI input does; parallel-in serial-out (PISO) does the reverse. A universal shift register can hold, shift left, shift right or load in parallel, chosen by two mode lines.

Shift register: serial in, serial or parallel out: interactive loads as you scroll

How does a ripple (asynchronous) counter count?

Chain T flip-flops (T = 1) so each one's output clocks the next. The first divides the clock by 2, the next by 4 and so on: n flip-flops count 0 to 2ⁿ − 1. It is simple, but each stage waits for the one before it, so the outputs settle one flip-flop delay apart and pass through wrong values for a moment. Decoding those outputs can produce glitches.

Counters: ripple, synchronous, mod-N, ring and Johnson: interactive loads as you scroll

Why are synchronous counters preferred?

All flip-flops share the clock, and logic decides who toggles: in a binary up-counter bit i toggles when all lower bits are 1 (T_i = Q0Q1…Q(i−1)). Every output changes at the same moment, so there are no ripple glitches and the speed does not fall as the counter grows. To design any sequence, write the state table, use the excitation table for the chosen flip-flop, and minimise each input with a K-map.

How do you make a mod-N counter?

A ripple counter can be cleared asynchronously the moment it reaches N: a NAND watches the bits that are 1 in N (for N = 10, Q3 and Q1) and pulls clear. State N appears for a few nanoseconds, a known weakness. A synchronous design instead routes state N − 1 back to 0 through the next-state logic. Unused states must also lead back into the count, otherwise the counter can lock out after power-up.

What are ring and Johnson counters?

Shift registers fed back on themselves. A ring counter circulates a single 1: n flip-flops give n states, each already decoded (one-hot). A Johnson (twisted-ring) counter feeds back the inverted last output: n flip-flops give 2n states, and any state is decoded with one 2-input gate. Both need the start state to be loaded at reset.

Predict, then check

A 5-flip-flop Johnson counter runs from a 1 MHz clock. What is the frequency of each output?

Worked examples

Ripple counter speed · 4-bit ripple counter, 12 ns per flip-flop
  1. The last output settles after 4 flip-flop delays
  2. 4 × 12 = 48 ns
  3. The outputs must settle before the next edge if they are to be read

Answer: f max ≈ 20.8 MHz

Mod-10 ripple counter · Clear a 4-bit ripple counter at 10
  1. 10 = 1010: Q3 = 1 and Q1 = 1
  2. Feed Q3 and Q1 to a NAND whose output drives the active-low clear
  3. The count runs 0 to 9; state 1010 lasts only until the clear acts

Answer: NAND(Q3, Q1) → CLR′ gives a decade (BCD) counter

Synchronous mod-6 with T flip-flops · Count 000 to 101 and back to 000
  1. T for each bit = present bit ⊕ next bit
  2. 000→001: T = 001; 001→010: 011; 010→011: 001
  3. 011→100: 111; 100→101: 001; 101→000: 101
  4. K-maps with 110 and 111 as don't-cares: T0 = 1, T1 = Q2′Q0, T2 = Q2Q0 + Q1Q0

Answer: T0 = 1, T1 = Q2′Q0, T2 = Q0(Q2 + Q1)

Chapter 8

Synchronous state machines

Which syllabus covers thisAU EC3352 Unit IIIVTU not in syllabusSPPU 204182 Unit VMU ECC303 Module 4.3KTU PBECT304 Module 4

What is a finite state machine?

A circuit whose output depends on what has happened before, summarised as one of a few states held in flip-flops. Next-state logic decides where to go on each clock from the present state and the inputs; output logic decides what to show. Traffic lights, vending machines, serial protocol decoders and the control unit of a processor are all state machines.

What is the difference between a Mealy and a Moore machine?

A Moore machine's outputs depend only on the state, so they change only on clock edges and are glitch-free. A Mealy machine's outputs depend on the state and the present input, so it reacts in the same cycle and usually needs fewer states, but an input glitch can reach the output. A Moore detector for an n-bit pattern needs n + 1 states, a Mealy one n.

Sequence detector state machine: Mealy and Moore: interactive loads as you scroll

How do you design a sequence detector?

Give each state a meaning: how much of the pattern has been seen. On a correct bit, move one step forward. On a wrong bit, don't always go back to the start: fall back to the longest part of the pattern that is still a suffix of what came in (for 1011, after 101 a 0 leaves 10). Overlapping detectors reuse the tail of a match, so 10110111 has two 1011 matches overlapping at the 1 they share; non-overlapping ones start fresh.

What are the design steps after the state diagram?

Draw the state diagram, write the state table, merge equivalent states (same outputs and same next states), assign binary codes (n flip-flops for up to 2ⁿ states; one-hot uses one flip-flop per state and simpler logic, common on FPGAs), derive flip-flop inputs from the excitation table, minimise with K-maps, and check that unused codes return to the sequence. ASM charts are a flowchart way to draw the same machine.

Predict, then check

A Moore machine detects 1011. How many flip-flops does it need with binary state codes?

Worked examples

Overlapping and non-overlapping detection · Detect 101 in the stream 110101101
  1. Matches end at bits 4, 6 and 9 (counting from 1) if overlap is allowed
  2. Overlapping output: 000101001
  3. Non-overlapping: the match ending at bit 6 uses bit 4, already part of the first match, so it is skipped
  4. Non-overlapping output: 000100001

Answer: 3 detections overlapping, 2 non-overlapping

Mealy detector for 1011, overlapping · States: S0 (nothing), S1 (1), S2 (10), S3 (101)
  1. S0: 1 → S1, 0 → S0
  2. S1: 0 → S2, 1 → S1 (still have a 1)
  3. S2: 1 → S3, 0 → S0
  4. S3: 1 → output 1 and go to S1 (the last 1 starts a new match); 0 → S2 (101 then 0 leaves 10)

Answer: 4 states, 2 flip-flops, output 1 on the S3 → S1 transition

Chapter 9

Asynchronous circuits and hazards

Which syllabus covers thisAU EC3352 Unit IVVTU not in syllabusSPPU not in syllabusMU not in syllabusKTU not in syllabus

What is an asynchronous sequential circuit?

One with feedback but no clock: the state is held in the loops themselves and changes as soon as inputs change. A state is stable when the feedback agrees with itself. They are fast and draw no clock power, but every gate delay matters, so they are designed in fundamental mode: only one input changes at a time, and only after the circuit has settled.

What are races and how are they avoided?

When two state variables must change together, they never change at exactly the same instant. If the order does not matter and the circuit ends in the same stable state, the race is non-critical; if it can settle in a different state, it is critical. The cure is a race-free state assignment, where every transition changes only one variable, sometimes using extra states or cycles of states.

What is a static hazard?

A brief wrong output caused by unequal path delays. In F = AB + A′C with B = C = 1, F should stay 1 when A falls, but the AB term turns off before A′C turns on (A′ comes through an inverter), so F dips to 0 for about one inverter delay. That is a static-1 hazard. On a K-map it shows up as two adjacent 1s covered by different groups, and the cure is the consensus term BC, a redundant group bridging them.

Static-1 hazard in a two-level circuit, and the consensus term that removes it: interactive loads as you scroll

What are dynamic and essential hazards?

A dynamic hazard is an output that should change once but changes three or more times, possible in multi-level logic with several paths. An essential hazard belongs to the asynchronous machine itself: an input change reaches one feedback loop before another, and no logic redundancy fixes it; it needs added delay in the feedback path. Synchronous designs mostly ignore hazards because flip-flops only sample after the logic settles.

Predict, then check

F = AB + A′C. Which change of A can make F glitch when B = C = 1?

Worked examples

Find and remove a static-1 hazard · F = A′B + AC
  1. K-map groups: A′B and AC
  2. Cells ABC = 011 and 111 are adjacent 1s covered by different groups (B = C = 1, A changes)
  3. Consensus of A′B and AC is BC
  4. F = A′B + AC + BC: same function, no hazard

Answer: Add the redundant term BC

Chapter 10

Logic families

Which syllabus covers thisAU EC3352 Unit VVTU not in syllabusSPPU 204182 Unit IMU ECC303 Module 2.1KTU PBECT304 Module 4

What are logic levels and noise margins?

A real gate guarantees its output is above VOH for a 1 and below VOL for a 0, and promises to read any input above VIH as 1 and below VIL as 0. The gaps are the noise margins: NMH = VOH − VIH and NML = VIL − VOL. Noise smaller than that cannot flip a bit between one gate and the next. For standard 5 V TTL (74 series) these are 0.4 V each.

How does a CMOS inverter work?

A pMOS transistor to VDD and an nMOS to ground share the input. A low input turns the pMOS on and the nMOS off: output high. A high input does the opposite. In either steady state one transistor is off, so almost no current flows: CMOS burns power mostly while switching. The transfer curve is steep in the middle, which gives CMOS wide noise margins.

CMOS inverter transfer curve and noise margins: interactive loads as you scroll

What is inside a TTL gate?

Bipolar transistors: a multi-emitter input transistor (the AND function), a phase splitter, and a totem-pole output with one transistor pulling up and one pulling down. Totem-pole outputs must never be wired together. Open-collector outputs can be (wired-AND with a pull-up resistor), and tri-state outputs add a third, high-impedance state so many devices can share one bus. An unconnected TTL input floats high; an unconnected CMOS input floats anywhere and must be tied off.

How are logic families compared?

By propagation delay (input change to output change, an average of the rise and fall delays), power per gate, the speed-power product, noise margins and fan-out: how many gate inputs one output can drive while keeping its levels. TTL fan-out comes from currents (10 for the standard 74 series); CMOS inputs draw almost no DC current, so its fan-out is limited by the capacitance the output must charge. ECL is the fastest of the classic families and also the most power-hungry, because its transistors never saturate.

Predict, then check

You lower a CMOS chip's supply from 3.3 V to 1.65 V at the same clock. Dynamic power becomes:

Worked examples

TTL fan-out · Standard 74 TTL: IOL = 16 mA, IIL = 1.6 mA, IOH = 0.4 mA, IIH = 0.04 mA
  1. Low state: 16 / 1.6 = 10
  2. High state: 0.4 / 0.04 = 10
  3. Fan-out is the smaller of the two

Answer: Fan-out = 10

TTL noise margins · VOH = 2.4 V, VOL = 0.4 V, VIH = 2.0 V, VIL = 0.8 V
  1. NMH = 2.4 − 2.0 = 0.4 V
  2. NML = 0.8 − 0.4 = 0.4 V

Answer: 0.4 V high and 0.4 V low

Symmetric CMOS inverter · VDD = 5 V, Vtn = |Vtp| = 1 V, equal kn and kp
  1. Switching threshold VM = VDD / 2 = 2.5 V
  2. VIL = (3VDD + 2Vt) / 8 = 2.125 V
  3. VIH = (5VDD − 2Vt) / 8 = 2.875 V

Answer: VIL = 2.125 V, VIH = 2.875 V; set the same values in the interactive above

Dynamic power · C = 50 pF switched, VDD = 3.3 V, f = 100 MHz, activity 0.25
  1. 0.25 × 50 pF × 3.3² × 100 MHz = 13.6 mW

Answer: About 13.6 mW

Chapter 11

Memories and programmable logic

Which syllabus covers thisAU EC3352 Unit VVTU BEC302 Module 2 (PLDs)SPPU 204182 Unit VIMU ECC303 Module 5KTU not in syllabus

How is a memory organised?

As 2ⁿ words of m bits: n address lines go into a decoder that selects one word, and m data lines carry it in or out. A 2K × 8 memory has 2048 words of 8 bits, 11 address lines and 16,384 bits. Bigger memories are built from smaller chips: chips side by side widen the word, and an extra decoder on the high address bits selects which chip answers.

What are SRAM, DRAM, ROM, EPROM, EEPROM and Flash?

SRAM keeps each bit in a pair of cross-coupled inverters (6 transistors): fast, used for caches, lost at power-off. DRAM keeps it as charge on a tiny capacitor (1 transistor + 1 capacitor): dense and cheap, but must be refreshed every few milliseconds. ROMs are non-volatile: mask ROM is fixed at the factory, PROM is programmed once, EPROM is erased with UV light, EEPROM electrically byte by byte, and Flash electrically in blocks, which is why it took over USB drives and SSDs.

What are PROM, PLA and PAL?

All implement sum-of-products logic with programmable connections. A PROM has a fixed AND array (a full decoder) and a programmable OR array. A PLA programs both arrays, so product terms can be shared between outputs. A PAL programs the AND array and fixes the OR array: cheaper and faster than a PLA, and the ancestor of the GAL chips still sold.

How do CPLDs and FPGAs differ?

A CPLD joins a few PAL-like blocks with a central switch matrix: predictable timing, instant-on, a few hundred flip-flops. An FPGA is a sea of small lookup tables (a 6-input LUT is a 64-bit memory holding a truth table) with flip-flops, programmable routing, block RAM and DSP slices, configured from a bitstream at power-up. Designs are written in Verilog or VHDL and synthesised into that fabric.

Predict, then check

A memory chip has 13 address lines and 8 data lines. How many bits does it store?

Worked examples

Address lines and capacity · A 2048 × 8 memory
  1. 2048 = 2^11, so 11 address lines
  2. Capacity = 2048 × 8 = 16,384 bits

Answer: 11 address lines, 16,384 bits (2 KB)

Building memory from smaller chips · Make 64K × 8 from 16K × 4 chips
  1. Two chips side by side give 8-bit words: 16K × 8
  2. Four such pairs give 64K words
  3. A 2-to-4 decoder on the top 2 address lines picks the pair
  4. Chips = (64K / 16K) × (8 / 4) = 8

Answer: 8 chips plus a 2-to-4 decoder

PLA product terms · Realise F1 = AB + AC and F2 = AC + BC on a PLA
  1. Product terms needed: AB, AC, BC
  2. AC is shared: the PLA generates it once and feeds both OR gates
  3. A PAL with fixed OR gates would have to generate AC twice

Answer: 3 product terms in a PLA (4 in a PAL)

Chapter 12

Verilog HDL

Which syllabus covers thisAU not in syllabusVTU BEC302 Modules 4 and 5SPPU not in syllabusMU ECC303 Module 6KTU PBECT304 Module 2

Why describe hardware in a language?

A modern chip has billions of transistors; nobody draws them. A hardware description language (Verilog or VHDL) describes what the circuit does, a simulator checks it against test inputs, and a synthesis tool turns it into gates for an FPGA or a chip. Unlike software, every statement describes hardware that runs at the same time as all the others.

What does a Verilog module look like?

A module has a name, a port list and a body: module half_adder(input a, b, output s, c); assign s = a ^ b; assign c = a & b; endmodule. Wires connect things and are driven continuously; regs hold values assigned inside procedural blocks. Vectors give buses: wire [3:0] sum;.

What are dataflow, behavioural and structural descriptions?

Dataflow uses continuous assignments with operators: assign y = s ? b : a; is a 2:1 mux. Behavioural code describes what happens inside always blocks with if, case and loops, the natural way to write a 4:1 or 8:1 mux. Structural code wires up instances of other modules, like four full adders chained into a ripple-carry adder. Real designs mix all three.

How is a flip-flop or counter written in Verilog?

With an always block triggered by a clock edge and non-blocking assignments: always @(posedge clk) if (rst) q <= 0; else q <= q + 1; is a synchronous-reset counter, and the width of q decides its modulus. Non-blocking <= updates all registers together at the edge, exactly like real flip-flops; blocking = is for combinational logic. Mixing them up is the classic beginner bug that simulates one way and synthesises another.

Predict, then check

In an always @(posedge clk) block you write a <= b; b <= a;. What happens at each edge?

Worked examples

Ripple-carry adder, structurally · Build a 4-bit adder from a full_adder module
  1. full_adder(a, b, cin, s, cout): assign s = a ^ b ^ cin; and assign cout = (a & b) | (cin & (a ^ b));
  2. Declare wire [4:0] c; and assign c[0] = cin;
  3. Instantiate four full_adder copies, stage i using a[i], b[i], c[i] and driving s[i], c[i+1]
  4. assign cout = c[4];

Answer: Four instances chained by the carry wires: the same circuit as chapter 4, written as text

Keep going

Recommended reading

  • Digital Design, M. Morris Mano and Michael D. Ciletti
  • Fundamentals of Logic Design, Charles H. Roth Jr.
  • Digital Design: Principles and Practices, John F. Wakerly
  • Digital Fundamentals, Thomas L. Floyd
  • Modern Digital Electronics, R. P. Jain
  • Verilog HDL, Samir Palnitkar

How this book was made

Chapters follow the official syllabi listed above. Every interactive's formulas and every worked-example number were checked by script. Explanations, animations and examples are original to Skill-Lync. Topics informed by MIT OpenCourseWare 6.004 (Computation Structures), CC BY-NC-SA. All explanations, animations and examples are original to Skill-Lync; MIT does not endorse this page.

From the exam to a core job

Talk to a counsellor.

Ask how embedded and VLSI engineers use digital electronics on real projects, and what the Basics of Digital Electronics course covers.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.