Top Banner
EE321 Computer Architecture Chap 03 : Central Processing Unit (CPU) Chap. 03 : Central Processing Unit (CPU) Dr. Abdelhakim Khouas Email : akhouas@hotmail.com ab khouas@univ boumerdes dz ab.khouas@univ-boumerdes.dz IGEE (ex. INELEC) University M’hamed Bougara of Boumerdes
60

EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

Mar 09, 2021

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

EE321Computer Architecture

Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central Processing Unit (CPU)

Dr. Abdelhakim KhouasEmail : [email protected]

ab khouas@univ boumerdes [email protected] (ex. INELEC)

University M’hamed Bougara of Boumerdes

Page 2: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

Course chapters

1. Review of Digital Design1. Review of Digital Design2. Top level of Computer3 Central Processing Unit (CPU)3. Central Processing Unit (CPU)4. Control Unit5 M5. Memory6. Instruction Set and Addressing Modes

EE321 - Chap. 03 – CPU © A. Khouas1

Page 3: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

Lecture Outline

1. CPU Organization 2 Registers Organization2. Registers Organization 3. Instruction Cycle4 I t t4. Interrupts5. CPU Examples

1. The X86 Processor Family2. The ARM Processor3. The Z80 Processor

EE321 - Chap. 03 – CPU © A. Khouas2

Page 4: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

Readings

TextbookComputer Organization and Structure,

Designing for Performance, By William Stallings, 8th edition

SectionsSectionsChapter 3, sections: 3.1 and 3.2Chapter 12, sections: 12.1, 12.2 and 12.3

EE321 - Chap. 03 – CPU © A. Khouas3

Page 5: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

1. CPU Organization

CPU with systemCPU with system buses

EE321 - Chap. 03 – CPU © A. Khouas4

Page 6: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

1. CPU Organization

CPU internalCPU internal structure

EE321 - Chap. 03 – CPU © A. Khouas5

Page 7: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

1. CPU Organization

To understand the organization of the CPU, let usTo understand the organization of the CPU, let us consider the things that it must do:

Fetch instruction: The processor reads an instruction fromFetch instruction: The processor reads an instruction from memoryInterpret instruction: The instruction is decoded to pdetermine what action is requiredFetch data: The execution of an instruction may require

di d t f I/O d lreading data from memory or an I/O moduleProcess data: The execution of an instruction may require performing some arithmetic or logical operation on dataperforming some arithmetic or logical operation on dataWrite data: The results of an execution may require writing data to memory or an I/O module

EE321 - Chap. 03 – CPU © A. Khouas6

Page 8: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

1. CPU Organization

To do the basic operations it should be clear thatTo do the basic operations, it should be clear that the processor needs to:

St d t t ilStore some data temporarily Remember the location of the last instruction so that it can know where to get the next instructioncan know where to get the next instruction. Store instructions and data temporarily while an instruction is being executedinstruction is being executed

I th d th CPU d ll i t lIn other words, the CPU needs a small internal memory

EE321 - Chap. 03 – CPU © A. Khouas7

Page 9: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

2. Registers Organization

CPU must have some working space (temporary storage) called registers

High speed storage locationsHigh speed storage locationsNumber and function vary between processor designsdesignsOne of the major design decisionsTop level of memory hierarchy

EE321 - Chap. 03 – CPU © A. Khouas8

Page 10: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

2. Registers Organization

The registers in the processor perform two roles:The registers in the processor perform two roles:i. User-visible registers: Enable the CPU to minimize

main memory references by optimizing use ofmain memory references by optimizing use of registers

ii. Control and status registers: Used by the control unit t t l th ti f th d bto control the operation of the processor and by privileged, operating system programs to control the execution of programs.execution of programs.

There is not a clean separation of registers into these two categories For example on x86 thethese two categories. For example, on x86, the program counter is user visible.

EE321 - Chap. 03 – CPU © A. Khouas9

Page 11: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

2.1. User Visible Registers

A user visible register is one that may beA user-visible register is one that may be referenced by means of the machine language y g gthat the processor executes. We can characterize these in the following categories:

General PurposeGeneral PurposeDataAddAddressCondition Codes

