Unit V: Control Unit - Computer Architecture - BCA Notes (Pokhara University)

Breaking

Saturday, May 16, 2020

Unit V: Control Unit - Computer Architecture

Introduction:

The control unit (CU) is a component of a Computer's Central Processing Unit (CPU) that directs the operation of the processor. It tells the computer's memory, arithmetic/logic unit, and input and output devices on how to respond to a program's instructions. It controls on primitive operations (micro-operations).
Control Unit, Control of the Processor, Hardwired Control Unit, Control Unit Inputs and Control Unit Logic, Micro programmed Control Unit, Micro Instructions and Its Types, Architecture of Micro programmed Control Unit, Microinstruction Sequencing, Micro Instruction Execution, Applications of Hardwired and Micro programmed Control Units

Registers Involved In Each Instruction Cycle:

1. Memory Address Registers (MAR): It is connected to the address lines of the system bus. It specifies the address in memory for a read or writes operation.
2. Memory Buffer Register (MBR): It is connected to the data lines of the system bus. It contains the value to be stored in memory or the last value read from the memory.
3. Program Counter (PC): Holds the address of the next instruction to be fetched.
4. Instruction Register (IR): Holds the last instruction fetched.

Micro-Operations For Different Sub-Cycles Are:

1. The Fetch Cycle:

At the beginning of the fetch cycle, the address of the next instruction to be executed is in the Program Counter (PC).

Control Unit, Control of the Processor, Hardwired Control Unit, Control Unit Inputs and Control Unit Logic, Micro programmed Control Unit, Micro Instructions and Its Types, Architecture of Micro programmed Control Unit, Microinstruction Sequencing, Micro Instruction Execution, Applications of Hardwired and Micro programmed Control Units

Step 1: The address in the program counter is moved to the Memory Address Register (MAR), as this is the only register which is connected to address lines of the system bus.

Control Unit, Control of the Processor, Hardwired Control Unit, Control Unit Inputs and Control Unit Logic, Micro programmed Control Unit, Micro Instructions and Its Types, Architecture of Micro programmed Control Unit, Microinstruction Sequencing, Micro Instruction Execution, Applications of Hardwired and Micro programmed Control Units

Step 2: The address in MAR is placed on the address bus, now the control unit issues a READ command on the control bus, and the result appears on the data bus and is then copied into the Memory Buffer Register (MBR). The program counter is incremented by one, to get ready for the next instruction. (These two actions can be performed simultaneously to save time). 

Control Unit, Control of the Processor, Hardwired Control Unit, Control Unit Inputs and Control Unit Logic, Micro programmed Control Unit, Micro Instructions and Its Types, Architecture of Micro programmed Control Unit, Microinstruction Sequencing, Micro Instruction Execution, Applications of Hardwired and Micro programmed Control Units

Step 3: The content of the MBR is moved to the Instruction Register (IR).

Control Unit, Control of the Processor, Hardwired Control Unit, Control Unit Inputs and Control Unit Logic, Micro programmed Control Unit, Micro Instructions and Its Types, Architecture of Micro programmed Control Unit, Microinstruction Sequencing, Micro Instruction Execution, Applications of Hardwired and Micro programmed Control Units

Thus, a simple Fetch Cycle consists of three steps and four micro-operation. Symbolically, we can write this sequence of events as follows:

Control Unit, Control of the Processor, Hardwired Control Unit, Control Unit Inputs and Control Unit Logic, Micro programmed Control Unit, Micro Instructions and Its Types, Architecture of Micro programmed Control Unit, Microinstruction Sequencing, Micro Instruction Execution, Applications of Hardwired and Micro programmed Control Units

Here ‘I’ is the instruction length. The notations (t1, t2, t3) represent successive time units. We assume that a clock is available for timing purposes and it emits regularly spaced clock pulses. Each clock pulse defines a time unit. Thus, all-time units are of equal duration. Each micro-operation can be performed within the time of a single time unit.

a. First Time Unit: Move the contents of the PC to MAR.
b. Second Time Unit: Move contents of the memory location specified by MAR to MBR. Increment content of PC by I.
c. Third Time Unit: Move contents of MBR to IR.

