Machine Instructions, Addressing Modes & Datapath
Addressing Modes, Effective Address & Expanding Opcodes
Open Full Lesson →Effective Address (EA) is the actual memory location accessed; always include instruction fetch memory cycle in total access count.
Must-Remember Principles:- —Immediate: EA = None; 0 operand memory references.
- —Direct: EA = Address field; 1 memory reference.
- —Indirect: EA = Memory[Address field]; 2 memory references.
- —Register Indirect: EA = [Register]; 1 memory reference.
- —Relative: EA = PC + Offset; position-independent conditional branches.
- —Indexed: EA = Base Address + Index Register; array traversal A[i].
- —Expanding Opcode: Unused prefixes at level k expand by 2^(freed_field_bits) at level k-1.
Critical Pitfalls & Exam Traps:- ×Never forget the memory access required to fetch the instruction code itself.
- ×PC-relative branch offsets are signed 2's complement numbers relative to the updated PC (pointing to the next instruction).
Machine Instructions, Addressing Modes & Datapath
Instruction Cycle State Machine & Datapath Timing Analysis
Open Full Lesson →Single-cycle clock period equals the sum of delays along the longest instruction path (LOAD); multi-cycle clock equals max stage delay.
Must-Remember Principles:- —Single-cycle clock = Sum of delays along the longest instruction path (LOAD).
- —Multi-cycle clock = Delay of the slowest individual functional stage.
- —Overflow Flag V: $V = C_{in} \oplus C_{out}$ at the most significant bit (MSB).
- —Carry Flag C: Unsigned arithmetic out-of-range indicator.
- —Sign Flag S: MSB of the result; indicates negative value in 2's complement.
Critical Pitfalls & Exam Traps:- ×Do not confuse Carry (unsigned overflow) with Overflow V (signed 2's complement overflow). An operation can produce Carry=1 with Overflow=0 (e.g., adding two large unsigned numbers that do not violate signed bounds).
Computer Arithmetic, IEEE 754 & Booth's Algorithm
IEEE 754 Floating Point & Booth's Algorithm
Open Full Lesson →IEEE 754 encodes (-1)^S * (1.M) * 2^(E-Bias) with Bias 127 (Single) and 1023 (Double); Booth shifts arithmetic right preserving MSB.
Must-Remember Principles:- —Single Precision: Bias = 127; E has 8 bits, M has 23 bits.
- —Double Precision: Bias = 1023; E has 11 bits, M has 52 bits.
- —Subnormal numbers: E = 0, M != 0; value = (-1)^S * (0.M) * 2^(-126).
- —Booth (Q_0, Q_-1): 10 -> Subtract & Shift; 01 -> Add & Shift; 00/11 -> Shift only.
- —ARS preserves MSB sign bit.
Critical Pitfalls & Exam Traps:- ×Never include the hidden 1 when writing the stored mantissa bits.
- ×For negative numbers in Booth's algorithm, always compute -M in two's complement before starting.
Computer Arithmetic, IEEE 754 & Booth's Algorithm
Restoring & Non-Restoring Division and Carry Lookahead Adders
Open Full Lesson →Non-restoring division eliminates the restore addition cycle by adding divisor when remainder is negative; CLA generates carries in 2 gate levels.
Must-Remember Principles:- —Restoring division: Subtract; if negative, restore by adding back and set Q_0 = 0.
- —Non-restoring division: If A >= 0, shift & subtract; if A < 0, shift & add.
- —CLA: $G_i = A_i B_i$ (generate), $P_i = A_i \oplus B_i$ (propagate).
- —CLA Carry latency is constant 2 gate levels (AND-OR) after P and G are available.
Critical Pitfalls & Exam Traps:- ×In non-restoring division, remember the final sign check on remainder A: if A is negative at the end of all steps, a final restore addition A = A + M is strictly required.
Memory Hierarchy, Cache Mapping & AMAT
Cache Memory: Direct, Associative, Set-Associative & AMAT
Open Full Lesson →In set-associative caches, Set Index = log2(Capacity / (Block Size * k)); AMAT = T_L1 + M_L1 * (T_L2 + M_L2_local * T_MM).
Must-Remember Principles:- —Direct: Line Index = log2(Lines); Tag = Address - Index - Offset.
- —Fully Associative: Zero index bits; Tag = Address - Offset.
- —k-way Set-Associative: Sets = Capacity / (Block Size * k); Set Index = log2(Sets).
- —AMAT = T_L1 + M_L1 * (T_L2 + M_L2_local * T_MM).
- —Global Miss Rate L2 = M_L1 * M_L2_local.
Critical Pitfalls & Exam Traps:- ×Do not forget to count the Dirty bit in write-back cache tag directory size calculations.
- ×Cache capacity refers to DATA capacity; tag bits, valid bits, and dirty bits are additional hardware overhead.
Memory Hierarchy, Cache Mapping & AMAT
Cache Replacement, Write Policies & Memory Interleaving
Open Full Lesson →Low-order memory interleaving maps consecutive memory addresses to parallel banks, reducing streaming latency to T_bank + (words - 1) * T_bus.
Must-Remember Principles:- —Write-Through: Main memory always consistent; write buffer avoids CPU stalls.
- —Write-Back: Writes to cache only; dirty bit tracks eviction flush to RAM.
- —Low-Order Interleaving: Bank = Address mod m; sequential words map to parallel banks.
- —Interleaved Latency: T_total = T_bank + (words - 1) * T_bus.
Critical Pitfalls & Exam Traps:- ×High-order interleaving places consecutive words in the SAME bank, so it provides zero speedup for sequential array streaming.
Instruction Pipelining, Hazards & Performance
Instruction Pipelining: Stages, Speedup & Hazards
Open Full Lesson →Pipeline clock period equals max stage delay plus latch overhead; full operand forwarding eliminates stalls for ALU-to-ALU dependencies.
Must-Remember Principles:- —T_clock = max(Stage Delays) + Latch Delay.
- —Ideal CPI = 1; Actual CPI = 1 + Stalls_data + Stalls_branch.
- —RAW (Read-After-Write) is the only data hazard in in-order pipelines.
- —Operand forwarding resolves ALU-to-ALU dependencies with 0 stalls.
- —Load-Use hazard requires 1 stall bubble even with full forwarding.
Critical Pitfalls & Exam Traps:- ×Do not forget latch delay when computing the pipelined clock period.
- ×Ensure register file write occurs in first half-cycle and read in second half-cycle before adding unnecessary bubbles.
Instruction Pipelining, Hazards & Performance
Branch Hazards, Dynamic Predictors & Branch Target Buffers
Open Full Lesson →Branch penalty cycles equal the stages elapsed before target address and branch condition are resolved; 2-bit counter requires two errors to flip.
Must-Remember Principles:- —Branch penalty = Stages elapsed before target address and condition are resolved.
- —Resolving branch at ID stage gives 1 stall cycle; at EX stage gives 2 stall cycles.
- —2-bit saturating counter states: 11 (Strongly Taken), 10 (Weakly Taken), 01 (Weakly Not Taken), 00 (Strongly Not Taken).
- —BTB cache eliminates branch penalty completely on hit.
Critical Pitfalls & Exam Traps:- ×Remember that the 2-bit counter requires two successive mispredictions to flip its prediction between Taken and Not Taken.
Control Unit Design, DMA & Interrupts
Microprogrammed Control Units & DMA Transfer Modes
Open Full Lesson →Vertical microinstructions group mutually exclusive signals with ceil(log2(n+1)) bits per group; DMA cycle stealing slows CPU by Rate * T_bus.
Must-Remember Principles:- —Horizontal microinstructions: 1 bit per signal; no decoder; high speed.
- —Vertical microinstructions: Groups encoded with ceil(log2(n+1)) bits; requires decoders.
- —Burst mode: CPU halted for the entire block transfer.
- —Cycle stealing: DMA steals 1 bus cycle per data word; CPU slows by fraction = Rate * T_bus.
Critical Pitfalls & Exam Traps:- ×Remember the +1 idle state when computing vertical field bit widths.
Control Unit Design, DMA & Interrupts
Interrupts, Daisy Chaining Priority & Bus Arbitration
Open Full Lesson →Vectored interrupts supply vector address directly on the data bus; daisy chaining arbitrates device priority in serial hardware order.
Must-Remember Principles:- —Vectored: Device supplies vector address directly over the bus to jump to ISR.
- —Non-vectored: CPU jumps to fixed location and polls devices sequentially.
- —Daisy chaining: Priority ordered by physical position closest to CPU.
- —DMA slowdown % = Data Transfer Rate * Bus Cycle Time.
Critical Pitfalls & Exam Traps:- ×Ensure matching units: If rate is in bytes/sec, multiply by bus cycle time in seconds per byte.