Computer ArchitectureUnit 418 min read
Control Unit Design: Hardwired vs. Microprogrammed Control
Unit 4 of Computer Architecture explores the design of control units, contrasting hardwired and microprogrammed approaches, their internal workings, and real-world applications in modern processors and embedded systems.
TAKEAWAYS:
- Control units decode and execute instructions by generating timing signals and control signals for ALU, registers, and memory.
- Hardwired control units use combinational logic (gates, decoders) for direct signal generation, offering speed but limited flexibility.
- Microprogrammed control units use a Control ROM (microprogram store) to translate instructions into microoperations, enabling easier updates and complex instruction sets.
- Microprogram sequencers (sequential or parallel) determine the next microinstruction address, either via hardwired logic or microprogram counter.
- Register Transfer Language (RTL) is used to describe data movements between registers and functional units in control unit design.
- Trade-offs: Hardwired is faster but rigid; microprogrammed is slower but flexible and easier to modify.
1. Introduction to Control Units
The control unit (CU) is the "brain" of a CPU. It fetches instructions from memory, decodes them, and generates control signals to coordinate operations between the ALU (Arithmetic Logic Unit), registers, memory, and I/O devices. The design of the control unit determines how efficiently and flexibly a CPU can execute instructions.
Key Functions of a Control Unit
- Instruction Fetch: Retrieves the next instruction from memory.
- Instruction Decode: Interprets the opcode (operation code) to determine the operation.
- Control Signal Generation: Sends signals to ALU, registers, and memory to perform the operation.
- Timing Control: Ensures operations occur in the correct sequence (e.g., fetch → decode → execute → write-back).
Why Two Design Approaches?
- Hardwired Control Unit (HCU): Uses combinational logic (AND/OR gates, decoders) to generate control signals directly. Faster but inflexible.
- Microprogrammed Control Unit (MCU): Uses a Control ROM to store microinstructions that define how each instruction is executed. Slower but flexible and easier to modify.
2. Hardwired Control Unit (HCU)
How It Works
A hardwired control unit uses combinational logic circuits to generate control signals based on the opcode and operand fields of an instruction. The logic is hardwired (fixed) into the circuit, meaning changes require physical modifications.
Components of HCU
- Instruction Register (IR): Holds the current instruction.
- Decoder: Decodes the opcode to select the appropriate control signals.
- Control Logic: Generates signals for ALU, registers, and memory.
- Timing Generator: Ensures signals are sent at the right time (clock cycles).
Example: Hardwired Control for an ADD Instruction
Assume a simple ISA with the following instruction format:
Opcode (4 bits) | Operand 1 (4 bits) | Operand 2 (4 bits)
For an ADD instruction (opcode 0001), the control unit must:
- Load Operand 1 and Operand 2 from registers into the ALU.
- Send an ADD signal to the ALU.
- Store the result back to a register.
Control Signal Generation (Simplified):
- The decoder detects
0001(ADD) and activates:Reg1 → ALU_A(load Operand 1 into ALU input A)Reg2 → ALU_B(load Operand 2 into ALU input B)ALU_OP = 00(select ADD operation)ALU → Reg3(store result to a register)
Advantages of HCU
- Speed: No extra memory access (microinstructions) → faster execution.
- Simplicity: No need for a microprogram store (Control ROM).
- Lower Cost: Fewer components (no ROM or microsequencer).
Disadvantages of HCU
- Inflexibility: Changing or adding instructions requires rewiring the logic.
- Complexity: Designing control logic for complex ISAs is error-prone.
- Hard to Maintain: Debugging requires tracing through thousands of gates.
3. Microprogrammed Control Unit (MCU)
How It Works
A microprogrammed control unit uses a Control ROM (or Control RAM) to store microinstructions. Each machine instruction is broken down into a sequence of microoperations (microinstructions), which are fetched and executed one by one.
Components of MCU
- Control ROM (Microprogram Store): Stores microinstructions.
- Microinstruction Register (μIR): Holds the current microinstruction.
- Microprogram Sequencer: Determines the next microinstruction address.
- Control Signal Generator: Decodes the microinstruction to generate control signals.
Microinstruction Format
A microinstruction typically includes:
- Control Field: Specifies control signals for ALU, registers, and memory.
- Next Address Field: Determines the next microinstruction address (sequencer logic).
Example Microinstruction Format:
| Next Address (6 bits) | Control Signals (10 bits) | Conditional Field (4 bits) |
- Next Address: Can be sequential (next microinstruction) or branched (based on conditions).
- Control Signals: Define operations like
Reg1 → ALU_A,ALU_OP = ADD, etc. - Conditional Field: Used for branching (e.g., if
Zero Flag = 1, jump to address X).
Microprogram Sequencer
The sequencer decides the next microinstruction address. Two types:
Sequential Microprogramming:
- Uses a microprogram counter (μPC) that increments automatically.
- Next address = μPC + 1 (unless modified by a branch).
- Example: Executing a loop where each microinstruction is fetched in order.
Parallel Microprogramming:
- Uses hardwired logic to compute the next address based on the current microinstruction.
- Faster but more complex.
- Example: Branching decisions (e.g., if
ALU Zero = 1, jump to error handler).
Example: Microprogram for an ADD Instruction
Assume the following microinstructions for ADD R1, R2, R3:
Fetch Operands:
μPC = 000000- Control:
Reg1 → ALU_A,Reg2 → ALU_B - Next Address:
000001(sequential)
Perform ADD:
μPC = 000001- Control:
ALU_OP = 00(ADD),ALU → Temp - Next Address:
000010(sequential)
Store Result:
μPC = 000010- Control:
Temp → Reg3 - Next Address:
000011(next instruction fetch)
Microprogram Store (Partial):
| μPC | Control Signals | Next Address |
|---|---|---|
| 000 | Reg1→ALU_A, Reg2→ALU_B | 001 |
| 001 | ALU_OP=00, ALU→Temp | 010 |
| 010 | Temp→Reg3 | 011 |
4. Comparison: Hardwired vs. Microprogrammed Control Units
| Feature | Hardwired Control Unit (HCU) | Microprogrammed Control Unit (MCU) |
|---|---|---|
| Speed | Faster (direct logic) | Slower (ROM access delay) |
| Flexibility | Inflexible (hardwired logic) | Flexible (modify microprogram) |
| Complexity | High (complex logic design) | Lower (microprogramming simplifies design) |
| Cost | Lower (no ROM) | Higher (requires Control ROM) |
| Maintainability | Difficult (rewiring needed) | Easier (update microprogram) |
| Instruction Set Support | Limited by hardware | Can support complex ISAs easily |
| Debugging | Hard (trace through gates) | Easier (step through microinstructions) |
| Power Consumption | Lower (no ROM access) | Higher (ROM access) |
5. Register Transfer Language (RTL)
Register Transfer Language (RTL) is a high-level language used to describe data movements between registers and functional units in a computer. It helps in designing and documenting control units.
Syntax of RTL
- Registers: Represented as
Reg1,ALU,Memory, etc. - Operations: Use symbols like
→(transfer),+(add), etc. - Example:
Reg1 → ALU_A Reg2 → ALU_B ALU_OP = ADD ALU → Reg3
Use in Control Unit Design
- Describe Data Flow: RTL shows how data moves between registers and ALU.
- Generate Control Signals: Helps in designing the control logic (HCU) or microinstructions (MCU).
- Verify Design: Ensures correctness before hardware implementation.
Example: RTL for SUBTRACT Instruction
IR → Decoder // Decode instruction
Reg1 → ALU_A
Reg2 → ALU_B
ALU_OP = SUB // Set ALU to subtract
ALU → Reg3 // Store result
6. Real-World Applications
In the Real World
eSewa (Nepal):
- Microprogrammed Control: Modern CPUs in eSewa’s servers use microprogrammed control units to handle complex financial transactions (e.g., bill payments, fund transfers). The flexibility of MCU allows easy updates to transaction protocols (e.g., adding new payment methods like Khalti or Ncell Pay).
- Example: When you pay an electricity bill via eSewa, the server’s CPU uses a microprogrammed control unit to:
- Fetch your account details.
- Validate the transaction.
- Update the NTC database.
- Send a confirmation SMS (via Ncell’s API).
Pathao (Ride-Hailing App):
- Hardwired Control in Embedded Systems: Pathao’s GPS and payment processing units in driver apps use hardwired control units for real-time operations like:
- Calculating the shortest route (using ALU for distance calculations).
- Processing payments instantly (low-latency operations).
- Why Hardwired? Speed is critical for real-time ride matching and payment processing.
- Hardwired Control in Embedded Systems: Pathao’s GPS and payment processing units in driver apps use hardwired control units for real-time operations like:
Nepal Rastra Bank (NRB) Core Banking Systems:
- Microprogrammed Control for Complex Logic: Banks use CPUs with microprogrammed control units to handle:
- Loan interest calculations (complex arithmetic operations).
- Fraud detection algorithms (conditional branching in microprograms).
- Example: When you take a loan from a bank, the system calculates compound interest using microinstructions that break down the formula into steps:
μPC = 000: Load principal amount → Reg1 μPC = 001: Load interest rate → Reg2 μPC = 010: Multiply Reg1 × Reg2 → ALU μPC = 011: Add to principal → Reg1 (compound step) μPC = 100: Repeat for each period
- Microprogrammed Control for Complex Logic: Banks use CPUs with microprogrammed control units to handle:
7. Worked Example: Microprogrammed Control for a LOAD Instruction
Instruction: LOAD R1, [MemAddr] (Load data from memory to register R1).
Assumptions:
- Memory address is in
Reg4. - Data is loaded into
Reg1. - Control ROM has microinstructions for this operation.
Microprogram Steps
Fetch Memory Address:
μPC = 0000- Control:
Reg4 → MAR(Memory Address Register) - Next Address:
0001
Read from Memory:
μPC = 0001- Control:
MemR(Memory Read),MDR → Reg1(Move Memory Data Register to R1) - Next Address:
0010
Next Instruction Fetch:
μPC = 0010- Control:
PC → MAR,MemR,MDR → IR(Fetch next instruction) - Next Address:
0011(or branch to next instruction)
Microprogram Store:
| μPC | Control Signals | Next Address |
|---|---|---|
| 000 | Reg4 → MAR | 001 |
| 001 | MemR, MDR → Reg1 | 010 |
| 010 | PC → MAR, MemR, MDR → IR | 011 |
8. Control ROM (Microprogram Store)
The Control ROM stores microinstructions. It is non-volatile (retains data when power is off) and read-only (cannot be modified during operation).
How Control ROM Works
- Addressing: The microprogram sequencer provides the address of the next microinstruction.
- Fetch: The microinstruction is read from the ROM.
- Decode: The control signals are generated based on the microinstruction.
Advantages of Control ROM
- Flexibility: Easy to update by changing the ROM contents.
- Complex ISA Support: Can implement complex instructions by adding more microinstructions.
- Debugging: Easier to trace microinstructions than combinational logic.
Disadvantages of Control ROM
- Speed Overhead: Accessing ROM adds delay.
- Cost: Requires additional memory.
- Power Consumption: ROM access consumes more power than combinational logic.
9. Choosing Between HCU and MCU
| Scenario | Recommended Control Unit | Reason |
|---|---|---|
| High-performance CPUs | Hardwired | Speed is critical (e.g., gaming PCs, servers). |
| Embedded Systems | Hardwired | Low power, cost-sensitive (e.g., Pathao’s GPS module). |
| Complex ISAs (e.g., x86) | Microprogrammed | Flexibility to support complex instructions (e.g., Intel CPUs). |
| Prototyping/Research | Microprogrammed | Easy to modify and test new instructions. |
| Real-time Systems | Hardwired | Predictable timing (e.g., industrial control systems). |
10. Exam Tip
What Examiners Look For
Definitions:
- Clearly define hardwired control unit and microprogrammed control unit.
- Explain microinstruction, Control ROM, and microprogram sequencer.
Comparison:
- Use a table to compare HCU and MCU (as above). Highlight speed vs. flexibility.
- Mention real-world examples (e.g., HCU in embedded systems, MCU in complex CPUs).
Diagrams:
- Draw a block diagram of HCU and MCU (show components like IR, decoder, Control ROM).
- Show a microinstruction format (fields like Next Address, Control Signals).
Worked Examples:
- Solve a microprogram trace for a given instruction (e.g.,
ADD,LOAD). - Write RTL pseudocode for an instruction.
- Solve a microprogram trace for a given instruction (e.g.,
Applications:
- Relate to real-world systems (e.g., eSewa’s transaction processing, Pathao’s GPS).
- Explain why a system uses HCU or MCU (e.g., speed in Pathao, flexibility in banks).
Common Mistakes to Avoid
- Mixing Definitions: Don’t confuse HCU and MCU. HCU uses logic gates; MCU uses ROM.
- Incorrect Microprogram Flow: Ensure the next address is correctly calculated (sequential or branched).
- Ignoring Timing: Control units work in clock cycles; show how signals are synchronized.
- Overlooking RTL: Always use RTL to describe data movements in examples.
Sample Exam Questions and Answers
Q1: Differentiate between hardwired and microprogrammed control units. A1:
| Feature | Hardwired Control Unit | Microprogrammed Control Unit |
|---|---|---|
| Implementation | Combinational logic (gates) | Control ROM + microinstructions |
| Speed | Faster (no ROM access) | Slower (ROM access delay) |
| Flexibility | Inflexible (hardwired) | Flexible (modify microprogram) |
| Complexity | High (complex logic) | Lower (microprogramming simplifies design) |
| Cost | Lower (no ROM) | Higher (requires ROM) |
Q2: Explain the microprogrammed control unit with an example of a microprogram sequencer. A2: A microprogrammed control unit uses a Control ROM to store microinstructions. Each machine instruction is broken into microoperations. The microprogram sequencer determines the next microinstruction address:
- Sequential: Uses a counter (
μPC + 1). - Branched: Uses conditional logic (e.g., if
Zero Flag = 1, jump to address X).
Example (Sequential):
For ADD R1, R2, R3:
μPC = 000: Reg1→ALU_A, Reg2→ALU_B → Next: 001
μPC = 001: ALU_OP=ADD, ALU→R3 → Next: 010
μPC = 010: Fetch next instruction → Next: 011
Q3: What is Register Transfer Language (RTL)? Explain its use in control function. A3: RTL is a language to describe data transfers between registers and functional units. It helps in:
- Designing Control Units: Specifies how data moves (e.g.,
Reg1 → ALU_A). - Documenting Logic: Provides a clear, high-level view of operations.
- Verifying Design: Ensures correctness before hardware implementation.
Example (SUBTRACT):
IR → Decoder
Reg1 → ALU_A
Reg2 → ALU_B
ALU_OP = SUB
ALU → Reg3
Visuals
1. Hardwired vs. Microprogrammed Control Unit Block Diagrams
graph TD
subgraph Hardwired Control Unit
A["Instruction Register (IR)"] --> B["Decoder"]
B --> C["Control Logic"]
C --> D["ALU/Registers/Memory"]
C --> E["Timing Generator"]
end
subgraph Microprogrammed Control Unit
F["Instruction Register (IR)"] --> G["Control ROM"]
G --> H["Microinstruction Register (μIR)"]
H --> I["Control Signal Generator"]
I --> J["ALU/Registers/Memory"]
H --> K["Microprogram Sequencer"]
K --> G
endCaption: Block diagrams of hardwired (left) and microprogrammed (right) control units.
2. Microinstruction Format
| Next Address (6 bits) | Control Signals (10 bits) | Conditional Field (4 bits) |
|---|---|---|
| 000000 | Reg1→ALU_A, Reg2→ALU_B | 0000 |
| 000001 | ALU_OP=ADD, ALU→Temp | 0000 |
| 000010 | Temp→Reg3 | 0000 |
Caption: Example microinstruction format for an ADD operation.
3. Microprogram Flow for LOAD Instruction
stateDiagram-v2
[*] --> FetchAddr: μPC=000
FetchAddr --> ReadMem: μPC=001
ReadMem --> NextInst: μPC=010
NextInst --> [*]: μPC=011
state FetchAddr {
[Reg4 → MAR]
}
state ReadMem {
[MemR, MDR → Reg1]
}
state NextInst {
[PC → MAR, MemR, MDR → IR]
}Caption: State diagram for microprogrammed LOAD instruction.
4. Real Picture: Control ROM Chip
Caption: A typical Control ROM chip (e.g., Intel 27C series EPROM) used to store microinstructions.
Summary
- Hardwired Control Units are fast and rigid, using combinational logic for direct control signal generation.
- Microprogrammed Control Units are flexible and slower, using a Control ROM to store microinstructions.
- RTL helps describe data movements in control unit design.
- Real-world systems (eSewa, Pathao, banks) use both approaches based on speed vs. flexibility needs.
- Exam focus: Compare HCU vs. MCU, trace microprograms, and relate to real-world applications.
Based on the TU BSc CSIT syllabus for Computer Architecture (CSC213), unit 4.
Discussion
Loading…