Match each addressing mode in List I with a data element or an element of a data structure (in a high-level language) in List II:
List I: P. Immediate; Q. Indirect; R. Base with index; S. Base with offset/displacement.
List II: 1. Element of an array; 2. Pointer; 3. Element of a record; 4. Constant.
- (A)P-4, Q-3, R-1, S-2
- (B)P-4, Q-2, R-1, S-3
- (C)P-1, Q-4, R-3, S-2
- (D)P-2, Q-3, R-1, S-4
Immediate: the operand value is inside the instruction, i.e. a constant (P-4). Indirect: the instruction names a location that holds the address of the operand, i.e. a pointer (Q-2). Base with index: base = array start, index register = variable subscript, i.e. array element (R-1). Base with fixed offset: base = record start, constant displacement = field offset, i.e. record element (S-3). Answer: (B) P-4, Q-2, R-1, S-3.
Concept: Addressing modes map to high-level constructs. The trap is mixing index (variable offset, arrays) with displacement (fixed offset, struct fields).
Consider a processor P whose instruction set architecture is the load-store architecture. The instruction format is such that the first operand of any instruction is the destination operand. Which one of the following sequences of instructions corresponds to the high-level language statement Z = X + Y ? Note: X, Y, and Z are memory operands. R0, R1, and R2 are registers.
- (A)ADD Z, X, Y
- (B)LOAD R0, X; ADD Z, R0, Y
- (C)ADD R0, X, Y; STORE Z, R0
- (D)LOAD R0, X; LOAD R1, Y; ADD R2, R0, R1; STORE Z, R2
In a load-store architecture only LOAD and STORE access memory; ALU instructions operate on registers only. (A), (B) and (C) all give an ALU instruction a memory operand, which is not allowed. (D) loads X and Y into registers, adds register to register, then stores the result to Z. Answer: (D).
Concept: Load-store (RISC) ISAs forbid memory operands in arithmetic instructions. Options that look shorter are tempting but violate that rule.
Which one of the following dependencies among the register operands of different instructions can cause a data hazard in a pipelined processor?
- (A)Read-after-read
- (B)Read-after-write
- (C)Write-after-read
- (D)Write-after-write
A data hazard arises when an instruction needs a value that an earlier instruction has not yet produced: a read after write (true dependence). Read-after-read never conflicts since nothing changes. WAR and WAW are name dependences that cannot cause a hazard in the standard in-order pipeline where reads happen in an early stage and writes in the last stage, in program order. Answer: (B) Read-after-write.
Concept: RAW is the true data dependence. WAR/WAW matter only with out-of-order execution or writes in different stages; RAR is never a hazard.
The size of the physical address space of a processor is 2³² bytes. The capacity of a cache memory unit is 2²³ bytes. The cache block size is 128 bytes. The cache memory unit can be built as a direct mapped cache or as a K-way set-associative cache, where K = 2^L and L ∈ {1, 2, 3}. Let the length of the TAG field be M bits for the direct mapped cache, and N bits for the set-associative cache. Which one of the following options is true?
- (A)N = M + L
- (B)N = M - L
- (C)N = M + K
- (D)N = M - K
Offset = log₂128 = 7 bits. Lines = 2²³/2⁷ = 2¹⁶. Direct mapped: index 16 bits, tag M = 32 - 16 - 7 = 9. K-way with K = 2^L: sets = 2¹⁶/2^L, index 16 - L bits, tag N = 32 - (16 - L) - 7 = 9 + L. So N = M + L. Answer: (A) N = M + L.
Concept: Doubling associativity halves the number of sets: one index bit moves into the tag. The trap is adding K (the number of ways) instead of log₂K.
Consider a system that has a cache memory unit and a memory management unit (MMU). The address input to the cache memory is a physical address. The MMU has a translation lookaside buffer (TLB). Assume that when a page is evicted from the main memory, the corresponding blocks in the cache are marked as invalid. For a given memory reference, which of the following sequences of events can NEVER happen?
- (A)TLB miss, Page table hit, Cache hit
- (B)TLB hit, Page table miss, Cache hit
- (C)TLB miss, Page table miss, Cache hit
- (D)TLB miss, Page table miss, Cache miss
The TLB caches only translations of resident pages, so a TLB hit implies a valid page table entry: 'TLB hit, page table miss' can never happen (B). A page table miss (page fault) means the page is not in memory; since evicting a page invalidates its cache blocks and the cache is physically addressed, no block of that page can hit: 'TLB miss, page table miss, cache hit' can never happen (C). (A) is a normal TLB miss on a resident, cached page. (D) is a page fault followed by a cache miss after the page is brought in. Answer: (B), (C).
Concept: Order of lookups: TLB, then page table, then physically addressed cache. A page fault implies nothing about that page can be in the TLB or (here) the cache.
The EX stage of a pipelined processor performs the memory read operations for LOAD instructions, and the operations for the arithmetic and logic instructions. Let t_EX denote the time taken by the EX stage to perform the operation for an instruction. For each instruction type, the values of t_EX and M (the number of instructions of that type in a sequence of 100 instructions for a program P), are given in the table below. The duration of the pipeline clock cycle is 1 nanosecond. Assume that the latch time for the interstage buffers in the pipeline is negligible.
Instruction t_EX (ns) M
LOAD 1.8 15
IMUL 1.5 10
IDIV 2.5 5
FADD 1.7 10
FSUB 1.7 5
FMUL 2.8 15
FDIV 3.2 5
All other Less than 1.0 35
When program P is executed, the number of clock cycles for which the pipeline is stalled due to structural hazards in the EX stage is ______. (answer in integer)
With a 1 ns clock, an instruction occupies EX for ceil(t_EX) cycles, stalling the following instruction for ceil(t_EX) - 1 cycles. LOAD 2 cycles: 1 × 15 = 15. IMUL 2: 1 × 10 = 10. IDIV 3: 2 × 5 = 10. FADD 2: 1 × 10 = 10. FSUB 2: 1 × 5 = 5. FMUL 3: 2 × 15 = 30. FDIV 4: 3 × 5 = 15. Others 1 cycle: 0. Total = 15 + 10 + 10 + 10 + 5 + 30 + 15 = 95. Answer: 95.
Concept: A multi-cycle, non-pipelined functional unit is a structural hazard: extra cycles = ceil(t/clock) - 1 per instruction. Rounding 1.5 or 2.5 down is the usual slip.
Consider the following two statements about interrupt handling mechanisms in a CPU.
S1: In non-vectored interrupt mechanism, it usually takes more time to start the Interrupt Service Routine (ISR) when compared to that in a vectored interrupt mechanism.
S2: In daisy-chain interrupt mechanism, the CPU polls all the input devices individually to determine the source of the interrupt.
Which one of the following options is correct with respect to S1 and S2?
- (A)Both S1 and S2 are true
- (B)Both S1 and S2 are false
- (C)S1 is true and S2 is false
- (D)S1 is false and S2 is true
S1: In a non-vectored scheme the CPU jumps to a fixed location and software must identify the source, so starting the right ISR takes longer than with a vector supplied by the device. True. S2: In a daisy chain the interrupt-acknowledge signal propagates through devices in hardware and the first requesting device places its vector on the bus; the CPU does not poll each device. Polling is a different scheme. False. Answer: (C).
Concept: Distinguish vectored, non-vectored, polling and daisy-chain priority. The trap is treating daisy chaining as software polling; it is a hardware priority chain.
Consider a processor that has 16 general purpose registers and it uses 2-byte instruction format for all its instructions. Variable-sized opcodes are permitted. There are three different types of instructions; M-type, R-type, and C-type. Each M-type instruction has 2 register operands and a 6-bit immediate operand. Each R-type instruction has 3 register operands. Each C-type instruction has a register operand and a 6-bit offset value. If there are 2 unique M-type opcodes and 7 unique R-type opcodes, which one of the following options gives the maximum number of unique opcodes possible for C-type instructions?
- (A)8
- (B)4
- (C)64
- (D)16
Instruction = 16 bits, register field = 4 bits. M-type: 4+4+6 = 14 operand bits, 2-bit opcode. R-type: 12 operand bits, 4-bit opcode. C-type: 4+6 = 10 operand bits, 6-bit opcode. Expanding opcodes: 2² = 4 codes, M uses 2, leaving 2. Each extends by 2 bits: 2 x 4 = 8 R-level codes; R uses 7, leaving 1. That extends by 2 more bits: 1 x 4 = 4 C-type opcodes. Answer: (B) 4.
Concept: Expanding-opcode technique: unused shorter opcodes become prefixes for longer ones. The trap is answering 64 by giving C-type the full 6-bit opcode space.
Consider a system with a processor and a 4 KB direct mapped cache with block size of 16 bytes. The system has a 16 MB physical memory. Four words P, Q, R, and S are accessed by the processor in the same order 10 times. That is, there are a total of 40 memory references in the sequence P, Q, R, S, P, Q, R, S, ... Assume that the cache memory is initially empty. The physical addresses of the words are given below (1 word = 1 byte).
P: 0x845B32, Q: 0x845B26, R: 0x845B36, S: 0x846B32
Which of the following statements is/are true?
Note: 1K = 2¹⁰ and 1M = 2²⁰
- (A)Every access to P results in a cache miss
- (B)Every access to R results in a cache hit
- (C)Every access to Q results in a cache miss
- (D)Except the first access to S, all subsequent accesses to S result in cache hits
24-bit address; 256 lines, so offset 4 bits, index 8 bits, tag 12 bits. P: tag 845, index B3. Q: tag 845, index B2. R: tag 845, index B3 (same block as P). S: tag 846, index B3. Each round: P misses (S evicted it, or cold), Q hits after the first round (own line B2), R hits (block just loaded by P), S misses and evicts P's block. So P always misses, R always hits, Q misses only once, S always misses. Answer: (A) and (B).
Concept: Split addresses into tag/index/offset; words in the same block share a line, and different tags on the same index thrash. The trap is thinking R misses because it differs from P - it is in the same 16-byte block.
Consider a system with 1 MB physical memory and a word length of 1 byte. The system uses a direct mapped cache, with block numbers starting from 0. The word with physical address 0xA2C28 is mapped to the cache block number 176 (decimal). The maximum possible size of the cache (in KB) for this configuration is ___________. (answer in integer)
Note: 1K = 2¹⁰ and 1M = 2²⁰
Address is 20 bits: 0xA2C28 = 1010 0010 1100 0010 1000. The index field is a contiguous bit range just above the offset whose value must be 176 = 10110000₂. The pattern 10110000 occurs at bits 13..6 (counting bit 0 as LSB), so the offset is bits 5..0 (block size 64 bytes). Leading zeros extend the index upward: bits 16, 15, 14 are 0, bit 17 is 1. So the index can be bits 16..6 = 11 bits, value 00010110000₂ = 176. Cache size = 2¹¹ blocks x 64 B = 128 KB. Answer: 128.
Concept: Index bits of the address must equal the block number; the cache is largest when the index is widened with leading zeros as far as possible. The trap is assuming a fixed block size or ignoring that leading zeros may join the index.
A non-pipelined instruction execution unit that operates at 1.6 GHz clock takes an average of 5 clock cycles to complete the execution of an instruction. To improve the performance, the system was pipelined with a goal of achieving an average throughput of one instruction per clock cycle. However, it could operate only at 1.2 GHz due to pipeline overheads. While executing a program in the pipelined design, 30% of instructions encountered a stall of 2 cycles due to pipeline hazards. The speed-up obtained by the pipelined design over the non-pipelined one for this program is ___________. (rounded off to two decimal places)
Note: 1G = 10⁹
Non-pipelined time per instruction = 5 / 1.6 GHz = 3.125 ns. Pipelined CPI = 1 + 0.3 x 2 = 1.6, time = 1.6 / 1.2 GHz = 1.333 ns. Speed-up = 3.125 / 1.333 = 2.34. Answer: 2.34 (accepted range 2.3 to 2.4).
Concept: Speed-up compares execution time per instruction (CPI x cycle time), so the slower pipelined clock must be included. Traps: using 5/1.6 cycles ratio alone (3.125) or ignoring stalls (3.75).
Suppose a program is running on a non-pipelined single processor computer system. The computer is connected to an external device that can interrupt the processor asynchronously. The processor needs to execute the interrupt service routine (ISR) to serve this interrupt. The following steps (not necessarily in order) are taken by the processor when the interrupt arrives:
(i) The processor saves the content of the program counter.
(ii) The program counter is loaded with the start address of the ISR.
(iii) The processor finishes the present instruction.
Which ONE of the following is the CORRECT sequence of steps?
- (A)(iii), (i), (ii)
- (B)(i), (iii), (ii)
- (C)(i), (ii), (iii)
- (D)(iii), (ii), (i)
Interrupts are recognised only at instruction boundaries, so the current instruction completes first (iii). Then the return address in the PC must be saved (i), otherwise it would be lost. Only then is the PC loaded with the ISR start address (ii). Sequence: (iii), (i), (ii). Answer: (A).
Concept: Interrupt handling order. Loading the PC before saving it destroys the return address, and saving before finishing the instruction would save a mid-instruction state.
A partial data path of a processor is given in the figure, where RA, RB, and RZ are 32-bit registers. Which option(s) is/are CORRECT related to arithmetic operations using the data path as shown?
Data path (from the figure): Mux_A selects between register RA and a 32-bit immediate value (control: Select RA/immediate). Mux_B selects between register RB and a 32-bit immediate value (control: Select RB/immediate). The outputs of Mux_A and Mux_B are the two ALU inputs (ALU control lines select the operation), and the ALU output is written to RZ.
- (A)The data path can implement arithmetic operations involving two registers.
- (B)The data path can implement arithmetic operations involving one register and one immediate value.
- (C)The data path can implement arithmetic operations involving two immediate values.
- (D)The data path can only implement arithmetic operations involving one register and one immediate value.
Each ALU input has its own mux with an independent select. RA and RB selected: register-register (A). RA with immediate on Mux_B, or immediate on Mux_A with RB: register-immediate (B). Both muxes on immediates: two immediate values (C). Since all three combinations are possible, the word "only" makes (D) false. Answer: (A), (B), (C).
Concept: Enumerate the mux select combinations: 2 x 2 = 4 input pairings. The trap is (D), which ignores that each mux can still pick its register.
Consider a memory system with 1M bytes of main memory and 16K bytes of cache memory. Assume that the processor generates 20-bit memory address, and the cache block size is 16 bytes. If the cache uses direct mapping, how many bits will be required to store all the tag values? [Assume memory is byte addressable, 1K = 2¹⁰, 1M = 2²⁰.]
- (A)6 × 2¹⁰
- (B)8 × 2¹⁰
- (C)2¹²
- (D)2¹⁴
Block offset: 16 = 2⁴ bytes, 4 bits. Number of cache lines: 16K / 16 = 2¹⁰, so 10 index bits. Tag = 20 - 10 - 4 = 6 bits. One tag per line: 6 x 2¹⁰ bits in total. Answer: 6 × 2¹⁰ (A).
Concept: Direct-mapped address split: tag | index | offset. Tag storage = tag bits x number of lines. Trap: using cache bytes instead of lines as the multiplier.
A processor has 64 general-purpose registers and 50 distinct instruction types. An instruction is encoded in 32-bits. What is the maximum number of bits that can be used to store the immediate operand for the given instruction?
ADD R1, #25 // R1 = R1 + 25
- (A)16
- (B)20
- (C)22
- (D)24
Opcode: 50 instruction types need ceil(log₂ 50) = 6 bits. Register field: 64 registers need 6 bits (R1 is both source and destination, one field). Immediate: 32 - 6 - 6 = 20 bits. Answer: 20 (B).
Concept: Instruction format field widths. The trap is allotting two register fields (giving 14) when the instruction names only one register.
A computer has a memory hierarchy consisting of two-level cache (L1 and L2) and a main memory. If the processor needs to access data from memory, it first looks into L1 cache. If the data is not found in L1 cache, it goes to L2 cache. If it fails to get the data from L2 cache, it goes to main memory, where the data is definitely available. Hit rates and access times of various memory units are shown in the figure. The average memory access time in nanoseconds (ns) is ________. (rounded off to two decimal places)
Figure data:
L1 cache: hit rate = 95%, access time = 10 ns
L2 cache: hit rate = 85%, access time (including L1 cache miss penalty) = 20 ns
Main memory: access time (including L1 and L2 cache miss penalty) = 200 ns
Each access time already includes the earlier misses, so weight each by the probability that the access is served there. L1: 0.95 x 10 = 9.5. L2: 0.05 x 0.85 x 20 = 0.85. Memory: 0.05 x 0.15 x 200 = 1.5. AMAT = 9.5 + 0.85 + 1.5 = 11.85 ns. Answer: 11.85.
Concept: When given times include miss penalties, do not add L1 and L2 times again. The trap is the hierarchical sum 10 + 0.05(20 + 0.15 x 200), which double counts.
Which of the following is/are part of an Instruction Set Architecture of a processor?
- (A)The size of the cache memory
- (B)The clock frequency of the processor
- (C)The number of cache memory levels
- (D)The total number of registers
The ISA is the programmer-visible contract: instructions, addressing modes, data types and the architectural registers. The total number of registers is part of it. Cache size, number of cache levels and clock frequency are implementation (microarchitecture) choices invisible to the instruction set and can differ between processors with the same ISA. Answer: (D).
Concept: Separate architecture from organization. The trap is treating performance features like caches or clock speed as part of the ISA.
For a direct-mapped cache, 4 bits are used for the tag field and 12 bits are used to index into a cache block. The size of each cache block is one byte. Assume that there is no other information stored for each cache block. Which ONE of the following is the CORRECT option for the sizes of the main memory and the cache memory in this system (byte addressable), respectively?
- (A)64 KB and 4 KB
- (B)128 KB and 16 KB
- (C)64 KB and 8 KB
- (D)128 KB and 6 KB
Block size is 1 byte, so there are no offset bits. Address = tag 4 + index 12 = 16 bits, so main memory = 2¹⁶ bytes = 64 KB. The cache has 2¹² blocks of 1 byte = 4 KB (tags are not counted as no other information is stored). Answer: (A) 64 KB and 4 KB.
Concept: Direct-mapped address split: tag | index | offset. With one-byte blocks the offset is 0 bits, a detail that is easy to overlook.
Given a computing system with two levels of cache (L1 and L2) and a main memory. The first level (L1) cache access time is 1 nanosecond (ns) and the "hit rate" for L1 cache is 90% while the processor is accessing the data from L1 cache. Whereas, for the second level (L2) cache, the "hit rate" is 80% and the "miss penalty" for transferring data from L2 cache to L1 cache is 10 ns. The "miss penalty" for the data to be transferred from main memory to L2 cache is 100 ns. Then the average memory access time in this system in nanoseconds is ___________ . (rounded off to one decimal place) A 5-stage instruction pipeline has stage delays of 180, 250, 150, 170, and 250, respectively, in nanoseconds. The delay of an inter-stage latch is 10 nanoseconds.
AMAT = L1 time + L1 miss rate x (L1 miss penalty), where L1 miss penalty = L2 time + L2 miss rate x (L2 miss penalty). L1 miss penalty = 10 + 0.2 x 100 = 30 ns. AMAT = 1 + 0.1 x 30 = 4 ns. Answer: 4.0.
Concept: Nested miss-penalty formula with local hit rates. The trap is multiplying absolute times for every level or treating 80% as a global hit rate.
A 5-stage instruction pipeline has stage delays of 180, 250, 150, 170, and 250, respectively, in nanoseconds. The delay of an inter-stage latch is 10 nanoseconds. Assume that there are no pipeline stalls due to branches and other hazards. The time taken to process 1000 instructions in microseconds is __________. (rounded off to two decimal places)
Clock cycle = max stage delay + latch delay = 250 + 10 = 260 ns. For k = 5 stages and n = 1000 instructions, cycles = k + n - 1 = 1004. Time = 1004 x 260 ns = 261040 ns = 261.04 µs. The accepted range 260.2 to 261.2 covers this; ignoring the pipeline fill (1000 x 260 = 260.00 µs) falls outside it. Answer: 261.04.
Concept: Pipeline cycle time is set by the slowest stage plus latch overhead, and n instructions need k + n - 1 cycles. Forgetting the latch delay or the fill cycles is the trap.
An application executes 6.4 × 10⁸ number of instructions in 6.3 seconds. There are four types of instructions, the details of which are given in the table. The duration of a clock cycle in nanoseconds is _________. (rounded off to one decimal place)
Instruction type CPI Number of instructions executed
Branch 2 2.25 × 10⁸
Load 5 1.20 × 10⁸
Store 4 1.65 × 10⁸
Arithmetic 3 1.30 × 10⁸
Total cycles = (2 x 2.25 + 5 x 1.20 + 4 x 1.65 + 3 x 1.30) x 10⁸ = (4.5 + 6.0 + 6.6 + 3.9) x 10⁸ = 21 x 10⁸. Clock period = 6.3 s / (2.1 x 10⁹) = 3 x 10⁻⁹ s. Answer: 3.0.
Concept: CPU time = total cycles x cycle time, with total cycles the CPI-weighted instruction counts. The trap is using an unweighted average CPI.
Which one of the following statements is FALSE?
- (A)In the cycle stealing mode of DMA, one word of data is transferred between an I/O device and main memory in a stolen cycle
- (B)For bulk data transfer, the burst mode of DMA has a higher throughput than the cycle stealing mode
- (C)Programmed I/O mechanism has a better CPU utilization than the interrupt driven I/O mechanism
- (D)The CPU can start executing an interrupt service routine faster with vectored interrupts than with non-vectored interrupts
(A) is true: cycle stealing moves one word per stolen bus cycle. (B) is true: burst mode holds the bus for the whole block, so it has higher throughput. (C) is false: programmed I/O busy-waits on the device, wasting CPU cycles, so interrupt-driven I/O gives better CPU utilization. (D) is true: a vectored interrupt supplies the ISR address directly, avoiding polling. Answer: (C).
Concept: Programmed I/O keeps the CPU polling; interrupts free it until the device is ready. The trap is reading 'programmed' as more efficient.
Consider a 5-stage pipelined processor with Instruction Fetch (IF), Instruction Decode (ID), Execute (EX), Memory Access (MEM), and Register Writeback (WB) stages. Which of the following statements about forwarding is/are CORRECT?
- (A)In a pipelined execution, forwarding means the result from a source stage of an earlier instruction is passed on to the destination stage of a later instruction
- (B)In forwarding, data from the output of the MEM stage can be passed on to the input of the EX stage of the next instruction
- (C)Forwarding cannot prevent all pipeline stalls
- (D)Forwarding does not require any extra hardware to retrieve the data from the pipeline stages
(A) True: that is the definition of forwarding (bypassing). (B) True: the MEM output (e.g., a loaded value or EX/MEM result) can be fed to the EX input of a following instruction. (C) True: a load followed immediately by a use still needs a one-cycle stall. (D) False: forwarding needs extra multiplexers, paths and hazard-detection logic. Answer: (A), (B), (C).
Concept: Forwarding removes most RAW stalls but not the load-use stall, and it costs hardware. The trap is believing it eliminates all stalls.
Consider two set-associative cache memory architectures: WBC, which uses the write back policy, and WTC, which uses the write through policy. Both of them use the LRU (Least Recently Used) block replacement policy. The cache memory is connected to the main memory. Which of the following statements is/are TRUE?
- (A)A read miss in WBC never evicts a dirty block
- (B)A read miss in WTC never triggers a write back operation of a cache block to main memory
- (C)A write hit in WBC can modify the value of the dirty bit of a cache block
- (D)A write miss in WTC always writes the victim cache block to main memory before loading the missed block to the cache
(A) False: in a write-back cache the LRU victim of a read miss may be dirty and must be written back. (B) True: write-through keeps memory current, so blocks are never dirty and evictions need no write-back. (C) True: a write hit in write-back sets the dirty bit. (D) False: write-through has no dirty victims to write back, and with no-write-allocate a write miss does not even load the block. Answer: (B), (C).
Concept: Write-back defers memory updates using a dirty bit; write-through updates memory on every write. The trap is (A), forgetting that dirty blocks can be chosen as victims on reads.
The baseline execution time of a program on a 2 GHz single core machine is 100 nanoseconds (ns). The code corresponding to 90% of the execution time can be fully parallelized. The overhead for using an additional core is 10 ns when running on a multicore system. Assume that all cores in the multicore system run their share of the parallelized code for an equal amount of time. The number of cores that minimize the execution time of the program is ________
Serial part = 10 ns, parallel part = 90 ns. With n cores: time = 10 + 90/n + 10(n − 1). n = 1: 100. n = 2: 10 + 45 + 10 = 65. n = 3: 10 + 30 + 20 = 60. n = 4: 10 + 22.5 + 30 = 62.5. n = 5: 10 + 18 + 40 = 68. Minimum at n = 3. Answer: 3.
Concept: Amdahl's law with a per-core overhead has an optimum where added overhead outweighs the parallel saving. The trap is charging the overhead for every core, including the first.
A given program has 25% load/store instructions. Suppose the ideal CPI (cycles per instruction) without any memory stalls is 2. The program exhibits 2% miss rate on instruction cache and 8% miss rate on data cache. The miss penalty is 100 cycles. The speedup (rounded off to two decimal places) achieved with a perfect cache (i.e., with NO data or instruction cache misses) is _________
Memory stall cycles per instruction = instruction fetch misses + data misses = 1 × 0.02 × 100 + 0.25 × 0.08 × 100 = 2 + 2 = 4. Real CPI = 2 + 4 = 6. Perfect cache CPI = 2. Speedup = 6/2 = 3.00. Answer: 3.
Concept: Every instruction is fetched, but only loads/stores access the data cache. The trap is applying the data miss rate to all instructions.
Consider a computer with a 4 MHz processor. Its DMA controller can transfer 8 bytes in 1 cycle from a device to main memory through cycle stealing at regular intervals. Which one of the following is the data transfer rate (in bits per second) of the DMA controller if 1% of the processor cycles are used for DMA?
- (A)2,56,000
- (B)3,200
- (C)25,60,000
- (D)32,000
Processor cycles per second = 4 × 10⁶. DMA steals 1% of them: 4 × 10⁴ cycles per second. Each cycle moves 8 bytes = 64 bits. Rate = 4 × 10⁴ × 64 = 2,560,000 bits per second, written in Indian digit grouping as 25,60,000. Answer: (C) 25,60,000.
Concept: Cycle-stealing DMA rate = fraction of cycles × clock rate × bits per cycle. Traps: forgetting to convert bytes to bits, or misreading the Indian digit grouping in the options.
An instruction format has the following structure:
Instruction Number: Opcode destination reg, source reg-1, source reg-2
Consider the following sequence of instructions to be executed in a pipelined processor:
I1: DIV R3, R1, R2
I2: SUB R5, R3, R4
I3: ADD R3, R5, R6
I4: MUL R7, R3, R8
Which of the following statements is/are TRUE?
- (A)There is a RAW dependency on R3 between I1 and I2
- (B)There is a WAR dependency on R3 between I1 and I3
- (C)There is a RAW dependency on R3 between I2 and I3
- (D)There is a WAW dependency on R3 between I3 and I4
I1 writes R3 and I2 reads it: RAW on R3 (A true). I1 and I3 both write R3: that is WAW, not WAR (B false). I2 reads R3 and later I3 writes it: WAR, not RAW (C false). I3 writes R3 and I4 reads it: RAW, not WAW (D false). Answer: (A).
Concept: Classify by order of access: write-then-read is RAW, read-then-write is WAR, write-then-write is WAW. Each wrong option names a real dependency with the wrong type.
A processor with 16 general purpose registers uses a 32-bit instruction format. The instruction format consists of an opcode field, an addressing mode field, two register operand fields, and a 16-bit scalar field. If 8 addressing modes are to be supported, the maximum number of unique opcodes possible for every addressing mode is _________
Register fields: 16 registers need 4 bits each, 2 × 4 = 8 bits. Addressing mode: 8 modes need 3 bits. Scalar: 16 bits. Opcode bits = 32 − 8 − 3 − 16 = 5, so 2⁵ = 32 opcodes for every addressing mode. Answer: 32.
Concept: Instruction field budgeting. The addressing-mode field is separate, so each mode gets the full opcode space.
A non-pipelined instruction execution unit operating at 2 GHz takes an average of 6 cycles to execute an instruction of a program P. The unit is then redesigned to operate on a 5-stage pipeline at 2 GHz. Assume that the ideal throughput of the pipelined unit is 1 instruction per cycle. In the execution of program P, 20% instructions incur an average of 2 cycles stall due to data hazards and 20% instructions incur an average of 3 cycles stall due to control hazards. The speedup (rounded off to one decimal place) obtained by the pipelined design over the non-pipelined design is _________
Pipelined CPI = 1 + 0.2 × 2 + 0.2 × 3 = 1 + 0.4 + 0.6 = 2. Non-pipelined CPI = 6. The clock is the same 2 GHz, so speedup = 6 / 2 = 3.0. Answer: 3.0.
Concept: Effective CPI = ideal CPI + average stall cycles per instruction. Using 5 (stage count) instead of the given 6 cycles is the trap.
A processor uses a 32-bit instruction format and supports byte-addressable memory access. The ISA of the processor has 150 distinct instructions. The instructions are equally divided into two types, namely R-type and I-type, whose formats are shown below.
R-type Instruction Format: OPCODE | UNUSED | DST Register | SRC Register 1 | SRC Register 2
I-type Instruction Format: OPCODE | DST Register | SRC Register | # Immediate value/address
In the OPCODE, 1 bit is used to distinguish between I-type and R-type instructions and the remaining bits indicate the operation. The processor has 50 architectural registers, and all register fields in the instructions are of equal size.
Let X be the number of bits used to encode the UNUSED field, Y be the number of bits used to encode the OPCODE field, and Z be the number of bits used to encode the immediate value/address field. The value of X + 2Y + Z is ________
75 instructions of each type need ⌈log₂ 75⌉ = 7 operation bits, plus 1 type bit: Y = 8. 50 registers need 6 bits per register field. R-type: 8 + X + 3 × 6 = 32, so X = 6. I-type: 8 + 2 × 6 + Z = 32, so Z = 12. X + 2Y + Z = 6 + 16 + 12 = 34. Answer: 34.
Concept: Field budgeting with a type bit: the 7 operation bits encode 75 operations per type, not 150. Using 8 operation bits gives Y = 9 and a wrong total.
Consider a 3-stage pipelined processor having a delay of 10 ns (nanoseconds), 20 ns, and 14 ns, for the first, second, and the third stages, respectively. Assume that there is no other delay and the processor does not suffer from any pipeline hazards. Also assume that one instruction is fetched every cycle. The total execution time for executing 100 instructions on this processor is ns.
The clock cycle must accommodate the slowest stage: max(10, 20, 14) = 20 ns. For k = 3 stages and n = 100 instructions with no hazards, total cycles = k + n - 1 = 3 + 99 = 102. Time = 102 × 20 = 2040 ns. Answer: 2040.
Concept: Pipeline time = (k + n - 1) × cycle time, with the cycle set by the slowest stage. Traps: using the sum of stage delays (44 ns) as the cycle, or using n × k.
A keyboard connected to a computer is used at a rate of 1 keystroke per second. The computer system polls the keyboard every 10 ms (milli seconds) to check for a keystroke and consumes 100 μs (micro seconds) for each poll. If it is determined after polling that a key has been pressed, the system consumes an additional 200 μs to process the keystroke. Let T1 denote the fraction of a second spent in polling and processing a keystroke. In an alternative implementation, the system uses interrupts instead of polling. An interrupt is raised for every keystroke. It takes a total of 1 ms for servicing an interrupt and processing a keystroke. Let T2 denote the fraction of a second spent in servicing the interrupt and processing a keystroke. The ratio T1/T2 is ________. (Rounded off to one decimal place)
Polling: 1 s / 10 ms = 100 polls per second, each 100 μs, giving 10,000 μs = 10 ms. Plus one keystroke processed: 200 μs. T1 = 10.2 ms per second. Interrupts: one keystroke per second, 1 ms each, so T2 = 1 ms per second. T1/T2 = 10.2 / 1 = 10.2. Answer: 10.2.
Concept: Polling costs time even when nothing happens; interrupts cost only per event. Remember to add the 200 μs processing for the one actual keystroke.
Consider the given C-code and its corresponding assembly code, with a few operands U1-U4 being unknown. Some useful information as well as the semantics of each unique assembly instruction is annotated as inline comments in the code. The memory is byte-addressable. Which one of the following options is a CORRECT replacement for operands in the position (U1, U2, U3, U4) in the above assembly code?
//C-code
int a[10], b[10], i;
// int is 32-bit
for (i=0; i<10;i++)
a[i] = b[i] * 8;
;assembly-code (; indicates comments)
;r1-r5 are 32-bit integer registers
;initialize r1=0, r2=10
;initialize r3, r4 with base address of a, b
L01: jeq r1, r2, end ;if(r1==r2) goto end
L02: lw r5, 0(r4) ;r5 <- Memory[r4+0]
L03: shl r5, r5, U1 ;r5 <- r5 << U1
L04: sw r5, 0(r3) ;Memory[r3+0] <- r5
L05: add r3, r3, U2 ;r3 <- r3+U2
L06: add r4, r4, U3
L07: add r1, r1, 1
L08: jmp U4 ;goto U4
L09: end- (A)(8, 4, 1, L02)
- (B)(3, 4, 4, L01)
- (C)(8, 1, 1, L02)
- (D)(3, 1, 1, L01)
Multiplying by 8 = 2³ is a left shift by 3, so U1 = 3. int is 32 bits = 4 bytes and memory is byte-addressable, so the pointers to a[i] and b[i] advance by 4 each iteration: U2 = 4, U3 = 4. The loop must re-test the condition r1 == r2 every iteration, so it jumps back to L01: U4 = L01 (jumping to L02 would never exit). Answer: (B) (3, 4, 4, L01).
Concept: Tests strength reduction (×8 = <<3) and byte addressing (stride = sizeof(int) = 4). The traps are shifting by 8 and stepping pointers by 1.
A 4 kilobyte (KB) byte-addressable memory is realized using four 1 KB memory blocks X1, X2, X3, X4. Two input address lines (IA4 and IA3) are connected to the chip select (CS) port of these memory blocks through a 2-to-4 decoder: IA4 drives decoder input A1, IA3 drives A0, and decoder outputs Q0, Q1, Q2, Q3 drive the CS of X1, X2, X3, X4 respectively. The remaining ten input address lines IA11-IA5 and IA2-IA0 are connected (as a 10-bit bus, IA11 as MSB and IA0 as LSB) to the address port of each block. The chip select (CS) is active high. The input memory addresses (IA11-IA0), in decimal, for the starting locations (Addr=0) of each block are among the options given below. Which one of the following options is CORRECT?
- (A)(0, 1, 2, 3)
- (B)(0, 1024, 2048, 3072)
- (C)(0, 8, 16, 24)
- (D)(0, 0, 0, 0)
Addr = 0 inside a block means all ten address-port lines (IA11-IA5, IA2-IA0) are 0. Only IA4 and IA3 vary, selecting the block. X1: IA4 IA3 = 00, address 0. X2: 01, IA3 = 1, address 2³ = 8. X3: 10, IA4 = 1, address 2⁴ = 16. X4: 11, address 16 + 8 = 24. Answer: (C) (0, 8, 16, 24).
Concept: Chip-select lines taken from the middle of the address bus interleave blocks. The trap is (B), which assumes the top two bits (IA11, IA10) select the block.
An 8-way set associative cache of size 64 KB (1 KB = 1024 bytes) is used in a system with 32-bit address. The address is sub-divided into TAG, INDEX, and BLOCK OFFSET. The number of bits in the TAG is .
Let the block size be 2^b bytes. Number of sets = cache size / (ways × block size) = 2¹⁶ / (2³ × 2^b) = 2^(13 - b), so INDEX = 13 - b bits and OFFSET = b bits. INDEX + OFFSET = 13 regardless of block size. TAG = 32 - 13 = 19. Answer: 19.
Concept: Index + offset bits equal log2(cache size / associativity), so the block size, which is not given, cancels out. Students often stall looking for the missing block size.
Which one of the following facilitates transfer of bulk data from hard disk to main memory with the highest throughput?
- (A)DMA based I/O transfer
- (B)Interrupt driven I/O transfer
- (C)Polling based I/O transfer
- (D)Programmed I/O transfer
In programmed (polling) I/O the CPU moves every word and busy-waits; interrupt-driven I/O still has the CPU move each word, with interrupt overhead per transfer. DMA lets the controller move a whole block directly between the device and memory, interrupting the CPU once at the end, so it gives the highest throughput for bulk transfers. Answer: (A) DMA based I/O transfer.
Concept: DMA is designed for block transfers. Interrupt-driven I/O helps CPU utilisation for slow devices but does not beat DMA for bulk data.
Let WB and WT be two set associative cache organizations that use LRU algorithm for cache block replacement. WB is a write back cache and WT is a write through cache. Which of the following statements is/are FALSE?
- (A)Each cache block in WB and WT has a dirty bit.
- (B)Every write hit in WB leads to a data transfer from cache to main memory.
- (C)Eviction of a block from WT will not lead to data transfer from cache to main memory.
- (D)A read miss in WB will never lead to eviction of a dirty block from WB.
(A) False: only a write-back cache needs a dirty bit; write-through keeps memory current. (B) False: a write hit in WB updates only the cache and sets the dirty bit; memory is written on eviction. (C) True: WT memory is always up to date, so eviction just discards the block. (D) False: a read miss in WB may choose a dirty LRU victim, which must be written back. The FALSE statements are (A), (B), (D). Answer: (A), (B), (D).
Concept: Write-back defers memory updates using a dirty bit; write-through writes every store to memory. Note the question asks for FALSE statements.
A cache memory that has a hit rate of 0.8 has an access latency 10 ns and miss penalty 100 ns. An optimization is done on the cache to reduce the miss rate. However, the optimization results in an increase of cache access latency to 15 ns, whereas the miss penalty is not affected. The minimum hit rate (rounded off to two decimal places) needed after the optimization such that it should not increase the average memory access time is _____________.
AMAT = hit time + miss rate × miss penalty. Before: 10 + 0.2 × 100 = 30 ns. After: 15 + (1 − h) × 100 must be ≤ 30, so (1 − h) × 100 ≤ 15, giving 1 − h ≤ 0.15 and h ≥ 0.85. Answer: 0.85.
Concept: Trade-off between hit time and miss rate in the AMAT formula. Use the same AMAT model before and after; mixing models changes the result.
Consider a system with 2 KB direct mapped data cache with a block size of 64 bytes. The system has a physical address space of 64 KB and a word length of 16 bits. During the execution of a program, four data words P, Q, R, and S are accessed in that order 10 times (i.e., PQRSPQRS...). Hence, there are 40 accesses to data cache altogether. Assume that the data cache is initially empty and no other data words are accessed by the program. The addresses of the first bytes of P, Q, R, and S are 0xA248, 0xC28A, 0xCA8A, and 0xA262, respectively. For the execution of the above program, which of the following statements is/are TRUE with respect to the data cache?
- (A)Every access to S is a hit.
- (B)Once P is brought to the cache it is never evicted.
- (C)At the end of the execution only R and S reside in the cache.
- (D)Every access to R evicts Q from the cache.
64 KB space: 16-bit addresses. 2 KB / 64 B = 32 lines, so 6 offset bits, 5 index bits, 5 tag bits. Block number = address / 64: P 0xA248 → block 649, line 649 mod 32 = 9. Q 0xC28A → block 778, line 10. R 0xCA8A → block 810, line 10. S 0xA262 → block 649, line 9 - the same block as P. Round 1: P miss, Q miss, R miss (evicts Q), S hit. Each later round: P hit, Q miss (evicts R), R miss (evicts Q), S hit. So every S access hits (A true), P's block is never evicted (B true), every R access evicts Q (D true). At the end line 9 holds P and S and line 10 holds R, so P is also resident and (C) is false. Answer: (A), (B), (D).
Concept: Split the address into tag, index and offset. The trap is missing that S lies in the same 64-byte block as P.
A processor X₁ operating at 2 GHz has a standard 5-stage RISC instruction pipeline having a base CPI (cycles per instruction) of one without any pipeline hazards. For a given program P that has 30% branch instructions, control hazards incur 2 cycles stall for every branch. A new version of the processor X₂ operating at same clock frequency has an additional branch predictor unit (BPU) that completely eliminates stalls for correctly predicted branches. There is neither any savings nor any additional stalls for wrong predictions. There are no structural hazards and data hazards for X₁ and X₂. If the BPU has a prediction accuracy of 80%, the speed up (rounded off to two decimal places) obtained by X₂ over X₁ in executing P is____________.
X₁: CPI = 1 + 0.3 × 2 = 1.6. X₂: only the 20% mispredicted branches stall, CPI = 1 + 0.3 × 0.2 × 2 = 1.12. Same clock, so speed up = 1.6 / 1.12 ≈ 1.43. Answer: 1.43 (accepted range 1.42 to 1.45).
Concept: Effective CPI = base CPI + branch fraction × stall fraction × penalty. The trap is applying the 80% to all instructions rather than to branches.
Consider the following processor design characteristics.
I. Register-to-register arithmetic operations only
II. Fixed-length instruction format
III. Hardwired control unit
Which of the characteristics above are used in the design of a RISC processor?
- (A)I and II only
- (B)II and III only
- (C)I and III only
- (D)I, II and III
RISC uses a load-store architecture, so arithmetic operates only on registers (I). Instructions have a fixed length to simplify fetch, decode and pipelining (II). The small, simple instruction set allows a fast hardwired control unit instead of microprogramming (III). All three are RISC characteristics. Answer: (D) I, II and III.
Concept: RISC traits: load-store, fixed-length simple instructions, hardwired control, many registers, pipelining. Microprogrammed control and variable-length formats are CISC traits. The trap is thinking hardwired control is optional for RISC.
The following are some events that occur after a device controller issues an interrupt while process L is under execution.
(P) The processor pushes the process status of L onto the control stack.
(Q) The processor finishes the execution of the current instruction.
(R) The processor executes the interrupt service routine.
(S) The processor pops the process status of L from the control stack.
(T) The processor loads the new PC value based on the interrupt.
Which one of the following is the correct order in which the events above occur?
- (A)QPTRS
- (B)PTRSQ
- (C)TRPQS
- (D)QTPRS
Interrupts are checked at instruction boundaries, so the current instruction finishes first (Q). The state of L is saved on the stack (P) before the PC is overwritten with the ISR address (T). The ISR runs (R), and on return the saved status is popped (S). Order: Q P T R S. Answer: (A).
Concept: Interrupt handling sequence: complete instruction, save context, vector to ISR, run ISR, restore context. The trap is (D), loading the new PC before saving the old state, which would lose L's return address.
A 32-bit wide main memory unit with a capacity of 1 GB is built using 256M × 4-bit DRAM chips. The number of rows of memory cells in the DRAM chip is 2¹⁴. The time taken to perform one refresh operation is 50 nanoseconds. The refresh period is 2 milliseconds. The percentage (rounded to the closest integer) of the time available for performing the memory read/write operations in the main memory unit is __________.
Each chip is 256M × 4 bits = 128 MB, so 1 GB needs 8 chips, and a 32-bit word needs 32/4 = 8 chips side by side: all 8 form one bank and are refreshed in parallel. Refreshing all 2¹⁴ rows takes 16384 × 50 ns = 819.2 µs in every 2 ms. Fraction spent refreshing = 0.8192/2 = 40.96%. Available = 59.04%, about 59. Answer: 59 (accepted range 59 to 60).
Concept: Refresh overhead = rows × refresh time / refresh period, with chips in a bank refreshed together. The trap is multiplying by the number of chips, as though they refreshed one after another.
The size of the physical address space of a processor is 2ᴾ bytes. The word length is 2ᵂ bytes. The capacity of cache memory is 2ᴺ bytes. The size of each cache block is 2ᴹ words. For a K-way set-associative cache memory, the length (in number of bits) of the tag field is
- (A)P - N - log₂K
- (B)P - N + log₂K
- (C)P - N - M - W - log₂K
- (D)P - N - M - W + log₂K
Block size = 2ᴹ words × 2ᵂ bytes = 2^(M+W) bytes, so the offset is M + W bits. Number of blocks = 2^(N-M-W); number of sets = 2^(N-M-W)/K, so the set index is N - M - W - log₂K bits. Tag = P - (N - M - W - log₂K) - (M + W) = P - N + log₂K. Answer: (B).
Concept: Address = tag + set index + block offset; higher associativity means fewer sets and a longer tag. The trap is the sign of log₂K, or forgetting to convert block size from words to bytes.
The instruction pipeline of a RISC processor has the following stages: Instruction Fetch (IF), Instruction Decode (ID), Operand Fetch (OF), Perform Operation (PO) and Writeback (WB). The IF, ID, OF and WB stages take 1 clock cycle each for every instruction. Consider a sequence of 100 instructions. In the PO stage, 40 instructions take 3 clock cycles each, 35 instructions take 2 clock cycles each, and the remaining 25 instructions take 1 clock cycle each. Assume that there are no data hazards and no control hazards.
The number of clock cycles required for completion of execution of the sequence of instructions is ______.
PO is the only multi-cycle stage, and the 1-cycle stages before it always have the next instruction ready, so PO is busy continuously once it starts. The first instruction spends 3 cycles in IF, ID, OF before reaching PO. PO then needs 40 × 3 + 35 × 2 + 25 × 1 = 120 + 70 + 25 = 215 cycles for all instructions back to back. The last instruction needs 1 more cycle in WB. Total = 3 + 215 + 1 = 219. Answer: 219.
Concept: With one variable-latency stage, total time = fill time before it + sum of its busy times + drain time after it. The trap is using the standard (k + n - 1) formula with the slowest stage time, which gives 3 × 104 = 312.
A processor has 16 integer registers (R0, R1, ..., R15) and 64 floating point registers (F0, F1, ..., F63). It uses a 2-byte instruction format. There are four categories of instructions: Type-1, Type-2, Type-3, and Type-4. Type-1 category consists of four instructions, each with 3 integer register operands (3Rs). Type-2 category consists of eight instructions, each with 2 floating point register operands (2Fs). Type-3 category consists of fourteen instructions, each with one integer register operand and one floating point register operand (1R+1F). Type-4 category consists of N instructions, each with a floating point register operand (1F).
The maximum value of N is __________.
An integer register needs 4 bits, a floating point register 6 bits; there are 2¹⁶ = 65536 encodings. Type-1: 4 instructions × 2¹² operand combinations = 16384. Type-2: 8 × 2¹² = 32768. Type-3: 14 × 2¹⁰ = 14336. Used = 63488, leaving 65536 - 63488 = 2048 encodings. Each Type-4 instruction uses 2⁶ = 64 encodings, so N = 2048 / 64 = 32. Answer: 32.
Concept: Expanding-opcode problems are solved by counting encodings: each instruction consumes 2^(operand bits) codes out of 2^(instruction length). The trap is assigning fixed opcode widths per category instead of counting the shared code space.
A processor can support a maximum memory of 4 GB, where the memory is word-addressable (a word consists of two bytes). The size of the address bus of the processor is at least ________ bits.
4 GB = 2³² bytes. Each address refers to one word of 2 bytes, so the number of addressable units is 2³² / 2 = 2³¹. The address bus needs log₂(2³¹) = 31 bits. Answer: 31.
Concept: Address width depends on the number of addressable units, not bytes. The trap is answering 32 by ignoring word addressing.
The size of the data count register of a DMA controller is 16 bits. The processor needs to transfer a file of 29,154 kilobytes from disk to main memory. The memory is byte addressable. The minimum number of times the DMA controller needs to get the control of the system bus from the processor to transfer the file from the disk to main memory is ________.
A 16-bit count register allows at most 2¹⁶ bytes = 64 KB per DMA transfer (one bus grant in burst mode). Number of grants = ⌈29154 KB / 64 KB⌉ = ⌈455.53⌉ = 456. Answer: 456.
Concept: The count register limits the block size per DMA operation. The trap is rounding down to 455 and leaving the last partial block untransferred.
The stage delays in a 4-stage pipeline are 800, 500, 400 and 300 picoseconds. The first stage (with delay 800 picoseconds) is replaced with a functionally equivalent design involving two stages with respective delays 600 and 350 picoseconds. The throughput increase of the pipeline is ________ percent.
Pipeline clock period = slowest stage. Old: max(800, 500, 400, 300) = 800 ps. New stages 600, 350, 500, 400, 300: max = 600 ps.
Throughput is 1/period, so the ratio is 800/600 = 1.333, an increase of 33.33%. Answer: 33.33 (key 33 to 34).
Concept: Throughput is set by the bottleneck stage. The trap is computing the change in period (25%) instead of the change in throughput.
A processor has 40 distinct instructions and 24 general purpose registers. A 32-bit instruction word has an opcode, two register operands and an immediate operand. The number of bits available for the immediate operand field is ______.
40 instructions need ceil(log₂ 40) = 6 opcode bits. 24 registers need ceil(log₂ 24) = 5 bits each, so two register fields take 10 bits. Immediate = 32 - 6 - 10 = 16 bits. Answer: 16.
Concept: Instruction-format sizing with the ceiling of log₂. The trap is using 4 bits for 24 registers or 5 bits for 40 opcodes.
Suppose the functions F and G can be computed in 5 and 3 nanoseconds by functional units U_F and U_G, respectively. Given two instances of U_F and two instances of U_G, it is required to implement the computation F(G(Xᵢ)) for 1 ≤ i ≤ 10. Ignoring all other delays, the minimum time required to complete this computation is ______ nanoseconds.
Each F needs its G result first. Pair one U_G with one U_F as a two-stage pipeline and run two such pipelines, 5 items each. The F stage (5 ns) is the bottleneck, so the U_G work stays ahead. In one pipeline: first G finishes at 3 ns, then the 5 F computations run back to back, ending at 3 + 5 × 5 = 28 ns. Both pipelines run in parallel. Answer: 28.
Concept: Pipelining with a slow stage: total time = fill time of earlier stages + (number of items × bottleneck time). Simply adding 10 × 8 / 2 = 40 ignores the overlap.
Consider a processor with 64 registers and an instruction set of size twelve. Each instruction has five distinct fields, namely, opcode, two source register identifiers, one destination register identifier, and a twelve-bit immediate value. Each instruction must be stored in memory in a byte-aligned fashion. If a program has 100 instructions, the amount of memory (in bytes) consumed by the program text is ______.
Opcode for 12 instructions: 4 bits. Each register identifier for 64 registers: 6 bits, three of them: 18 bits. Immediate: 12 bits. Total 4 + 18 + 12 = 34 bits, which needs 5 bytes when byte-aligned. 100 instructions × 5 bytes = 500 bytes. Answer: 500.
Concept: Byte alignment rounds each instruction up to whole bytes: 34 bits becomes 40. Answering 425 (34 × 100 / 8) ignores the alignment.
The width of the physical address on a machine is 40 bits. The width of the tag field in a 512 KB 8-way set associative cache is ______ bits.
Cache size 512 KB = 2¹⁹ bytes. With block size 2ᵇ, the number of sets is 2¹⁹ / (8 × 2ᵇ) = 2¹⁶⁻ᵇ, so index + offset = (16 - b) + b = 16 bits whatever the block size. Tag = 40 - 16 = 24 bits. Answer: 24.
Concept: Tag width depends only on address width, cache size and associativity: tag = address bits - log₂(cache size / ways). The block size cancels, which is why it was not given.
Consider a 3 GHz (gigahertz) processor with a three-stage pipeline and stage latencies τ₁, τ₂, and τ₃ such that τ₁ = 3τ₂/4 = 2τ₃. If the longest pipeline stage is split into two pipeline stages of equal latency, the new frequency is ______ GHz, ignoring delays in the pipeline registers.
Let τ₁ = 6k. Then τ₂ = 8k and τ₃ = 3k. The clock is set by the longest stage τ₂ = 8k = 1/3 ns, so k = 1/24 ns. Splitting τ₂ gives two 4k stages; the longest stage is now τ₁ = 6k = 0.25 ns. New frequency = 1/0.25 ns = 4 GHz. Answer: 4 (accepted range 3.9 to 4.1).
Concept: Pipeline clock period equals the slowest stage. After splitting, the bottleneck moves to the next longest stage; assuming the frequency doubles to 6 GHz is the trap.
Consider the following processors (ns stands for nanoseconds). Assume that the pipeline registers have zero latency.
P1: Four-stage pipeline with stage latencies 1 ns, 2 ns, 2 ns, 1 ns.
P2: Four-stage pipeline with stage latencies 1 ns, 1.5 ns, 1.5 ns, 1.5 ns.
P3: Five-stage pipeline with stage latencies 0.5 ns, 1 ns, 1 ns, 0.6 ns, 1 ns.
P4: Five-stage pipeline with stage latencies 0.5 ns, 0.5 ns, 1 ns, 1 ns, 1.1 ns.
Which processor has the highest peak clock frequency?
- (A)P1
- (B)P2
- (C)P3
- (D)P4
The clock period of a pipeline is the slowest stage latency.
P1: 2 ns (500 MHz). P2: 1.5 ns (667 MHz). P3: 1 ns (1 GHz). P4: 1.1 ns (909 MHz).
P3 has the shortest period and hence the highest frequency. Answer: (C) P3.
Concept: Pipeline clock is set by the bottleneck stage. The trap is summing stage latencies or picking P4 for having many short stages.
An instruction pipeline has five stages, namely, instruction fetch (IF), instruction decode and register fetch (ID/RF), instruction execution (EX), memory access (MEM), and register writeback (WB) with stage latencies 1 ns, 2.2 ns, 2 ns, 1 ns, and 0.75 ns, respectively (ns stands for nanoseconds). To gain in terms of frequency, the designers have decided to split the ID/RF stage into three stages (ID, RF1, RF2) each of latency 2.2/3 ns. Also, the EX stage is split into two stages (EX1, EX2) each of latency 1 ns. The new design has a total of eight pipeline stages. A program has 20% branch instructions which execute in the EX stage and produce the next instruction pointer at the end of the EX stage in the old design and at the end of the EX2 stage in the new design. The IF stage stalls after fetching a branch instruction until the next instruction pointer is computed. All instructions other than the branch instruction have an average CPI of one in both the designs. The execution times of this program on the old and the new design are P and Q nanoseconds, respectively. The value of P/Q is __________.
Old design: clock = slowest stage = 2.2 ns. A branch resolves at the end of EX (stage 3), so the next fetch waits 2 extra cycles. CPI = 0.8 × 1 + 0.2 × 3 = 1.4. Time per instruction = 1.4 × 2.2 = 3.08 ns.
New design: stages IF 1, ID 0.733, RF1 0.733, RF2 0.733, EX1 1, EX2 1, MEM 1, WB 0.75; clock = 1 ns. A branch resolves at the end of EX2 (stage 6), a 5-cycle stall. CPI = 0.8 × 1 + 0.2 × 6 = 2.0. Time per instruction = 2.0 ns.
P/Q = 3.08 / 2.0 = 1.54. Answer: 1.54 (official range 1.50 to 1.60).
Concept: Deeper pipelines raise frequency but enlarge the branch penalty. The trap is counting the penalty as the branch's stage number instead of stage number minus one.
The memory access time is 1 nanosecond for a read operation with a hit in cache, 5 nanoseconds for a read operation with a miss in cache, 2 nanoseconds for a write operation with a hit in cache and 10 nanoseconds for a write operation with a miss in cache. Execution of a sequence of instructions involves 100 instruction fetch operations, 60 memory operand read operations and 40 memory operand write operations. The cache hit-ratio is 0.9. The average memory access time (in nanoseconds) in executing the sequence of instructions is __________.
Instruction fetches are reads: 100 + 60 = 160 reads, 40 writes, 200 accesses in all.
Average read time = 0.9 × 1 + 0.1 × 5 = 1.4 ns. Average write time = 0.9 × 2 + 0.1 × 10 = 2.8 ns.
Total = 160 × 1.4 + 40 × 2.8 = 224 + 112 = 336 ns. Average = 336 / 200 = 1.68 ns. Answer: 1.68.
Concept: Weighted average memory access time over reads and writes. The trap is forgetting that instruction fetches are read operations, or averaging the read and write times without weighting.