目录

Computer Organization and Architecture Control Unit Operation & Microprogrammed Control


Computer Organization and Architecture

Control Unit Operation & Microprogrammed Control

Outline

  • Control Unit Operation

    • Micro-Operations

    • Control of the Processor

    • Hardwired Implementation

  • Microprogrammed Control

    • Basic Concepts
    • Microinstruction Sequencing
    • Microinstruction Execution

Control Unit Operation

The function of a processor

  • Instruction Fetch and Execute

    • Execute program
  • Interrupts

    • Handling performance differences between CPU and other components
  • I/O Function

    • Inter-working with peripherals

Composition of instructions

  • Instructions include opcodes and operands

  • Opcodes

    • Determines what type of operation the instruction does
  • Operands

    • Determine the object of instruction operation

    • Operands may be in registers, memory, I/O, or immediate

    • Finding operands through addressing mode

Micro-operations

  • A computer executes a program to complete user specified functions

    • Program contains many instructions

    • Instruction execution includes several cycles, such as fetch cycle, execution cycle, indirect cycle, etc

  • Each cycle has a number of steps

    • Called micro-operations

    • Each step does very little

    • Atomic operation of CPU

/img/Computer Organization and Architecture/chapter15-1.png
Constituent of program
  • 程序的执行是由若干个指令执行组成的

  • 每个指令的执行就是一个指令周期

  • 指令周期由若干个子周期组成,比如取指周期、执行周期等

  • 每个子周期包含若干个更小的操作,这些操作称为微操作

Fetch
  • Program Counter (PC)

    • Holds address of next instruction to be fetched
  • Memory Address Register (MAR)

    • Connected to address bus

    • Specifies address for read or write op

  • Memory Buffer Register (MBR)

    • Connected to data bus

    • Holds data to write or last data read

  • Instruction Register (IR)

    • Holds last instruction fetched

Step1

/img/Computer Organization and Architecture/chapter15-2.png
  • 下一个指令的地址是放在PC里

  • MAR是与地址总线连接的唯一寄存器

  • 取指的第一步是PC把下一个指令的地址给MAR

  • 经过第一步之后,PC寄存器的内容复制到MAR寄存器中


Step2

/img/Computer Organization and Architecture/chapter15-3.png
  • MAR收到地址后,把地址放到地址总线上

  • 控制单元发一个读命令到控制总线上

  • 存储器收到读命令后,根据地址读出指令内容,并放到数据总线

  • 数据总线上的数据读到MBR

  • PC中还需要递增一个指令长度,以得到下一个指令的地址


Step3

/img/Computer Organization and Architecture/chapter15-4.png
  • MBR的内容传送给IR

  • 传送完成后,MBR就可以释放,用于下一步操作

  • IR中保存的就是下一个需要执行的指令

  • 通过这几个微操作,完成了取指


Fetch sequence

  • 取指周期实际上由三步、四个微操作组成。每个微操作都涉及到数据在寄存器之间的流动

  • 如果数据的流动是独立的,这些操作可以在同一个时钟周期内完成

  • PC递增微操作,既可以在t2完成,也可以在t3完成


Rules for Micro-operations grouping

  • Proper sequence must be followed

    • MAR <- (PC) must precede MBR <- (memory)
  • Conflicts must be avoided

    • Must not read & write same register at same time

    • MBR <- (memory) & IR <- (MBR) must not be in same cycle

  • Also: PC <- (PC) +1 involves addition

    • Use ALU

    • May need additional micro-operations


Indirect cycle

  • In indirect addressing, it is necessary to get the address of the operand from the memory first. This process is called indirect cycle

Interrupt cycle

  • After instruction processing is completed, check whether there is an interrupt

  • Interrupt cycle needs to complete these operations

    • The instruction address before the interrupt needs to be saved

    • Get the instruction address of the start of the interrupt handler to the PC

  • After the PC gets the interrupt processing address, it enters the index retrieval cycle


Execute cycle

  • Fetching, indirect and interruption cycle can be determined in advance

    • Each cycle contains a fixed sequence of micro operations
  • For execution cycle

    • Different operation codes correspond to different operations

    • Each operation has a specific micro operation sequence

Flowchart for instruction cycle

/img/Computer Organization and Architecture/chapter15-5.png
  • 取指周期后,看是否是间接寻址。如果是间接寻址,进入01间接周期,如果不是,进入执行周期。

  • 间接周期后,读取地址,然后进入10执行周期

  • 执行周期,根据操作码来确定做什么操作。然后判断是否有中断。如果有中断,进入11中断周期。如果没有,进入00取指周期。

  • 中断周期,设置中断,然后进入中断处理程序的取指周期,继续取指


  • Control of the Processor

    • Functional Requirements

    • Control Signals

    • A Control Signals Example

    • Internal Processor Organization