Note: Second and third micro-operations both take place during the second time unit.

2. The Indirect Cycle:

Once an instruction is fetched, the next step is to fetch source operands. Source Operand is being fetched by indirect addressing (it can be fetched by any addressing mode, where it’s done by indirect addressing). Register-based operands need not be fetched. Once the opcode is executed, a similar process may be needed to store the result in the main memory. Following micro-operations takes place:

Control Unit, Control of the Processor, Hardwired Control Unit, Control Unit Inputs and Control Unit Logic, Micro programmed Control Unit, Micro Instructions and Its Types, Architecture of Micro programmed Control Unit, Microinstruction Sequencing, Micro Instruction Execution, Applications of Hardwired and Micro programmed Control Units

Step 1: The address field of the instruction is transferred to the MAR. This is used to fetch the address of the operand.

Step 2: The address field of the IR is updated from the MBR. (So that it now contains a direct addressing rather than indirect addressing)

Step 3: The IR is now in the state as if indirect addressing has not occurred.

Note: Now IR is ready for the execute cycle, but it skips that cycle for a moment to consider the Interrupt Cycle.

3. The Execute Cycle:

The other three cycles (Fetch, Indirect and Interrupt) are simple and predictable. Each of them requires a simple, small, and fixed sequence of micro-operation. In each case, the same micro-operation is repeated each time around.

The execute Cycle is different from them. Like, for a machine with N different opcodes there are N different sequences of micro-operations that can occur. Let’s take a hypothetical example:

Consider an add instruction:

Control Unit, Control of the Processor, Hardwired Control Unit, Control Unit Inputs and Control Unit Logic, Micro programmed Control Unit, Micro Instructions and Its Types, Architecture of Micro programmed Control Unit, Microinstruction Sequencing, Micro Instruction Execution, Applications of Hardwired and Micro programmed Control Units

Here, this instruction adds the content of location X to register R. Corresponding micro-operation will be:

Control Unit, Control of the Processor, Hardwired Control Unit, Control Unit Inputs and Control Unit Logic, Micro programmed Control Unit, Micro Instructions and Its Types, Architecture of Micro programmed Control Unit, Microinstruction Sequencing, Micro Instruction Execution, Applications of Hardwired and Micro programmed Control Units

We begin with the IR containing the ADD instruction.
Step 1: The address portion of IR is loaded into the MAR.
Step 2: The address field of the IR is updated from the MBR, so the reference memory location is read.
Step 3: Now, the contents of R and MBR are added by the ALU.

Let’s take a complex example:

Control Unit, Control of the Processor, Hardwired Control Unit, Control Unit Inputs and Control Unit Logic, Micro programmed Control Unit, Micro Instructions and Its Types, Architecture of Micro programmed Control Unit, Microinstruction Sequencing, Micro Instruction Execution, Applications of Hardwired and Micro programmed Control Units

Here, the content of location X is incremented by 1. If the result is 0, the next instruction will be skipped. The corresponding sequence of micro-operation will be:


Control Unit, Control of the Processor, Hardwired Control Unit, Control Unit Inputs and Control Unit Logic, Micro programmed Control Unit, Micro Instructions and Its Types, Architecture of Micro programmed Control Unit, Microinstruction Sequencing, Micro Instruction Execution, Applications of Hardwired and Micro programmed Control Units

Here, the PC is incremented if (MBR) = 0. This test (is MBR equal to zero or not) and action (PC is incremented by 1) can be implemented as one micro-operation.

Note: This test and action micro-operation can be performed during the same time unit during which the updated value MBR is stored back to memory.

4. The Interrupt Cycle:

At the completion of the Execute Cycle, a test is made to determine whether any enabled interrupt has occurred or not. If an enabled interrupt has occurred then the Interrupt Cycle occurs. The nature of this cycle varies greatly from one machine to another.

Let’s take a sequence of micro-operation:

Control Unit, Control of the Processor, Hardwired Control Unit, Control Unit Inputs and Control Unit Logic, Micro programmed Control Unit, Micro Instructions and Its Types, Architecture of Micro programmed Control Unit, Microinstruction Sequencing, Micro Instruction Execution, Applications of Hardwired and Micro programmed Control Units

