Vous êtes sur la page 1sur 41

Computer Architecture and Design

Control Unit Design

CONTROL UNIT
Control unit (CU) of a processor translates from machine instructions to the control signals for the microoperations that implement them Control units are implemented in one of two ways Hardwired Control CU is made up of sequential and combinational circuits to generate the control signals Microprogrammed Control A control memory on the processor contains microprograms that activate the necessary control signals We will consider a hardwired implementation of the control unit for the Basic Computer

Control unit of Basic Computer


15 Instruction register (IR) 14 13 12 11 - 0

Other inputs

3x8 decoder 7 6543 210 I D0 D7 T15 T0 15 14 . . . . 2 1 0 4 x 16 decoder Increment (INR) Clear (CLR) Clock Combinational Control logic Control signals

4-bit sequence counter (SC)

Datapath Design
Similarity in functions for the datapath design Given the steps for unsigned multiplication and 2s complement multiplication, it would be more efficient to have a single datapath
Simply control the datapath different for each function Costly to have a custom datapath for each function (instruction) Thus, part of efficient datapath design is control unit design

Control Unit Design


Design of control units for special purpose computers Processor refers to a component which has its own control unit A computer system has multiple components
Processors, memory system, and the input&output system have to work together to form a complete computer

Processor Model

C (in) condition signals from the data path C (out) control signals to the data path C (in) control signals from other components C (out) control signals to external components

Control Unit Design Steps


Step1 : Construct control flow graph according to the given register transfer program Each arc should be labeled with the corresponding condition signals
Conditions indicate that the arc should occur Empty conditions (no conditions) indicate explicit control transfers

Each node (or state) in the graph should indicate the control signals

Step1: Control Graph


Details of the register transfer statements are eliminated from the program
The Datapath guarantees that the statements are executed provided that the control unit enables the correct signals

Multiplier Control Graph

Control and Condition Signals


For Multiplier Datapath: C(in): COUNTIS6_H C(out): RESET_H, LOADQ_H, LOADM_H, ADD_H, SUB_H C(in): START_H C(out): DONE_H

Control Unit Design Methods


Two methods: Hardwired Control Unit Design Microprogrammed Control Unit Design

Hardwired Design
Designing a custom digital circuit using digital logic and states (D-flip flops or registers) Digital logic course on building truth tables and Finite State Machines (FSM)

State Table Method


Construct a state table which describes the behavior of the control unit Need to generate control signals (output) based on current state and current condition signals Moore state machine- control signals generated are independent of current inputs Mealy state machine- control signals generated are a function of both state and current inputs

State Table Method


Step1: Construct state table which describes the behavior of the control unit Essentially a more detailed description of the control flow graph

State Table Observation


Most of the control transfers are sequential State1 goes to state 2, state 2 goes to state 3 Simply use a binary counter and have each binary encoding represent a state

Sequential Circuit

3 Bits

Sequential Circuit
State machine is only counting after the control unit receives the RESET_H signal State machine stops counting (waits in state 3) until the datapath signal COUNTIS6_H signal states that 6 repetitions of that state have occurred.

General View of Hardwired Control

Hardwired Control Summary


Advantages: Easy to derive from control flow graphs Disadvantages Have to create a new circuit corresponding to a state machine for each instruction Cannot handle large complex control units Cannot modify without re-writing and development

Microprogrammed Control Unit


Want a general method of defines the steps of each instruction Just as datapath is generalized to handle multiple functions (and respective steps) Control unit should uniformly handle each instruction
No custom circuit (state machine and logic) for each instruction

Microprogram Control
Use ROM and RAM memories to implement the combinatorial circuit A control unit whose circuit makes use of a ROM or RAM is called a microprogrammed control unit The memory used in the circuit is called control memory The practice of designing a control unit with ROM&RAM is called: microprogramming First introduced by Maurice Wilkes

Maurice Wilkes introduces microprogramming


1951

Use Memory Instead of Logic

General Microprogramming Model

ROM or RAM

General Microprogramming Model


Previously in hardwired design, state encoding went into a logic function In microprogrammed design, state encoding goes into ROM or RAM memory The data of each memory location now represents the signals that are to be activated if the state is reached Each memory location is called a micro-instruction or micro-operation

Micro-instruction
Each micro-instruction has three components Condition signals
Correspond to the the controls of the datapath or other external devices

NEXT ADDRESS field Condition masks

Next Address field


Generally, which micro-instruction is next to be executed If the current micro-instruction is at address 000, and it automatically goes to state 001, then the Next Address field indicates 001

Condition Masks
Similar to branch instructions Generally, what happens if the next micro-instruction to be executed depends on what the datapath condition signals are: Example: staying in state 3 for 6 executions to output ADD_H signal If the current micro-instruction is at address 000, and depends on the condition COUNTIS6_H to determine the next state, then the system needs to pay attention to COUNTIS6_H and cant simply use the Next Address field

Condition Mask Examples

Condition Mask Examples

Next-Address Logic

Condition Mask To Change LSB of CMAR

Assigning microinstructions to CM

Complete Control Memory Contents

General Stages of an Instruction


IF ID EX 4) Access to memory MEM WB 5) Write Back results 3) ALU Execution 1) Instruction FETCH

2) Instruction DECODE

Control Memory for all ISA instructions


Micro-instruction for ADD or SUB

ADD or SUB

CONTROL MEMORY

DECODER

Starting Address

MULTIPLY

Micro-instructions for MULTIPLY

Control Signal Encoding

Control Signal Design


ROM or RAM space could be optimized Typically a state (a micro-instruction) may only do one thing.
One active high signal N-1 low signals

Waste of space

Control Signal Encoding

More efficient Encoding

Microprogramming Summary
Currently characterizes almost all modern microprocessor designs Datapaths and control units can be shared or be similar between generations of processors (PentiumII and Pentium III, ahead) Encoding signals into codes saves space, but codes must then be decoded (using logic)

Vous aimerez peut-être aussi