EE321 - Chap. 03 – CPU © A. Khouas10

Page 12: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

2.1. User Visible Registers

General purpose registers can be assigned to aGeneral-purpose registers can be assigned to a variety of functions by the programmer

That is, any general-purpose register can contain the operand for any opcode. This provides true p y p pgeneral-purpose register use

Often, however, there are restrictions. For example, there may be dedicated registers for stack operations. In some cases, general-purpose registers can be used for addressing functions. In other cases, there is a partial oraddressing functions. In other cases, there is a partial or clean separation between data registers and address registers.

EE321 - Chap. 03 – CPU © A. Khouas11

Page 13: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

2.1. User Visible Registers

Data registers: may be used only to hold data andData registers: may be used only to hold data and cannot be employed in the calculation of an operand addressoperand address

Address registers: may themselves be somewhat general purpose, or they may be devoted to a particular addressing mode. Examples include the p g pfollowing:

Segment pointersSegment pointersIndex registersStack pointer

EE321 - Chap. 03 – CPU © A. Khouas

p

12

Page 14: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

2.1. User Visible Registers

condition codes (also referred to as flags) are bits set by the processor hardware as thebits set by the processor hardware as the result of operations

For example, an arithmetic operation may produce a positive, negative, zero, or overflow result. a pos t e, egat e, e o, o o e o esu tCodes may be tested (read) by programs as part of a conditional branch operation (JZ inst )of a conditional branch operation (JZ inst.)Codes can not be set by programs

EE321 - Chap. 03 – CPU © A. Khouas13

Page 15: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

2.1. User Visible Registers

How many?F 8 t 32 i tFrom 8 to 32 registersFewer = more memory references

How big?L h h ld f ll ddLarge enough to hold full addressLarge enough to hold full wordOften possible to combine two data registers

EE321 - Chap. 03 – CPU © A. Khouas14

Page 16: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

2.2. Control & Status Registers

Used by the control unit to control the operation of the processor and the execution of programsprograms

Used during the fetching, decoding and execution f i iof instructions

Many are not visible to the programmer, some are visible but can not be (easily) modified

EE321 - Chap. 03 – CPU © A. Khouas15

Page 17: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

2.2. Control & Status Registers

Typical control and status registers include:Typical control and status registers include:PC: Contains the address of an instruction to be fetchedIR: Contains the instruction most recently fetchedIR: Contains the instruction most recently fetchedMAR: Contains the address of a location in memoryMBR C t i d f d t t b itt tMBR: Contains a word of data to be written to memory or the word most recently readProgram Status Word (PSW): typically contains condition codes plus other status information

EE321 - Chap. 03 – CPU © A. Khouas16

Page 18: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

2.2. Control & Status Registers

Program Status Word (PSW):g ( )Sign: sign bit of the result of the last arithmetic operationZero: Set when the result is 0C S if i l d i ( ddi i ) iCarry: Set if an operation resulted in a carry (addition) into or borrow (subtraction) out of a high-order bit. Used for multiword arithmetic operationspEqual: Set if a logical compare result is equalityOverflow: Used to indicate arithmetic overflowI t t E bl /Di bl U d t bl di blInterrupt Enable/Disable: Used to enable or disable interruptsSupervisor: Indicates whether the processor is executing in p p gsupervisor or user mode. Certain privileged instructions can be executed only in supervisor mode, and certain areas of memory can be accessed only in supervisor mode

EE321 - Chap. 03 – CPU © A. Khouas

memory can be accessed only in supervisor mode

17

Page 19: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

2.3. Example of CPU Register Organizations

Processor Register Organization is generallyProcessor Register Organization is generally called the Programming Model

it represents an internal register map for the programmer to write assembly programsprogrammer to write assembly programs

EE321 - Chap. 03 – CPU © A. Khouas18

Page 20: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

2.3. Example of CPU Register Organizations

The Intel 8086 is 16-bit processor with 20 bitsThe Intel 8086 is 16 bit processor with 20 bits address bus and 16 bit data bus. It has:

Four 16-bit data registers (AX, BX, CX, and DX)addressable on a byte or 16-bit basiscan be used as general purpose in some instructions

