Tribhuvan University
Faculty of Management
Office of the Dean
Official Model Question Paper / Dean's Office Blueprint
Candidates are required to give their answers in their own words as far as practicable. The figures in the margin indicate full marks.
Group A
Brief Answer Questions. Attempt ALL questions.
[5 × 2 = 10]- [2]
Distinguish between von Neumann Architecture and Harvard Architecture in terms of memory bus structure.
View model solution
Answer:
Parameter von Neumann Architecture Harvard Architecture Bus Structure Single shared bus for conveying both instructions and data between CPU and memory. Separate physical buses for instructions (instruction bus) and data (data bus). Memory Space Unified memory address space storing both code and data. Separate physical memory address spaces for program instructions and data. Bottleneck von Neumann Bottleneck: Instruction fetch and data read/write cannot occur simultaneously. High throughput: CPU can fetch an instruction and read/write data concurrently. Typical Usage General-purpose microprocessors (x86, ARM desktop). Digital Signal Processors (DSP), Microcontrollers (PIC, AVR). - [2]
What is an Addressing Mode? Explain Immediate Addressing and Register Indirect Addressing with 8085/8086 assembly examples.
View model solution
Answer:
- Addressing Mode: The rule or technique by which the CPU interprets an instruction’s operand field to locate the effective memory address of the required data.
- Immediate Addressing: The actual operand data is specified directly within the instruction itself.
8085 Example:
MVI A, 45H(Loads immediate hex byte45Hdirectly into Accumulator). - Register Indirect Addressing: The instruction specifies a register pair that holds the physical memory address where the operand is stored.
8085 Example:
MOV A, M(Loads Accumulator with data from memory address pointed by the HL register pair).
- [2]
Describe the operational functions of the Program Counter (PC) and the Stack Pointer (SP) in CPU architecture.
View model solution
Answer:
- Program Counter (PC): A 16-bit internal register that holds the memory address of the next instruction to be fetched and executed. It is automatically incremented as instructions are fetched sequentially, or updated during branch/jump instructions.
- Stack Pointer (SP): A 16-bit register that stores the memory address of the current top of the LIFO (Last-In, First-Out) stack structure in RAM. It decrements when data is pushed (
PUSHor subroutineCALL) and increments when data is popped (POPorRET).
- [2]
Define Cache Hit, Cache Miss, and the mathematical formula for the Cache Hit Ratio (
). View model solution
Answer:
- Cache Hit: Occurs when the memory word or block requested by the CPU is already present in cache memory, allowing immediate retrieval at high speed (
). - Cache Miss: Occurs when the requested memory word is absent from cache, requiring an access to slower main RAM (imposing a miss penalty).
- Hit Ratio (
): The fraction of total memory references satisfied by the cache: Miss ratio is.
- Cache Hit: Occurs when the memory word or block requested by the CPU is already present in cache memory, allowing immediate retrieval at high speed (
- [2]
What is an Interrupt? Differentiate between Maskable Interrupts and Non-Maskable Interrupts (NMI) in microprocessors.
View model solution
Answer:
- Interrupt: An asynchronous hardware or software signal that suspends the CPU’s normal program execution sequence, saves context, and forces execution of an Interrupt Service Routine (ISR).
- Maskable Interrupt: An interrupt whose servicing can be enabled or disabled/ignored by software commands (e.g.
EI/DIinstructions in 8085; e.g., RST 7.5, RST 6.5, INTR). Used for normal peripheral I/O. - Non-Maskable Interrupt (NMI): An interrupt that the CPU cannot ignore or mask under any software condition (e.g., TRAP in 8085). Reserved for catastrophic events like power failure or hardware memory parity faults.
Group B
Descriptive Answer Questions. Attempt any THREE questions.
[3 × 10 = 30]- [10]
Analyze the internal architecture of the Intel 8085 Microprocessor: a) Draw and describe its functional block diagram: Register array (B, C, D, E, H, L), Accumulator, ALU, Status Flags, and Timing/Control Unit. (5 Marks) b) Write a complete 8085 assembly language program to find the maximum number in an array of
bytes stored in memory starting from address 2050H. Store the largest value at address3050H. Provide a register trace. (5 Marks)View model solution
8085 Microprocessor Architecture and Maximum Number Assembly Program
a) 8085 Functional Internal Architecture
1. Functional Units
- Arithmetic and Logic Unit (ALU): Performs 8-bit arithmetic (add, subtract) and logical (AND, OR, XOR, compare) operations.
- Accumulator (Register A): 8-bit register serving as the primary source operand and destination for all ALU results.
- General Purpose Registers: Six 8-bit registers (
) that can function individually or as 16-bit register pairs ( ) where serves as the default memory pointer . - Flags Register (F): 5 flip-flops recording arithmetic status:
- S (Sign): Set if MSB (
) is 1 (negative). - Z (Zero): Set if ALU result is exactly zero.
- AC (Auxiliary Carry): Set on carry from bit
to (for BCD). - P (Parity): Set if result contains even number of 1s.
- CY (Carry): Set on arithmetic overflow/carry beyond bit
.
- S (Sign): Set if MSB (
- Timing and Control Unit: Decodes instructions and generates synchronization pulses (
ALE,RD,WR,IO/M).
b) 8085 Assembly Language Program: Find Maximum Value
; Problem: Find maximum byte in array of length N ; Array length N stored at: 2050H ; Array data starts at: 2051H ; Store maximum result at: 3050H LXI H, 2050H ; HL points to array count N MOV C, M ; Load counter C with array size N INX H ; HL points to first array element (2051H) MOV A, M ; Initialize Accumulator with first element DCR C ; Decrement counter (1 element already processed) JZ STORE ; If array had only 1 element, jump to store LOOP: INX H ; HL points to next element CMP M ; Compare Accumulator with memory element M ; If A >= M: Carry flag CY = 0 ; If A < M: Carry flag CY = 1 JNC SKIP ; If A >= M, do not replace, skip MOV A, M ; If A < M, load new maximum into Accumulator SKIP: DCR C ; Decrement remaining elements counter JNZ LOOP ; Repeat until all elements examined STORE: STA 3050H ; Store maximum value in memory address 3050H HLT ; Terminate program executionStep-by-Step Register Trace
- Let array at
2050Hcontain: Count, elements: [25H, 64H, 12H].
Instruction Executed Reg A Reg C Reg HL Carry Flag (CY) Comment LXI H, 2050H-- -- 2050H-- Pointer initialized MOV C, M-- 03H 2050H-- Counter INX H-- 03H 2051H-- Pointer to first item MOV A, M25H 03H 2051H-- Initial max DCR C25H 02H 2051H0 Count INX H25H 02H 2052H0 Points to 64HCMP M25H 02H 2052H1 MOV A, M64H 02H 2052H1 New max DCR C64H 01H 2052H0 Count INX H64H 01H 2053H0 Points to 12HCMP M64H 01H 2053H0 JNC SKIP64H 01H 2053H0 Skips replacement DCR C64H 00H 2053H0 Counter Loop ends STA 3050H64H 00H 2053H0 Memory 3050Hreceives64H - [10]
Explain the concept of an Instruction Pipeline: a) Detail the 5 stages of a classic RISC instruction pipeline (IF, ID, EX, MEM, WB). (4 Marks) b) Analyze the three primary classes of pipeline hazards: Structural Hazards, Data Hazards (RAW, WAR, WAW), and Control Hazards. Explain techniques used to eliminate each hazard. (4 Marks) c) Calculate the theoretical pipeline speedup for executing
instructions on a stage pipeline with clock cycle compared to an unpipelined processor requiring 10 ns per instruction. (2 Marks) View model solution
Instruction Pipelining, Hazard Analysis, and Speedup Calculation
a) 5-Stage Classic RISC Instruction Pipeline
- IF (Instruction Fetch): The instruction pointed to by the PC is fetched from memory/I-Cache into the Instruction Register (IR); PC is incremented.
- ID (Instruction Decode / Register Fetch): The instruction opcode is decoded in the control logic; source operands are read from the register file.
- EX (Execute / ALU): ALU performs the arithmetic operation, computes memory effective address for loads/stores, or evaluates branch conditions.
- MEM (Memory Access): Data memory or D-Cache is accessed to read (load) or write (store) data operands.
- WB (Write Back): The resulting data from ALU or memory is written back to the destination register in the register file.
b) Pipeline Hazards and Mitigation Techniques
1. Structural Hazards
- Cause: Hardware resource conflict when two pipeline stages attempt to access the exact same physical hardware component in the same clock cycle. Example: IF stage fetching instruction from RAM while MEM stage is simultaneously reading data from RAM.
- Remedy: Separate instruction and data caches (Harvard memory split) or duplicating hardware execution units.
2. Data Hazards
Occur when an instruction depends on the result of a previous instruction that is still in flight in the pipeline:
- RAW (Read After Write - True Dependency): Instruction
tries to read a register before instruction writes to it. Remedy: Operand Forwarding (Bypassing) routes ALU output directly from EX/MEM stage registers to the EX stage of the next instruction without waiting for WB; or inserting software/hardware pipeline stalls (bubbles). - WAR (Write After Read - Anti-dependency): Occurs in out-of-order execution when
tries to write before reads. - WAW (Write After Write - Output dependency): Occurs when
overwrites a register before an earlier instruction writes. Remedy for WAR/WAW: Register Renaming.
3. Control Hazards (Branch Hazards)
- Cause: Conditional branches change the PC, but the branch outcome and target address are not resolved until the EX/MEM stage, during which incorrect sequential instructions have already been fetched.
- Remedy: Branch Prediction (Dynamic 2-bit saturating branch history tables), Delayed Branching with branch delay slots.
c) Pipeline Speedup Calculation
- Number of stages
- Number of instructions
- Pipelined clock cycle
- Unpipelined execution time per instruction
1. Total Unpipelined Time (
) 2. Total Pipelined Time (
) The first instruction takes
cycles to fill the pipe; the remaining instructions complete at the rate of 1 instruction per cycle: 3. Speedup (
) The 5-stage pipeline achieves a near-ideal
speedup. - [10]
Analyze Cache Memory Organization and Address Mapping: a) Compare Direct Mapping, Associative Mapping, and Set-Associative Mapping. (5 Marks) b) A system has a 32-bit byte-addressable main memory and a 64 KB 4-way Set-Associative Cache with a block size of 64 bytes. Determine the exact bit allocation for the Tag, Set Index, and Word (Block) Offset fields of the memory address. (5 Marks)
View model solution
Cache Mapping Techniques and Set-Associative Address Partitioning
a) Comparison of Cache Mapping Techniques
Parameter Direct Mapping Associative (Fully Associative) Set-Associative Mapping Placement Rule Block can map to strictly one cache line: . Block can be placed into any arbitrary line in the cache. Cache is divided into sets; block can be placed into any line within set: . Hardware Complexity Lowest; requires only 1 comparator per lookup. Highest; requires simultaneous parallel comparators for every line. Moderate; requires comparators for a -way set-associative cache. Conflict Misses High; multiple blocks competing for the same line trigger thrashing. Zero conflict misses (only capacity and compulsory misses). Significantly reduced conflict misses; balances speed and hit rate.
b) Mathematical Address Bit Allocation Calculation
1. System Parameters
- Total Address Space: 32 bits (
bytes = 4 GB byte-addressable memory) - Cache Size =
- Block Size (Line Size) =
- Set Associativity (
) = 4-way ( lines per set)
2. Block (Word) Offset Calculation
The block offset determines the exact byte within a 64-byte cache block:
3. Set Index Calculation
Total number of lines in cache:
Total number of sets in a 4-way set-associative cache:
4. Tag Bits Calculation
The remaining most significant bits constitute the Tag:
5. 32-Bit Memory Address Partitioning Map
Field Name Tag Set Index Block Offset Bit Width 18 bits 8 bits 6 bits Bit Range Bits 31 down to 14 Bits 13 down to 6 Bits 5 down to 0 Total check:
bits. - Total Address Space: 32 bits (
- [10]
Examine Input/Output Organization and Direct Memory Access (DMA): a) Contrast Programmed I/O, Interrupt-Driven I/O, and Direct Memory Access (DMA) with respect to CPU utilization and data transfer speed. (5 Marks) b) Describe the functional architecture of a DMA Controller (e.g. Intel 8237). Detail the bus handshake signals (HOLD and HLDA) and contrast Burst Mode versus Cycle Stealing Mode of data transfer. (5 Marks)
View model solution
I/O Organization and Direct Memory Access (DMA) Mechanics
a) Comparison of I/O Transfer Techniques
Parameter Programmed I/O Interrupt-Driven I/O Direct Memory Access (DMA) CPU Involvement Continuous Polling: CPU is trapped in a tight loop checking device status flags. Partial: CPU executes other tasks until device raises an interrupt request. Zero during transfer: Dedicated DMA controller manages entire bulk block transfer. CPU Utilization Extremely wasteful; CPU idle waiting for slow peripherals. Efficient; CPU only handles context switch and ISR execution. Maximum efficiency; CPU only initializes transfer registers. Transfer Speed Slow; bounded by polling loop cycle overhead. Moderate; bounded by interrupt latency and register pushing/popping. Wire-Speed: Maximum hardware bus transfer rates (essential for NVMe, Gigabit NICs).
b) DMA Controller Architecture and Bus Handshake
1. Core Internal Registers of DMA Controller (Intel 8237)
- Memory Address Register: Stores the starting RAM memory address for data read/write. Increments after each byte transferred.
- Byte Count Register: Stores the number of bytes to transfer. Decrements after each byte until reaching zero (Terminal Count - TC).
- Control / Status Register: Configures transfer direction (Memory-to-I/O or I/O-to-Memory) and DMA channel priority.
2. Bus Handshake Protocol (HOLD and HLDA)
- When a high-speed peripheral (e.g., Disk Controller) needs to transfer a block, it asserts DMA Request (
DREQ). - The DMA Controller asserts the
HOLDline to the CPU, requesting complete ownership of the system address, data, and control buses. - The CPU completes its current bus machine cycle, floats its buses into a high-impedance state, and replies with Hold Acknowledge (
HLDA). - The DMA controller asserts
DACKto the peripheral and drives memory address and read/write control lines directly, transferring data directly between peripheral and RAM without passing through CPU registers. - Upon transferring the final byte, the DMA Controller drops
HOLD, and the CPU resumes normal bus control.
3. Data Transfer Modes
- Burst Mode (Block Transfer): The DMA controller retains continuous control of system buses until the entire block of data is completely transferred. Delivers maximum transfer speed, but locks the CPU out of main memory for prolonged intervals.
- Cycle Stealing Mode: The DMA controller acquires the bus, transfers exactly one byte/word, and immediately relinquishes the bus back to the CPU. It “steals” idle CPU memory cycles, allowing CPU execution and high-speed I/O to interleave seamlessly without starving the processor.
Group C
Comprehensive Answer / Case Analysis Question. Attempt ALL questions.
[1 × 20 = 20]- [20]
Computer Architecture Case Study: High-Reliability Smart Electric Grid Telemetry Station
Nepal Electricity Authority (NEA) is engineering an embedded telemetry microprocessor node for automated substation monitoring across the Kaligandaki transmission corridor. The microcontroller processes real-time 3-phase AC voltage and current sensor samples to detect dangerous grid surges:
- Performance & Real-Time Constraints: The telemetry node samples 16 ADC channels at 50 kHz. Incoming sensor data generates 3.2 MB of raw waveform data per second.
- Memory Hierarchy Challenges: The processor runs at a core frequency of 200 MHz (
cycle). Main off-chip DRAM has an access latency of 60 ns. To prevent buffer overflows, the system incorporates a split Level 1 (L1) Cache and a unified Level 2 (L2) Cache. - Telemetry Latency: When a transmission line flashover or grid surge occurs, the system must trigger an electrical trip breaker within less than 500 nanoseconds via a prioritized hardware interrupt.
Questions: a) Formulate the core processor architecture. Contrast 32-bit RISC versus CISC design choices for this real-time embedded monitoring system, detailing register file sizing, instruction cycle predictability, and hardware DSP multiplication support. (6 Marks) b) Design and optimize the memory hierarchy. Given:
- L1 Cache latency
, Hit Ratio - L2 Cache latency
, Local Hit Ratio - Main DRAM latency
Formulate the Average Memory Access Time (AMAT) mathematical equation, compute the exact AMAT in nanoseconds, and evaluate the Write-Back versus Write-Through cache coherency policy for high-speed sensor streams. (7 Marks) c) Design the I/O subsystem, DMA channel architecture, and real-time interrupt handling: Explain how a circular dual-buffer DMA configuration allows continuous ADC sampling without CPU intervention, and specify the Vectored Priority Interrupt Controller (NVIC) configuration ensuring sub-500ns trip breaker response. (7 Marks)
View model solution
Computer Architecture Solution: Smart Electric Grid Telemetry Node
a) Core Processor Architecture: Embedded RISC vs. CISC Selection
1. Architectural Selection: 32-Bit RISC (ARM Cortex-M / RISC-V RV32IMF)
- Deterministic Instruction Timing: RISC architectures feature fixed-length 32-bit instructions executing in uniform, single-cycle or predictable pipelined stages. In power grid safety systems, deterministic execution is critical for real-time fault guarantees; CISC variable-length instructions (1 to 15 bytes in x86) cause unpredictable instruction decoding jitter.
- Register File Sizing (32 General-Purpose 32-bit Registers): A large orthogonal register file (
) minimizes memory spills. Time-critical sensor variables, Fast Fourier Transform (FFT) coefficients, and threshold limits are pinned permanently inside CPU registers. - Hardware DSP / Single-Cycle MAC (Multiply-Accumulate): Real-time RMS voltage calculation requires continuous quadratic summation (
). A hardware single-cycle MAC unit computes in , processing sensor streams without CPU stalls.
b) Memory Hierarchy Optimization and AMAT Calculation
1. Average Memory Access Time (AMAT) Formulation
For a two-level cache hierarchy, AMAT is:
where:(1 clock cycle) (4 clock cycles) (12 clock cycles)
2. Step-by-Step AMAT Calculation
- L2 Miss Penalty to DRAM:
- Overall AMAT:
- Conclusion: Cache hierarchy reduces effective memory access latency from
down to —a memory access speedup!
3. Cache Write Policy: Write-Back with Dirty Bit
- Write-Through: Every write must update both cache and main DRAM. At 3.2 MB/s continuous ADC input, Write-Through saturates the 60ns DRAM bus, creating severe bus contention stalls.
- Write-Back (Selected): Writes update only the high-speed L1/L2 cache blocks. A Dirty Bit flags modified lines; data is written back to DRAM only when a cache line is evicted. This isolates the CPU and DMA from slow DRAM latency during steady-state monitoring.
c) DMA Subsystem and Sub-500ns Interrupt Architecture
1. Circular Ping-Pong (Dual Buffer) DMA Configuration
[16-Channel ADC] | v (Hardware DREQ trigger) [DMA Controller Channel 0] | +---> [Buffer A (RAM)] ---> Processed by CPU (FFT & Surge Algorithm) | +---> [Buffer B (RAM)] ---> Concurrently filled by DMA (Zero CPU overhead)- Ping-Pong Buffer Mechanism: While the DMA engine autonomously writes incoming ADC samples into
Buffer A, the CPU processes completed waveform samples inBuffer B. - When
Buffer Afills, DMA controller asserts a half-transfer interrupt and automatically flips write pointers toBuffer B. Zero CPU cycles are wasted copying sensor bytes.
2. Nested Vectored Interrupt Controller (NVIC) for Sub-500ns Response
To guarantee breaker trip under
: - Zero-Latency Hardware Vectoring: The hardware surge comparator output is wired directly to Interrupt Line 0 (highest priority NMI). The NVIC hardware fetches the ISR address directly from the vector table in hardware without software polling.
- Hardware Register Stacking: In ARM Cortex-M, the processor hardware automatically pushes caller registers (
) onto the stack in 12 clock cycles ( ). - Dedicated Trip Breaker ISR Execution:
- At
, CPU enters ISR. - Executes single-cycle atomic GPIO set instruction:
*GPIO_BSRR = (1 << TRIP_PIN);(). - Total latency from physical fault detection to breaker trip pulse is
, well within the stringent safety requirement.
- At