Digital Logic Design & Basic Electronics
This guide is a complete, formula-and-example walkthrough of Digital Logic Design and Basic Electronics, built entirely around worked examples rather than code, taking you from raw voltage all the way up to how a CPU is structured. It opens with basic electronics fundamentals – voltage, current, resistance, Ohm’s Law, series and parallel circuits, Kirchhoff’s Laws, and the core components (resistors, capacitors, inductors, diodes, transistors, op-amps) that make digital switching physically possible. From there it covers number systems and codes, showing how to convert between binary, octal, decimal, and hexadecimal, along with two’s complement, binary addition, BCD, Gray code, and ASCII. It then moves into Boolean algebra and logic gates, covering the fundamental laws, De Morgan’s Theorem proved by truth table, all seven standard gates, SOP/POS forms, and Karnaugh Map simplification. The guide then builds up combinational logic circuits half and full adders, ripple carry adders, subtractors, multiplexers, demultiplexers, decoders, encoders, and comparators followed by sequential logic circuits, including SR latches, D/JK/T flip-flops, shift registers, ripple counters, registers, and finite state machines. It also explains memory and programmable logic (RAM, ROM, SRAM, DRAM, Flash, PLA, PAL, FPGA, CPLD), ADC/DAC and mixed-signal systems with quantization and reconstruction formulas, and the digital design flow using HDLs like Verilog and VHDL, from specification through synthesis to a working chip. It closes by tying everything together into real-world applications — microprocessors, embedded systems, communication buses, and computer architecture along with the career paths and learning roadmap built on these exact skills.