Four 16-bit pointer and index reg. (SP, BP, SI and DI)Four 16-bit segment registers (CS, DS, SS, and ES)

Physical PC address = CS*16 + PC

Instruction (or program) pointer register16-bit flags register with 9 active flags

EE321 - Chap. 03 – CPU © A. Khouas

g g g

19

Page 21: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

2.3. Example of CPU Register Organizations

EE321 - Chap. 03 – CPU © A. Khouas20

Page 22: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

2.3. Example of CPU Register Organizations

The Motorola MC68000 has 32-bit registers:The Motorola MC68000 has 32 bit registers:Eight 32-bit data registers (D0-D7) that are used

i il f d t i l ti d dd iprimarily for data manipulation and addressing as index registers. The width of the registers allows 8 16 and 32 bit data ope ations dete mined b8,16, and 32-bit data operations, determined by opcode. Nine 32-bit address registers (A0-A7)

Two A7 registers used as stack pointer (user or OS)

32-bit program counter 16-bit status register

EE321 - Chap. 03 – CPU © A. Khouas

16 bit status register

21

Page 23: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

2.3. Example of CPU Register Organizations

The Zilog Z80 has:The Zilog Z80 has:Six 8-bit general purpose registers: B, C, D, E, H, g p p g , , , , ,and L that can be used to load or copy data 8-bit Accumulator A used to store 8-bit data and to8 bit Accumulator A used to store 8 bit data and to perform ALU operations8-bit flag register F that includes six flags that are8-bit flag register F that includes six flags that are set or reset according to the resultFo 16 bit add ess egiste s IX IY SP and PCFour 16-bit address registers: IX, IY, SP, and PC Two special purpose registers: I and R

EE321 - Chap. 03 – CPU © A. Khouas22

Page 24: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

2.3. Example of CPU Register Organizations

Zilog Z80 registersZilog Z80 registers

EE321 - Chap. 03 – CPU © A. Khouas23

Page 25: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

2.3. Example of CPU Register Organizations

Example x86 Program to calculate the sum of twoExample x86 Program to calculate the sum of two numbers:

MOV EAX, 20H ; EAX = 20H (MOV = move )MOV EAX, 20H ; EAX 20H (MOV move )MOV EBX, 3AH ; EBX = 3AH ADD EAX, EBX ; EAX = EAX + EBX

Example Z80 Program to calculate the sum of twoExample Z80 Program to calculate the sum of two numbers:

LD A, 20H ; Accumulator A = 20H (LD = load )LD A, 20H ; Accumulator A 20H (LD load )LD B, 3AH ; General purpose register B = 3AHADD A, B ; A = A + B

EE321 - Chap. 03 – CPU © A. Khouas24

Page 26: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

3. Instruction Cycle

The basic direct instruction cycle contains theThe basic direct instruction cycle contains the following states:

Instruction address calculation (IAC)Instruction fetch (IF)Instruction fetch (IF)Instruction operation decoding (IOD)O d dd l l ti (OAC)Operand address calculation (OAC)Operand fetch (OF)Data operation (DO)Operand store (OS)

EE321 - Chap. 03 – CPU © A. Khouas

Operand store (OS)

25

Page 27: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

3. Instruction CycleCPU-Memory/IO

exchange

Instruction Cycle State Diagram (Direct Cycle)

EE321 - Chap. 03 – CPU © A. Khouas26

Instruction Cycle State Diagram (Direct Cycle)Source: Computer Organization and Structure, by W. Stallings

Page 28: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

3. Instruction Cycle

For any given instruction cycle some states mayFor any given instruction cycle, some states may be null and others may be visited more than once

Examples:Examples:LOAD A,30H instruction involves the sequence: IAC, IF, IOD, OAC, and OFADD A,30H instruction involves the sequence: IAC, IF, IOD, and DOJUMP 200H instruction involves IAC, IF, and IOD

EE321 - Chap. 03 – CPU © A. Khouas27

Page 29: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

3. Instruction Cycle