Step 1: Contents of the PC is transferred to the MBR so that they can be saved for return.
Step 2: MAR is loaded with the address at which the contents of the PC are to be saved.
PC is loaded with the address of the start of the interrupt-processing routine.
Step 3: MBR, containing the old value of PC is stored in memory.

Note: In step 2, two actions are implemented as one micro-operation. However, most processors provide multiple types of interrupts, it may take one or more micro-operation to obtain the save_address and the routine_address before they are transferred to the MAR and PC respectively.

Control of Processor/CPU:

Responsibilities:

The basic responsibilities of the control unit are to control various operations of CPU such as:
1. Data Exchange Of CPU With Memory Or Input/output Module:
2. Internal Operations Of CPU Such As:
    a. Moving data between Registers.
    b. Making ALU to perform a particular operation on data.
    c. Regulating internal operations.

Functional Requirement:

In order to define the functions of a control unit that it must perform, we have to know what resources and means the control unit need to perform those operations. A control unit must have the following three requirements:

1. Defining Basic Elements of Processor:

The basic functional units of processor are ALU, Registers, Internal Data Path, External Data Path, and Control Unit itself.

2. Describe The Micro-Operations That The Processor Performs:

a. Transfer data from one register to another.
b. Transfer data from the external interface to register.
c. Performing arithmetic logical and shift micro-operations.

3. Determine The Functions That The CPU Must Perform To Cause Micro-Operation To Be Performed:

a. Execution: The control unit cause each micro-operation to be performed.
b. Sequencing: It enables the CPU to execute the proper sequence of micro-operations.

Structure of Control Unit with Control Signals:

Control Unit, Control of the Processor, Hardwired Control Unit, Control Unit Inputs and Control Unit Logic, Micro programmed Control Unit, Micro Instructions and Its Types, Architecture of Micro programmed Control Unit, Microinstruction Sequencing, Micro Instruction Execution, Applications of Hardwired and Micro programmed Control Units

For the control unit to perform its function it must have input that allows it to determine the state of the system. These are the external specification of the control unit. An internal control unit must have logics that are required to perform its sequencing and execution function. The input control unit is:

1. Clock:

This is how a control unit keeps time. The control unit causes one micro-operation or a set of simultaneous micro-operations to be performed for each clock pulse or system clock cycle time.

2. Flags:

These are needed by the control unit to determine the status of processor and outcome of previous ALU operation.

3. Instruction Register:

The Opcode of the current instruction is used to determine, which micro-operation is to be performed.

4. Control Signals from System Bus:

The control bus portion of the system bus provides a signal to control unit such as interrupt signal, acknowledgment signal, etc.

5. Control Signals within CPU:

These control signals cause two types of micro-operation such as data transfer from one register to another and performing various ALU operations using input/output and register.

6. Control Signals to System Bus:

The basic purpose of these control signals is to bring or transfer data from CPU register to memory or input/output module.

Types of Design Issues in Control Unit:

1. Hardwired Control Unit:

In a hardwired organization control logic is implemented with logic gates, flip-flops, decoder, and other digital circuits with control bus signals. On the basis of this input, the output signals are generated. Therefore, output control signals are the functions of input signals.

Advantages:
1. It can be optimized to produce a fast mode of operations.

Disadvantages:
1. It is inflexible in design because of which it is more difficult to modify.
2. It is quite difficult to test and implement because there are hundreds of control lines on the computer.

Two Main Issues in Hardwired Implementation:

a. Control Unit Input:

The main key inputs for the control unit are instruction register, clock signals or time generator, flags, and decoded instructions.

For flags and control bus signals, each bit has a typical meaning but in other two keys, instruction register and time generator extra the circuit is required i.e. decoder.

The function of the decoder is to produce more output from less number of input bits.

Control Unit, Control of the Processor, Hardwired Control Unit, Control Unit Inputs and Control Unit Logic, Micro programmed Control Unit, Micro Instructions and Its Types, Architecture of Micro programmed Control Unit, Microinstruction Sequencing, Micro Instruction Execution, Applications of Hardwired and Micro programmed Control Units

