A CPU executes instructions in order through a five-stage pipeline, allowing different instructions to occupy different stages during the same clock cycle. The stages are instruction fetch (IF), decode and register read (ID), execute (EX), memory access (MEM), and register write-back (WB). Each stage takes one cycle.
Starting with an empty pipeline, the CPU fetches the first of these instructions in cycle 1:
All three instructions pass through all five stages. Instruction and data memory accesses do not conflict, memory always responds within the MEM stage, and there are no other delays.
Compare two configurations:
When an instruction waits in ID for an operand, IF also waits while earlier instructions continue. Each extra cycle spent waiting in ID counts as one stall cycle.
Complete the table with exact integers. Report the total stall cycles and the cycle number in which the final instruction finishes WB.
Unlock full course notes by signing up
Register transfers for a LOAD instruction
In a simple accumulator machine, a LOAD instruction copies the value stored at a memory address, given in the instruction itself, into the accumulator. Arrange the register transfers in order, from the start of the instruction fetch to the end of execution. The program counter increment, which overlaps the fetch, is not listed.
Separating carry from signed overflow
An embedded controller has an 8-bit arithmetic unit. Its carry flag is set when an unsigned addition produces a ninth bit. Its overflow flag is set when the exact signed sum falls outside the representable range of −128 through 127.
The operands below are written as unsigned decimal values identifying their 8-bit patterns. For the signed check, interpret those same patterns using two's complement.
Complete each classification using exactly one of these words: carry, overflow, both, neither. Each addition is independent.
Evaluating a lower-frequency CPU redesign
An engineer compares two CPU designs using a program that executes 120 million instructions. In both designs, 50% of the executed instructions are arithmetic instructions, 30% are loads and 20% are branches.
The cycles per instruction (CPI) value measures the average number of clock cycles used per executed instruction. Use the following class costs as complete cycle accounting, including any stalls; ignore startup and shutdown costs.
The original CPU runs at 2.40 GHz; the redesigned CPU runs at 2.00 GHz. The instruction count and instruction mix remain unchanged.
Bits left for an immediate field
A processor uses fixed-length 32-bit instructions. One instruction format contains an opcode field, two register fields and an immediate field. The processor has 64 general-purpose registers, and the instruction set defines 120 distinct opcodes. If the opcode field and each register field use the fewest bits that can encode every possibility, how many bits remain for the immediate field? Answer as a whole number of bits.