d C l ( d )Indirect Cycle (mode)The instruction operand is an addressThe instruction operand is an addressThe memory fetch get the addressAdditi l i i d t f t h thAdditional memory access is required to fetch the data (multiple OF state)

EE321 - Chap. 03 – CPU © A. Khouas28

Page 30: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

4. Interrupts

DefinitionDefinitionInterrupt is a process by which other modules (e.g.

I/O) may interrupt normal sequence of processingThe process is asynchronousp y

Interrupts improve processing efficiencyInterrupts allow the CPU to respond to peripherals on demands while it is free to perform other tasksIn the polling method, the CPU remains in a loop continuously checking the peripheral

EE321 - Chap. 03 – CPU © A. Khouas

y g p p

29

Page 31: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

4. Interrupts

Classes of interrupts:Classes of interrupts:Program

e.g. overflow, division by zeroTimer

Generated by internal processor timerTo perform certain functions on regular basis

I/Ofrom I/O devices

Hardware failuree.g. memory parity error

EE321 - Chap. 03 – CPU © A. Khouas30

Page 32: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

4. Interrupts

Types of Interruptsyp pHardware interrupts: Interrupt generated by HardwareSoftware Interrupts: Interrupt generated by Softwarep p g yMaskable Interrupts: Interrupt can be enabled/disabled or delayed.N k bl I t t I t t l bl dNonmaskable Interrupts: Interrupt always enabled, can not be delayed.Vectored Interrupts: The address of the InterruptVectored Interrupts: The address of the Interrupt Service Routine (ISR) is hard wired. The ISR is the software routine (program) invoked to respond to an interruptinterruptNon-vectored Interrupts: The address of the ISR needs to be supplied

EE321 - Chap. 03 – CPU © A. Khouas

to be supplied

31

Page 33: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

4.1. Interrupt Cycle

Interrupt CycleInterrupt CycleCPU checks for interrupt at the end of the current instructioninstructionWhen CPU receives an interrupt signal, it suspends the currently executed program and jumps to an ISR tocurrently executed program and jumps to an ISR to respond to the incoming interruptThe interrupt is ignored if it is maskable or disabledThe interrupt is ignored if it is maskable or disabledThe address of the ISR can be:

Al d k b th CPU ( t d I t t)Already known by the CPU (vectored Interrupt)Supplied by the peripheral to the CPU (Non-vectored Interrupt)

EE321 - Chap. 03 – CPU © A. Khouas

Interrupt)

32

Page 34: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

4.1. Interrupt Cycle

Program executionIt consists of repeating Fetch, Execute and Interrupt cyclesInterrupt cycles

Instruction cycle with Interrupts

EE321 - Chap. 03 – CPU © A. Khouas33

Source: Computer Organization and Structure, by W. Stallings

Page 35: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

4.1. Interrupt CycleCPU-Memory/IO

exchange

Instruction Cycle State Diagram with Interrupt cycle

EE321 - Chap. 03 – CPU © A. Khouas34

Instruction Cycle State Diagram with Interrupt cycleSource: Computer Organization and Structure, by W. Stallings

Page 36: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

4.1. Interrupt Cycle

If interrupt pending:If interrupt pending:The CPU suspends execution of current program S t tSave contextSet PC to start address of ISRProcess interruptRestore context and continue current programRestore context and continue current program

EE321 - Chap. 03 – CPU © A. Khouas35

Page 37: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

4.1. Interrupt Cycle

User program does notUser program does not have to contain any

i l d tspecial code to accommodate interrupts

CPU and OS are responsible forresponsible for suspending the user program and then

Transfer of Control via Interruptprogram and then resuming it

EE321 - Chap. 03 – CPU © A. Khouas36

Page 38: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

4.2. Multiple Interrupts

We discussed only on the occurrence of a single interrupt however multiple interrupts caninterrupt, however, multiple interrupts can occur

Two approaches can be taken to dealing with multiple interrupts: I Disable interruptsI. Disable interruptsII. Define priorities

EE321 - Chap. 03 – CPU © A. Khouas37

Page 39: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

4.2. Multiple Interrupts

Disable interruptsDisable interruptsCPU will ignore further interrupts while processing one interruptpInterrupts remain pending and are checked after current interrupt has been processedI t t h dl d i thInterrupts handled in sequence as they occur