Functional requirement

  • Micro-operations are the most basic function of the processor

  • Three elements of the controller include

    • Basic elements of processor

    • Micro-operations that processor performs

    • How to control

    • ALU

    • Registers

    • Internal data paths

    • External data paths

    • Control Unit

Types of micro-operation

  • Micro-operations can be divided into the following four categories

    • Transfer data between registers

    • Transfer data from register to external

    • Transfer data from external to register

    • Perform arithmetic or logical ops

Functions of control unit

  • Operation object and operation type have been determined

  • Function of the controller is to determine how to do it

    • Sequencing

    • Execution

    • This is done using Control Signals

Model of control unit

/img/Computer Organization and Architecture/chapter15-6.png
  • 控制器的输入包括:时钟信号,各种标志,指令寄存器中的指令,来自控制总线的控制信号(中断)

  • 控制器的输出包括:CPU内部的控制信号,到控制总线的控制信号

  • 控制器内部就是如何根据输入,来生成控制信号


Control signals

  • Clock

    • Provide clock signal for timing of controller
    • One micro-instruction (or set of parallel micro-instructions) per clock cycle
  • Instruction register

    • Op-code for current instruction

    • Addressing mode

    • Determines which micro-instructions are performed

  • Flags

    • State of CPU

    • Results of previous operations

  • Control signal from control bus

    • Interrupts

    • Acknowledgements

  • output

    • Within CPU

      • Cause data movement

      • Activate specific functions

    • Via control bus

      • To memory,control read or write

      • To I/O modules

    • It generates three types of output control signals

      • Data paths: the signals control the internal flow of data

      • ALU: the signals control the operation of the ALU

      • System bus: the control unit sends these signals to the control lines of the system bus

Internal organization

  • CPU adopts single bus structure

    • All components, including ALU and registers, are connected to the bus

    • A gate is set between each component and the bus to control the data transmission between the component and the bus

  • Data transfer to and from external systems bus is controlled by the control signal

  • Temporary registers needed for proper operation of ALU

/img/Computer Organization and Architecture/chapter15-7.png
Internal processor organization
  • 各个寄存器都链接到内部总线上。寄存器和内部总线之间有个逻辑门,用于寄存器和内部总线的连接控制

  • ALU没有内部存储部件。如果ALU的操作涉及2个操作数的话,一个由内部总线得到,另一个必须通过其他的数据源来得到,不能都在内部总线上。需要增加一个Y寄存器,用于临时保存源操作数

  • ALU还需要有一个寄存器,来临时保存输出结果。这个结果不能总线上,因为如果放总线上的话,它又会当作ALU的输入

Implementation of control unit

  • The control unit implementation can be done by two methods

    • Hardwired implementation

    • Microprogrammed implementation

  • Hardwired implementation: the control unit is a combinational circuit

    • The input signals are transferred into a set of output control signals
  • 时钟发生器:产生时钟信号,并提供计数器

  • 译码器:根据指令寄存器中的指令操作码,生成操作码对应的唯一输出,提供给输出控制单元

  • 标志:为控制单元提供相关的标志信号

  • 控制单元:是控制器的核心,负责产生控制信号

Control matrix

  • Programmable arrays may also be numerous

  • Large control matrices are implemented hierarchically for speed

Problems With Hard Wired

  • Complex micro-operation logic

  • Difficult to design and test

  • Inflexible design

  • Difficult to add new instructions

Summary

  • The instructions are divided into a sequence of stages

  • Fetch, indirect, execute, interrupt

  • Each stage is further divided into a sequence of microoperations

    • T1, T2, T3, …
  • Each micro-operation occupies one clock unit

  • The function of the control unit is to produce a sequence of timed control signals to control the data paths and ALU operations

  • The control unit is a combinational circuit that transfers inputs to a group of control signals

    • Inputs: flags, instruction registers, clock, control signals from system bus

    • Outputs: control signals to system bus and within CPU

Microprogrammed Control

