Hardwired vs. Microprogrammed Control Unit Design
Overview: A hardwired controller produces signals through logic circuits.
What is a Control Unit?
- The Control Unit (CU) is the manager and traffic cop of the CPU.
- While the ALU performs calculations, the Control Unit tells the ALU, registers, and memory what to do, when to do it, and in what order.
- It does this by generating electronic control signals.
- Hardwired Control Unit: Built with fixed, physical electronic gates.
- Microprogrammed Control Unit: Built using software-like micro-code stored in a special ROM memory.
- An everyday example
-
- Hardwired Control: Think of a fixed mechanical toy car.
-
- Microprogrammed Control: Think of a remote-controlled smart car driven by code.
Hardwired Control Unit
- In a Hardwired Control Unit, the control logic is permanently wired using physical logic gates, decoders, and counters:
- Key Highlights: Blazing Fast Speed: Signals shoot directly through physical gates without reading any memory.
- Very Rigid (Cannot be Modified): If you discover a bug or want to add a new instruction, you must physically melt down and redesign the silicon chip!
- Where is it used? Used in modern high-speed RISC processors (ARM chips, Apple Silicon).
View diagram · Hardwired Control Architecture
Microprogrammed Control Unit
- Invented by Maurice Wilkes, this design treats generating control signals as executing a mini-program:
- The control signals for each clock tick are stored as a binary word called a Microinstruction.
- A sequence of microinstructions is called a Microprogram.
- The microprogram is permanently stored in a dedicated high-speed ROM called Control Memory (CM).
- Key Components: Control Memory (CM): Fast ROM chip that holds all the micro-code routines.
- Control Address Register (CAR): Holds the memory address of the next microinstruction to read.
- Control Data Register (CDR): Holds the microinstruction currently being executed.
- Sequencer: Calculates the next microinstruction address (step forward or branch).
View diagram · Microprogrammed Control Flow
Comparison: Hardwired vs. Microprogrammed
- Basic Technology: Fixed logic gates, flip-flops, and decoders
- Speed: Extremely Fast (gate delay only)
- Flexibility: Rigid; cannot be changed after manufacture
- Design Complexity: Difficult to design and debug
- Best Architecture: Ideal for RISC (simple instruction sets)
- Cost & Size: Gets huge and expensive for complex CPUs
General Register Organization and ALU Control Word
Overview: To calculate R3 = R1 + R2, select R1 and R2 as the ALU inputs, choose addition, then enable a write to R3.
What is General Register Organization?
- In early, basic computers, the CPU had only one main working register: the Accumulator (AC).
- Every single math problem had to pass through this single register.
- This created a huge traffic jam (bottleneck) inside the CPU!
- We call this General Register Organization (GRO).
- Any register can supply inputs to the ALU, and any register can receive the calculated answer!
- An everyday example
- Think of a college library.
- If there is only 1 book-issue counter, all students must stand in one long line (like an Accumulator CPU).
Block Diagram of General Register Organization
- The system has 4 main hardware components:
- 7 General Purpose Registers:
R₁throughR₇to store intermediate data. - Two Multiplexer Buses (Bus A and Bus B): Select two registers to send data into the ALU.
- Arithmetic Logic Unit (ALU): Performs the requested math or logic operation.
- Destination Decoder (3-to-8 Line): Chooses which register will save the ALU result.
View diagram · Data Path in General Register Organization
The 14-Bit Control Word
- To command this entire register bank during one single clock tick, the CPU issues a 14-bit binary command called a Control Word:
- SELA (3 Bits) Selects source register for Bus A
- SELB (3 Bits) Selects source register for Bus B
- SELD (3 Bits) Selects destination register to save result
- OPR (5 Bits) Selects ALU operation (ADD, SUB, AND, OR)
000: External Input (IN)001: R₁010: R₂
View diagram · 14-Bit Control Word Structure
Solved Control Word Problem
- Problem: Find the 14-bit control word to perform:
- Step-by-Step Field Resolution: Bus A Source: Register
R₂→ Code is010 - Bus B Source: Register
R₃→ Code is011 - Destination: Register
R₁→ Code is001 - Operation: ADD → Code is
00010 - 010: 011
- Final Control Word: Complete 14-bit Binary Word:
010 011 001 00010 - In Hexadecimal notation:
2 6 2 2
Stack Organization, Reverse Polish Notation, and Instruction Formats
Overview: Push 3 and then 4 onto a stack.
What is a Stack?
- A Stack is a storage structure that follows the LIFO (Last-In, First-Out) rule.
- The last item placed on top is always the first item removed!
- A CPU register called the Stack Pointer (SP) keeps track of the memory address of the topmost item.
- An everyday example
- Think of a stack of steel plates (thaalis) at a wedding dinner:
-
- The caterer puts clean plates on top of the stack.
-
- Guests pick plates from the top.
-
- You cannot pull a plate out from the bottom without knocking the pile down!
Register Stack Organization and PUSH / POP
- A 64-word hardware stack uses a 6-bit Stack Pointer (SP) (since
2⁶ = 64) and two status flags: FULL and EMPTY. - PUSH (Insert Item) 1.
- POP (Remove Item) 1.
View diagram · Stack Operations: PUSH vs. POP
Reverse Polish Notation (RPN / Postfix)
- Humans write math formulas in Infix notation (operators between numbers).
- Infix:
(A + B) × (C + D) - Computers must evaluate brackets and operator precedence (BODMAS), which slows them down.
- In Postfix (Reverse Polish Notation), operators come after the numbers:
- In Postfix, brackets are completely eliminated!
- How the CPU Evaluates RPN Using a Stack: Read the expression from left to right.
- If you see a number/variable (
A, B, C, D) → PUSH it onto the stack. - If you see an operator (
+,×) → POP the top two items, perform the math, and PUSH the result back onto the stack!
Four Instruction Formats
- How many memory addresses can fit inside a single instruction?
- 1. Three-Address Instructions: Specifies two source operands and one destination register.
- Advantage: Program is very short (only 3 instructions).
- Disadvantage: Each instruction needs many bits to store 3 full addresses.
- 2. Two-Address Instructions: One address serves as both an input and the final answer holder.
- 3. One-Address Instructions (Accumulator Architecture): All math automatically uses the CPU Accumulator (AC) register.
- 4. Zero-Address Instructions (Stack Architecture): Numbers are popped directly from the stack, and the result is pushed back.
RISC vs. CISC Processor Architecture: Concepts, Advantages, and Disadvantages
Overview: A load-store design first loads a memory value into a register and then operates on the register.
Introduction: The Two CPU Philosophies
- In processor design, there has been a famous 40-year rivalry between two contrasting architectures:
- CISC (Complex Instruction Set Computer):
- RISC (Reduced Instruction Set Computer):
- An everyday example
-
- CISC is like a heavy Swiss Army knife: It has a knife, scissors, screwdriver, and nail cutter all in one.
-
- RISC is like a sharp Chef’s knife: It does one cut, but it cuts with lightning speed in a single clean slice!
CISC (Complex Instruction Set Computer)
- Design Idea: In the 1970s, RAM was very expensive and compilers were primitive.
- Key Characteristics: Variable-Length Instructions: Instructions can be 1 byte to 15 bytes long.
- Many Addressing Modes: Often 12 to 24 different modes.
- Microprogrammed Control Unit: Needs ROM microcode to decode complex multi-step instructions.
- Memory-to-Memory Operations: Math can be done directly between RAM locations.
- Pros and Cons: ✅ Pros: Programs take fewer lines of code; saves RAM space.
- ❌ Cons: Complex chip hardware; consumes more electrical power; generates heat; harder to pipeline.
- Real-World Examples: Intel Core i3 / i5 / i7 / i9 and AMD Ryzen desktop CPUs.
RISC (Reduced Instruction Set Computer)
- Design Idea: Researchers discovered that real software spends 80% of its time running only 20% of simple instructions (like ADD, LOAD,…
- Key Characteristics: Single-Cycle Execution: Almost every instruction executes in 1 single clock tick.
- Fixed-Length Instructions: Strictly 32 bits (4 bytes) each.
- Load / Store Architecture: Only
LOADandSTOREare allowed to touch RAM. - Hardwired Control Unit: Uses blazing-fast physical logic gates.
- Large Register File: 32 or more general-purpose registers.
- Efficient Pipelining: Uniform 32-bit instructions make pipelining work smoothly.
- Pros and Cons: ✅ Pros: Blazing fast speed; low battery consumption; runs very cool.
Comparison: CISC vs. RISC
- Instruction Length: Variable (1 to 15 bytes)
- Total Instructions: Large (300+ complex commands)
- Execution Time: Multi-cycle (takes 2 to 10+ clock ticks)
- Memory Access: Allowed directly inside math instructions
- Control Unit: Microprogrammed (uses Control ROM)
- Registers: Fewer registers (typically 8 to 16)
- Load-store instructions Load the value, then add in registers
- Memory operand An arithmetic instruction may read a memory operand
Pipelining Concepts, Pipelined Data Path, and Hazard Handling
Overview: When one instruction adds two numbers and the next needs their sum, the second may reach its input stage too early.
What is Pipelining?
- In a normal, non-pipelined CPU, an instruction must finish completely before the next instruction can even begin.
- While Instruction 1 is executing math in the ALU,
- Instruction 2 is fetching its data numbers from memory,
- And Instruction 3 is being decoded at the exact same time!
- An everyday example
- Think of washing clothes at your hostel: (1) Washing, (2) Drying, (3) Ironing.
-
- Without Pipeline: You wash Load 1, dry Load 1, iron Load 1.
-
- With Pipeline: As soon as Load 1 moves into the dryer, you put Load 2 into the washing machine!
4-Stage Instruction Pipeline
- A standard CPU instruction pipeline is divided into 4 sequential hardware stages:
View diagram · Four instructions across seven clock cycles View diagram · 4-Stage Instruction Pipeline
Speedup (S) of Pipelining
- Let:
k= Number of stages in the pipeline (e.g.n= Total instructions to execute (e.g.τ= Clock cycle time.- The Formulas: Time without Pipeline (tₙ):
- Time with Pipeline (tₚ):
- Speedup Ratio (S):
- 📌 Maximum Theoretical Speedup:
Pipeline Hazards and How to Fix Them
- In real computer hardware, situations arise that pause or break the smooth flow of the pipeline.
- 1. Structural Hazards Hardware conflict: two stages try to access the same physical memory or bus at the same time.
- 2. Data Hazards An instruction needs an answer from a previous instruction that has not finished calculating yet.
- 3. Control Hazards Branch or jump instructions change the program counter, making fetched instructions useless.
- A. Data Hazards (Data Dependency): Happens when Instruction 2 needs a value produced by Instruction 1:
- Here
I₂tries to readR₁beforeI₁has even finished writing it (Read After Write - RAW conflict). - Solutions: Stalling (Pipeline Bubbles): The hardware pauses
I₂for 2 cycles untilR₁is ready. - Data Forwarding (Bypassing): A special internal wire routes the calculated answer directly from the ALU output of
I₁straight into the ALU input of…