Control Unit Operation (Cao.pdf)

Document Details

GratifyingAffection7102

Uploaded by GratifyingAffection7102

P.E.S. Modern College of Engineering

Tags

computer architecture control unit micro-operations instruction sequencing

Summary

This document provides a detailed explanation of the control unit in computer architecture. It covers instruction sequencing, branching (conditional and unconditional), and the concept of micro-operations. The text also includes examples and diagrams for better understanding.

Full Transcript

# CONTROL UNIT OPERATION ## 5.1 Instruction Sequencing - Every processor has some basic types of instructions like: - Arithmetic instructions - Logical instructions - Data transfer instructions - Branch instructions - It is the programmers job to select and write appropriate instru...

# CONTROL UNIT OPERATION ## 5.1 Instruction Sequencing - Every processor has some basic types of instructions like: - Arithmetic instructions - Logical instructions - Data transfer instructions - Branch instructions - It is the programmers job to select and write appropriate instructions in a proper sequence. - This is called **Instruction Sequencing** and a set of these instructions is called a **program**. ## 5.1.1 Instruction Sequencing ### Three Distinct Phases 1. Determining the memory address that contains the instruction. 2. Fetching the instruction from memory. 3. Executing the instruction. ### Read/Decode Instruction - Read two bytes from memory using the PC value as the address to start reading from. - Depending on what is contained in those two first bytes, read any subsequent bytes as required. - Read source operands (data) - Perform operation. - Write result to destination. ### PC - PC = PC + size of(instruction). ### Straight Line Execution - Once an instruction is executed, then the next will be executed. - Instructions are stored in memory and the contents of the PC register are used to fetch the address of the next instruction to be executed. ## 5.1.2 Branching - Sometimes it is not possible to store a program in consecutive memory locations. - We have to use **branch instructions** to transfer the program control from one straight line sequence to another. - PC holds the address of the instruction to be executed next. ### Two Types of Branching 1. **Conditional Branching**: - Some condition is specified in an instruction. - If the condition is true, transfer program control to another loop. - A new address is loaded into the PC and execution starts from this new address. - Such branch instructions are called **conditional branch instuctions**. - Example: If A > B, perform A - B. If B > A, perform B - A. - `MOV R, A` - Get the number in R<sub>0</sub>. - `MOV R₁, B` - Get the number in R<sub>1</sub>. - `CMP R<sub>0</sub>, R<sub>1</sub>` - A - B. - `JB NEXT` - If A < B go to NEXT - `SUB R<sub>0</sub>, R<sub>1</sub>` - A = A - B. - `MOV R₂, R<sub>0</sub>` - Store result in R<sub>2</sub>. - `NEXT:` - `SUB R₁, R<sub>0</sub>` - B = B - A - `MOV R₂, R₁` - Store result in R<sub>2</sub>. 2. **Unconditional Branching**: - Without checking any condition, transfer program control to some another loop. - Example: Add 2 numbers A and B. - `MOV R₂, A` - `MOV R₁, B` - `CALL NEXT` - `NEXT: ADD R<sub>0</sub>, R<sub>1</sub>` - `MOV R<sub>3</sub>, R<sub>0</sub>` ## 5.1.3 Micro-Operations - A computer executes a program of instructions (or instruction cycles). - Each instruction cycle has a number of steps or phases: - Fetch - Indirect (if specified) - Execute - Interrupt (if requested). - Each of these steps are made up of a smaller series of steps called micro-operations. ### Micro-Operation Execution - Each micro-operation is initiated and controlled based on the use of control signals/lines coming from the control unit. ## Computer Architecture & Organization ### Micro-operations - Are the functional or atomic operations of a processor. - In this section, we will examine micro-operations to gain an understanding of how the events of any instruction cycle can be described as a sequence of such micro-operations. ## The Fetch Cycle - Occurs at the beginning of each instruction cycle and causes an instruction to be fetched from memory. ### Four Registers involved 1. **Memory Address Register (MAR)** - Connected to the address lines of the system bus. It specifies the address in memory for a read or write operation. 2. **Memory Buffer Register (MBR)** - Connected to the data lines of the system bus. It contains the value to be stored in memory or the last value read from memory. 3. **Program Counter (PC)** - Holds the address of the next instruction to be fetched. 4. **Instruction Register (IR)** - Holds the last instruction to be fetched. ### Sequence of Events for the Fetch Cycle Let us look at the sequence of events for the fetch cycle from the point of view of its effect on the processor registers. - An example appears in the diagram. #### Beginning - `MAR = 0000000001100100` - `MBR = 000000010000000` - `PC = 0000000001100100`. - `IR = 0` #### First Step - `MAR = 0000000001100100` - `MBR = 000000010000000` - `PC = 0000000001100100` - `IR = 0` - **Control Signals**: `PCout` and `MARin`. #### Second Step - `MAR = 0000000001100100` - `MBR = 0001000001000000` - `PC = 0000000001100100` - `IR = 0` - **Control Signals**: `MARout`, `RAMout`, and `MDRin`. #### Third Step - `MAR = 0000000001100100` - `MBR = 0001000001000000` - `PC = 0000000001100100` - `IR = 0001000001000000` - **Control Signals**: `MDRout`, `Opcode`, and `IRin`. #### Fourth Step - `MAR = 0000000001100100` - `MBR = 0001000001000000` - `PC = 0000000001100101` - `IR = 0001000001000000` - **Control Signals**: `PCout`, `MARin` and `PCin`. ## 5.1.4 Four Categories of Micro-Operations in Digital Computers 1. **Register Transfer Micro-operations**: Transfer binary information from one register to another. 2. **Arithmetic Micro-operations**: Perform arithmetic operations on numbers stored in registers. 3. **Logic Micro-operations**: Perform bit manipulation operations on non-numeric data stored in registers. 4. **Shift Micro-operations**: Perform shift operations on the contents of registers. ### Register Transfer - Symbols for register transfers: > `R<sub>2</sub> <- R<sub> 1</sub>` - The contents of register `R<sub>1</sub>` are copied (loaded) into register `R<sub>2</sub>`. ## 5.2 Control of the Processor ### Functional Requirements - Decomposed the behavior or functioning of the processor into elementary operations, called micro-operations. - By reducing the operation of the processor to its most fundamental level, we are able to define exactly what it is that the control unit must cause to happen. ### Functional Requirements for the Control Unit - Those functions that the control unit must perform. - A definition of these functional requirements is the basis for the design and implementation of the control unit. ### Three-Step Process 1. **Define the basic elements of the processor.** 2. **Describe the micro-operations that the processor performs.** 3. **Determine the functions that the control unit must perform to cause the micro-operations to be performed. ** ### Basic Functional Elements of the Processor - ALU - Registers - Internal data paths - External data paths - Control Unit ### All Micro-Operations fall into one of the following categories: 1. **Transfer data from one register to another.** 2. **Transfer data from a register to an external interface (e.g., system bus).** 3. **Transfer data from an external interface to a register.** 4. **Perform an arithmetic or logic operation using registers for input and output.** ### Control Signals - Inputs that allow it to determine the state of the system. - Outputs that allow it to control the behavior of the system. ### Two Basic Tasks 1. **Sequencing**: The control unit causes the processor to step through a series of micro-operations in the proper sequence, based on the program being executed. 2. **Execution**: The control unit causes each micro operation to be performed. ## 5.3 Hardwired Implementation - The control unit is essentially a state machine circuit. - Its input logic signals are transformed into a set of output logic signals which are the control signals. ### Control Unit Inputs: - Instruction register - Clock - Flags - Control bus signals ### Control Signals go to Three Separate Destinations: 1. **Data paths**: The control unit controls the internal flow of data. For example, on instruction fetch, the contents of the memory buffer register are transferred to the instruction register. 2. **ALU**: The control unit controls the operation of the ALU by a set of control signals. These activate various logic circuits and gates within the ALU. 3. **System bus**: The control unit sends control signals out over the control lines of the system bus (e.g., memory READ). ## 5.4 Microprogrammed Control Unit - An orderly method of designing the control unit of a conventional computer. - The term microprogramming is based on the analogy between a sequence of transfer required to execute a machine instruction and a conventional user program. ### The Control Unit Functions as Follows: 1. To execute an instruction, the sequencing logic unit issues a READ command to the control memory. 2. The word whose address is specified in the control address register is read into the control buffer register. 3. The content of the control buffer register generates the control signal and next address information for sequencing logic unit. 4. The sequencing logic unit loads a new address into the control address register based on the next address information from the control buffer register and the ALU flags. ## 5.4.1 Basic Layout of a Microprogrammed Control Unit - Instruction Register - ALU - Flags - Control Address Register - Sequencing Logic - *Clock* - Control Memory - Control Buffer Register - Control Logic - Internal External control signals ## 5.4.2 Grouping of Control Signals in Microprogrammed Control - A simple way to structure micro instructions is to assign one-bit position to each control signal required in the CPU. - This scheme has one drawback: the assigning individual bits to each control signal results in long micro instructions, because the number of required signals is usually large. - Moreover, only a few bits are used in any given instruction.. ### Solution: Grouping of control signals - To reduce the number of bits in the micro instruction, we can use a grouping technique. ## 5.5 Basic Concepts ### Micro Operations - A sequence of steps that make up the instruction cycle. - Example: Fetch, decode, execute. ### Micro-Operation Execution - Each step of the instruction cycle can be decomposed into micro-operation primitives that are performed in a precise time sequence. - Each micro-operation is initiated and controlled based on the use of control signals/lines coming from the control unit.. ### Micro-Instruction - Each instruction of the processor is translated into a sequence of lower-level micro-instructions. ### Microprogramming - The process of translation and execution are referred to as _microprogramming_. - A _microprogram_ consits of a sequence of _micro-instructions_ in a _microprogramming_. ### Microprogrammed Control Unit - A logic circuit capable of sequencing through micro-instructions and generating control signals to execute each micro-instruction. ### Control Unit - An important portion of the processor. - Issues external control signals to cause data exchange with memory and 1/O unit. - Issues internal signals to move data between registers, to perform the ALU and other internal operations in the processor. ## 5.6 Micro-Instruction Sequencing - Two basic tasks performed by a microprogrammed control unit: 1. **Micro-Instruction Sequencing**: Get the next instruction from the control memory. 2. **Micro-Instruction Execution**: Generate the control signals needed for execution. ### Design Considerations in Micro-instruction Sequencing - Two concerns in the design of micro-instruction sequencing techniques: 1. **The Size of Micro-Instruction**: Minimizing the size of the control unit reduces the cost of components. 2. **The Address Generation Time**: To execute micro instructions as fast as possible. In executing a microprogram, the address of the next micro instruction to be executed is in one of these categories: - Determined by instruction register - Next sequential address - Branch ### 5.6.1 Sequencing Techniques - Based on the current instruction, condition flags, and the content of the instruction register, the control memory address must be generated for the next micro-instruction. - Three general categories for a control memory address are as follows: 1. Two address fields 2. Single address field 3. Variable format ## 5.7 Micro-Instruction Execution - The micro-instruction cycle is the basic event on a microprogrammed processor. - Each cycle is made up of the two parts: fetch and execute. ## 5.8 Applications of Microprogramming - Input/output processing - Real-time data processing - Airbone systems - Data management systems - Security - Software production - Emulation - Micro diagnostics - Special-purpose devices - Dynamic microprogramming ## 5.9 Control Unit Architecture and Organization - To define the hardwired implementation of a control unit, all that remains is to discuss the internal logic of the control unit that produces output control signals as a function of its input signals. - Essentially, what must be done is, for each control signal, to derive a Boolean expression of that signal as a function of the inputs. ### Control Signals within the Processor - **Control Signals to memory, and control signals to the I/O modules.** - **Three types of control signals are used**: 1. **Those that activate an ALU function.** 2. **Those that activate a data path.** 3. **Those that are signals on the external system bus or other external interface.** ### Control Signals from the Control Bus - The output signals are as follows: - **Control signals within the processor**: These signals are of two types: 1. Signals that cause data to be moved from one register to another. 2. Signals that activate specific ALU functions. - **Control Signals to Control Bus**. ### Instruction Register - The opcode and addressing mode of the current instruction are used to determine which micro operations to perform during the execute cycle. ### Flags - Used by the control unit to determine the status of the processor and the outcome of previous ALU operations. ### Control Signals from Control Bus - The control bus portion of the system bus provides signals to the control unit. ## 5.10 Microprogrammed Control Unit ### Microprogramming - orderly method of designing the control unit of a conventional computer. - Wilkes (1951) introduced the concept. ### 5.10.1 Control Unit Logic - Define the hardwired implementation of a control unit by discussing the internal logic of the control unit that produces output control signals as a function of its input signals. - Essentially, for each control signal, derive a Boolean expression of that signal as a function of the inputs. ### 5.10.2 Control Signals Example - Simple example: illustrates a single accumulator processor. ## 5.11 Microprogrammed Control Unit Organization - A simple way to structure micro-instructions is to assign one-bit position to each control signal required in the CPU. - However, this scheme has one drawback: assigning individual bits to each control signal results in long micro instructions, because the number of required signals is usually large. - Moreover, only a few bits are used in any given instruction. ### Solution: Grouping of Control Signals - Reduce the number of bits in the micro-instruction using a grouping technique. ## 5.12 Micro-Instruction Sequencing - Two basic tasks performed by a microprogrammed control unit: 1. **Micro-Instruction Sequencing**: Get the next instruction from the control memory. 2. **Micro-Instruction Execution**: Generate the control signals needed for execution. ### Design Considerations in Micro-instruction Sequencing - Two concerns in the design of micro-instruction sequencing techniques: 1. **The Size of Micro-Instruction**: Minimizing the size of the control unit reduces the cost of components. 2. **The Address Generation Time**: To execute micro instructions as fast as possible. In executing a microprogram, the address of the next micro instruction to be executed is in one of these categories: - Determined by instruction register - Next sequential address - Branch ### 5.12.1 Sequencing Techniques - Based on the current instruction, condition flags, and the content of the instruction register, the control memory address must be generated for the next micro-instruction. - Three general categories for a control memory addresses are as follows: 1. Two address fields 2. Single address field 3. Variable format ## 5.13 Micro-Instruction Execution - Micro-instruction cycle is the basic event on a microprogrammed processor. - Each cycle is made up of the two parts: fetch and execute. ### Control Levels - A microprogrammed computer has two distinct levels of control: 1. **Instruction Level**: CPU continuously executes instruction cycles that involve the following steps: - By using PC, CPU fetches an instruction from main memory. - Store the opcode part of instruction in IR, the operation specified by IR is then decoded and executed. - PC is altered to point to the next instruction to be fetched from memory. 2. **Micro-Instruction Level**: The control unit continuously executes micro-instruction cycles as follows: - The addressing portion of the control unit fetches a Micro-Instruction M<sub>i</sub> from Control Memory CM, whose address is stored in the microprogram counter. - M<sub>i</sub> is loaded into the Micro-Instruction Register MIR and is decoded to produce the required control signals. - Micro PC is altered to point to the next instruction to be fetched from CM. ## 5.14 Applications of Microprogramming - Input/Output Processing - Real-time data processing - Airbone systems - Data management systems - Security - Software production - Emulation - Micro diagnostics - Special-purpose devices - Dynamic microprogramming ## 5.15 Multiple Choice Questions 1. Which of the following registers in a single-bus organization of the processor is inaccessible to the programmer? - Temp - y - z - All of these 2. Which coordinates the input and output devices of a computer system? - Processor - ALU - Control Unit - None of these 3. Which registers are used as temporary registers? - Y - Z - A and B - None of these 4. The ..... bus is a set of lines that carry information about where in memory data is to be transferred to or from. - Data - Control - Address - All of these 5. The ...... bus are the lines that actually carry data being transferred. - Address - Control - Data - None of these ## 5.16 Data Management Systems - Through microprogramming reduce the implementation and performance problems of data management systems and to make it easier to instrument system software for debugging. - These systems usually offer data management services consisting, at a minimum, of file creation, updating, retrieval, and report generation. ## 5.17 Security - Protection must be provided against accidental or overt destruction of processes and data as well as illegal access. - The solution will probably involve a combination of hardware and software techniques. ## 5.18 Software Production: - High-order programming languages can be used to improve programmer productivity and software reliability. - Microprogramming can be used to improve the effectiveness of HOLs in the _software production processes_. ## 5.19 Emulation: - Combined software/hardware interpretation of the machine instruction of one machine by another. - The target's machine architecture is mapped onto the host machine - Programs written in the machine language of one processor can then be run by another processor. - This is known as _emulation_. If P<sub>1</sub> can execute instructions of P<sub>2</sub> then we can say that P<sub>1</sub> emulates P<sub>2</sub>. ### Advantages of Emulation - *Replace obsolete equipment with more up-to-date machines*. The replacement computer fully emulates the original one so no software changes have to be made to run existing programs. - *Test and Debug the Hardware and Software of an external system such as the prototype of a microprocessor-based instrument*. ## 5.20 Micro Diagnostics: - Microprogramming diagnostic routines have allowed refinements and increased the speed of detecting and localizing faults, including error detection and correction of micro-storage itself. ### Types of Diagnostics - Software diagnostics - Hardware diagnostics (Test Generation Methods) - Microdiagnostics - ## 5.21 Special-Purpose Devices: - Special processors for data communication, data acquisition, and device controllers can be designed through microprogramming. ## 5.22 Dynamic Microprogramming: - Allows routines to be easily microprogrammed. - Computer can be restructured to represent any instruction vocabulary by use of writable control memory (WCM). - It allows the instruction set of the machine to be changed and be TAILORED to specific applications.

Use Quizgecko on...
Browser
Browser