Basic Concepts

  • Control unit can be implemented by a more flexible technique called microprogrammed control unit

    • The logic of the control unit is specified by a microprogram

    • Each line in microprogram describes a group of micro-operations in one time,called microinstruction

    • Construct a control word corresponding to this microinstruction

    • The control word determines the opening or closing of all doors

  • 微指令中包括CPU内控制信号、系统总线控制信号、跳转条件、微指令地址

  • 执行这条微指令的效果是,打开CPU内外所有为1的控制线,关闭所有为0的控制线

  • 如果条件条件为假,自动执行下一个顺序的微指令

  • 如果跳转条件为真,则执行“微指令地址”中对应的微指令

Micro-instruction Types

  • horizontal microinstruction

    • 水平微指令包括四个部分

      • 内部控制信号:CPU内的每一个控制线都有相应的1位
      • 总线控制信号:每一个系统控制总线都有相应的1位
      • 条件字段:指示转移发生条件的字段
      • 微指令地址:转移的目标指令地址
    • 打开位值为1的控制线,关闭所有位值为0的控制线。执行一个或多个微操作

    • 如果跳转条件为假,顺序执行下一个指令。如果跳转条件为真,执行“微指令地址” 指向的微指令

    • Characteristic

      • Each control line inside the CPU and bus needs to have a separate control bit

        • The width of the control word is very large
      • Each line is a separate control bit

        • Each control line can be controlled independently
        • More kinds of micro operations that can be supported
    • The control lines are controlled by one bit of the control word independently

      • The coding of control signal is not compact
  • vertical microinstruction

    • 垂直微指令也包括条件和跳转微指令地址,跟水平微指令类似

    • 在控制方面,和水平微指令的每一位对应一个控制线不同,垂直微指令又做了一次编码

    • 解决水平微指令的控制字太长的问题

    • 编码后,由一个解码器再翻译成控制线的控制信号

    • Characteristic

      • Width is narrow

        • n control signals encoded into $\log_2 n$ bits($n \rightarrow 2^n$)

        • Limited number of micro operations supported

      • Additional steps required

        • External memory word decode is needed
        • Identify the exact control line being manipulated
        • Send control signal

Micro-program Word Length

  • Word length is an important factor in microprogram

  • Word length is determined by three factors\

    • Maximum number of simultaneous micro-operations supported

    • The way control information is represented or encoded

    • The way in which the next micro-instruction address is specified


Compromise

  • Divide control signals into disjoint groups

  • Implement each group as separate field in memory word

  • Supports reasonable levels of parallelism without too much complexity

The control memory

  • The control words are put into a special memory block called control memory, with each word having a unique address

  • The microinstructions are organized as different routines

    • The microinstructions in each routine are executed sequentially

    • Each routine ends with a branch instruction points to the next routine

/img/Computer Organization and Architecture/chapter15-8.png
Control memory
  • 存储控制器中存储了取指例程、间接例程、中断例程、执行例程等,这些例程规定了在每个周期内需要执行的微操作序列

  • 例程中还规定了在执行结束后转移到下面哪一个例程,也就是指定了周期的执行顺序

  • 例如,取指周期后,可能会到间接周期,也可能到执行周期,需要根据取指周期来确定

/img/Computer Organization and Architecture/chapter15-9.png
Control Unit Microarchitecture
  • Sequencing logic

  • Control address register

  • Control memory

  • Control buffer register

  • 控制存储器:存储微指令

  • 控制地址寄存器:包含下一个将要被读取的微指令地址。类似于PC

  • 控制缓冲寄存器:微指令由控制存储器读取之后,放到控制缓冲寄存器中。控制缓冲寄存器的左半部分直接和控制线连接,读取微指令直接生成控制信号,控制门的开或关

  • 定序逻辑:负责为控制地址寄存器提供地址,并发出读命令

Control Unit Function

  • Sequence logic unit issues read command

    • Word specified in control address register is read into control buffer register

    • Control buffer register contents generates control signals and next address information

  • Sequence logic loads new address into control address register based on next address information from control buffer register and ALU flags

Next Address Decision

  • Sequencing logic needs to determine the next microinstruction

    • At the end of each microinstruction, the next microinstruction address is loaded into the control address register
  • Depending on ALU flags and control buffer register

    • Next microinstruction in sequence

    • Jump to a new routine based on jump instructions

    • Jump to a machine instruction routine

Next Address

  • Next microinstruction in sequence

    • Add 1 to control address register
  • Jump to new routine based on jump microinstruction

    • Load address field of control buffer register into control address register
  • Jump to machine instruction routine

    • Load control address register based on opcode in IR

  1. 指令译码器是将指令寄存器中的操作码翻译成控制寄存器地址

  2. 控制地址寄存器到控制存储器中找到控制字,并放到控制缓冲寄存器中

  3. 控制缓冲寄存器进行控制操作。如果是垂直微指令,则需要译码器进行译码后生成控制信号

  4. 控制信号译码器用于垂直微指令,将控制字翻译成控制线的控制信号,发送到CPU内部和系统总线

  5. 对于垂直微指令,有一个附加逻辑和时间延迟

  6. 下一个微指令地址给定序逻辑,以确定执行哪一个微指令