AdvantageSimple approach

DrawbackDrawback It does not take into account relative priority or time-critical needs

EE321 - Chap. 03 – CPU © A. Khouas38

Page 40: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

4.2. Multiple Interrupts

Sequential Interrupts

EE321 - Chap. 03 – CPU © A. Khouas

Sequential Interrupts

39

Page 41: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

4.2. Multiple Interrupts

Define priorities Low priority interrupts can be interrupted by higherLow priority interrupts can be interrupted by higher priority interruptsWhen higher priority interrupt has been processedWhen higher priority interrupt has been processed, CPU returns to previous interrupt

EE321 - Chap. 03 – CPU © A. Khouas40

Page 42: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

4.2. Multiple Interrupts

Nested Interrupts

EE321 - Chap. 03 – CPU © A. Khouas

Nested Interrupts

41

Page 43: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

4.2. Multiple Interrupts

Example:Example:Consider a system with 3 I/O devices: a printer, a

di k d i ti li ith i idisk, and a communications line, with increasing priorities of 2,4, and 5, respectivelyt 0 b it=0, user program beginst=10, a printer interrupt occurs t=15, a communications interrupt occurst=20, a disk interrupt occurs

Give time sequence of the interrupts (assume all ISRs take 10 units)

EE321 - Chap. 03 – CPU © A. Khouas42

Page 44: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

4.2. Multiple Interrupts

Example of Time Sequence of Multiple Interrupts

EE321 - Chap. 03 – CPU © A. Khouas

Example of Time Sequence of Multiple Interrupts

43

Page 45: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

5. CPU Examples

In this section we examine some of the details of some processor organizations, concentrating

l t i i lon common elements in single processors:Z80 processor80 p ocessoARM processorX86 processor familyX86 processor family

EE321 - Chap. 03 – CPU © A. Khouas44

Page 46: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

5. CPU Examples

Z80 Processor: Programming model8-bit processor8-bit processor8-bit data bus and 16-bit address bus8x8-bit registers and 6x16-bit address registers158 instructions, from 1-byte to 4-bytes , y yinstructions256 input ports256 input ports256 output ports

EE321 - Chap. 03 – CPU © A. Khouas45

Page 47: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

5. CPU Examples

Z80 Processor: Instruction CycleZ80 Processor: Instruction CycleZ80 instruction cycle consists of one to six machine

lcycles Machine cycle can be opcode fetch, memory read and write, and I/O read and writeEach machine cycle consists of three to six T-states y(clock cycles) in duration

Opcode fetch: 4 clock cyclesp yMemory read and write: 3 clock cyclesI/O read and write: 4 clock cycles

EE321 - Chap. 03 – CPU © A. Khouas

I/O read and write: 4 clock cycles

46

Page 48: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

5. CPU Examples

Z80 P I t tZ80 Processor: InterruptsReset signal: /RESETg /

Z80 starts executing ISR at 0000H

1 Non-maskable interrupt: /NMI1 Non maskable interrupt: /NMIZ80 starts executing ISR at address 0066H

1 maskable interrupt: /INT1 maskable interrupt: /INTCan be enabled and disabled using EI and DI instISR dd d d i t t dISR address depends on interrupt mode

8 software interrupts RST 0 to RST 7

EE321 - Chap. 03 – CPU © A. Khouas47

Page 49: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

5. CPU Examples

Z80 Processor: InterruptsZ80 saves the context and PC in the stackZ80 saves the context and PC in the stackZ80 fetch the first instruction of ISR. For maskable interrupt (/INT) the address of ISR depends oninterrupt (/INT), the address of ISR depends on the interrupt mode

Z80 has three processing modes for maskable interruptsZ80 has three processing modes for maskable interrupts that can be set using IM0, IM1, and IM2 instruction

After executing the ISR Z80 restores PC fromAfter executing the ISR, Z80 restores PC from stack and continue execution of the program

EE321 - Chap. 03 – CPU © A. Khouas48

Page 50: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

5. CPU Examples

