2014 question paper
COMPUTER ORGANIZATION & ARCHITECTURE
23 questions
Q1a. Registers R1 and R2 of a computer contain the decimal values 1200 and 4600. What is the effective address of the memory operand in each of the following instructions? - (i) Load 20(R1), R5 - (ii) Add –(R2), R520142m
Module 2: x86 Architecture, CPU Control, I/O, Memory System Design
View this question on its own page →Registers R1 and R2 of a computer contain the decimal values 1200 and 4600. What is the effective address of the memory operand in each of the following instructions?
- (i) Load 20(R1), R5
- (ii) Add –(R2), R5
Worked SolutionAnswer: Effective Address calculation:
Given R1=1200, R2=4600
(i) Load 20(R1), R5 → Indexed/Displacement mode: EA = R1 + 20 = 1200+20 = 1220. Content at memory 1220 loaded into R5.
(ii) Add -(R2), R5 → Autodecrement mode: First R2 = R2 - word size (assume 4 for 32-bit or 1 for simplicity; textbook uses R2 = 4600-1 = 4599 if byte, or 4596 if word). If byte-addressable decrement by 2? Typically -(R) means R ← R - size, then EA = R (new). So EA = 4599 (byte) or 4596 (word), value at that address added to R5. If size unspecified, EA = R2 -1 = 4599.Q1b. Explain MIPS and MFLOPS.20147m
Module 2: x86 Architecture, CPU Control, I/O, Memory System Design
View this question on its own page →Explain MIPS and MFLOPS.
Worked SolutionMIPS and MFLOPS - Performance Measures
1. MIPS - Million Instructions Per Second:
where = clock frequency, = cycles per instruction.Measures integer/overall CPU throughput. e.g., CPU @ 2 GHz with CPI=2: MIPS.
Limitations of MIPS:
- Depends on instruction set - one ISA's instruction does more work than another.
- Ignores instruction complexity and mix.
- Not reliable for comparing different architectures or compilers.
2. MFLOPS - Million Floating Point Operations Per Second:
Measures capability for scientific/numerical workload (add, mul, div on floats). Higher MFLOPS = better for supercomputing.Limitations: Only counts FP ops, ignores integer, branch, I/O; depends on program (Linpack, etc) and compiler optimization.
Comparison: MIPS general-purpose speed, MFLOPS scientific speed. MFLOPS rating typically lower than MIPS on same machine because FP ops take more cycles. Both are crude; today SPEC, CPI, execution time preferred.
Q1b. What is the use of condition code register?20142m
Module 2: x86 Architecture, CPU Control, I/O, Memory System Design
View this question on its own page →What is the use of condition code register?
Worked SolutionCondition Code Register (CCR) / Flag Register Uses:
CCR holds flags N, Z, V, C set by ALU after arithmetic/logic operation:
- N (Negative): N=1 if result MSB=1 (negative in 2's complement). Used for signed branch (BMI/BPL).
- Z (Zero): Z=1 if result = 0. Used to test equality (BEQ/BNE) and loop termination.
- V (Overflow): V=1 if signed 2's complement overflow (result exceeds range). Used for signed arithmetic error detection.
- C (Carry): C=1 if carry out from MSB (unsigned overflow) or borrow. Used for multi-precision addition/subtraction (ADC/SBC), unsigned comparison (BCS/BCC).
Uses: Conditional branching, decision making (
CMP+ flags), interrupt control, and detecting arithmetic errors without extra comparator.Q1c. **What do you mean by end-around carry correction?20142m
Module 1: Functional Block of computer and Data representaion
View this question on its own page →**What do you mean by end-around carry correction?
Worked SolutionEnd-Around Carry (EAC) Correction - 1's Complement Addition:
In 1's complement, negative numbers are bitwise complements. When adding, a carry out of MSB is not discarded but added back to LSB (end-around carry).
Rule: Add numbers as unsigned. If carry-out , add 1 to result to get correct sum.
Example: Add (
0101) and (1100in 1's complement):0101 + 1100 = 10001-> 4-bit result0001with . Add EAC:0001+1 = 0010(2), which is correct ().If no carry (), result is already correct and negative (1's complement) if MSB=1. Double complement case represents -0.
Q1d. Discuss the role of Booth algorithm in the design of fast multipliers.20142m
Module 1: Functional Block of computer and Data representaion
View this question on its own page →Discuss the role of Booth algorithm in the design of fast multipliers.
Worked SolutionBooth Algorithm — Role in Fast Multipliers (2m):
Booth's algorithm enables fast signed (two's complement) multiplication with fewer add/sub operations.
- Standard shift-and-add requires an addition for every 1 in multiplier. Booth recodes multiplier and examines pairs of bits ():
00or11→ arithmetic right shift only01→ Add multiplicand (A = A + M)10→ Subtract multiplicand (A = A - M)
followed by arithmetic right shift.
- Handles positive and negative operands uniformly without separate sign correction.
- Reduces number of operations for strings of 1s (e.g.,
01110handled with one add and one subtract), speeds up multiplier and naturally supports efficient hardware (Booth recoding, Modified Booth Radix-4). - Basis for modern high-speed array / Wallace-tree multipliers.
- Standard shift-and-add requires an addition for every 1 in multiplier. Booth recodes multiplier and examines pairs of bits ():
Q1e. Why is the wait-for-memory-function-completed step needed when reading from or writing to the main memory?20142m
Module 4: Memory Organization
View this question on its own page →Why is the wait-for-memory-function-completed step needed when reading from or writing to the main memory?
Worked SolutionWhy WMFC is needed:
Main memory (DRAM) is asynchronous and slower than CPU. Its access time is variable and longer than one CPU clock period. CPU issues read/write by placing address/data on bus and issues Memory Enable but cannot proceed until memory completes the operation.
WMFC (Wait-for-Memory-Function-Completed) is a control step where CPU waits for MFC (Memory Function Completed) signal from memory controller.
- Ensures data in MDR/MBR is valid before it is used (read) or guarantees write has been latched.
- Synchronizes fast synchronous CPU with slow asynchronous memory.
- Without WMFC, CPU would fetch stale/wrong data or overwrite next operation, causing incorrect execution. Cycle time = access time + recovery time, so next memory operation can start only after WMFC/MFC.
In synchronous control sequence:
MAR ← address; MDR ← data (for write); WMFC; MDR ← valid data (for read).Q1f. Write the sequence of control steps required for three-bus structure for the following instruction: - Add R4, R5, R620142m
Module 2: x86 Architecture, CPU Control, I/O, Memory System Design
View this question on its own page →Write the sequence of control steps required for three-bus structure for the following instruction:
- Add R4, R5, R6
Worked SolutionThree-bus Structure – Add R4, R5, R6 (meaning )
In three-bus organization, bus A and bus B supply operands and bus C carries result, so execution needs only one clock cycle (fetch/decode steps same as usual).
Sequence:
- Fetch & Decode:
PC_{out}, MAR_{in}, Read, WMFC; MDR_{out}, IR_{in}; PC_{inc}; Decode - Execute Add:
R5_{outA}, R6_{outB}, ALU_{add}, R4_{inC}, End
Explanation: Contents of R5 placed on Bus A, R6 on Bus B, ALU adds them concurrently, result on Bus C is latched into R4.
Note: For single-bus it would need 3 steps:
R5_{out}, Y_{in}; R6_{out}, Y+ R6 → Z; Z_{out}, R4_{in}. For two-bus:R5_{outA}, R6_{outB}, ALU → Z; Z_{out}, R4_{in}. Three-bus is fastest.Q1g. Define locality of reference.20142m
Module 4: Memory Organization
View this question on its own page →Define locality of reference.
Worked SolutionLocality of Reference - Defined (2 Marks)
Locality of reference is the empirical observation that memory references tend to cluster in a small region over a short time interval. It is the basis for cache and virtual memory.
Temporal Locality: If a memory location is referenced, it is likely to be referenced again soon. e.g. loops, reusable variables, stack. Keeping recently used blocks in cache yields hits.
Spatial Locality: If a location is referenced, nearby locations are likely to be referenced soon. e.g. sequential instruction fetch, arrays. Fetching a whole block/line exploits this.
Sequential Locality: Special case of spatial — ordered instruction execution.
Due to locality, 90/10 rule holds: 90% of time CPU accesses only 10% of address space, making cache hierarchy very effective.
Q1h. Give the features of a ROM cell.20142m
Module 4: Memory Organization
View this question on its own page →Give the features of a ROM cell.
Worked SolutionROM Cell Features (2 Marks)
ROM (Read Only Memory) cell stores a fixed bit permanently:
Non-volatile: Retains contents without power — used for bootstrap, firmware, microprogram.
Mask-programmed: Contents written at fabrication via contact mask / transistor presence (1 = transistor present, 0 = absent). Not field-writable.
Non-destructive read: Reading does not erase cell; access via address decoder → word line → bit line sense.
High density, low cost/bit for large volumes; slower write-once but fast read comparable to RAM.
Variants: PROM (fusible link, OTP), EPROM (floating gate, UV erase), EEPROM/Flash (electrically erasable) retain ROM cell principle but allow reprogramming.
Single ROM cell = 1 transistor + contact/via; array is OR plane of word lines.
Q1i. Define bus arbitration.20142m
Module 2: x86 Architecture, CPU Control, I/O, Memory System Design
View this question on its own page →Define bus arbitration.
Worked SolutionAnswer: Bus Arbitration - Definition
Bus Arbitration is the process of resolving contention when multiple bus masters (CPU, DMA controller, processors in multiprocessor system, I/O controllers) simultaneously request control of the system bus. Since only one master can drive the bus at a time, an arbiter decides priority and grants bus access.
Need: Prevents collision and ensures orderly transfer.
Approaches:
- Centralized Arbitration: Single hardware arbiter (e.g., priority encoder) grants bus via Bus Request () / Bus Grant () daisy-chain or independent requests.
- Distributed Arbitration: Each master has its own arbitration logic and decides collectively (e.g., self-selection).
Common schemes: Daisy chaining, Polling, Independent Request (Parallel arbitration). Priority may be fixed, rotating, or dynamic.
In short, bus arbitration = mechanism to select one master among contenders to become next bus master.
- Install PocketlyBudget App•POCKETLY
Pocketly on Android
Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.
Q1i. What is the difference between a subroutine and an interrupt service routine?20142m
Module 2: x86 Architecture, CPU Control, I/O, Memory System Design
View this question on its own page →What is the difference between a subroutine and an interrupt service routine?
Worked SolutionSubroutine vs Interrupt Service Routine (ISR):
Feature Subroutine (Procedure) Interrupt Service Routine (ISR / Interrupt Handler) Invocation Synchronous, explicitly called by program via CALLinstructionAsynchronous, invoked by hardware signal (INTR, NMI) or exception/trap. CPU diverts without program request Control Program has control - known location in code flow Unpredictable timing, depends on external event / fault Linkage CALLsaves return address (PC) on stack;RETreturnsInterrupt logic saves PC and PSW/FLAGS automatically; return via IRET/RETIContext Saving Caller may save few registers (convention dependent) Must save entire processor state (registers, flags) as interrupt can occur between any two instructions Priority/Nesting No priority concept, normal nesting via calls Has priority; higher priority interrupts can preempt lower ISR; requires PIC (8259) arbitration Synchronization Blocking / sequential flow Must be reentrant, short, ends with EOI to PIC; often disables interrupts at entry Key Idea: Subroutine = software-initiated planned transfer; ISR = hardware-initiated event-driven transfer that transparently suspends current task. Example:
CALL SORTvs keyboard ISR at vector 21h invoked on key press.Q2a. Explain Flynn’s classification of computer system architecture.20147m
Module 3: Pipelining
View this question on its own page →Explain Flynn’s classification of computer system architecture.
Worked SolutionFlynn's Classification of Computer Architecture (7M)
Proposed by Michael J. Flynn (1966) - classifies parallel architectures based on number of Instruction streams vs Data streams.
Streams = independent sequence of instructions / data as seen by CPU.
Single Data (SD) One data stream ┌───────────────── │ Single Instruction │ SISD Single instruction │ stream │ (von Neumann) │ -------------------+--------------------------------- │ Multiple Instruction│ MISD Multiple instruction│ (rare - systolic) stream │ └───────────────── Multiple Data (MD) Multiple data streams Actually 2x2 grid: ┌─────────────┬──────────────┐ │ SD │ MD │ ─────────┼─────────────┼──────────────┤ SI │ SISD │ SIMD │ ─────────┼─────────────┼──────────────┤ MI │ MISD │ MIMD │ └─────────────┴──────────────┘1. SISD - Single Instruction Single Data
One instruction stream, one data stream. Sequential.
- Architecture: Conventional Von Neumann uniprocessor. One CU fetches one instruction, one ALU operates on one data element at a time. (No parallelism)
- Execution:
IF -> ID -> EX -> MEM -> WBsingle thread. - Example: Intel 8086, 80386 uniprocessor, ARM single-core, IBM 360. Old mainframes.
- Diagram:
┌────┐ ┌─────┐ ┌─────┐ ┌─────┐ │ CU |----->| PU |----->| MU | IS DS -> Single pipeline └────┘ └─────┘ └─────┘ (IS= Instruction Stream, DS=Data Stream, PU=Processing Unit, MU=Memory)- Performance: Limited by clock, CPI, pipelining is still SISD (ILP but not classified separately by Flynn). Speedup via pipelining/superscalar still logically SISD.
2. SIMD - Single Instruction Multiple Data
One instruction executed on multiple data elements in parallel (Lockstep). Data parallelism.
- Architecture: One CU broadcasts same instruction to multiple Processing Elements (PEs)/ALUs, each with own data. Requires array of processors + interconnection network (shared memory or mesh).
- Execution: Fetch once, decode once, execute simultaneously on
Ndata:
for (i=0..N-1) C[i] = A[i] + B[i]single instruction ADD does all. - Examples:
- Vector processors: Cray-1, CDC STAR-100, TI ASC
- Array processors: ILLIAC-IV (64 PEs), CM-2, DAP
- Modern: GPU warp (SIMT - extension), Intel SSE/AVX (single core SIMD within register), AVX-512 executes 16 floats per instruction, Multimedia extensions
MMX.
- Diagram:
┌────┐ │ CU |---- IS (same instruction broadcast) ----+ └────┘ | ┌──────┼──────┬───────┐ v v v v ┌────┐┌────┐┌────┐ ┌────┐ │PE0 ││PE1 ││PE2 │..│PEN │ each PE has own data DS0..DSN │ALU ││ALU ││ALU │ │ALU │ └────┘└────┘└────┘ └────┘ ↕ ↕ ↕ ↕ Data Memory Module 0..N or interleaved- Use: Matrix operations, image processing, graphics, scientific loops where same operation applied to large dataset. Excellent speedup for vectorizable code; branch divergence hurts (masking).
- Types: Word-slice vs bit-slice, true array vs vector/pipelined.
3. MISD - Multiple Instruction Single Data
Multiple instruction streams on same single data stream. Rare/ theoretical.
- Architecture: Multiple CUs each with distinct instruction on same data item, pipelined through stages. Data flows through chain of processors.
- Example / Interpretation:
- Pipeline / Systolic array where data flows
X -> PE1 (Op1) -> PE2 (Op2) -> PE3 (Op3)each stage different instruction but same datum stream - e.g., real-time signal processing, fault-tolerant systems with redundant execution for voting (N-version). - Carnegie Mellon C.mmp (conceived but no commercial)
- Some view pipeline within single CPU as MISD-like (IF,ID,EX operate on same instruction stream overlapped) but not true.
- Pipeline / Systolic array where data flows
- Diagram:
DS ---->┌────┐ ┌────┐ ┌────┐ │PE0 │--->│PE1 │--->│PE2 │----> Result IS0---->|CU0 | IS1|CU1 | IS2|CU2 |- Use: Almost no general-purpose machine purely MISD; considered for specialized: multiple frequency filters on same sample stream, cryptographic pipelines.
4. MIMD - Multiple Instruction Multiple Data
Multiple instruction streams, multiple data streams. True parallelism - autonomous processors.
- Architecture: Multiple independent processors (each with own CU+ALU+Memory/Local) work on own instruction & data. Two flavors:
- Shared Memory (Tightly coupled): SMP (Symmetric Multiprocessors) - bus/cache coherent shared address space. E.g., Multicore CPU (Intel i7 8 cores), Xeon server.
- Distributed Memory (Loosely coupled): Message-passing - cluster, network of workstations (NOW), supercomputer. E.g., Beowulf cluster, IBM BlueGene, NUMA.
- Execution: MIMD can execute completely independent tasks (MIMD - multiple Programs) or cooperate on single problem (parallel programs) via synchronization (lock, barrier, MPI_Send).
- Examples: Multicore processors, Multiprocessors, Clusters, Grids, Multi-computer (Cray T3D, Intel Paragon).
- Diagram:
┌────┐ ┌────┐ ┌────┐ ┌────┐ │CU0 │->│PE0 │->DS0 │CU1 │->│PE1 │->DS1 └────┘ └────┘ └────┘ └────┘ IS0 \ shared/ \ IS1 Distribution Network (Bus/Crossbar/Network) ┌────┐ ┌────┐ ┌────┐ ┌────┐ │CUN │->│PEN │->DSN etc. └────┘ └────┘- Use: General-purpose parallel computing - database servers, OS multitasking, HPC. Most flexible; speedup limited by Amdahl's law:
Speedup = 1 / (f + (1-f)/N).
Comparison Table
Class Instr Streams Data Streams Parallelism Examples Use Case SISD 1 1 None (sequential) 8086, ARM single Basic PC SIMD 1 N Data parallel ILLIAC, GPU warp, AVX Vector/matrix MISD N 1 Pipeline on data Systolic (rare) Fault tolerance, pipeline MIMD N N Task parallel Multicore, Cluster General parallel Extended Classifications (Johnson, later): SISD vs pipelines etc., but Flynn remains standard.
For exam: Draw 4 quadrants diagram + small block for each type with CU/PE and arrows.
Q3. ### 3. A program runs on a 10 GHz CPU with the instruction mix and corresponding clock cycle count as given in the table: | Instruction type | Clock cycle count | Instruction count | | ---------------- | ----------------- | ----------------- | | Control transfer | 5 | 5000 | | Data transfer | 4 | 4000 | | Floating point | 2 | 2000 | | Integer | 1 | 1000 | --- ### Determine the following: - (a) CPI - (b) Execution time - \(c\) MIPS rate for program201414m
Module 3: Pipelining
View this question on its own page →3. A program runs on a 10 GHz CPU with the instruction mix and corresponding clock cycle count as given in the table:
Instruction type Clock cycle count Instruction count Control transfer 5 5000 Data transfer 4 4000 Floating point 2 2000 Integer 1 1000
Determine the following:
- (a) CPI
- (b) Execution time
- (c) MIPS rate for program
Worked SolutionGiven Data
Clock GHz ns s
Type CPI () Control 5 5000 Data transfer 4 4000 Floating 2 2000 Integer 1 1000 Total instructions
Total cycles
cycles(a) CPI (Average Clock Cycles per Instruction)
cycles/instr
If weighted:
(b) Execution Time
s
Alternatively
(if , )
(c) MIPS Rate
MIPS MIPS BIPS
Check:
If using MIPS = I/(T in ) same result.
Summary: CPI , at 10GHz ( at 1GHz), ~2609 MIPS.
Q4a. Explain fetch-decode-execution cycle.20147m
Module 2: x86 Architecture, CPU Control, I/O, Memory System Design
View this question on its own page →Explain fetch-decode-execution cycle.
Worked SolutionFetch-Decode-Execute Cycle (Instruction Cycle)
Every instruction goes through this cycle, driven by clock and controlled by Control Unit + SC (Sequence Counter). Also called Fetch-Decode-Execute (FDE) or Instruction Cycle.
1. Fetch Phase
- PC holds address of next instruction.
AR <- PCIR <- M[AR](Memory Read),PC <- PC+1(point to next)- ,
- Instruction now in IR: bits 0-11 = opcode+mode, 12-...= address. SC -> 0.
- Micro-operations use common bus + control signals.
2. Decode Phase
- Control Unit decodes opcode in or depending on model, and indirect bit .
- Decodes addressing mode, determines instruction type: Memory-reference (7 ops: AND, ADD, LDA, STA, BUN, BSA, ISZ), Register-reference, I/O.
- Generates control signals for next phase. No bus transfer, just combinational decode.
3. Execute Phase
- Performs operation specific to opcode. Different micro-ops.
Examples:
- LDA (Load AC): ,
- ADD: ,
- BUN (Branch Unconditional):
- Register-reference (e.g., CLA, CMA) executed at in one cycle.
- Indirect cycle adds
AR <- M[AR]if ().
After execute, cleared to 0, cycle repeats for next instruction.
Diagram / Flow
+------+ Fetch +------+ Decode +--------+ Execute +------+ | PC | ------------> | IR | ------------> | Control| ------------> | ALU | | AR | M[AR]->IR | | opcode->D | Unit | micro-ops | AC | | MEM | PC++ | | AR<-addr | | AC<-AC+DR | DR | +------+ +------+ +--------+ PC<-AR etc +------+ ^ | |<---------------------- SC=0, next instruction -------------------|Timing: Each phase takes 1+ clock cycles; CPI = cycles per instruction (1 for simple, 5-6 for memory-reference). Interrupts checked after Execute before next Fetch:
if R=1: handle interrupt (save PC -> M[0], PC=1).Pipelined CPUs overlap F-D-E of successive instructions; single-cycle vs multi-cycle vs pipelined designs differ in how many clocks per phase.
Q4b. Differentiate between hardwired programmed control and microprogrammed control.20147m
Module 4: Memory Organization
View this question on its own page →Differentiate between hardwired programmed control and microprogrammed control.
Worked SolutionHardwired vs Microprogrammed Control Unit
Aspect Hardwired Control Microprogrammed Control Principle Control signals generated by combinational circuit (logic gates, encoder/decoder, sequence counter SC, flip-flops). Fixed wiring. Control signals generated by microprogram stored in Control Memory (ROM). Each microinstruction bit = one control signal; execution = fetching microinstructions. Structure Gates + Decoder (IR opcode -> D0-D7) + Timing from SC + Flip-flops (E, I) + Encoder to generate , etc. Control Address Register (CAR), Control Data Register (CDR), Control Memory (256x20 bits), Next-address logic / Sequencer, Control Buffer Register. Storage No stored program. Combinational logic. Microprogram in ROM/RAM (firmware). microinstructions per machine instruction. Speed Fast (gate delay only) ~ 1-2 gate levels. Ideal for RISC, pipelined. Slower (control memory access each microcycle, ~1 memory fetch per microinstruction) Flexibility Inflexible - to change instruction set need to redesign hardware/wiring. Complex to modify. Flexible - change by updating microcode ROM; add new instruction by adding microroutine. Easy to support CISC complex instructions. Design Cost Complex design for many instructions (many states, hard to debug). But cheap hardware for simple ISAs. Easier design: write microprogram akin to programming. Modular. Complexity handling Becomes unwieldy when instructions > ~50, addressing modes many (state explosion). Handles complex instructions (MUL, interrupt) easily - just longer microroutine. Used in CISC (IBM 360, VAX, 68000). Control signals Generated as Boolean equations: e.g., Each bit of microinstruction directly drives signal: etc. Modification Requires hardware change (ECN). Can be patched via writable control store (WCS) - firmware update. Example RISC processors (MIPS, ARM), old 8085 hardwired, Mano basic computer simplified hardwired version. Historical: IBM System/360, Intel microcode for x86 CISC, modern x86 decodes complex instructions to micro-ops from microcode ROM. Control memory size None Need width ROM; control throughput is fetch-decode of microinstructions (horizontal vs vertical microcode). Techniques Sequence counter + decoder; one-hot, PLA Horizontal (many bits per microinst, parallel) vs Vertical (encoded fields, compact) ; Wilkes model. Diagram Analogy
- Hardwired:
IR,T,I,SC -> Combinational Logic (PLA) -> 30 control lines - Microprogrammed:
IR -> Map -> CAR -> Control Memory -> CDR -> control lines; CDR.next_addr -> CAR
Horizontal vs Vertical within Microprogrammed
- Horizontal: 40-60 bits, each bit one signal - high parallelism, fast but large ROM.
- Vertical: 16-20 bits encoded, needs decoder, compact but slower.
Modern hybrid: RISC core hardwired for simple ops + microcode ROM for complex x86 instructions translated to micro-ops (e.g., Intel/AMD).
Conclusion: Use Hardwired when speed is critical and instruction set simple/small; use Microprogrammed when instruction set is complex/variable and design flexibility/upgradeability matters.
- Hardwired:
Q5a. Explain stack-based architecture of a CPU with the help of a diagram.20147m
Module 2: x86 Architecture, CPU Control, I/O, Memory System Design
View this question on its own page →Explain stack-based architecture of a CPU with the help of a diagram.
Worked SolutionStack-Based Architecture of CPU
Definition: A stack is a LIFO (Last-In-First-Out) storage structure where access is only at the TOP. In a stack-based CPU (0-address machine), operands are implicitly taken from the top of stack and result is pushed back onto stack. Instructions do not contain address fields for operands e.g.
ADD,PUSH A,POP B.1. Organization
Stack can be:
- Register Stack: Small set of registers organized as stack (fast, limited depth)
- Memory Stack: Reserved memory region with Stack Pointer (SP) register pointing to TOS. Grows toward lower addresses (in x86) or upward.
Main Registers involved:
- SP (Stack Pointer): Holds address of Top-Of-Stack (TOS)
- TOS: Top element itself, sometimes a dedicated register for fast access
- PC, MAR, MDR, IR as usual
2. Diagram
CPU +-------------------------------+ | ALU | | ^ | | | | | TOS <-- Top of Stack | Memory (Stack Region) | | | +-------------------+ | SP ---> [ STACK ] -----------+----> | ... | | (LIFO) | | TOS -> [ Data ] | <- SP | | | [ Data ] | | MAR / MDR -------------------+----> | [ Data ] | +-------------------------------+ | ... | +-------------------+ PUSH: SP <- SP-1 ; M[SP] <- data POP : data <- M[SP] ; SP <- SP+1 (for descending stack)For Register Stack (e.g. 64-word stack):
SP -> | A | <- TOS | B | | C | | D | |_____| DR --TOS-- ALU3. Operations
- PUSH X:
SP ← SP +/- 1 ; M[SP] ← X(orTOS ← X ; SP ← SP+1) - POP X:
X ← M[SP] ; SP ← SP -/+ 1 - ADD:
TOS ← TOS + NEXT; pop one item. Example:ADDdoesA← M[SP]; B← M[SP-1]; M[SP-1]← A+B; SP← SP-1
Expression Evaluation Example:
X = (A+B)*(C-D)PUSH A PUSH B ADD ; TOS = A+B PUSH C PUSH D SUB ; TOS = C-D MUL ; TOS = (A+B)*(C-D) POP X4. Characteristics
- 0-address instruction - opcode only, operand location implicit.
- No need to specify addresses, instruction length small, code compact.
- Hardware simplifies compiler for expression evaluation using postfix (Reverse Polish Notation).
- Used in HP calculators, Java Virtual Machine (JVM), Burroughs B5000.
5. Advantages & Disadvantages
Advantages: Simple instruction format, efficient for subroutine calls (saving return address, registers), interrupt handling, easy compilation of arithmetic expressions.
Disadvantages: Stack is bottleneck (sequential access only), random access to stack elements difficult, stack overflow/underflow must be handled, slower than register-to-register if many stack memory accesses (needs cache/TOS optimization).
In modern CPUs, stack is used for CALL/RET, parameter passing, local variables, while general-purpose register architecture is preferred for speed.
Q5b. List registers of a non-pipelined CPU. Explain the purpose of each register.20147m
Module 2: x86 Architecture, CPU Control, I/O, Memory System Design
View this question on its own page →List registers of a non-pipelined CPU. Explain the purpose of each register.
Worked SolutionRegisters of a Non-Pipelined (Single-Cycle / Multi-cycle) CPU
In a non-pipelined CPU only one instruction is in execution at a time (fetch-decode-execute completes before next fetch). Registers are small, fast storage inside CPU.
1. Main Register Set
Register Full Name Size (typ) Purpose PC Program Counter 16/32/64-bit Holds address of next instruction to fetch. Incremented after fetch; loaded with branch target on jump. IR Instruction Register 16-32 bit Holds current instruction opcode + operand fields after fetch. Decoded to generate control signals. MAR Memory Address Register same as address bus Buffers address to be sent to memory. MAR ← PCfor fetch,MAR ← operand addressfor data.MBR/MDR Memory Buffer/Data Register word size Buffers data to/from memory. MBR ← M[MAR]on read;M[MAR] ← MBRon write. Isolates CPU from memory bus timing.AC Accumulator word size Implicit operand and result register in accumulator machines. ALU operations: AC ← AC op MBR. Single AC minimizes address field.GPRs R0-Rn General Purpose Registers word size Hold operands, addresses, intermediate results, loop counters. Reduce memory accesses. SP Stack Pointer address size Points to Top-Of-Stack for PUSH/POP, CALL/RET. SP ← SP ±1automatically.PSW/FLAGS Processor Status Word / Condition Codes 8-32 bit Flags: Z(Zero), C(Carry), N(Negative/Sign), V(Overflow), P(Parity), I(Interrupt enable). Set by ALU, tested by branches. Index / Base Registers X, BR address size Effective address calculation: EA = BR + Index + displacementfor arrays.Temporary / Buffer Registers TMP, Y, Z word size Invisible to programmer, hold intermediate ALU inputs (e.g., TMP ← R1 ; R3 ← TMP + R2). Needed because ALU is combinational.Some CPUs also have: SC (Sequence Counter), AR, DR in textbook (Mano) notation.
2. Diagram - Datapath with Registers (Non-Pipelined)
+----+ +----+ +------+ PC --->| MAR|-->|Memory|--->| MBR |----> IR (opcode) +----+ +----+ +------+ | ^ | v | v Control Unit +--------------->+-----+ | | ALU |<--AC/GPRs--> Registers +-----+ | | PSW/FLAGS v MDR/MAR path to memory3. Operation Flow (Example:
ADD M[X])MAR ← PC ; PC ← PC+1MBR ← M[MAR] ; IR ← MBR(Fetch)- Decode
IR MAR ← IR(address);MBR ← M[MAR]AC ← AC + MBR ; Z,C,N,V updated in PSW
All registers hold values stable for the whole cycle; non-pipelined means no overlapping - next instruction waits until write-back finishes, so no pipeline registers needed, but CPI = 1 (single-cycle, long clock) or CPI >1 (multi-cycle).
Q6(a). Differentiate between expansion and extension of memory.20147m
Module 4: Memory Organization
View this question on its own page →Differentiate between expansion and extension of memory.
Worked SolutionDifferentiate between Expansion and Extension of Memory
Although both are techniques to increase memory capacity using smaller chips, they address different dimensions: depth (words) vs. width (bits). Sometimes textbooks use the terms interchangeably, but standard distinction is:
Aspect Memory Expansion (Word/Depth Expansion) Memory Extension (Bit/Width Extension) Goal Increase number of words (depth) e.g., -> Increase word length / bits per word (width) e.g., -> What is increased Address space (more addresses) Data bus width (more bits per address) Address lines Extra MSB lines needed for chip selection; address split into chip-select + intra-chip address Same address lines to all chips; no extra address decoding for width Data lines Data width unchanged; chips' data buses share via tri-state/bus, only one active at a time Data buses concatenated; each chip contributes part of word, all active simultaneously Chip Select (CS) logic Decoder required: -to- decoder driven by high-order address bits enables one chip at a time No decoder: CS of all chips tied together (common CS), all chips enabled together Connection Address buses common, data buses common (wired-OR via tri-state), CS decoded Address buses common, data buses split/combined, CS common Example Four to make : <br> A0-A9to all chips,A10-A11-> 2:4 decoder -> CS0-CS3. Data D0-D7 common bus.Two to make : <br> A0-A9to both, CS0=CS1= CS, Chip1 D0-D3 -> system D0-D3, Chip2 D0-D3 -> system D4-D7.Diagram CPU A0-A9 ----> all chips A0-A9<br>`CPU A10-A11 -> Decoder -> CS0CS1 Analogy Adding more pages to a book (more pages) Widening each page (more columns per page) Diagrams
Expansion (Depth) using x2:
A0-A9 +----------------+ +---------->| 1Kx8 Chip0 |----> D0-D7 --+ | +----------------+ | Tri-state A0-A9-+ +----------------+ +--> System D0-D7 +---------->| 1Kx8 Chip1 |----> D0-D7 --+ | +----------------+ A10 --> Decoder -> CS0 (A10=0), CS1 (A10=1) (only one active)Extension (Width) using x2:
A0-A9 ------> +--------+ D0-D3 ----> System D0-D3 |1Kx4 C0 | CS -------->| | +--------+ A0-A9 ------> +--------+ D0-D3 ----> System D4-D7 |1Kx4 C1 | CS -------->| | +--------+Combined: To make from chips, do both: need 4 groups (expansion) each with 2 chips in parallel (extension) = 8 chips.
In short: Expansion = more words, Extension = wider words. Both together give arbitrary memory from chips.
Q6b. Describe organization of a typical RAM chip. Differentiate between static RAM chip and dynamic RAM chip.20147m
Module 4: Memory Organization
View this question on its own page →Describe organization of a typical RAM chip. Differentiate between static RAM chip and dynamic RAM chip.
Worked SolutionSolution - RAM Chip Organization & SRAM vs DRAM
A) Organization of a Typical RAM Chip:
A RAM chip of size (e.g., , ) has:
- Memory Array: Matrix of memory cells arranged in rows columns. For , 8192 cells (128 rows 64 columns).
- Address Decoder: address lines decoded to select one row/word. Row decoder selects row, column decoder selects bit group. Example: 10 lines for 1024 words (5 for row, 5 for column or 10 for row).
- Memory Cells: Each cell stores 1 bit (flip-flop for SRAM, capacitor+transistor for DRAM).
- Chip Select (CS) / Chip Enable (CE): Enables chip only when selected - allows building larger memories by combining chips.
- Read/Write Control (RD/WR, WE, OE): write enabled, read.
- Bidirectional Data Lines (): Input data for write, output for read - tri-state buffers. lines = word length.
- Address Lines (): Input address.
Construction of larger memory: Using chip select and address decoding. Eg., to make from two chips, drives CS via decoder.
Block diagram: Address Lines -> Row/Column Decoder -> Memory Cell Array -> Sense Amplifiers / Write Drivers -> Data Lines. Control logic coordinates CS, OE, WE.
B) Difference between Static RAM (SRAM) and Dynamic RAM (DRAM):
Parameter Static RAM (SRAM) Dynamic RAM (DRAM) Cell Design 6 transistors (bistable latch/flip-flop) 1 transistor + 1 capacitor (charge storage) Storage Holds data as long as power on (static) Charge leaks, needs periodic refresh every ~2ms Refresh Circuit Not needed Required (refresh controller, ROW strobing) Density Low (6T per bit) High (1T per bit) - 4-5x denser Speed Fast (access 1-10 ns, no refresh overhead) Slower (access 50-70 ns + refresh) Power More power per cell, but no refresh power Less per cell, but refresh consumes power Cost Costly per bit Cheap per bit Use Cache (L1,L2,L3), fast buffers, registers Main memory (DDR SDRAM) Volatility Volatile (like DRAM) Volatile Summary: SRAM = speed, DRAM = density & cost-effectiveness for large memory.
Typical RAM Chip Pin Diagram: , , , , , , .
Q7a. Explain swapping. Why is it used in memory management?20147m
Module 4: Memory Organization
View this question on its own page →Explain swapping. Why is it used in memory management?
Worked SolutionSwapping in Memory Management
Definition
Swapping is the technique of temporarily moving a process (whole or part) from main memory (RAM) to secondary storage (swap space/backing store) and bringing it back later for execution.Introduced in early time-sharing systems (Atlas, UNIX) to support multiprogramming beyond physical memory size.
Stored image on disk is called swap-out; retrieving is swap-in (roll-out / roll-in).
How it Works
- Scheduler detects low free frames or blocked process waiting for I/O.
- Swapper (mid-term scheduler) selects victim process → copies its entire address space (code, data, stack, PCB) to contiguous swap area on disk.
- Page tables / base-limit registers updated, frames freed.
- Later when memory available and process scheduled, swapper reads image back (possibly at different physical address → requires relocation / dynamic binding via relocation register).
Modern systems swap pages/segments, not whole processes (demand paging is a lazy swap).
Diagram:
Main Memory [P1|P2|P3|hole] ↔ Disk Swap Area [P4(swapped)] ↔ SchedulerWhy Used? (Objectives)
- Multiprogramming degree: Run more processes than fits in RAM. Example processes on RAM via time-multiplexing.
- Memory compaction / fragmentation removal: Swapping out creates large contiguous free blocks, reducing external fragmentation.
- Priority & scheduling: Swap out low-priority/blocked processes to give room to urgent ones (mid-term
suspend). - Fairness & time-sharing: Quantum expired → swap out to let next process in.
- Emergency handling: Low-memory handler frees RAM quickly.
- I/O overlap & backing store for paging: Pages not resident stay on disk.
Types
- Whole-process swapping: Simple but heavy I/O (entire address space).
- Page swapping (paging): Swap only pages, more efficient, foundation for virtual memory.
- Segment swapping: Similar for segmented systems.
Cost & Issues
- Transfer time: Main cost . e.g. . So swap only if process idle for longer.
- Blocked I/O: Process with pending I/O or pinned pages cannot be swapped.
- Thrashing risk: Excessive swapping degrades CPU utilization → need working set / locality.
Today pure swapping rare; virtual memory + demand paging is generalized swapping with finer granularity, and swap file/partition remains as overflow store.
- Install PocketlyBudget App•POCKETLY
Pocketly on Android
Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.
Q7b. Explain virtual memory. Explain the role of logical as well as physical address.20147m
Module 4: Memory Organization
View this question on its own page →Explain virtual memory. Explain the role of logical as well as physical address.
Worked SolutionVirtual Memory
Definition: Virtual memory is a memory management technique that makes an application think it has contiguous, large private address space, independent of physical RAM size, by automatically moving data between RAM and disk (swap/backing store) via paging/segmentation. It gives illusion of
virtual size >> physical size.OS + MMU provide address translation per reference; only active working set stays in RAM, rest on disk, loaded on demand (page fault).
Why Virtual Memory?
- Run programs larger than physical memory.
- Multiprogramming isolation & protection (each process virtual space).
- Simplified linking/loading, no external fragmentation (with paging).
Logical (Virtual) vs Physical Address - Roles
Logical / Virtual Address - Generated by CPU before translation.
- Address seen by process/compiler: e.g. -bit virtual → per process (), -bit in x86-64.
- Partitioned:
| Virtual Page Number (VPN) | Offset |(offset = page size bits; e.g. page → bits offset). - Never used to access RAM directly; goes through MMU.
- Contiguous from process view; sparse vs file mapping allowed.
- Protect bits checked per virtual page.
Physical Address - Actual address on RAM bus after translation.
- After MMU/TLB lookup:
| Physical Frame Number (PFN) | Offset |. - Range limited by installed RAM: e.g. RAM → -bit physical.
- Used by cache/memory controller.
- Multiple virtual pages (even from different processes) can map to same physical frame (shared memory) or one virtual page can map nowhere (paged out → page fault).
Translation flow:
CPU issues VA ──► TLB (VPN→PFN) hit? ──► PA to cache/RAM │ miss └─► Page Table walk (in RAM) ──► PFN + valid bit │ invalid (not resident) └─► Page Fault → OS loads frame from disk, updates table, retriesExample: VA
0x00403F12() with pages, page table maps → PA0x1A2F12.Key distinction: Logical addresses give program portability & protection; physical addresses give actual storage location. Compiler/linker deals in logical; MMU/OS manages physical. Without translation, process would see raw RAM limits and fragmentation.
Modern extensions: Demand paging, copy-on-write, memory-mapped files, TLB, multi-level page tables all build on this split.
Q8. Explain the use of DMA controllers in a computer system with a neat diagram.201414m
Module 2: x86 Architecture, CPU Control, I/O, Memory System Design
View this question on its own page →Explain the use of DMA controllers in a computer system with a neat diagram.
Worked SolutionDMA Controller
DMA controller is a dedicated hardware module that manages direct memory ↔ I/O transfers without CPU per-word involvement.
Block Diagram (textual):
CPU ── Address/Data/Control Bus ─┬─ Main Memory ┌──────────────┐ ├─ DMA Controller ── I/O Device(s) │ CPU │--HOLD/BR-->│ Address Reg (AR) │ │ │<--HLDA/BG--│ Count Reg (WC) │-- DREQ/DRQ ← Device └──────────────┘ │ Control Reg │-- DACK → Device │ Data Buffer │-- IRQ → CPU │ Bus Arbiter │ └──────────────┘Internal components: Address Register (current memory address, auto-incremented), Word Count Register (down-counter), Control/Status Register (R/W direction, transfer mode, enable, interrupt enable flag), Data Buffer/Latch, Bus Control Logic.
Use in System:
- CPU programs DMA: loads AR = start address, WC = block size, Control = read/write, burst vs cycle-steal, channel priority. Enables DREQ mask.
- CPU issues I/O command to peripheral, then continues program.
Operation:
- Peripheral asserts DRQ when ready for word.
- Controller asserts HOLD / Bus Request to CPU.
- CPU finishes current machine cycle, floats buses, asserts HLDA / Bus Grant.
- Controller drives address from AR onto address bus, generates MEM RD/WR and I/O RD/WR, transfers word via buffer. AR++, WC--.
- If WC≠0 and cycle-steal mode, releases HOLD for one cycle and reacquires next transfer; in burst mode holds bus until WC=0.
- When WC=0 → Terminal Count (TC) → controller deasserts HOLD, asserts Interrupt (IRQ) to CPU, sets DONE bit.
Modes: Single transfer, Block/Burst, Demand/Cascade (8237 A has 4 channels, chained). Advantage: For -word block only one interrupt, bandwidth near memory bandwidth (~MB-GB/s) instead of ISR per word.
Multichannel controllers include priority resolver (fixed/rotating) for multiple devices arbitrating for DMA.
Q9. Explain handshake protocol. Depict clearly how it controls data transfer during an input operation.201414m
Module 2: x86 Architecture, CPU Control, I/O, Memory System Design
View this question on its own page →Explain handshake protocol. Depict clearly how it controls data transfer during an input operation.
Worked SolutionHandshake Protocol – Input Operation Control (14 Marks)
Defines asynchronous handshaking to transfer data from input device to CPU/memory without common clock, ensuring data is not lost when device and CPU speeds differ.
Principle: Two control lines: DATA VALID (source says data ready) and DATA ACCEPTED / ACK (destination says data captured). Both sides interlock.
Destination-Initiated Handshake for Input (CPU reading from device):
This is typical for input – CPU/destination initiates because it knows when it can accept.
Steps with timing:
- Idle: Data bus invalid,
VALID=0,ACCEPT=0,Ready=0 - Destination (CPU interface) is ready to receive → asserts READY / REQUEST (or
ACCEPThigh) - Input device places data byte on data bus (e.g., keyboard, ADC) and after settling asserts DATA VALID / STROBE
- Destination latches data into input buffer register on seeing VALID, then asserts DATA ACCEPTED / ACK =1
- Device sees ACK, deasserts VALID =0 and removes data from bus
- Destination sees VALID low, deasserts ACK/READY =0, handshake cycle complete, next data can be requested
Sequence diagram:
Device: ----data valid----> CPU: <--- ack -------- Time: Req↑ → Data→ Valid↑ → Latch → Ack↑ → Valid↓ → Ack↓Source-Initiated alternative: Device asserts VALID first (if data arrives spontaneously), CPU responds with ACK after reading. Used for interrupts.
Hardware Control:
- Device side: Data register + Valid flip-flop
- CPU side: Buffer register + Ready/Ack logic + Interrupt/DMA request
- Example: 8255 PPI Handshake Input Mode –
STB(strobe input, active low from device),IBF(Input Buffer Full to device),INTRto CPU. Device pulsesSTBafter putting data,IBFgoes high acknowledging latch, CPU reads port resettingIBF.
Advantages: No clock correlation needed, reliable at any speed, automatic flow control.
Disadvantage: Extra 2-wire overhead and handshake delay lowers max throughput; need 4-phase protocol for reliability.- Idle: Data bus invalid,
Coursify Android App
Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.