Digital Logic β BIT Exam
2083 BS β’ Complete Study Guide β’ English
Number Systems
The foundation of Digital Logic β understanding Binary, Octal, Decimal, and Hexadecimal number systems, their conversions, and arithmetic operations.
Number System Bases
| System | Base | Digits Used | Example |
|---|---|---|---|
| Binary | 2 | 0, 1 | (1010)β = 10 |
| Octal | 8 | 0β7 | (12)β = 10 |
| Decimal | 10 | 0β9 | (10)ββ = 10 |
| Hexadecimal | 16 | 0β9, AβF | (A)ββ = 10 |
Decimal to Binary Conversion
Repeatedly divide by 2 and collect remainders from bottom to top (LSB first).
25 Γ· 2 = 12 remainder 1 β LSB (Least Significant Bit β rightmost) 12 Γ· 2 = 6 remainder 0 6 Γ· 2 = 3 remainder 0 3 Γ· 2 = 1 remainder 1 1 Γ· 2 = 0 remainder 1 β MSB (Most Significant Bit β leftmost) // Read remainders from BOTTOM to TOP: (25)ββ = (11001)β // Verify: 1Γ16 + 1Γ8 + 0Γ4 + 0Γ2 + 1Γ1 = 16+8+1 = 25 β
Binary to Decimal Conversion
Multiply each bit by its positional power of 2, then sum all values.
Position: 3 2 1 0 β position number (right = 0)
Bit: 1 1 0 1
= 1Γ2Β³ + 1Γ2Β² + 0Γ2ΒΉ + 1Γ2β°
= 1Γ8 + 1Γ4 + 0Γ2 + 1Γ1
= 8 + 4 + 0 + 1
= 13
(1101)β = (13)ββ
π Quick Reference: Powers of 2 & Hex Table
| 2βΏ | Value | Hex Digit | Decimal | Binary |
|---|---|---|---|---|
| 2β° = 1 | 1 | A | 10 | 1010 |
| 2ΒΉ = 2 | 2 | B | 11 | 1011 |
| 2Β² = 4 | 4 | C | 12 | 1100 |
| 2Β³ = 8 | 8 | D | 13 | 1101 |
| 2β΄ = 16 | 16 | E | 14 | 1110 |
| 2β΅ = 32 | 32 | F | 15 | 1111 |
| 2βΆ = 64 | 64 | β | β | β |
| 2β· = 128 | 128 | β | β | β |
1's and 2's Complement
Complement notation is used to represent negative numbers and to perform binary subtraction.
// 1's Complement: Flip every bit (0β1, 1β0) (1010)β β (0101)β β 1's Complement // 2's Complement: 1's Complement + 1 0101 + 1 ββββββ 0110 β 2's Complement of (1010)β // Binary Subtraction using 2's Complement: // A - B = A + (2's complement of B) Example: 8 - 3 = ? 8 = 1000 3 = 0011 β 1's comp = 1100 β 2's comp = 1101 1000 + 1101 = 10101 β drop carry β 0101 = 5 β
Example: 1 0 1 0 β Copy "10" from right β flip rest β 0 1 1 0
Octal & Hexadecimal Conversions
// Binary β Octal: Group bits in sets of 3 from right (101 110 011)β = (5 6 3)β = (563)β // Binary β Hex: Group bits in sets of 4 from right (1010 1111 0011)β = (A F 3)ββ = (AF3)ββ // Decimal to Hex: Divide by 16 255 Γ· 16 = 15 r 15 (F) 15 Γ· 16 = 0 r 15 (F) β (255)ββ = (FF)ββ
Codes β BCD, Gray, ASCII
Different coding techniques used in digital systems to represent data in a way that minimizes errors, simplifies arithmetic, or enables communication.
BCD (Binary Coded Decimal)
In BCD, each individual decimal digit is represented separately using 4 binary bits. It is different from pure binary β (12)ββ in BCD is 0001 0010, NOT (1100)β.
| Decimal | BCD | Decimal | BCD |
|---|---|---|---|
| 0 | 0000 | 5 | 0101 |
| 1 | 0001 | 6 | 0110 |
| 2 | 0010 | 7 | 0111 |
| 3 | 0011 | 8 | 1000 |
| 4 | 0100 | 9 | 1001 |
// (39)ββ in BCD: encode each digit separately 3 β 0011, 9 β 1001 BCD = 0011 1001 // BCD Addition Rule: If sum of a digit group > 9, add 0110 (6) 0111 (7) + 0110 (6) ββββββ 1101 β 13 in binary, but 13 > 9 in BCD context! + 0110 β Add 6 correction factor ββββββ 1 0011 β 1 (carry) | 0011 (3) β BCD of 13 β
Gray Code
Gray Code is a binary numbering system where adjacent values differ by exactly only one bit. This property minimizes switching errors in mechanical and digital systems.
| Decimal | Binary | Gray Code | Bit Changed |
|---|---|---|---|
| 0 | 000 | 000 | β |
| 1 | 001 | 001 | LSB |
| 2 | 010 | 011 | Bit 1 |
| 3 | 011 | 010 | LSB |
| 4 | 100 | 110 | MSB |
| 5 | 101 | 111 | LSB |
| 6 | 110 | 101 | Bit 1 |
| 7 | 111 | 100 | LSB |
// Rule: MSB stays the same. Each subsequent bit = XOR of adjacent binary bits Binary: 1 0 1 1 β β β β MSB: 1 β copy as is 1 XOR 0: 1 0 XOR 1: 1 1 XOR 1: 0 Gray Code: 1 1 1 0 // Gray to Binary (reverse): MSB same, each bit = XOR with previous gray bit Gray: 1 1 1 0 Binary: 1 1 XOR 1 = 0 0 XOR 1 = 1 1 XOR 0 = 1 Binary: 1 0 1 1 β back to original β
ASCII Code
- ASCII = American Standard Code for Information Interchange
- Uses 7 bits β can represent 128 characters (0 to 127)
- Extended ASCII uses 8 bits β 256 characters
- Covers: uppercase letters, lowercase letters, digits, special characters, control codes
| Character | ASCII (Decimal) | ASCII (Hex) | ASCII (Binary) |
|---|---|---|---|
| 'A' | 65 | 41 | 1000001 |
| 'Z' | 90 | 5A | 1011010 |
| 'a' | 97 | 61 | 1100001 |
| 'z' | 122 | 7A | 1111010 |
| '0' | 48 | 30 | 0110000 |
| '9' | 57 | 39 | 0111001 |
| Space | 32 | 20 | 0100000 |
Logic Gates
Logic gates are the fundamental building blocks of digital circuits. They take binary inputs and produce a binary output based on a specific logical function. All digital systems β from simple calculators to modern CPUs β are built from combinations of these gates.
π© Basic Gates β AND, OR, NOT
| A | B | AND (AΒ·B) | OR (A+B) | NOT (Δ) |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 |
OR = "Any one is enough" β output is 1 when AT LEAST ONE input is 1
NOT = "Invert everything" β flips 0 to 1 and 1 to 0 (single input only)
Universal Gates β NAND and NOR
| A | B | NAND | NOR | XOR (β) | XNOR |
|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 0 | 1 |
| 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 | 0 | 1 |
XOR rule: Output is 1 when inputs are DIFFERENT (odd number of 1s)
XNOR rule: Output is 1 when inputs are SAME (even number of 1s, including zero)
π οΈ Implementing Other Gates Using NAND
// NOT using NAND: connect both inputs together NOT(A) = NAND(A, A) // Single NAND gate, both inputs = A // AND using NAND: NAND then NOT the result AND(A,B) = NAND[NAND(A,B), NAND(A,B)] // 2 NAND gates // OR using NAND: invert both inputs then NAND OR(A,B) = NAND[NAND(A,A), NAND(B,B)] // 3 NAND gates // NOR using NAND: build OR then invert NOR(A,B) = NAND[OR(A,B), OR(A,B)] // 4 NAND gates total // Same logic applies for NOR as Universal Gate: NOT(A) = NOR(A, A) OR(A,B) = NOR[NOR(A,B), NOR(A,B)] AND(A,B) = NOR[NOR(A,A), NOR(B,B)]
Boolean Algebra
Boolean Algebra is the mathematical framework for working with logical expressions. It provides rules and laws to simplify complex logic circuits, reducing the number of gates needed and lowering cost and power consumption.
π Boolean Laws (Complete Reference)
| Law Name | AND Form | OR Form |
|---|---|---|
| Identity Law | A Β· 1 = A | A + 0 = A |
| Null / Dominance Law | A Β· 0 = 0 | A + 1 = 1 |
| Idempotent Law | A Β· A = A | A + A = A |
| Complement Law | A Β· Δ = 0 | A + Δ = 1 |
| Double Complement | ΔΜ = A (NOT of NOT = original) | |
| Commutative Law | AΒ·B = BΒ·A | A+B = B+A |
| Associative Law | (AΒ·B)Β·C = AΒ·(BΒ·C) | (A+B)+C = A+(B+C) |
| Distributive Law | AΒ·(B+C) = AΒ·B + AΒ·C | A+(BΒ·C) = (A+B)Β·(A+C) |
| Absorption Law | AΒ·(A+B) = A | A + AΒ·B = A |
| Consensus Theorem | AΒ·B + ΔΒ·C + BΒ·C = AΒ·B + ΔΒ·C | |
βοΈ De Morgan's Theorem
De Morgan's theorems are the most important tool for simplifying logic expressions, especially when converting between NAND/NOR implementations.
// First Theorem: "Break the bar, change the operator" Μ(AΒ·B) = Δ + BΜ // NOT(AND) = OR of NOTs β NAND = NOT-AND // Second Theorem: Μ(A+B) = Δ Β· BΜ // NOT(OR) = AND of NOTs β NOR = NOT-OR // Extended De Morgan: works for any number of variables Μ(AΒ·BΒ·C) = Δ + BΜ + CΜ Μ(A+B+C) = Δ Β· BΜ Β· CΜ // Simplification Example: F = Μ(AΒ·B) + Μ(A+C) = (Δ+BΜ) + (ΔΒ·CΜ) β apply De Morgan to each term = Δ + BΜ + ΔΒ·CΜ β expand = Δ(1+CΜ) + BΜ β factor out Δ = ΔΒ·1 + BΜ β (1+CΜ) = 1 by Null Law = Δ + BΜ β final simplified form
"Break the bar β change the operation β complement all variables"
SOP and POS Forms
// SOP (Sum of Products) = Minterm form // Take rows where output F = 1, AND the variables, then OR all terms // If variable = 1 in that row β use A, if 0 β use Δ // Truth Table: F = Ξ£m(1,2,3) [minterms where F=1] Row: A B | F 0 0 | 0 0 1 | 1 β ΔΒ·B 1 0 | 1 β AΒ·BΜ 1 1 | 1 β AΒ·B F (SOP) = ΔΒ·B + AΒ·BΜ + AΒ·B // POS (Product of Sums) = Maxterm form // Take rows where output F = 0, OR the variables, then AND all terms // If variable = 0 in that row β use A, if 1 β use Δ Row: 0 0 β (A+B) β complement of 0,0 F (POS) = (A+B)
Karnaugh Map (K-Map)
The K-Map is a visual method for minimizing Boolean expressions without using algebraic manipulation. It is the most exam-heavy topic in Digital Logic β expect at least one question on it every year.
K-Map Rules
- Group only 1s together (for SOP minimization)
- Group sizes must be powers of 2 only: 1, 2, 4, 8, 16
- Make groups as large as possible β larger groups eliminate more variables
- Groups can and should overlap β a cell can belong to multiple groups
- The map wraps around β left/right edges connect, top/bottom edges connect, and even corners connect
- Don't-care values (X or d) can be treated as 1 or 0, whichever makes the group larger
- Every 1 must be covered by at least one group β no 1 can be left uncovered
2-Variable K-Map
B=0 B=1
βββββββββββββ
A=0 | mβ | mβ |
A=1 | mβ | mβ |
// Example: F = Ξ£m(0,1,3) β F=1 at mβ, mβ, mβ
B=0 B=1
βββββββββββββ
A=0 | 1 | 1 | β Group 1: pair mβ,mβ (top row, B varies β Δ)
A=1 | 0 | 1 | β Group 2: pair mβ,mβ (right column, A varies β B)
Groups:
Group 1 (mβ,mβ): A=0 constant, B varies β term = Δ
Group 2 (mβ,mβ): B=1 constant, A varies β term = B
F = Δ + B
3-Variable K-Map
// 3-var: rows = C, columns = AB in Gray Code order AB=00 AB=01 AB=11 AB=10 ββββββββββββββββββββββββββ C=0 | mβ | mβ | mβ | mβ | C=1 | mβ | mβ | mβ | mβ | // Example: F = Ξ£m(0,1,2,3,4) AB=00 AB=01 AB=11 AB=10 C=0 | 1 | 1 | 0 | 1 | C=1 | 1 | 1 | 0 | 0 | // Group 1 (Octet impossible): mβ,mβ,mβ,mβ form a Quad β AB=00,01 both rows // A=0 constant β term = Δ // Group 2: mβ,mβ (first and last column) β wrap around! // C=0, B=0 constant β term = CΜΒ·BΜ F = Δ + BΜΒ·CΜ // Grouping elimination rule: // Pair (2 cells) β eliminates 1 variable // Quad (4 cells) β eliminates 2 variables // Octet (8 cells) β eliminates 3 variables
4-Variable K-Map Layout
// 4 variables A,B,C,D β rows = AB, columns = CD (Gray Code) CD=00 CD=01 CD=11 CD=10 βββββββββββββββββββββββββββββββββ AB=00 | mβ | mβ | mβ | mβ | AB=01 | mβ | mβ | mβ | mβ | AB=11 | mββ | mββ | mββ | mββ | AB=10 | mβ | mβ | mββ | mββ | // Corner grouping example: mβ,mβ,mβ,mββ form a Quad (four corners!) // B=0, D=0 constant β term = BΜΒ·DΜ
Combinational Circuits
In combinational circuits, the output depends only on the current input β there is no memory or feedback. The output changes immediately whenever the input changes. Key examples: adders, subtractors, multiplexers, decoders, and encoders.
Half Adder
Adds two single bits. Has two inputs (A, B) and two outputs (Sum and Carry). It CANNOT handle a carry input from a previous stage.
| A | B | Sum (S) | Carry (C) |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
Sum = A XOR B = A β B // Use XOR gate Carry = A AND B = A Β· B // Use AND gate // Hardware: 1 XOR gate + 1 AND gate = Half Adder // Limitation: No Carry-in input β cannot chain multiple stages
Full Adder
Adds three bits β two data bits (A, B) plus a Carry-In (Cin) from the previous stage. Used in multi-bit binary addition by chaining multiple Full Adders together (called a Ripple Carry Adder).
| A | B | Cin | Sum | Cout |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 |
Sum = A β B β Cin
Cout = AΒ·B + BΒ·Cin + AΒ·Cin
= AΒ·B + CinΒ·(AβB) // Simplified form
// Full Adder can be built from 2 Half Adders + 1 OR gate:
HA1: S1 = AβB, C1 = AΒ·B
HA2: Sum = S1βCin, C2 = S1Β·Cin
Cout = C1 + C2
Full Adder has 3 inputs (A, B, Cin) β handles carry from previous stage β used for all higher bit positions in multi-bit addition.
A 4-bit adder needs: 1 Half Adder (for bit 0) + 3 Full Adders (for bits 1, 2, 3).
Multiplexer (MUX)
A multiplexer selects one of many input signals and forwards it to the output, based on the selection lines. It is also called a "Data Selector."
- 2:1 MUX β 2 data inputs, 1 select line, 1 output
- 4:1 MUX β 4 data inputs, 2 select lines, 1 output
- 8:1 MUX β 8 data inputs, 3 select lines, 1 output
- General: 2βΏ data inputs require n selection lines
// 4:1 MUX with inputs Iβ,Iβ,Iβ,Iβ and select lines Sβ,Sβ Y = ΔͺβΒ·ΔͺβΒ·Iβ + ΔͺβΒ·SβΒ·Iβ + SβΒ·ΔͺβΒ·Iβ + SβΒ·SβΒ·Iβ // Selection truth table: Sβ Sβ | Output βββββββββββββββββ 0 0 | Iβ 0 1 | Iβ 1 0 | Iβ 1 1 | Iβ // MUX as Universal Function Generator: // Connect variables to select lines, 0/1 to data inputs // Any function of n variables can be realized with a 2βΏ:1 MUX
Decoder and Encoder
- Decoder (n:2βΏ): Takes n-bit input and activates exactly one of 2βΏ output lines. Example: 3:8 decoder has 3 inputs and 8 outputs, activating the output line corresponding to the binary value of the input.
- Encoder (2βΏ:n): The opposite of a decoder β converts one of 2βΏ active input lines to an n-bit binary code. Example: 8:3 encoder converts 8-line input to 3-bit binary output.
- Priority Encoder: When multiple inputs are active simultaneously, the encoder outputs the binary code of the highest-priority (usually highest-numbered) active input. Adds a V (valid) output to indicate at least one input is active.
- BCD to 7-Segment Decoder: Converts a 4-bit BCD digit (0β9) to the 7 signals needed to light up the correct segments on a 7-segment display.
Sequential Circuits
Unlike combinational circuits, sequential circuits have memory. The output depends not only on the current input but also on the previous state. They are the foundation of registers, counters, and all memory elements in computers.
Combinational vs Sequential β Key Differences
| Feature | Combinational | Sequential |
|---|---|---|
| Memory | No β stateless | Yes β stores state |
| Output depends on | Current inputs only | Current inputs + Previous state |
| Clock signal | Not required | Required (usually) |
| Feedback | No feedback paths | Output fed back to input |
| Examples | Adder, MUX, Decoder | Flip-Flop, Counter, Register |
| Analysis tool | Truth table | State diagram / State table |
Synchronous vs Asynchronous Sequential Circuits
- Synchronous: All flip-flops are triggered by the same clock signal edge. State changes happen only at the clock edge. Predictable, easy to design and analyze. Most modern digital systems are synchronous.
- Asynchronous: State changes happen immediately when inputs change β no clock needed. Faster response, but harder to design. Race conditions and hazards are common problems.
- Positive Edge Triggered: Circuit responds on the rising edge of the clock (0β1 transition)
- Negative Edge Triggered: Circuit responds on the falling edge of the clock (1β0 transition)
A Flip-Flop is edge-triggered β it only samples and stores data at the precise instant of a clock edge. This makes it much more reliable and predictable in synchronous systems. Most modern circuits use edge-triggered flip-flops.
State Diagrams and State Tables
Sequential circuits are analyzed using state diagrams (bubbles = states, arrows = transitions) and state tables (tabular form showing next state and output for each state/input combination).
// State table format: Present State | Input | Next State | Output Present State | Input X | Next State | Output Z βββββββββββββββββββββββββββββββββββββββββββββββββ S0 | 0 | S0 | 0 S0 | 1 | S1 | 0 S1 | 0 | S0 | 0 S1 | 1 | S2 | 1 S2 | 0 | S0 | 1 S2 | 1 | S2 | 1 // Mealy Machine: Output depends on state AND input // Moore Machine: Output depends ONLY on state (not input)
Flip-Flops
A flip-flop is the basic memory cell in digital circuits β it stores exactly one bit of information. Different types of flip-flops (SR, D, JK, T) offer different behavior and are used in different applications.
π§ SR Flip-Flop (Set-Reset)
The simplest flip-flop. S=Set forces output to 1, R=Reset forces output to 0. When S=R=0, the previous state is maintained (memory).
| S | R | Q (next) | QΜ (next) | Operation |
|---|---|---|---|---|
| 0 | 0 | Q | QΜ | No change β hold state |
| 0 | 1 | 0 | 1 | Reset β output becomes 0 |
| 1 | 0 | 1 | 0 | Set β output becomes 1 |
| 1 | 1 | ? | ? | FORBIDDEN β undefined! |
JK Flip-Flop
The most versatile flip-flop. It corrects the SR flip-flop's forbidden state problem by defining J=K=1 as a toggle operation (output flips to its complement).
| J | K | Q (next) | Operation |
|---|---|---|---|
| 0 | 0 | Q | No change β hold state |
| 0 | 1 | 0 | Reset β output becomes 0 |
| 1 | 0 | 1 | Set β output becomes 1 |
| 1 | 1 | QΜ | Toggle β output complements! β key advantage |
β Set J=K=T to get T Flip-Flop behavior (toggle)
β Set J=D, K=DΜ to get D Flip-Flop behavior (data latch)
β Set J=S, K=R to get SR Flip-Flop behavior (but J=K=1 is now valid toggle instead of forbidden)
The JK FF is the most commonly used flip-flop in practice.
D Flip-Flop (Data / Delay)
| D (input) | Q (next) | Operation |
|---|---|---|
| 0 | 0 | Stores 0 |
| 1 | 1 | Stores 1 |
Q(next) = D β Output simply follows the input D at clock edge // D FF eliminates the forbidden state by using D and DΜ directly // Built from SR FF: S = D, R = DΜ (they are always opposite) // Primary use: data registers, memory cells, pipeline registers // Also called "Delay FF" because output is delayed by one clock cycle
T Flip-Flop (Toggle)
| T (input) | Q (next) | Operation |
|---|---|---|
| 0 | Q | No change β hold state |
| 1 | QΜ | Toggle β output flips |
Q(next) = T β Q β XOR of T and current state // Built from JK FF: J = K = T // Primary use: counters, frequency dividers // When T=1 permanently, FF toggles every clock cycle // β output frequency = clock frequency / 2 (binary divide-by-2)
Flip-Flop Conversion Summary
| Convert FROM β TO | Required Logic |
|---|---|
| JK β D | J = D, K = DΜ (invert D for K) |
| JK β T | J = T, K = T (connect same signal to both) |
| JK β SR | J = S, K = R (direct mapping) |
| D β JK | D = JΒ·QΜ + KΜΒ·Q (use characteristic equation) |
| D β T | D = T β Q |
| D β SR | D = S + RΜΒ·Q (must ensure SΒ·R = 0) |
| T β D | T = D β Q |
| T β JK | T = JΒ·QΜ + KΒ·Q |
Registers & Counters
Registers and counters are practical sequential circuits built from flip-flops. Registers store and transfer multi-bit data; counters advance through a sequence of binary states with each clock pulse.
Shift Registers
A shift register is a chain of D flip-flops connected so that each clock pulse shifts data one position in the chain. They are used for serial-to-parallel conversion, data delay, and generating sequences.
| Type | Full Form | Description | Use Case |
|---|---|---|---|
| SISO | Serial In, Serial Out | Data enters one bit at a time, exits one bit at a time. Acts as a time delay element. | Time delay, pipeline |
| SIPO | Serial In, Parallel Out | Data enters serially, but all bits are available simultaneously at the output after n clocks. | Serial-to-parallel conversion (UART receiver) |
| PISO | Parallel In, Serial Out | All bits loaded simultaneously, then shifted out one-by-one serially. | Parallel-to-serial conversion (UART transmitter) |
| PIPO | Parallel In, Parallel Out | All bits loaded and available simultaneously. Acts as a simple data register. | CPU registers, data storage |
Counters β Types and Properties
| Counter Type | Key Property | Speed | Notes |
|---|---|---|---|
| Ripple (Asynchronous) | Flip-flops trigger each other in sequence | Slow β delay accumulates with each stage | Simple to build, but propagation delay increases with bit width |
| Synchronous | All FFs share the same clock β toggle simultaneously | Fast β no cumulative delay | More hardware needed (logic gates for each FF), but preferred in practice |
| Up Counter | Counts 0 β 1 β 2 β ... β Max β 0 | β | Normal counting direction |
| Down Counter | Counts Max β ... β 1 β 0 β Max | β | Decrements on each clock |
| Up-Down Counter | Counts either direction based on control | β | Has a direction control input |
| BCD Counter (Mod-10) | Cycles 0 β 9 β 0 β ... | β | Resets after reaching 9 (1001); counts 10 states |
| Ring Counter | Single 1 rotates through all FFs | β | Built from a shift register in a loop; self-decoding, n FFs = n states |
| Johnson (Twisted Ring) | Complement fed back; 2n states from n FFs | β | Better than ring counter β more states per FF |
// n-bit counter cycles through 2βΏ states 2-bit counter: Mod-4 β states: 00, 01, 10, 11 3-bit counter: Mod-8 β states: 000 to 111 4-bit counter: Mod-16 β states: 0000 to 1111 // To build a Mod-N counter where N is NOT a power of 2: // Use enough FFs for the next higher power of 2, then reset when count = N Mod-6 counter: use 3 FFs (Mod-8 base), reset at binary 6 (110) Mod-10 counter: use 4 FFs (Mod-16 base), reset at binary 10 (1010) // Ring Counter: n FFs β n states (0001, 0010, 0100, 1000 for 4-bit) // Johnson Counter: n FFs β 2n states
Memory
Memory stores binary data in digital systems. Understanding the different types, their properties (volatile vs non-volatile, read-write vs read-only), and how to calculate memory size is essential for both exams and real-world computing.
Memory Types β Complete Reference
| Type | Full Form | Volatile? | Writable? | Use |
|---|---|---|---|---|
| RAM | Random Access Memory | Yes β data lost on power off | Yes β freely | Main working memory (programs, data) |
| ROM | Read Only Memory | No β data permanent | No β factory programmed | BIOS, firmware, boot code |
| PROM | Programmable ROM | No | Once only β by user with a programmer | One-time field programming |
| EPROM | Erasable PROM | No | Yes β erase with UV light, then reprogram | Development and prototyping |
| EEPROM | Electrically Erasable PROM | No | Yes β erase and write electrically, byte by byte | Configuration storage, settings |
| Flash | Flash Memory | No | Yes β erase and write in sectors/blocks | USB drives, SSDs, SD cards |
SRAM vs DRAM β Critical Comparison
| Property | SRAM (Static RAM) | DRAM (Dynamic RAM) |
|---|---|---|
| Storage element | Flip-flop (6 transistors/cell) | Capacitor + transistor (1 transistor/cell) |
| Speed | Very fast (1β10 ns) | Slower (50β70 ns) |
| Cost | Very expensive | Cheap |
| Density | Low β large cells | High β tiny cells |
| Refresh needed? | No β holds state as long as powered | Yes β capacitors leak, must refresh every ~64ms |
| Power consumption | Higher (idle) | Lower, but extra for refresh |
| Typical use | CPU cache (L1, L2, L3) | Main memory (RAM sticks in PC) |
DRAM is slow but cheap and dense β used in large amounts as main memory.
Key fact: DRAM capacitors lose charge over time due to leakage, requiring periodic refresh circuits to recharge them β this is why DRAM is "dynamic." SRAM uses flip-flops which hold state indefinitely without refresh.
Memory Capacity Calculation
// Formula: Total capacity = 2^(address lines) Γ data width // Example 1: 12 address lines, 8 data lines Memory locations = 2ΒΉΒ² = 4096 = 4K locations Data width = 8 bits = 1 byte Total capacity = 4K Γ 8 bits = 4 KB // Example 2: How many address lines for 64KB memory with 8-bit data? 64KB = 64 Γ 1024 = 65536 locations = 2ΒΉβΆ Address lines needed = 16 // Example 3: 16 address lines, 16-bit data bus Locations = 2ΒΉβΆ = 64K = 65536 locations Word size = 16 bits = 2 bytes Total = 64K Γ 16 bits = 64K Γ 2 bytes = 128 KB // Standard prefixes: 1 KB = 2ΒΉβ° = 1024 bytes 1 MB = 2Β²β° = 1,048,576 bytes 1 GB = 2Β³β° = 1,073,741,824 bytes
Digital Logic Quiz π―
Test your exam preparation with these in-depth questions covering all 10 chapters!