UNIHIVE

Study Hub UNIPORT CSC 382

CSC 382 · Computer Architecture 1

The CPU and the fetch-execute cycle

The registers inside the CPU, the datapath, the control unit, and how an instruction is fetched, decoded and executed.

Our notes

2 min read

Registers

RegisterRole
Program counter (PC)address of the next instruction
Instruction register (IR)the instruction being executed
Memory address register (MAR)address sent to memory
Memory buffer (data) register (MBR or MDR)data to or from memory
Accumulator (AC) and general registersoperands and results
Status register (flags)zero, carry, sign, overflow, interrupt enable
Stack pointer (SP)top of the stack

The fetch-execute cycle

  1. Fetch: MAR ← PC; read memory: MBR ← M[MAR]; IR ← MBR; PC ← PC + 1.
  2. Decode: the control unit examines the opcode in IR and finds the operand address.
  3. Fetch operands if needed: MAR ← address; MBR ← M[MAR].
  4. Execute: the ALU operates (AC ← AC + MBR).
  5. Store results; check for interrupts; repeat.

The steps written with arrows are register transfer language (RTL); each step is one or more micro-operations.

Worked example: ADD 205

With AC = 7 and memory location 205 holding 5, at PC = 100:

  • MAR ← 100; MBR ← "ADD 205"; IR ← MBR; PC ← 101.
  • Decode: add, operand at 205.
  • MAR ← 205; MBR ← 5.
  • AC ← 7 + 5 = 12. Next instruction from 101.

The control unit

Generates the control signals for each micro-operation.

  • Hard-wired: logic circuits produce the signals directly. Fast; hard to change. Typical of RISC.
  • Microprogrammed: each machine instruction runs a small microprogram stored in a control memory. Easier to design and extend; slower. Typical of classic CISC machines (IBM System/360, 1964).

Interrupts

An interrupt (a key press, a disk finishing, a timer) makes the CPU save the PC and status, run an interrupt service routine, then return. This lets slow devices work without the CPU waiting.

Pipelining (in brief)

Overlap the stages of successive instructions, like an assembly line: while one is executing, the next is decoded and a third fetched. Ideally one instruction finishes every cycle. Hazards (data dependencies, branches) cause stalls.
Example: 5 stages, 100 instructions, no stalls: 5 + 99 = 104 cycles instead of 500.

Exams usually ask

  • Name and describe the CPU registers.
  • Describe the fetch-execute cycle in register transfer notation.
  • Compare hard-wired and microprogrammed control.

Common mistake

Forgetting that PC is increased during the fetch, before execution. A jump instruction then overwrites the already increased PC.

Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.

No reading links here yet

Our team adds free books, videos and practice for each topic, and opens every link before it goes up.

All CSC 382 topics

Report

Sign in to report this. It is free.

Is this your work (a lecturer, author or publisher)? Ask us to take it down.