Introduction To Digital Logic & Electronics
- 1. Electrical Quantities and Fundamental Laws
- 2. Number Systems and Codes
- 3. Boolean Algebra and Logic Gates
- 4. Combinational Logic Circuits
- 5. Sequential Logic Circuits
- 6. Memory and Programmable Logic
- 7. ADC/DAC and Mixed‑Signal Systems
- 8. Digital Design Flow (HDL)
- 9. Applications and Career Paths
1. Electrical Quantities and Fundamental Laws
1.1 What Is Electronics ?
Electronics is the branch of engineering that deals with the controlled movement of electrons through materials to perform useful tasks. Think of it as a highly precise plumbing system, but instead of water, we control electric charges.
Every electronic device works because of the structure of atoms. Atoms are made of a nucleus (protons and neutrons) surrounded by orbiting electrons. In some materials, called conductors (e.g., copper, aluminium), the outermost electrons are loosely attached and can easily break free. These free electrons move randomly, but when an external force is applied, they drift in one direction – that drift is electric current.
Insulators (e.g., rubber, plastic) hold their electrons very tightly, so current cannot flow. Semiconductors (like silicon) sit in between: they can be modified to act as either conductors or insulators, which makes them perfect for building transistors – the switches that power all modern electronics.
- Analogy: Think of conductors like a crowded hallway where people (electrons) can move easily. Insulators are a solid wall; semiconductors are a door that can be opened or closed.
Analog vs. Digital Signals
An analog signal is continuous – like a dimmer switch that can be set to any brightness. In practice, noise and heat distort these exact values. A digital signal uses only two discrete levels (HIGH and LOW). By defining wide voltage margins for these states, digital circuits become highly noise‑resistant. This simplicity allows us to build reliable, scalable computers.
1.2 Voltage, Current, Resistance, Ohm’s Law, and Power
Voltage – The Electrical “Push”
Voltage is the driving force that moves electric charge through a conductor, representing the electrical energy difference between two points in a circuit. Measured in volts (V) , one volt is defined as the energy of one joule required to move one coulomb of electric charge between two points. A joule is a unit of energy that measures work done, while a coulomb is a unit of electric charge that counts approximately 6.24 × 10¹⁸ electrons. Therefore, voltage tells you how much energy each unit of charge carries – the higher the voltage, the more energy each electron possesses, enabling greater work to be performed in the circuit. This energy per unit charge creates the electrical pressure that pushes electrons through conductors, functioning similarly to how water pressure drives water through a pipe.
Current – The Flow of Electricity
Current is the rate of flow of electric charge through a conductor, representing the quantity of electrons passing a given point per second. Measured in amperes (A) , one ampere is defined as the flow of one coulomb of charge per second (1 A = 1 C/s). Since one coulomb equals approximately 6.24 × 10¹⁸ electrons, an ampere means that vast number of electrons streams past a point every single second. Current is the actual “flow” or “throughput” of electricity—like the volume of water rushing through a pipe, where gallons per minute represent the physical amount of water moving. Without current, voltage is just a static potential, like a pressurized pipe with no open faucet.
Resistance – The Opposition to Flow
Resistance is the measure of opposition to the flow of electric current in a material, arising from collisions between moving electrons and the vibrating atoms of the conductor. Measured in ohms (Ω) , one ohm is defined as the resistance that allows exactly one ampere of current to flow when exactly one volt of electrical pressure is applied (Ω = V/A). Think of it as the friction or narrowness in a pipe—the higher the resistance, the more energy is lost as heat for a given current. As temperature rises, atomic vibrations increase, which raises resistance. This property is intentionally used in resistors to limit current, divide voltages, and generate heat.
Power – The Rate of Doing Work
Power is the rate at which electrical energy is consumed or converted into another form of energy (heat, light, motion). Measured in watts (W) , one watt is defined as the rate of one joule of energy transferred per second (1 W = 1 J/s). In electrical circuits, power is the product of voltage and current (P = V × I). This means the higher the pressure (voltage) and the more the flow (current), the greater the work done per second. In a resistor, this electrical energy is turned entirely into heat, which is why components have power ratings—exceeding them causes overheating and failure.
Ohm’s Law – The Fundamental Relationship
Ohm’s Law states that the voltage across a resistor equals the current through it multiplied by its resistance:
V = I × R
This law is the cornerstone of electronics. It tells us that if you know any two of the three quantities, you can calculate the third. For example, to find current, rearrange to I = V/R; to find resistance, R = V/I. This relationship assumes the temperature remains constant and the resistor is linear (its value does not change with voltage). The microscopic form of Ohm’s Law is J = σE, where J is current density (current per unit area), σ is conductivity (the inverse of resistivity), and E is the electric field strength – showing that the law holds at the atomic level.
Example: LED Resistor Calculation
Problem: Power a red LED from a 12 V supply. The LED drops 2.0 V and needs 20 mA.
Step 1: Voltage across the resistor:
VR = 12 – 2.0 = 10.0 V
Step 2: Required resistance:
R = VR / I = 10.0 / 0.020 = 500 Ω
Step 3: Choose a standard 470 Ω resistor. Actual current:
I = 10.0 / 470 ≈ 0.02128 A (21.28 mA)
Step 4: Power dissipated:
P = I² × R = (0.02128)² × 470 ≈ 0.213 W
Step 5: Select a 0.5 W resistor for safety.
Why this matters: LEDs are current‑driven; the resistor sets a stable current regardless of small supply variations.
1.3 Series and Parallel Resistance
Series Connection – resistors are connected end‑to‑end, so the same current flows through each. The total resistance is the sum:
R_total = R1 + R2 + … + Rn
This is like adding more toll booths on a highway – each adds opposition, increasing the total resistance. In a voltage divider, this configuration produces a fraction of the input voltage.
Parallel Connection – resistors are connected across the same two nodes, so each has the same voltage. The total resistance is given by:
1/R_total = 1/R1 + 1/R2 + … + 1/Rn
The equivalent resistance is always less than the smallest individual resistor. This is like adding more lanes to a highway – more paths reduce overall resistance. This configuration is used in current dividers and to reduce effective resistance in power applications.
Example: Series vs. Parallel
Given R1 = 100 Ω, R2 = 220 Ω, R3 = 330 Ω
Series:
R_total = 100 + 220 + 330 = 650 Ω
Interpretation: Current must pass through all three sequentially.
Parallel:
1/R_total = 1/100 + 1/220 + 1/330 = 0.01758 → R_total ≈ 56.9 Ω
Interpretation: Current splits among three paths, so the total resistance is lower than any single resistor.
1.4 Kirchhoff’s Laws
Kirchhoff’s laws describe how voltages and currents behave in entire circuits.
Kirchhoff’s Current Law (KCL)
The total current entering a junction (node) equals the total current leaving it. This is based on charge conservation – charge cannot accumulate at a node. If more current entered than left, charge would pile up infinitely, which is physically impossible. Therefore, the algebraic sum of currents at any node is always zero.
Σ I_in = Σ I_out
KCL is the foundation of nodal analysis, a systematic method for solving complex circuits by writing current equations at each node.
Kirchhoff’s Voltage Law (KVL)
The sum of all voltage drops around any closed loop equals the sum of voltage rises. This follows energy conservation – the work done by the source is completely consumed by the components in the loop. If you start at a point and travel around a circuit and return to the same point, the net change in voltage must be zero because the electric field is conservative (no energy is gained or lost overall).
Σ V_drops = Σ V_rises
KVL is the foundation of mesh analysis, a systematic method for solving circuits by writing voltage equations around each independent loop.
Example: KVL Verification
Using the 650 Ω series circuit with a 12 V source:
I = 12 / 650 = 0.01846 A
Voltage drops:
VR1 = 0.01846 × 100 = 1.846 V
VR2 = 0.01846 × 220 = 4.061 V
VR3 = 0.01846 × 330 = 6.092 V
Sum = 1.846 + 4.061 + 6.092 = 11.999 V ≈ 12 V → KVL verified.
1.5 Passive Components
Passive components do not amplify signals and do not require external power.
Resistors – Properties and Construction
Resistors oppose current and dissipate energy as heat. Their value (in ohms) depends on the material’s intrinsic property called resistivity (ρ) , the length (L) of the conductor, and its cross‑sectional area (A): R = ρL/A. A longer path increases resistance; a wider path decreases it. Resistors are manufactured from materials with specific resistivity, such as carbon composition (cheap, high noise), metal film (precise, low noise), or wire‑wound elements (high power). The temperature coefficient (α) describes how resistance changes with temperature: R(T) = R₀[1 + α(T – T₀)]. They are essential for current limiting, voltage division (creating reference voltages), biasing transistors, and impedance matching to maximize power transfer.
Capacitors – Properties and Types
Capacitors store electric charge on two conductive plates separated by an insulator (dielectric). The capacitance C (measured in farads, F) relates the stored charge to the voltage across it: Q = C × V. One farad is defined as the capacitance that stores one coulomb of charge when one volt is applied. A farad is a very large unit; practical capacitors are microfarads (µF, 10⁻⁶ F), nanofarads (nF, 10⁻⁹ F), or picofarads (pF, 10⁻¹² F). Capacitors block DC (after they fully charge) but pass AC – the higher the frequency, the lower their opposition (capacitive reactance Xc = 1/(2πfC)). They act like tiny, fast‑charging batteries, used extensively for filtering ripple in power supplies, coupling AC signals between amplifier stages, and timing circuits (where the time constant τ = R × C determines charging/discharging speed). Common types include electrolytic (high capacitance, polarized), ceramic (stable, non‑polarized), film (precision), and tantalum (high density, polarized).
Inductors – Properties and Types
Inductors store energy in a magnetic field when current flows through a coil of wire. Inductance L (measured in henries, H) is defined such that one henry induces one volt of electromotive force when the current changes at a rate of one ampere per second (1 H = 1 V·s/A). Inductors pass DC with very little resistance but oppose changes in AC – the higher the frequency, the greater their opposition (inductive reactance XL = 2πfL). They act like flywheels for electricity, resisting sudden changes in current, making them ideal for smoothing current ripples in power supplies and for building filters with capacitors. The time constant for current through an inductor with a resistor is τ = L/R. Types include air‑core (low inductance, high frequency), iron‑core (high inductance, low frequency), and ferrite‑core (high‑frequency power).
1.6 Active/Semiconductor Components
Active components can amplify or switch signals and require external power.
Diodes – Physics and Varieties
A diode allows current to flow in one direction (forward bias) and blocks it in the reverse direction. It is formed by joining P‑type and N‑type semiconductors, creating a depletion region. When forward‑biased (positive on anode), the barrier shrinks, and current flows. The forward voltage drop is about 0.7 V for silicon and 0.3 V for germanium – this is the energy “cost” to push electrons across the junction. In reverse bias, only a tiny leakage current flows until the breakdown voltage is reached. Common types include rectifier diodes (high current for AC‑to‑DC conversion), signal diodes (low current, high‑frequency), Zener diodes (operate in reverse breakdown for voltage regulation), LEDs (emit light via electroluminescence), Schottky diodes (very fast, low forward drop), and varactor diodes (capacitance varies with reverse voltage for tuning).
Transistors – BJT and MOSFET
Transistors are the building blocks of modern electronics. They act as switches or amplifiers:
- BJT (Bipolar Junction Transistor): Current‑controlled. A small base current (I_B) controls a much larger collector current (I_C), with I_C = β × I_B (where β is the current gain). It has three regions: Cutoff (off switch, no current), Active (amplifier, I_C = βI_B), and Saturation (on switch, I_C is maximum). Modes include common‑emitter (voltage gain), common‑base (current gain), and common‑collector (buffer).
- MOSFET (Metal‑Oxide‑Semiconductor Field‑Effect Transistor): Voltage‑controlled. The gate voltage controls the conductivity of a channel between source and drain. They have extremely high input impedance (so they draw almost no current from the driving circuit) and very low power consumption, making them the dominant choice for digital logic. They come in N‑channel and P‑channel, and in enhancement mode (normally off) or depletion mode (normally on).
Transistor switching is the physical basis of every logic gate – a gate is simply a handful of transistors wired so the output snaps cleanly HIGH or LOW. This binary action is what makes digital computing possible.
Operational Amplifiers (Op‑Amps)
Op‑amps are high‑gain differential amplifiers with two inputs (inverting and non‑inverting) and one output. Ideal op‑amps have infinite gain, infinite input impedance, zero output impedance, infinite bandwidth, and zero offset voltage. In practice, they approach these ideals closely. They are used in configurations like:
- Inverting amplifier: Vout = – (Rf/Rin) × Vin
- Non‑inverting amplifier: Vout = (1 + Rf/Rin) × Vin
- Voltage follower: Vout = Vin (acts as a buffer to drive heavy loads)
- Summing amplifier: Vout = –Rf × Σ(Vi/Ri)
- Differential amplifier: Vout = (V+ – V–) × (Rf/Rin)
- Comparator: Output saturates HIGH or LOW when comparing voltages (used in ADCs and zero‑crossing detectors).
1.7 AC vs. DC – Detailed Parameters
Direct Current (DC) flows in one constant direction with a constant magnitude. It comes from batteries, solar cells, and regulated power supplies. Digital circuits use DC because logic levels need stable references (e.g., 0 V = LOW, 5 V = HIGH).
Alternating Current (AC) periodically reverses direction, typically as a sine wave. It is described by:
- Frequency (f) – measured in hertz (Hz) , where 1 Hz equals one complete cycle per second. Power grids use 50 or 60 Hz; audio signals range from 20 Hz to 20 kHz.
- Period (T) – time for one cycle, T = 1/f.
- Peak voltage (Vp) – maximum value.
- Peak‑to‑peak voltage (Vpp) – twice the peak value.
- RMS voltage (Vrms) – equivalent DC value that produces the same heating; for a sine wave, Vrms = Vp/√2.
- Phase (φ) – the relative timing between two waveforms, measured in degrees or radians.
In AC circuits, the opposition to current is impedance (Z) , which combines resistance (R) and frequency‑dependent reactance (X) from capacitors and inductors: Z = √(R² + X²) . Power in AC circuits is divided into real power (P) (consumed), reactive power (Q) (stored and returned), and apparent power (S) (total). The power factor (PF = P/S) indicates how efficiently power is used.
2. Number Systems and Codes
2.1 Why Binary?
Circuits can reliably distinguish two states (ON/OFF) much more easily than ten levels. Binary (base‑2) uses only digits 0 and 1. This simplicity provides:
- Noise immunity – wide voltage margins.
- Hardware simplicity – simple switches (transistors).
- Reliability – unambiguous states.
- Mathematical fit – Boolean algebra.
Bit – The Fundamental Unit of Information
A bit (binary digit) is the most basic unit of information in computing and digital communications, physically implemented as voltage levels (e.g., 0 V for 0, 5 V for 1), magnetic orientations (north/south on a disk), or optical states (on/off light). It can hold only one of two values: 0 or 1.
Data Organization:
- Nibble: 4 bits – represents values from 0 to 15 in decimal (0 to F in hexadecimal). It is commonly used in hexadecimal notation.
- Byte: 8 bits – represents values from 0 to 255 in decimal (0 to FF in hex). The byte is the standard unit for memory addressing and character storage (e.g., ASCII characters).
- Word: Typically 16, 32, or 64 bits – the natural data unit for a given processor architecture. A 32‑bit word can hold values from 0 to 4,294,967,295.
🔧 Real‑World Example: This very text you are reading is stored in your computer’s memory as millions of bits, organized into bytes (each character is one byte in ASCII or multiple bytes in Unicode). Every image, video, and program is ultimately a sequence of bits interpreted by the hardware according to defined rules.
2.2 The General Positional Formula
Any number system follows the rule that the value of a digit depends on its position:
Value = Σ (digit_i × baseⁱ)
For binary (base 2), octal (8), decimal (10), and hexadecimal (16), the same formula applies.
Example: Binary to Decimal
Convert 10011100₂ to decimal:
1×2⁷ + 0×2⁶ + 0×2⁵ + 1×2⁴ + 1×2³ + 1×2² + 0×2¹ + 0×2⁰ = 128 + 16 + 8 + 4 = 156₁₀.
Example: Decimal to Binary (Division‑Remainder)
156 ÷ 2 = 78 r0, 78÷2=39 r0, 39÷2=19 r1, 19÷2=9 r1, 9÷2=4 r1, 4÷2=2 r0, 2÷2=1 r0, 1÷2=0 r1 → read upwards: 10011100₂.
2.3 Octal and Hexadecimal – Shorthand Systems
Because 2³ = 8 and 2⁴ = 16, we can group binary digits into threes (octal) or fours (hexadecimal) for compact representation.
- Octal: group in threes from the right – e.g., 10011100₂ = 010 011 100 = 234₈. Each octal digit directly maps to three binary bits. Used in older systems and Unix file permissions.
- Hexadecimal: group in fours from the right – e.g., 1001 1100 = 9C₁₆. Each hex digit maps to four binary bits (a nibble). Hex is universally used in programming, debuggers, memory dumps, and color codes (e.g., #FF0000 for red).
These are just different labels for the same value (156₁₀). Hex is preferred in modern computing because it aligns perfectly with 8‑bit bytes (two hex digits per byte).
2.4 Signed Numbers – Two’s Complement
Two’s complement is the standard way to represent negative binary numbers. The most significant bit (MSB) is the sign bit: 0 for positive, 1 for negative. For an n‑bit number, the range is –2^(n‑1) to +2^(n‑1)–1.
To negate a number: invert all bits (one’s complement) and add 1. This works because adding a number to its complement yields 2^n, which is ignored in n‑bit arithmetic (modulo 2^n). This unified representation means addition and subtraction hardware are identical, simplifying ALU design. Sign extension replicates the sign bit when expanding to more bits (e.g., 4‑bit -3 = 1101 becomes 8‑bit 11111101).
Example: –25 in 8‑bit two’s complement
+25 = 00011001₂ → invert → 11100110₂ → add 1 → 11100111₂. This represents –25. Verification: –128 + 64 + 32 + 4 + 2 + 1 = –25.
2.5 Binary Addition and Subtraction
Binary addition follows the same principles as decimal but with carries in base‑2. The addition rules are: 0+0=0 (carry 0), 0+1=1 (carry 0), 1+0=1 (carry 0), 1+1=0 (carry 1), and 1+1+1(carry)=1 (carry 1). Carries propagate from the least significant bit (LSB) to the MSB – this propagation delay is the basis of the ripple carry adder.
Subtraction is performed by adding the two’s complement of the subtrahend (A – B = A + (–B)). This eliminates the need for separate subtraction hardware.
Overflow occurs when the result of adding two numbers with the same sign gives the opposite sign – it indicates that the result cannot fit in the available bits. Detection is simple: overflow happens when the carry into the MSB differs from the carry out of the MSB. This is critical for programmers and engineers to detect errors.
Example: Binary Addition
Add 23 (00010111₂) and 9 (00001001₂). Bit‑by‑bit: LSB: 1+1=0 carry1; bit1: 1+0+1=0 carry1; bit2: 1+0+1=0 carry1; bit3: 0+1+1=0 carry1; bit4: 1+0+1=0 carry1; bit5: 0+0+1=1 carry0; bits6‑7 are 0. Result = 00100000₂ = 32₁₀.
Example: Binary Subtraction
25 – 9 = 25 + (–9). –9 in two’s complement = 11110111₂. Add 00011001₂ + 11110111₂ = 100010000₂ → discard overflow → 00010000₂ = 16₁₀.
2.6 BCD (Binary Coded Decimal)
BCD encodes each decimal digit in 4 bits, using only codes 0000 through 1001 (0–9). Codes 1010–1111 (A–F) are illegal. For example, 259₁₀ = 0010 0101 1001₂ (BCD). It is used in applications that need exact decimal representation (financial systems, digital clocks) because there is no rounding error when converting to and from decimal. However, it is less efficient than pure binary (12 bits vs 9 bits for 259) and requires correction logic in arithmetic operations: if a BCD sum exceeds 9 or generates a carry, you must add 6 (0110) to correct it.
2.7 Gray Code
Gray code ensures that consecutive values differ by only one bit. This is useful in rotary encoders (shaft position sensors) and error‑sensitive applications because it avoids ambiguous transitions when multiple bits would otherwise change simultaneously, which could cause false readings. The code is also used in Karnaugh maps to ensure adjacent cells differ by one variable. Conversion: G = B XOR (B >> 1). For example, 1011₂ → 1110₂ (Gray). To convert back: B = G XOR (G >> 1) XOR (G >> 2) XOR … .
2.8 ASCII
ASCII (American Standard Code for Information Interchange) assigns a 7‑bit code to characters, providing 128 codes. Printable characters range from 32 (space) to 126 (~). Control characters (0–31) are used for formatting (e.g., LF=10, CR=13). For example, ‘A’ = 65 = 01000001₂, ‘a’ = 97 (which is exactly 32 more than ‘A’), ‘0’ = 48. It is the foundation of text representation in computers, mapping keys to binary patterns that circuits can process, store, and transmit. Extended ASCII (8‑bit) added 128 more characters, but Unicode (UTF‑8, UTF‑16) is now the global standard, using multiple bytes to represent all world scripts.
3. Boolean Algebra and Logic Gates
3.1 Boolean Algebra Fundamentals
Boolean algebra uses variables that are either 0 (false) or 1 (true). The three basic operations are:
- AND (·) – true only if both are true.
- OR (+) – true if at least one is true.
- NOT (‾) – flips the value.
These operations obey laws (commutative, associative, distributive, De Morgan’s, etc.) that allow us to manipulate logical expressions. The duality principle states that every theorem has a dual obtained by interchanging AND with OR and 0 with 1.
De Morgan’s theorems are especially important:
- (A·B)’ = A’ + B’
- (A+B)’ = A’ · B’
They allow the conversion between NAND and NOR logic, giving designers flexibility in gate choice and enabling the use of universal gates.
3.2 Logic Gates – Complete Behaviour
Logic gates are the physical circuits that implement Boolean operations. The basic gates and their truth tables are:
| 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 |
- AND: Outputs 1 only when ALL inputs are 1. Acts like a series of switches – current flows only if every switch is closed.
- OR: Outputs 1 when AT LEAST one input is 1. Acts like parallel switches – current flows if any switch is closed.
- NOT: Inverts the input (0 becomes 1, 1 becomes 0).
- NAND: Opposite of AND. Outputs 0 only when all inputs are 1. It is a universal gate – any other gate can be built using just NANDs.
- NOR: Opposite of OR. Outputs 1 only when all inputs are 0. Also a universal gate.
- XOR: Outputs 1 when inputs differ. This is the heart of binary addition (sum = A XOR B) and parity generation.
- XNOR: Outputs 1 when inputs are equal. Used in comparators and parity checkers.
3.3 Sum of Products (SOP) and Karnaugh Maps
SOP expresses a function as OR of AND terms (minterms). One minterm exists for each row in the truth table where the output is 1. POS (Product of Sums) is the dual, using OR terms (maxterms) ANDed together for each row where output is 0.
Karnaugh maps (K‑maps) provide a visual way to simplify SOP expressions by grouping adjacent 1s in powers of 2 (1, 2, 4, 8). The map uses Gray code ordering so that adjacent cells differ by one variable, allowing elimination of that variable. Larger groups simplify more variables. Edges of the map wrap around.
Example: K‑Map Simplification
Simplify F = A’B’C + A’BC + ABC’ + ABC. Minterms: 1, 3, 6, 7. The K‑map groups (1,3) → A’C, (5,7) → AC, and cell 6 → AB’. Since A’C + AC = C, the simplified expression is F = C + AB.
4. Combinational Logic Circuits
Combinational circuits produce outputs solely from current inputs – no memory.
4.1 Adders
- Half Adder: Adds two bits → sum = A XOR B, carry = A AND B.
- Full Adder: Adds two bits plus carry‑in → sum = A XOR B XOR Cin, carry = (A·B) + Cin·(A XOR B). The alternative expression Cout = AB + ACin + BCin is also common.
- Ripple Carry Adder: Chains full adders to add multi‑bit numbers. The carry propagates through every stage, causing delay (critical path = n × t_pd). Faster designs use carry‑lookahead, which pre‑calculates carries in parallel using generate and propagate signals, reducing delay to O(log n).
Subtraction uses the same adder by taking the two’s complement of the subtrahend (invert and add 1 as the initial carry into the LSB). This unified design is why ALUs only implement addition and rely on two’s complement for subtraction.
4.2 Data Routing Circuits
- Multiplexer (MUX): Selects one of many inputs based on select lines. For a 2‑to‑1 MUX, F = S’D0 + SD1. For a 4‑to‑1 MUX, F = S1’S0’D0 + S1’S0D1 + S1S0’D2 + S1S0D3. Used for routing data, implementing logic functions, and parallel‑to‑serial conversion.
- Demultiplexer (DEMUX): Routes one input to one of many outputs. For 1‑to‑4 DEMUX, the selected output equals the input, all others are 0. Used for serial‑to‑parallel conversion and address decoding.
- Decoder: Converts an n‑bit binary code into 2ⁿ outputs, with exactly one output active at a time. For 2‑to‑4 decoder, outputs are O0=A’B’, O1=A’B, O2=AB’, O3=AB. Used for memory address decoding (selecting one chip from many).
- Priority Encoder: Outputs the binary code of the highest‑priority active input. If D7 has highest priority, then when D7=1, the output is 111 regardless of other inputs. Essential for interrupt handling (higher priority interrupts override lower ones).
- Magnitude Comparator: Compares two binary numbers and indicates A>B, A=B, or A<B. Algorithm: compare from MSB to LSB; the first inequality determines the result. Used in ALU condition checks and control logic.
5. Sequential Logic Circuits
Sequential circuits have memory – outputs depend on current inputs and previous state.
5.1 Latches and Flip‑Flops – Detailed Operation
- SR Latch: Basic memory element with Set and Reset inputs. It holds its state when both inputs are low. Invalid when both are high (outputs unpredictable). It is the building block of all memory but is asynchronous (no clock). The hold state (S=0, R=0) is the essence of memory – feedback keeps the state stable.
- D Flip‑Flop: A clocked memory element that captures the value present on its data input (D) at the exact instant of a clock edge (e.g., rising edge) and holds that value until the next active clock edge. It eliminates the invalid state of the SR latch. It is the fundamental building block for registers and shift registers. Setup time is the minimum time D must be stable before the clock edge; hold time is the minimum time D must remain stable after the clock edge. Violating these causes metastability (unreliable output).
- JK Flip‑Flop: Enhances the SR latch by eliminating the invalid state and adding a toggle function (J=K=1 flips the output). Used in counters and state machines. The characteristic table: J=0,K=0 → hold; J=0,K=1 → reset; J=1,K=0 → set; J=1,K=1 → toggle.
- T Flip‑Flop: A simplified JK with J and K tied together. T=1 toggles; T=0 holds. It is the core of ripple counters and frequency dividers (each toggle divides the clock frequency by 2).
5.2 Registers, Counters, and State Machines
- Shift Register: Shifts bits on each clock pulse. Types: SIPO (Serial In, Parallel Out – for receiving serial data like from a keyboard), PISO (Parallel In, Serial Out – for transmitting), SISO (Serial In, Serial Out – for delay lines), PIPO (Parallel In, Parallel Out – basic register). The shifting action allows conversion between serial and parallel data streams.
- Ripple Counter: Chains T flip‑flops to count binary; each stage divides clock by 2. The propagation delay ripples through the chain (hence the name). A 3‑bit counter counts 000 → 001 → … → 111 → 000. The program counter in a CPU works this way, incrementing on each clock cycle to fetch the next instruction. Limitations: propagation delay limits maximum clock frequency. Synchronous counters (all stages clocked together) avoid this.
- Register: A bank of D flip‑flops storing a multi‑bit word (e.g., 8, 16, 32 bits). They are the fastest storage in the memory hierarchy and are used as CPU general‑purpose registers, address registers, and status registers.
- Finite State Machine (FSM): Models sequential behaviour with states, inputs, outputs, and transition rules. A Mealy machine output depends on state and inputs (faster, but more complex); a Moore machine output depends only on state (simpler, but slower). FSMs are used in CPU control units (instruction decoders), protocol handlers (e.g., I2C, UART), and traffic light controllers. Design process: specification → state diagram → state assignment → transition/output tables → K‑map simplification → implementation.
6. Memory and Programmable Logic
6.1 Memory Devices – Types and Characteristics
Memory stores data. Hierarchy: registers (fastest, smallest) → cache (SRAM) → main memory (DRAM) → disk/SSD (slowest, largest).
- SRAM (Static RAM): No refresh needed, 6 transistors/bit, fast (~1‑10 ns access time), used in cache. Retains data as long as power is on. High cost per bit, low density.
- DRAM (Dynamic RAM): Dense, needs periodic refresh (reading and rewriting data every few milliseconds), 1 transistor + capacitor/bit, used in main memory (~50‑100 ns access time). The capacitor leaks charge over time, requiring refresh to maintain data integrity. Types: SDRAM (synchronous), DDR SDRAM (double data rate – transfers data on both clock edges).
- ROM (Read‑Only Memory): Non‑volatile, retains data without power. Variants: Mask ROM (factory‑programmed, permanent), PROM (one‑time programmable via blowing fuses), EPROM (erasable with UV light, requires a windowed package), EEPROM/Flash (electrically erasable, in‑circuit rewritable). Flash memory comes in NOR (byte‑addressable, fast read, used for code execution) and NAND (block‑addressable, high density, used for SSDs, USB drives, SD cards).
6.2 Programmable Logic – Evolution and Types
- PLA (Programmable Logic Array): Programmable AND and OR planes. Maximum flexibility (any SOP function can be implemented), but expensive and slower.
- PAL (Programmable Array Logic): Programmable AND plane, fixed OR plane. Cheaper and faster than PLA, widely used in simple glue logic.
- FPGA (Field‑Programmable Gate Array): Contains Configurable Logic Blocks (CLBs) with Look‑Up Tables (LUTs – small memories that implement any combinational function) and flip‑flops, a routing interconnect matrix, and I/O blocks. FPGAs are reprogrammable (SRAM‑based – lost on power‑down; or flash‑based – non‑volatile) and used for prototyping, hardware acceleration, networking, and AI. Design flow: RTL → simulation → synthesis → place & route → bitstream generation → programming.
7. ADC/DAC and Mixed‑Signal Systems
7.1 Why Conversion?
The physical world is analog (temperature, pressure, sound, light); digital systems are discrete (0s and 1s). ADCs convert analog signals to digital numbers for processing; DACs convert digital numbers back to analog signals for output (e.g., audio speakers, motor control, video displays).
7.2 ADC – Quantization and Conversion
Quantisation is the process of mapping a continuous analog voltage to a finite set of discrete levels. Resolution (N bits) gives 2^N levels. Step size = Vref / 2^N. Quantization error is ±½ step (the inherent rounding error when mapping continuous voltage to discrete levels). Sampling must obey the Nyquist rate (≥2× signal frequency) to avoid aliasing (false low‑frequency signals that appear when high frequencies are undersampled).
ADC Types:
- Flash ADC: Uses 2^N – 1 comparators in parallel. Extremely fast (nanoseconds), but low resolution (4‑8 bits) and high power.
- Successive Approximation ADC: Uses a binary search algorithm with a DAC and comparator. Medium speed (microseconds), medium resolution (8‑16 bits). Most common general‑purpose type.
- Sigma‑Delta ADC: Uses oversampling and noise shaping. Very high resolution (16‑24 bits), but slow (kilohertz). Used in audio and precision measurements.
- Dual‑Slope ADC: Integrates the input over time. Very high accuracy, but slow. Used in digital multimeters.
Example: 4‑bit ADC with Vref=5V
Step = 5/16 = 0.3125 V. For Vin=1.2 V, digital value = round(1.2/0.3125) = 4 (0100₂). The input range for code 4 is 3.5×0.3125 to 4.5×0.3125 = 1.09375 V to 1.40625 V.
7.3 DAC – Reconstruction and Conversion
DAC converts a digital code to an analog voltage. Output = digital value × step size. The R‑2R ladder is the most common type because it uses only two resistor values (R and 2R), enabling high precision and easy manufacturing. Settling time is the time required for the output to reach the final value within a given tolerance.
DAC Types:
- Binary‑weighted DAC: Uses resistors in powers of 2. Fast but requires precise values and is impractical for high resolutions.
- R‑2R Ladder DAC: Uses only two resistor values. Easier to manufacture accurately, most common.
- Sigma‑Delta DAC: Uses oversampling and noise shaping for high resolution (audio applications).
Example: 4‑bit DAC with Vref=5V
Step = 0.3125 V. Code 0111₂ (7) gives Vout = 7 × 0.3125 = 2.1875 V. Code 1111₂ (15) gives Vout = 15 × 0.3125 = 4.6875 V (one step below Vref).
8. Digital Design Flow (HDL)
Hardware Description Languages (Verilog, VHDL) describe circuits textually. The design flow:
- Specification – define requirements (functional, performance, interface, verification, compliance).
- RTL Design – write code describing registers and combinational logic at the Register Transfer Level. E.g.,
always @(posedge clk) q <= d; - Simulation & Verification – test functionality using testbenches; run behavioural, RTL, gate‑level, and timing simulations. Techniques include directed testing, random testing, formal verification (mathematical proof), and coverage analysis.
- Synthesis – convert RTL to gate‑level netlist mapped to a specific technology library. The tool optimizes for speed, area, or power.
- Place & Route – map to physical FPGA or silicon (floorplanning, cell placement, clock tree synthesis, routing, design rule checking).
- Programming/Fabrication – for FPGA: generate bitstream and download; for ASIC: generate masks and send to foundry for manufacturing.
9. Applications and Career Paths
Digital electronics appears in:
- Microprocessors – CPU, ALU, control unit (FSM), cache (SRAM), registers.
- Embedded Systems – microcontrollers combining CPU, memory, ADC/DAC, and peripherals for automotive (engine control), medical (patient monitors), consumer (smartphones), and IoT (sensors).
- Communication – UART, SPI, I2C, USB, Ethernet (encoders, decoders, shift registers, CRC generators).
- FPGAs & ASICs – networking (routers, switches), AI acceleration (neural network inference), cryptography, video processing (encoding/decoding).
Career Paths: Digital Design Engineer (RTL and architecture), Verification Engineer (testbenches, formal methods), Embedded Engineer (software/hardware co‑design), FPGA Engineer (performance optimization, acceleration), Hardware Engineer (PCB design, signal integrity). Essential skills: HDL (Verilog/VHDL), simulation/synthesis tools, logic analyzers, oscilloscopes, computer architecture, and a solid grasp of the fundamental concepts covered in this guide.