UNIT 2: Digital Electronics Logic Design
I. Number Systems and Codes
Base Conversion Techniques
Core Principle: Positional number system. Value = Σ (digit × base^position).
Conversion Steps:
-
Integer Part: Repeated division by new base (remainders give digits, LSB first).
-
Fractional Part: Repeated multiplication by new base (integer parts give digits, MSB first).
-
Non-standard bases (e.g., base 6, 8): Same procedure, ensure digits < base.
| Conversion Type | Key Steps / Formula |
|---|---|
| Binary ↔ Octal | Group 3 bits (binary → octal), pad with leading/trailing zeros. |
| Binary ↔ Hex | Group 4 bits (binary → hex), pad with leading/trailing zeros. |
| Any Base → Decimal | $$\displaystyle (d_n...d_1d_0.d_{-1}...)_b = \sum_{i=0}^{n} d_i \times b^i + \sum_{j=1}^{m} d_{-j} \times b^{-j} $$ |
| Decimal → Any Base | Integer: ÷ base, collect remainders. Fraction: × base, collect integers. |
[!TIP] Exam Focus: Fractional conversions are very frequent. Practice (53.625)₁₀ → binary and (A69.8)₁₆ → decimal. For non-standard bases (like base 6), remember valid digits are 0-5.
Binary Coded Decimal (BCD)
-
Definition: 4-bit binary code representing each decimal digit separately (0000 to 1001). Invalid codes: 1010-1111.
-
Key Point: Not a pure binary number. (259)₁₀ in BCD is
0010 0101 1001, not100000011.
Gray Code
-
Definition: Only one bit changes between successive numbers. Cyclic property (last to first also 1-bit change).
-
Binary → Gray: $$\displaystyle G_i = B_i \oplus B_{i+1} $$ (MSB same: $$\displaystyle G_n = B_n $$).
-
Gray → Binary: $$\displaystyle B_n = G_n $$, $$\displaystyle B_{i-1} = B_i \oplus G_{i-1} $$ (work MSB to LSB).
[!TIP] Conversion Shortcut: For Gray→Binary, the first bit is same, subsequent bits are XOR of previous binary bit and current gray bit.
ASCII Code & Parity Error Detection
-
ASCII: 7-bit code (A=1000001, B=1000010). Often stored/transmitted as 8-bit byte (MSB=0 or parity bit).
-
Parity Bit: Extra bit for odd/even number of 1s in data byte.
-
Even Parity: Parity bit = 1 if data has odd 1s, else 0. Total 1s (data+parity) is even.
-
Odd Parity: Parity bit = 1 if data has even 1s, else 0. Total 1s is odd.
-
-
Error Detection: Receiver counts total 1s. If parity doesn't match expected (even/odd), single-bit error is detected. Cannot correct or detect even-numbered bit errors.
[!EXAMPLE] Letter 'B' in ASCII: 'B' = 1000010₂ (has 2 ones).
Even Parity: Data has even 1s → Parity bit = 0. Transmitted:
0 1000010.
Odd Parity: Data has even 1s → Parity bit = 1. Transmitted:
1 1000010.
II. Boolean Algebra and Minimization
Karnaugh Map (K-Map) Method
-
Purpose: Graphical minimization of SOP/POS.
-
Rules:
-
Group powers of 2 (1,2,4,8...). Groups must be rectangular.
-
Don't Cares (X): Use to enlarge groups if helpful; ignore if not.
-
Wrap-around: Top/Bottom, Left/Right edges are adjacent.
-
Minimize literals: Larger groups → fewer literals.
-
Essential Prime Implicant (EPI): Minterm covered by only one prime implicant. Must be in final expression.
-
| Output | SOP from K-Map | POS from K-Map |
|---|---|---|
| F=1 | Circle 1s → write product terms (0=variable, 1=variable') → SUM | Circle 0s → write sum terms (0=variable', 1=variable) → PRODUCT |
| F=0 | Circle 0s → write sum terms → PRODUCT | Circle 1s → write product terms → SUM |
[!TIP] Common Pitfall: Forgetting wrap-around or mis-grouping with don't cares. Always check for EPIs first.
Quine-McCluskey (Tabulation) Method
Algorithm for n>4 variables.
-
List Minterms: Group by number of 1s.
-
Combine: Compare adjacent groups (differs in 1 bit). Combine → mark with '-'. Repeat until no more combinations.
-
Prime Implicants (PIs): Uncombined terms + final combined terms.
-
Prime Implicant Chart:
-
Rows = PIs, Columns = Minterms.
-
Mark 'X' where PI covers minterm.
-
-
Essential Prime Implicants (EPIs): Column with only one X → corresponding PI is essential.
-
Minimal Cover: Select all EPIs. For remaining uncovered minterms, choose minimal set of remaining PIs (Petrick's method if needed).
[!FORMULA] Minimal Expression: Sum of all EPIs + minimal set of remaining PIs to cover leftover minterms.
De Morgan's Theorems
-
Two Variables: $$\displaystyle (A+B)' = A'B' $$, $$\displaystyle (AB)' = A' + B' $$
-
n Variables: $$\displaystyle \left( \sum_{i=1}^{n} x_i \right)' = \prod_{i=1}^{n} x_i' $$, $$\displaystyle \left( \prod_{i=1}^{n} x_i \right)' = \sum_{i=1}^{n} x_i' $$
-
Generalized: Complement of a function = Replace each variable with its complement, swap AND/OR, invert entire expression.
[!EXAMPLE] Complement $$\displaystyle F = a(b'c' + bc) $$:
Step 1: $$\displaystyle F' = [a(b'c' + bc)]' $$
Step 2: $$\displaystyle = a' + (b'c' + bc)' $$
Step 3: $$\displaystyle = a' + (b'c')' \cdot (bc)' $$
Step 4: $$\displaystyle = a' + (b + c) \cdot (b' + c') $$
III. Combinational Logic Design
Logic Gates & Universal Gates
-
NAND/NOR are Universal: Any function can be implemented using only NAND or only NOR.
-
Implementation Summary:
| Gate | NAND Implementation | NOR Implementation |
|---|---|---|
| NOT | $$\displaystyle A' = A \cdot A $$ | $$\displaystyle A' = A + A $$ |
| AND | $$\displaystyle AB = (AB)' ' = ((A \cdot B)')' $$ | $$\displaystyle AB = (A' + B')' $$ |
| OR | $$\displaystyle A+B = (A' \cdot B')' $$ | $$\displaystyle A+B = (A+B)' ' = ((A+B)')' $$ |
| XOR | $$\displaystyle A \oplus B = (AB' + A'B)'' = ((A \cdot B')' \cdot (A' \cdot B)')' $$ | Similar approach |
[!TIP] Implementation Rule: For NAND-only, convert expression to sum-of-products, then double invert each product term and final sum.
Adders and Subtractors
Half Adder (HA)
-
Function: Adds 2 bits (A, B). Outputs: Sum (S), Carry (Cout).
-
Truth Table:
| A | B | S | Cout | |---|---|---|------| | 0 | 0 | 0 | 0 | | 0 | 1 | 1 | 0 | | 1 | 0 | 1 | 0 | | 1 | 1 | 0 | 1 |
-
Equations: $$\displaystyle S = A \oplus B $$, $$\displaystyle C_{out} = AB $$
Full Adder (FA)
-
Function: Adds 3 bits (A, B, Cin). Outputs: S, Cout.
-
Equations: $$\displaystyle S = A \oplus B \oplus C_{in} $$, $$\displaystyle C_{out} = AB + BC_{in} + AC_{in} $$
-
Implementation: 2 HAs + OR gate.
Half Subtractor (HS)
-
Function: Subtracts B from A. Outputs: Difference (D), Borrow (Bout).
-
Equations: $$\displaystyle D = A \oplus B $$, $$\displaystyle B_{out} = A'B $$
Full Subtractor (FS)
- Equations: $$\displaystyle D = A \oplus B \oplus B_{in} $$, $$\displaystyle B_{out} = A'B + B_{in}(A \oplus B)' $$
BCD Adder
-
Purpose: Add two BCD digits (4-bit each). Output is valid BCD (0-9) or carry to next digit.
-
Logic: If sum > 9 or carry_out=1, add 0110 (6) to correct. Correction logic: $$\displaystyle Y = C_{out} + S_3S_2 + S_3S_1 $$.
Multiplexers (MUX)
-
Definition: $$\displaystyle 2^n : 1 $$ MUX has $ n $ select lines, $$\displaystyle 2^n $$ data inputs, 1 output. $$\displaystyle Y = \sum_{i=0}^{2^n-1} D_i \cdot m_i(S) $$.
-
Design using MUX: Implement any SOP function. Connect minterms to 1, others to 0 (or use enable). Select lines = function variables.
-
Example: $$\displaystyle F(A,B,C) = \Sigma m(0,2,5,6) $$ using 8:1 MUX. Connect D₀, D₂, D₅, D₆ = 1; others = 0. S₂=A, S₁=B, S₀=C.
Decoders
-
Definition: $$\displaystyle n : 2^n $$ decoder. $ n $ inputs, $$\displaystyle 2^n $$ outputs, one-hot (only one output = 0 or 1 active).
-
Binary to Gray Decoder: Gray code outputs = $$\displaystyle G_2 = B_2 $$, $$\displaystyle G_1 = B_2 \oplus B_1 $$, $$\displaystyle G_0 = B_1 \oplus B_0 $$.
-
3×8 Decoder: 3 inputs (A,B,C), 8 outputs (Y₀-Y₇). $$\displaystyle Y_i = m_i(A,B,C) $$. Can implement any 3-variable SOP by ORing relevant minterm outputs.
Encoders & Priority Encoder
-
Encoder: $$\displaystyle 2^n : n $$. Reverse of decoder. Assumes only one input is active.
-
Priority Encoder: Handles multiple active inputs. Outputs code of highest-priority (highest-numbered) active input. Includes Valid (V) output (0 if no input active) and sometimes Group Signal (GS).
Magnitude Comparators
-
2-bit Comparator: Inputs A₁A₀, B₁B₀. Outputs: A>B, A=B, A<B.
-
Equality: $$\displaystyle A=B = (A_1 \oplus B_1)' \cdot (A_0 \oplus B_0)' $$
-
A>B: $$\displaystyle A>B = A_1B_1' + (A_1 \oplus B_1)'A_0B_0' $$
-
A<B: $$\displaystyle A<B = A_1'B_1 + (A_1 \oplus B_1)'A_0'B_0 $$
Parity Generators & Checkers
-
Even Parity Generator: $$\displaystyle P_{even} = \bigoplus_{i=0}^{n-1} D_i $$ (XOR of all data bits).
-
Even Parity Checker: $$\displaystyle Check = P_{received} \oplus \bigoplus_{i=0}^{n-1} D_i $$. Output 0 = no error (even parity), 1 = error.
-
Odd Parity: Invert even parity output or generator output.
De-Multiplexers (DEMUX)
-
Definition: $$\displaystyle 1 : 2^n $$ DEMUX. 1 data input, $ n $ select lines, $$\displaystyle 2^n $$ outputs. Routes input to one selected output.
-
Implementation: $$\displaystyle 1:2^n $$ DEMUX = $ n $ enable lines of a $$\displaystyle (n+1):2^n $$ decoder. Connect data input to decoder enable.
IV. Sequential Logic Fundamentals
Latches vs. Flip-Flops
| Feature | Latch | Flip-Flop |
|---|---|---|
| Trigger | Level-sensitive (enabled by clock level). | Edge-sensitive (triggered on clock edge). |
| Behavior | Transparent when enabled. | Changes state only at clock edge. |
| Timing | Susceptible to glitches, race-through. | Synchronous, predictable. |
| Application | Temporary storage, asynchronous systems. | Synchronous sequential circuits (counters, registers). |
Flip-Flop Types & Characteristics
| FF | Truth Table (Qₙ₊₁) | Characteristic Equation | Key Feature |
|---|---|---|---|
| SR | S R Qₙ₊₁<br>0 0 Qₙ (Hold)<br>0 1 0 (Reset)<br>1 0 1 (Set)<br>1 1 Invalid | $$\displaystyle Q_{n+1} = S + R'Q_n $$ | Invalid state (S=R=1). |
| JK | J K Qₙ₊₁<br>0 0 Qₙ (Hold)<br>0 1 0 (Reset)<br>1 0 1 (Set)<br>1 1 Qₙ' (Toggle) | $$\displaystyle Q_{n+1} = JQ_n' + K'Q_n $$ | Toggle eliminates invalid state. |
| D | D Qₙ₊₁<br>0 0<br>1 1 | $$\displaystyle Q_{n+1} = D $$ | No state ambiguity. Single input. |
| T | T Qₙ₊₁<br>0 Qₙ (Hold)<br>1 Qₙ' (Toggle) | $$\displaystyle Q_{n+1} = T \oplus Q_n $$ | Toggle flip-flop. |
Master-Slave & Edge-Triggered
-
Master-Slave JK FF:
-
Master (positive level) active when CLK=1. Outputs change but isolated from slave.
-
Slave (negative level) active when CLK=0. Master's output transferred to slave's output.
-
Race-Around Condition: In basic JK FF (transparent when J=K=1), output may toggle multiple times in one clock pulse. Master-Slave prevents this by making output change only on clock edge (transition from 1→0).
-
-
Edge-Triggered: Responds only to clock transition (↑ or ↓). Uses master-slave or dedicated edge-trigger circuit.
Flip-Flop Conversions
General Method: Use excitation table of target FF (JK, D, T) and characteristic equation of given FF (SR) to derive required inputs.
[!EXAMPLE] SR → JK:
From JK FF excitation table, for given (Qₙ, Qₙ₊₁), find required (J,K).
From SR FF characteristic eq: $$\displaystyle Q_{n+1} = S + R'Q_n $$.
Equate and solve: $$\displaystyle S = JQ_n' $$, $$\displaystyle R = K'Q_n $$.
Circuit: Connect J to S input via AND (with Q_n'), K to R input via AND (with Q_n).
V. Sequential Circuit Design Methodology
State Machine Concepts
-
State Diagram: Circles = states, arrows = transitions (label:
inputs/outputs). -
State Table: Lists Present State (PS), Inputs (X), Next State (NS), Outputs (Z).
-
State Equation: Boolean equation for each flip-flop's next state in terms of PS and inputs. $$\displaystyle Q_{A+1} = f(A, B, X) $$.
-
State Assignment: Assign unique binary code to each state. Guidelines: Minimize logic, avoid adjacent states differing in many bits (for one-hot or Gray).
Excitation Tables & Equations
-
Purpose: Find required flip-flop inputs (J,K for JK; D for D; T for T) to cause transition from (Qₙ) to (Qₙ₊₁).
-
Procedure:
-
From state table, for each row, note (PS, NS).
-
Use excitation table of chosen FF to find (J,K) or (D) or (T) for that transition.
-
Create excitation equations by plotting these required inputs on K-maps (variables = PS bits + inputs).
-
Draw logic diagram from equations.
-
Design Procedure (Synchronous)
-
State Diagram/Table from problem statement.
-
State Assignment (binary, Gray, one-hot).
-
Choose FF type (JK/D/T common).
-
Construct Excitation Table: Merge state table with FF excitation table.
-
Simplify excitation equations (K-map/Quine-McCluskey).
-
Draw Logic Diagram: FF inputs from equations, outputs from state/output table.
-
Timing Diagram/Verification.
VI. Counters
Asynchronous (Ripple) vs Synchronous
| Feature | Asynchronous (Ripple) | Synchronous |
|---|---|---|
| Clock | FF0 external clock, others from previous FF's output. | All FFs clocked simultaneously by same clock. |
| Speed | Slow (ripple delay accumulates). | Fast (no ripple). |
| Glitches | Possible temporary invalid states. | No glitches (all change together). |
| Example | 4-bit binary up counter: T inputs of all FFs = 1. | 4-bit binary up counter: T₀=1, T₁=Q₀, T₂=Q₀Q₁, T₃=Q₀Q₁Q₂. |
4-bit Synchronous Up-Down Counter
-
Control (M): M=0 → Up, M=1 → Down.
-
JK FF Implementation:
-
Up: T inputs = $$\displaystyle T_0=1, T_1=Q_0, T_2=Q_0Q_1, T_3=Q_0Q_1Q_2 $$
-
Down: T inputs = $$\displaystyle T_0=1, T_1=Q_0', T_2=Q_0'Q_1', T_3=Q_0'Q_1'Q_2' $$
-
Combined: $$\displaystyle T_i = M' \cdot (Up\_eq) + M \cdot (Down\_eq) $$
-
Example T₁: $$\displaystyle T_1 = M'Q_0 + M Q_0' = M \oplus Q_0 $$
-
Design of Custom Sequence Counters (e.g., 0-1-2-4-5-6-0)
-
State Diagram: Draw states 0,1,2,4,5,6 in sequence, back to 0.
-
State Table: PS (3 FFs needed for 6 states), NS.
-
Excitation Equations: Use JK FFs. Derive J,K for each FF from state table.
-
Simplify using K-maps. May get don't cares for unused states (3,7).
-
Check self-starting: Ensure unused states eventually enter valid sequence.
Ring Counter & Johnson Counter
-
Ring Counter (n-bit): Shift register with Qₙ output fed to D₀ input. Single '1' circulates. Modulo-n. Self-decoding (only one high).
-
Johnson Counter (Twisted Ring): Complement of Qₙ fed to D₀. Sequence length = 2n. States: n zeros, n ones. Example 4-bit: 0000 → 1000 → 1100 → 1110 → 1111 → 0111 → 0011 → 0001 → back to 0000.
BCD Counter (Decade Counter)
-
Counts 0000 to 1001 (0-9). Resets to 0000 after 1001.
-
Synchronous Design: Use 4 JK FFs. Reset logic: $$\displaystyle Reset = Q_3 Q_1 $$ (when state=1010) or $$\displaystyle Q_3 Q_2 $$. Clear FFs on next clock.
Decoding in Counters
-
Purpose: Detect specific count state (e.g., for control signals, display).
-
Method: Use decoder or simple gates. For active-low decoder outputs, connect counter outputs to decoder inputs. Output goes low for that state.
-
Example: 1-of-10 decoder for BCD counter. Output Y₅ low when count=5 (0101).
VII. Shift Registers
Basic Configurations
| Type | Input | Output | Operation |
|---|---|---|---|
| SISO | Serial | Serial | Shift right/left one bit per clock. |
| SIPO | Serial | Parallel | Serial in, all bits available parallel after n clocks. |
| PISO | Parallel | Serial | Parallel load, then serial out (shift right/left). |
| PIPO | Parallel | Parallel | Parallel load, no shifting. |
4-bit Bidirectional Shift Register with Parallel Load
-
Control Lines:
S1 S0(Shift control: 00=hold, 01=shift right, 10=shift left, 11=parallel load),CLK,[D₃ D₂ D₁ D₀](parallel data). -
Operation:
-
Parallel Load (S1S0=11): $$\displaystyle Q_i = D_i $$ on clock edge.
-
Shift Right (01): $$\displaystyle Q_i = Q_{i+1} $$ (Q₃ gets serial input
SI). -
Shift Left (10): $$\displaystyle Q_i = Q_{i-1} $$ (Q₀ gets serial input
SI). -
Hold (00): $$\displaystyle Q_i = Q_i $$ (no change).
-
-
Implementation: 4 D-FFs with multiplexers at each D input. MUX selects between parallel data, shift direction (neighbor's Q), or hold (feedback Q).
Universal Shift Register
-
Definition: Supports all four operations (SISO, SIPO, PISO, PIPO) + hold.
-
Block Diagram: 4 D-FFs + 4 multiplexers (4:1 each) at D inputs. Select lines
S1 S0control MUX:-
00: Hold (feedback Q) -
01: Shift Right (Q₃→Q₂, Q₂→Q₁, Q₁→Q₀, Q₀→SI_out) -
10: Shift Left (Q₀→Q₁, Q₁→Q₂, Q₂→Q₃, Q₃→SI_out) -
11: Parallel Load (D₃→Q₃, etc.)
-
VIII. Memory and Programmable Logic Devices
Read-Only Memory (ROM)
-
Definition: Non-volatile, read-only after fabrication/programming. Stores fixed data/instructions.
-
Organization: $$\displaystyle 2^n $$ address lines → $$\displaystyle 2^n $$ words, each word $ m $ bits. Decoder + OR array.
-
Types:
-
PROM: Programmable once (fuse links).
-
EPROM: Erasable by UV light, reprogrammable.
-
EEPROM: Electrically erasable, byte-wise erase.
-
Flash: Fast erase/program, block-wise. Used in USB drives, SSDs.
-
Random-Access Memory (RAM)
-
Definition: Volatile, read/write. Any address accessible in equal time.
-
SRAM Cell: 6 transistors (6T) – bistable latch. Fast, used for cache.
-
Read Cycle:
-
Address applied.
-
CS(Chip Select) andRD(Read) active. -
Data appears on output after access time (t_ACC).
-
-
Write Cycle:
-
Address and data applied.
-
CSandWR(Write) active. -
Data stored after write time (t_WR).
WRmust be low for > t_WR.
-
Memory Decoding: Two-Dimensional Scheme
-
Problem: Large memory (e.g., 64K x 8) needs 16 address lines. Decoder with 64K outputs is huge.
-
Solution: Two-stage decoding.
-
Split address into row (A₀-A₇) and column (A₈-A₁₅).
-
Row Decoder: 8:256 decoder. Activates one of 256 row lines.
-
Column Decoder: 8:256 decoder. Activates one of 256 column lines.
-
Memory Array: 256 rows × 256 columns = 64K cells. Intersection of active row & column selects one byte.
-
-
Advantage: Reduces decoder size from 2^16 to 2×2^8.
Programmable Logic Array (PLA)
-
Structure: Programmable AND array → Programmable OR array.
-
Implementation: Both product terms (AND) and sum terms (OR) are programmable.
-
Flexibility: High. Can implement any SOP/POS. Product terms can be shared.
-
Example: Implement $$\displaystyle F_1 = \Sigma m(3,5,7) $$, $$\displaystyle F_2 = \Sigma m(4,5,7) $$.
-
AND array: Generate minterms 3,4,5,7 as needed.
-
OR array: F1 gets outputs of m3, m5, m7. F2 gets m4, m5, m7.
-
Programmable Array Logic (PAL)
-
Structure: Fixed OR array → Programmable AND array.
-
Implementation: Each output has a fixed number of product terms (e.g., 8) ORed together. Product terms are programmable.
-
Flexibility: Lower than PLA. Faster, cheaper. Output structure fixed (cannot share PTs between outputs easily).
-
Use Case: Simple functions with limited product terms per output.
Sequential PLDs & Basic Microcell
-
Sequential PLD: Includes flip-flops on outputs. Can implement both combinational and sequential logic.
-
Basic Microcell: One AND-OR logic cell + one flip-flop. Output of OR feeds D input of FF. FF output can be fed back to AND array for state machines.
Data Converters
Digital-to-Analog Converter (DAC): R-2R Ladder
-
Principle: Uses two resistors (R, 2R) in ladder network. Each digital bit controls a switch to Vref or GND.
-
Operation: Each bit position has Thevenin equivalent of $$\displaystyle V_{out} = -V_{ref} \times \frac{D_{n-1}}{2} + ... $$. For n-bit unsigned, $$\displaystyle V_{out} = -V_{ref} \times \frac{D_{binary}}{2^n} $$.
-
Advantages: Only 2 resistor values, excellent matching, monotonic.
Analog-to-Digital Converter (ADC): Successive Approximation
-
Components: Successive Approximation Register (SAR), DAC, Comparator, Control logic.
-
Procedure (n bits):
-
Start: SAR = 100...0 (MSB=1).
-
DAC converts SAR value to analog $$\displaystyle V_{DAC} $$.
-
Comparator: $$\displaystyle V_{in} $$ vs $$\displaystyle V_{DAC} $$.
-
If $$\displaystyle V_{in} \geq V_{DAC} $$, keep bit=1; else clear bit=0.
-
Shift left (next bit=1), repeat step 2-4 for n cycles.
-
-
Result: SAR holds digital approximation after n clock cycles.
-
Advantage: Fast (n cycles), moderate cost. Disadvantage: Sample-and-hold required for AC signals.
[!BOX] Key Formula: R-2R Ladder Output (n-bit, unsigned, Vref positive):
$$ V_{out} = -\frac{V_{ref}}{2^n} \left( D_{n-1} \cdot 2^{n-1} + D_{n-2} \cdot 2^{n-2} + ... + D_0 \cdot 2^0 \right) $$
Successive Approximation ADC Time: n clock periods for n-bit conversion.