b. Control Unit Logic:

Here each expression can be expressed (written) in the form of Boolean expression for each operation. The output control signals are the same as the function of input signals. Let us consider two control signals P and Q, which maybe expressed as:
PQ = 00; Fetch Cycle
PQ = 01; Indirect Cycle
PQ = 10; Execute Cycle
PQ = 11; Interrupt Cycle

2. Micro-Programmed Control Unit:

Control Unit, Control of the Processor, Hardwired Control Unit, Control Unit Inputs and Control Unit Logic, Micro programmed Control Unit, Micro Instructions and Its Types, Architecture of Micro programmed Control Unit, Microinstruction Sequencing, Micro Instruction Execution, Applications of Hardwired and Micro programmed Control Units

An alternative way to implement the control unit is a microprogram control unit. In which the logic of the control unit is specified by micro-program. A micro-program consists of a sequence of micro-instructions in a micro-programming language.

On executing these micro-instructions, they are responsible for the execution of one or more micro-operation and sequencing through micro-operation.

A micro-program is also known as firmware or mid-way between hardware and software. In comparison to hardware, it is easier to design whereas in comparison to software it is difficult to write. A micro-instruction is made responsible for generating control signals for desired control lines to implement the desired micro-operation.

A set of control signals with each bit representing a single control line is called the control word. The micro-programs are stored in Read Only Memory (ROM) known as control memory.

Advantages:
1. It is easy to design. So it is both cheaper and less error-prone to implement.
2. Since, micro-program can be changed relatively easily so, it is very flexible in comparison to a hardwired control unit.

Disadvantages:
1. It is slower than the hardwired control unit because micro-instructions are to be fetched from control memory which is time-consuming.

Difference between Hardwired and Micro-programmed Control Unit:

Hardwired Control Unit
Micro-programmed Control Unit
It uses flags, decoder, logic gates and other digital circuits.
It uses a sequence of micro-instruction in microprogramming language.
As the name implies it is a hardware control unit.
It is mid-way between Hardware and Software.
On the basis of input Signal output is generated.
It generates a set of a control signal on the basis of the control line.
Difficult to design, test, and implement.
Easy to design, test and implement.
Inflexible to modify.
Flexible to modify.
Faster mode of operation.
Slower mode of operation.
Expensive and high error.
Cheaper and less error.
Used in the RISC processor.
Used in CISC processor.

Micro-instruction Format:

The format of micro-instruction must include the following fields:
1. Micro-instruction address
2. Jump condition, unconditional, zero, overflow, etc.
3. System bus control signals
4. Internal CPU control signals

Types of Micro-instruction Format:

1. Horizontal Micro-instruction Format:

Control Unit, Control of the Processor, Hardwired Control Unit, Control Unit Inputs and Control Unit Logic, Micro programmed Control Unit, Micro Instructions and Its Types, Architecture of Micro programmed Control Unit, Microinstruction Sequencing, Micro Instruction Execution, Applications of Hardwired and Micro programmed Control Units

In horizontal micro-instruction, there is one bit for each internal processor control line and one bit for each system bus control line, therefore the length of such microinstruction may be 100 bits. Such micro-instructions may be executed as follows:

a. To execute micro-instruction turn ON all the control lines indicated by 1 and leave OFF all the control lines indicated by 0 bit. The resulting control signal will cause one or more micro-operations to be performed.

b. If the condition indicated by condition bit is FALSE to execute the next instruction in sequence.

c. If the condition indicated by condition bit is TRUE the next micro-instruction to be executed is indicated in the address field.

2. Vertical Micro-instruction Format:

Control Unit, Control of the Processor, Hardwired Control Unit, Control Unit Inputs and Control Unit Logic, Micro programmed Control Unit, Micro Instructions and Its Types, Architecture of Micro programmed Control Unit, Microinstruction Sequencing, Micro Instruction Execution, Applications of Hardwired and Micro programmed Control Units

In vertical micro-instruction, a code is used for each action to be performed and a decoder is used for translation of these codes into individual control signals. The advantages of vertical micro-instruction are that they are more complex and compact than horizontal microinstruction.

Difference between Horizontal and Vertical Micro-instruction Format:

