CPU, memory hierarchy, addressing and system software
Topics: Von Neumann architecture, functional units, buses; instruction formats and addressing modes; ALU and control unit; memory hierarchy, cache and virtual memory; I/O, interrupts, DMA; pipelining; assemblers, loaders, linkers, macros, compilers.
Computer organisation and addressing
A von Neumann machine keeps program and data in the same memory and runs the fetch–decode–execute cycle. Buses: address (one-way, its width sets the addressable memory, 2ⁿ locations), data and control. Addressing modes: immediate, register, direct, indirect, indexed, relative.
- n address lines → 2ⁿ locations
- Fetch → decode → execute
- Immediate, direct, indirect, indexed
Example: How many bytes can a 32-bit address bus reach?
- 2³² bytes.
- = 4 GB.
Answer: 4 GB
Example: In which addressing mode is the operand part of the instruction?
- The value itself is in the instruction.
- Immediate addressing.
Answer: Immediate
Memory hierarchy and cache
Faster memory is smaller and costlier, so computers use a hierarchy. Cache works because of locality of reference. Effective access time ≈ h·t_cache + (1 − h)·t_memory for hit ratio h (simple model). Cache mapping: direct (each block to one line), fully associative, set-associative. Virtual memory lets programs use more memory than RAM by paging to disk.
- Locality makes caches work
- EAT = h t_c + (1 − h) t_m
- Lines = cache size/block size
Example: Cache 10 ns, memory 100 ns, hit ratio 0.9. Find the effective access time.
- EAT = 0.9 × 10 + 0.1 × 100.
- = 19 ns.
Answer: 19 ns
Example: How many lines has a 64 KB direct-mapped cache with 64-byte blocks?
- 65 536/64.
- = 1024 lines.
Answer: 1024
Pipelining, I/O and system software
A k-stage pipeline finishes n instructions in k + n − 1 cycles instead of nk, giving a speed-up approaching k (hazards reduce it). I/O uses programmed I/O, interrupts or DMA (direct memory access, the device moves data without the CPU). System software: assemblers (two-pass), compilers, linkers (join object files), loaders (place programs in memory), and macro processors.
- Pipeline time = k + n − 1 cycles
- DMA: data without CPU
- Linker joins; loader loads
Example: A 5-stage pipeline runs 100 instructions. Find the speed-up over no pipelining.
- Without: 500 cycles; with: 5 + 99 = 104 cycles.
- Speed-up ≈ 4.8.
Answer: ≈ 4.8
Example: Which phase of a compiler turns characters into tokens?
- It groups characters into keywords, identifiers and symbols.
- Lexical analysis.
Answer: Lexical analysis
A Von Neumann machine stores data and instructions in one memory; a Harvard machine separates them. Instructions run fetch, decode, execute. Hardwired control is fast, and microprogrammed control is flexible. Addressing modes locate operands: immediate, direct, indirect, register, indexed. Cache exploits locality with average access time T = hT_c + (1 − h)T_m. DMA moves data without CPU involvement. Interrupts signal the CPU rather than polling. Pipelining raises throughput but faces structural, data and control hazards. An assembler translates assembly code, a linker joins object files, a loader places a program in memory, and a compiler translates high-level code in phases from lexical analysis to code generation.
- RISC: simple fixed-length instructions; CISC: many complex ones.
- Cache mappings: direct, associative, set-associative.
- Two-pass assemblers build a symbol table on the first pass.
- Lexical analyser produces tokens.
- Word length is the bits processed at a time.
Key formulas
- T_avg = hT_c + (1 − h)T_m
- speedup ≤ n stages
- memory = 2^(address bits)
Practice questions
Von Neumann architecture uses
- one memory for data and code
- separate memories
- no memory
- cache only
Show the answer
Answer: A. one memory for data and code Stored-program concept.
DMA transfers data
- through the CPU only
- without CPU involvement
- only to printers
- only by polling
Show the answer
Answer: B. without CPU involvement Direct memory access.
Pipelining improves
- throughput
- instruction length
- memory size
- power at zero cost
Show the answer
Answer: A. throughput Parallel stages.
Cache works because of
- locality of reference
- large size
- low price
- magnets
Show the answer
Answer: A. locality of reference Temporal and spatial.
RISC processors have
- many complex instructions
- few simple instructions
- no registers
- no pipeline
Show the answer
Answer: B. few simple instructions Reduced set.
An assembler converts
- high-level code to assembly
- assembly to machine code
- machine code to source
- text to PDF
Show the answer
Answer: B. assembly to machine code Translator.
A linker
- joins object files
- edits text
- prints output
- runs interrupts
Show the answer
Answer: A. joins object files Resolves references.
The compiler phase producing tokens is
- lexical analysis
- syntax analysis
- code generation
- optimisation
Show the answer
Answer: A. lexical analysis Scanner.
The fastest storage is
- registers
- cache
- RAM
- disk
Show the answer
Answer: A. registers Inside the CPU.
Immediate addressing has the operand
- in the instruction
- in memory
- in a port
- on disk
Show the answer
Answer: A. in the instruction Encoded directly.
The practice questions were written for this studio; they are not copied from ASTU papers. ASTU publishes no topic syllabus for these exams, so the topics are an informed guide based on diploma courses, not an official list.