Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSE 241 Computer Organization Lecture # 8 Ch. 7 Control Unit Dr. Tamer Samy Gaafar Dept. of Computer & Systems Engineering.

Similar presentations


Presentation on theme: "CSE 241 Computer Organization Lecture # 8 Ch. 7 Control Unit Dr. Tamer Samy Gaafar Dept. of Computer & Systems Engineering."— Presentation transcript:

1 CSE 241 Computer Organization Lecture # 8 Ch. 7 Control Unit Dr. Tamer Samy Gaafar Dept. of Computer & Systems Engineering

2 Course Web Page http://www.tsgaafar.faculty.zu.edu.eg — Email: tsgaafar@yahoo.com

3 General-purpose arithmetic and logic functions Data Results Instruction Interpreter Instruction codes Control signals Each code is an instruction. A sequence of codes (or instructions) is called software. CPU

4 Micro-operations A computer executes programs. A program is a sequence of instructions  instruction cycles. Each instruction is made up of smaller units (subcycles). —e.g., fetch/execute subcycles. Each subcycle has a number of steps. Each step has a number of micro-operations. Each micro-operation does very little. Micro-operation is an atomic operation of CPU. Any instruction can be described as a sequence of micro-operations.

5 Constituent Elements of Program Execution

6 Fetch Subcycle 0000000001100100 0001000000100000 0000000001100100 0001000000100000 MAR MBR PC IR AC Memory Address Register (MAR) —Connected to address bus. —Specifies address for read or write operation. Memory Buffer Register (MBR) —Connected to data bus. —Holds data to write or last data read. Program Counter (PC) —Holds address of next instruction to be fetched. Instruction Register (IR) —Holds last instruction fetched.

7 Fetch Sequence Address of next instruction is in PC. Address (MAR) is placed on address bus. Control unit issues READ command. Result (data from memory) appears on data bus. Data from data bus copied into MBR. PC incremented by 1 (in parallel with data fetch from memory). Data (instruction) moved from MBR to IR. MBR is now free for further data fetches.

8 Fetch Sequence (symbolic) t 1 :MAR ← (PC) t 2 :MBR ← (memory), PC ← (PC) +I t 3 :IR ← (MBR) (tx = time unit/clock cycle) Micro-operations take equal times. Or t 1 :MAR ← (PC) t 2 :MBR ← (memory) t 3 :PC ← (PC) +I, IR ← (MBR) Step Micro-operation t1t1 t2t2 t3t3

9 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 step (cycle). PC ← (PC) +1 involves addition Use ALU. May need additional micro-operations. Rules for Clock Cycle Grouping

10 Indirect Subcycle MAR ← (IRaddress) - address field of IR MBR ← (memory) IRaddress ← (MBR) MBR contains an address. IR is now in same state as if direct addressing had been used.

11 Interrupt Subcycle At the end of the execute subcycle, interrupts are tested. Some interrupt occurred  interrupt subcycle. t 1 :MBR ← (PC) t 2 :MAR ← save-address, PC ← routine-address t 3 :memory ← (MBR) This is a minimum May be additional micro-ops to get addresses. N.B. saving context is done by interrupt handler routine, not micro-ops.

12 Execute Subcycle (ADD) Execute subcycle is different for each instruction. ADD R1, X Add the contents of location X to register R1, result in R1 t 1 :MAR ← (IRaddress) t 2 :MBR ← (memory) t 3 :R1 ← R1 + (MBR) Note no overlap of micro-operations.

13 Execute Subcycle (ISZ) ISZ X - increment and skip if zero t 1 :MAR ← (IRaddress) t 2 :MBR ← (memory) t 3 :MBR ← (MBR) + 1 t 4 :memory ← (MBR) if (MBR) == 0 then PC ← (PC) + 1 Notes: “If …” is a single micro-operation. Micro-operations done during t 4.

14 Functional Requirements of Control Unit 1.Define basic elements of processor ALU Registers Internal data paths External data paths Control Unit 2.Describe micro-operations processor performs Transfer data between registers. Transfer data from register to external/system bus. Transfer data from external/system bus to register. Perform arithmetic or logical operations. 3.Determine functions control unit must perform Sequencing: Causing the CPU to step through a series of micro-operations in the proper sequence. Execution: Causing each micro-operation to be performed.

15 Model of the Control Unit

16 Control Unit – Inputs and Outputs Inputs Clock: One micro-operation (or set of parallel micro-operations) per clock cycle. Instruction register Opcode for current instruction. Determines which micro-operations are performed. Flags State of CPU. Results of previous operations. Control signals from control bus Interrupts. Acknowledgements. Outputs (control signals) Within CPU Causes data movement. Activates specific functions. Via control bus: to memory and to I/O modules.

17 Data Paths and Control Signals MAR ← (PC) - Control unit activates signal to open gates between PC and MAR: C 2 MBR ← (memory) - Open gates between MAR and address bus : C 0 - Memory read control signal. - Open gates between data bus and MBR : C 5 Instruction Fetch

18

19 Internal Organization Usually a single internal bus. Gates control movement of data onto and off the bus. Control signals control data transfer to and from external systems bus. Temporary registers needed for proper operation of ALU. t 1 : MAR ← (IRaddress) t 2 : MBR ← (memory) t 3 : Y ← (MBR) t 4 : Z ← (AC) + (Y) t 5 : AC ← (Z) ALU

20


Download ppt "CSE 241 Computer Organization Lecture # 8 Ch. 7 Control Unit Dr. Tamer Samy Gaafar Dept. of Computer & Systems Engineering."

Similar presentations


Ads by Google