Horizontal Micro-instruction Format
Vertical Micro-instruction Format
In a horizontal microinstruction every bit in the control field attaches to a control line.
In a vertical microinstruction, a code is used for each action to be performed and the decoder translates this code into individual control signals.
They do not have a decoder.
They have a decoder.
They need higher bits or wider bits.
They need fewer bits but a higher number of the decoder.
They are faster.
They are slower.
They are not complex and compact.
They are complex and compact.
They are easy to design.
They are hard to design.

Microinstruction Sequencing:

Sequencing means getting the next microinstruction from control memory. Two consequences are involved in the design of microinstruction sequencing techniques and they are:
a. Size Of Microinstruction
b. Address Generation Time

The first issues try to minimize the size of control memory to reduce the cost of the control memory component. Similarly, the second issue is used to develop or design a microinstruction that can be executed as fast as possible.

In executing a microinstruction the address of next microinstruction to be executed is one of the following categories:
a. Determine by instruction register
b. Next sequential address
c. Branch address

Microinstruction Sequencing Techniques:

Based on the current microinstruction condition (the content of the flag and content of instruction register). A control memory address must be generated for the next microinstruction. In general three techniques based on the number of the address field in microinstruction are utilized for sequencing.

1. Two Address Field Microinstruction:

Control Unit, Control of the Processor, Hardwired Control Unit, Control Unit Inputs and Control Unit Logic, Micro programmed Control Unit, Micro Instructions and Its Types, Architecture of Micro programmed Control Unit, Microinstruction Sequencing, Micro Instruction Execution, Applications of Hardwired and Micro programmed Control Units

The simplest approach is to provide two address fields in each microinstruction. The above figure suggests how this information is to be used. A multiplexer is provided that serves as a destination for both address fields plus the instruction register. On the basis of address selection input, the multiplexor transmits either the Opcode or one of the two addresses to Control Address Register (CAR).

Address selection signals are provided by the branch logic module whose input consists of control unit flags plus bits from the control portion of the microinstruction. Although the two addresses approach is simple, it requires more bits in microinstruction than other approaches.

2. Single Address Field Microinstruction:

Control Unit, Control of the Processor, Hardwired Control Unit, Control Unit Inputs and Control Unit Logic, Micro programmed Control Unit, Micro Instructions and Its Types, Architecture of Micro programmed Control Unit, Microinstruction Sequencing, Micro Instruction Execution, Applications of Hardwired and Micro programmed Control Units

Single Address Field approach is a common approach in which option for the next address will be one of the following address:
a. Address Field
b. Instruction Register Code
c. Next Sequential Address

The address selection signal determines which option is selected. The approach reduces the number of the address field to one.

3. Variable Format Microinstruction:

Control Unit, Control of the Processor, Hardwired Control Unit, Control Unit Inputs and Control Unit Logic, Micro programmed Control Unit, Micro Instructions and Its Types, Architecture of Micro programmed Control Unit, Microinstruction Sequencing, Micro Instruction Execution, Applications of Hardwired and Micro programmed Control Units

In variable format branch control logic, one bit designates which format is being used. In one format, the remaining bits are used to active control signals. In the other format, some bits drive the branch logic module, and the remaining bits provide the address. With the first format, the next address is either the next sequential address or an address derived from the instruction register. With the second format, either a conditional or unconditional branch is being specified.

One disadvantage of this approach is that one entire cycle is consumed with each branch microinstruction.

Micro-instruction Execution:

The microinstruction cycle is the basic event on a micro-programmed processor. Each cycle is made up of the two parts: fetch and execute. This section deals with the execution of microinstruction. The effect of the execution of a microinstruction is to generate control signals for both the internal control to the processor and the external control to the processor.

Control Unit, Control of the Processor, Hardwired Control Unit, Control Unit Inputs and Control Unit Logic, Micro programmed Control Unit, Micro Instructions and Its Types, Architecture of Micro programmed Control Unit, Microinstruction Sequencing, Micro Instruction Execution, Applications of Hardwired and Micro programmed Control Units

No comments:

Post a Comment

If you have any doubt, then don't hesitate to drop comments.