Simple summary

  • All the control unit does is generate a set of control signals

    • Control the opening and closing of each gate

    • Use one control bit to represent the control signal of a door

    • Control bits of all gates constitute control words

  • Have a control word for each group of micro-operations in one time

  • The next microinstruction can be specified in the microinstruction and executed conditionally


  • For machine code instruction

    • It is generally divided into multiple cycles, such as fetch cycle, execution cycle, etc

    • Multiple microoperations need to be completed

    • Each microoperation corresponds to one control word

    • A group of control words realizes the control function of a machine code


  • Today’s large microprocessor

    • Many instructions and associated register-level hardware

    • Many control points to be manipulated

  • This results in control memory that

    • Contains a large number of words,co-responding to the number of instructions to be executed

    • Has a wide word width,due to the large number of control points to be manipulated

Advantages and Disadvantages

  • Advantages

    • Simplifies design of control unit

    • Cheaper

    • Less error-prone

  • Disadvantages

    • Additional processing required

    • Slower

Microinstruction Sequencing

  • Microinstruction controller has two basic tasks

    • Microinstruction sequencing: Get the next microinstruction from the control memory

    • Microinstruction execution : Through control word generates control signal for executing the micro instruction

  • Must consider both together

    • Affects instruction format and controller timing

Sequencing Techniques

  • Two problems must be considered

    • Size of microinstructions

    • Address generation time

  • Size of microinstructions

    • The larger the microinstruction, the larger the control memory, and the more expensive
    • Size of microinstructions should be reduced
  • Address generation time

    • The requirement to execute microinstructions as quickly as possible
Address generation time
  • Determined by instruction register

    • Once per cycle, after instruction is fetched
  • Next sequential address

    • Use in most cases
  • Branch

    • Both conditional and unconditional

    • Generally, there is a jump after 3-4 microinstructions

    • Very important

Sequencing Techniques
  • Based on current microinstruction, condition flags, contents of IR, generate control memory address of next microinstruction

  • The jump of microinstructions can be divided into three modes according to the address information format in the microinstructions

    • Two address fields

      • 对于双地址字段模式,微指令中提供了2个地址字段

      • 控制缓冲寄存器读取微指令后,第一部分产生控制信号,第二部分和第三部分是2个地址,这2个地址,加上指令寄存器的内容,连接到一个多路器中。多路器选择一个送到控制地址寄存器中

      • 控制地址寄存器通过译码,产生下一个微指令的地址。地址选择的输入是由转移逻辑模块来完成的,它根据微指令中的控制部分,以及标志位,向多路器提供选择信号

      • 双地址字段方式比较简单,微指令中有2个地址,需要更多的位

    • Single address field

      • 单地址字段方式中,微指令中只有一个地址。下一个地址的选择方法是:

        • 地址字段中指定的地址

        • 指令寄存器中的代码

        • 下一个顺序地址

      • 下一个顺序地址是用上一次的控制地址寄存器中的地址+1来得到的

    • Variable format

      • 可变格式提供两种不同格式的指令。用1位来标识当前是哪种格式。

      • 在一种格式中,所有位都用于产生控制信号。所以,下一个微指令的地址,或者是下一顺序地址,或者是由指令寄存器来指定

      • 另一种格式中,有一些位用于启动转移逻辑模块,其余的位来提供地址。这样就可以进行条件或者无条件转移

      • 这种方法的缺点是转移微指令需要花费一个时钟周期

Microinstruction Execution

  • Microinstruction execution is a periodic basic even

  • Each cycle is made up of two events

    • Fetch

    • Execute

  • Fetch

    • Get the microinstruction from the control memory according to the generated microinstruction address
  • Execute

    • Execute microinstructions and generate control signals

Execution effect

  • Effect is to generate control signals

  • Internal

    • Control signals inside the processor

    • Control the internal components of the processor

  • External

    • Control signals to external control bus or other interface

    • Control disk read-write, I/O read-write etc

  • With the function to generate next address

Summary

  • A microprogrammed control unit is a relatively simple logic circuit that is capable of

    • Sequencing through microinstructions

    • Generating control signals to execute each microinstruction