Z80 Processor: Interrupt modesZ80 Processor: Interrupt modesIM0: Z80 reads a byte from the data bus and executes the ISR at one of the eight locationsexecutes the ISR at one of the eight locations 0000H to 0038H (data*8)IM1: Z80 starts executing ISR at address 0038HIM1: Z80 starts executing ISR at address 0038HIM2: Z80 the program execution is transferred to the memory location: (I register * 256) + Datathe memory location: (I register * 256) + Data bus value

I register store high order 8 bits of the 16 bits ISRI register store high order 8 bits of the 16 bits ISR addressThe low 8 bits must be supplied by the I/O device

EE321 - Chap. 03 – CPU © A. Khouas

pp y /

49

Page 51: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

5. CPU Examples

ARM ProcessorARM (Advanced RISC Machine) processor is the most used IP (Intellectual Property) CPU

IP is a functional block that can be licensed and incorporated as building block within ASIC chip or FPGA design

15 billions ARM-based chip are sold in 2014 (400 millions processors sold by Intel)

EE321 - Chap. 03 – CPU © A. Khouas50

Page 52: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

5. CPU Examples

ARM Processor OrganizationARM Processor Organization

EE321 - Chap. 03 – CPU © A. Khouas51

Page 53: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

5. CPU Examples

ARM Processor OrganizationARM Processor OrganizationMany variations depending on ARM versionA load/store model of data processing, in which operations only perform on operands in registers

d t di tl iand not directly in memoryData goes to register file (Set of 32 bit registers)Rotation and shift unit (before ALU)Conditional execution of instructions minimizes the need for conditional branch instructionsMultiply/accumulate unit

EE321 - Chap. 03 – CPU © A. Khouas52

Page 54: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

5. CPU Examples

ARM Register Organization37 x 32-bit registers37 x 32 bit registers

R0-R12 and R15(PC)6 x R13(SP)6 x R13(SP)6 x R14 (LR)R8 R12 for Fast InterruptR8-R12 for Fast Interrupt6 (1 for each mode) current program status registers (CPSR)(CPSR)

6 saved program status register (SPSR)

EE321 - Chap. 03 – CPU © A. Khouas53

Page 55: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

5. CPU Examples

ARM Register OrganizationARM Register OrganizationR13 normally stack pointer (SP)

Each exception mode has its own R13

R14 link register (LR)Subroutine and exception mode return address

R15 program counter5 p og a ou

EE321 - Chap. 03 – CPU © A. Khouas54

Page 56: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

5. CPU Examples

Intel 8085

EE321 - Chap. 03 – CPU © A. Khouas55

Page 57: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

5. CPU Examples

X86 Family: Pentium 4 registers8x32-bit GP user registers8x32-bit GP user registers6x16-bit segment registersOne 32-bit flags registerOne 32-bit instruction counter8x80-bit registers for floating point numbersOther control and status registers for floating pointOther control and status registers for floating point unit

EE321 - Chap. 03 – CPU © A. Khouas56

Page 58: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

5. CPU Examples

X86 Family: 80486 Instruction Cycle80486 instruction cycle is divided to the following80486 instruction cycle is divided to the following

machine cycles:F t hFetch Decode stage 1Decode stage 2ExecuteExecuteWriteback

EE321 - Chap. 03 – CPU © A. Khouas57

Page 59: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

5. CPU Examples

X86 Family: Pentium Interrupt ProcessingX86 Family: Pentium Interrupt Processing Interrupts

MaskableMaskableNonmaskable

ExceptionspProcessor detectedProgrammed

Interrupt vector tableInterrupt vector tableEach interrupt type assigned a numberIndex to vector table256 * 32 bit interrupt vectors

5 priority classes

EE321 - Chap. 03 – CPU © A. Khouas58

Page 60: EE321 Computer Architecture Chap 03 : Central Processing ...akhouas.univ-boumerdes.dz/ee321/ee321_chap03_CPU_structure_an… · Chap 03 : Central Processing Unit (CPU)Chap. 03 : Central

Summary

CPU Component and functionCPU Component and function

Registers organizationRegisters organization

Instruction Cycley

Interrupts

EE321 - Chap. 03 – CPU © A. Khouas59