41
Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Embed Size (px)

Citation preview

Page 1: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Computer Architecture

Lecture 2: Processor, program cycle, interrupts, system bus

Piotr Bilski

Page 2: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

von Neumann Machine

Main memory

I/O devices

CPU

MBR

AC

MAR

PC IR CU

ALU

Internal bus

I/O AR

I/O BR

Page 3: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Program

• Program is a set of instructions which, executed is a predefined order, assures processing of the information in a desired way.

• Instruction is a machine word, containing information about the executed instruction and memory location, where arguments, results and the next instruction are stored.

Page 4: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Requirements for the computer system executing program (von

Neumann)Computer system should:• Have finite and functionally coherent instruction list;• Be able to insert program into the computer system using

external devices and store instructions in the memory in the identical way as data;

• Store data and instructions in the memory in a way that they were equally accessible for the processor (by the addresses in the memory);

• Be able to process the information by sequential reading of the instructions from the memory and executing them by the processor .

Page 5: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Program vs hardware „program”

X1

X2

X3

X4

Y1

Y2

X1

X2

X3

X4

Y1

Y2

0000: move 4

0001: add 5

0010: store 6

0011: stop

control

Hard-wired program

Page 6: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Computer operation

STARTInstruction fetching

Instruction execution

STOP

Interrupt execution

Fetch cycle Execution cycle

Interrupt cycle

Interrupts valid?

NO

YES

Page 7: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Register transfer language• Symbols of capital letters stand for the content • M – memory• A, MAR etc. – register• writing• ( ) – address• 0:7 – range of bits of the memory word or

registry, used in the operation

For instance: MAR PC

MBR M(MAR)

Page 8: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Instruction fetching cycle

• Program counter (PC) stores address of the next instruction to acquire (at the beginning it is so called entry point)

• Processor fetches instruction from the address pointed by PC

• Value of the PC is increased by 1 (unless something else is required - jump)

• Instruction is loaded into the instruction register (IR)• Processor decodes instruction and executes

operation pointed by it

Page 9: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Illustration of the instruction fetching cycle

MBRAC

MAR

PC IR CU

ALU

ADDRESS BUS

Entry point

MAR PC

Address Content

100 Move 104

101 Add 105

102 Store 106

103 Stop

104 3

105 5

106 100

Page 10: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

MBRAC

MAR

PC IR CU

ALU

CONTROL BUS

READ

101

DATA BUS

ADDRESS BUS

MBR M(MAR)Move 104

Illustration of the instruction fetching cycle (cont.)

Address Content

100 Move 104

101 Add 105

102 Store 106

103 Stop

104 3

105 5

106

Page 11: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

MBRAC

MAR

PC IR CU

ALU

CONTROL BUS

PC PC + 1READ

100

DATA BUS

ADDRESS BUS

Move 104

101

Illustration of the instruction fetching cycle (cont.)

Address Content

100 Move 104

101 Add 105

102 Store 106

103 Stop

104 3

105 5

106

Page 12: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

MBRAC

MAR

PC IR CU

ALU

CONTROL BUS

READ

100

ADDRESS BUS

Move 104

101

Move 104

IR MBR

Illustration of the instruction fetching cycle (cont.)

DATA BUS

Address Content

100 Move 104

101 Add 105

102 Store 106

103 Stop

104 3

105 5

106

Page 13: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

MBRAC

MAR

PC IR CU

ALU

CONTROL BUS

READ

100

DATA BUS

ADDRESS BUS

Move 104

101

Move 104CU IR

Illustration of the instruction fetching cycle (cont.)

Address Content

100 Move 104

101 Add 105

102 Store 106

103 Stop

104 3

105 5

106

Page 14: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Instruction execution cycle

• Processor-memory– data transfer between CPU and memory

• Processor – input/output– data transfer between CPU and input/output module

• Data processing– Arithmetic or logical operations on the data – Change of the instruction execution order (for

example, jump)

• Control• Combination of the above

Page 15: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

MBRAC

MAR

PC IR CU

ALU

CONTROL BUS

104

Data BUS

ADDRESS BUS

3

101

Move 104

READ

MAR IR(104)

104

MBR M(104)

AC MBR

Illustration of the instruction execution cycle (cont.)

Address Content

100 Move 104

101 Add 105

102 Store 106

103 Stop

104 3

105 5

106

Page 16: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Next instruction fetching cycle

MBRAC

MAR

PC IR CU

ALU

CONTROL BUS

101

DATA BUS

ADDRESS BUS

101

READ

Add 105

MAR PC

MBR M(101)

Address Content

100 Move 104

101 Add 105

102 Store 106

103 Stop

104 3

105 5

106

Page 17: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

MBRAC

MAR

PC IR CU

ALU

CONTROL BUS

101

DATA BUS

ADDRESS BUS

101

READ

Add 105

IR MBR

CU IRAdd 105

Next instruction fetching cycle (cont.)

Address Content

100 Move 104

101 Add 105

102 Store 106

103 Stop

104 3

105 5

106

Page 18: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Instruction format

0 3 4 15

0 1 15

Operation code Address

Size

Sign

For example Move 104 - 0101000001101000

instruction argument

Page 19: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

State graph of the instruction cycle

Fetch instr.

Calculate instr.

address

Instr. decode

Calculate argument addr.

Fetching argument

Data operation

Check for

interrupts

Interrupt execution

Calculate argument addr.

Saving argument

Instruction executed, fetch the next one

Many arguments

Many results

No interrupts Return to data

Page 20: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Interrupts

• Mechanism allowing to disturb the original execution order by the other system components

• Programmed– For example, overflow, divide by zero

• Clock-generated– Generated by the internal processor clock– Used for process scheduling

• Input/Output– From the I/O controller

• Hardware failure– Memory parity error

Page 21: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Application of the interruptsUser program

1

2

3

WRITE

WRITE

I/O program

4

5

I/O instruction

User program

1

2a@2b

3a@3b

WRITE

WRITE

I/O Program

4

5

I/O instruction

Interrupt execution program

Stop

Stop

Page 22: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Interrupt cycle

• Processor checks periodically, if the interrupt ocurred– It is shown by the interrupt signal

• If no interrupt occured, the next instruction is fetched

• If the interrupt occured:– The executed program is suspended– Its context is saved– Program counter is set to the address of the first

instruction of the interrupt execution program– Interrupt is processed– After that, the previous context is loaded to the CPU

and the user program is executed from the point it was suspended

Page 23: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Multiple interrupts

Two ways of the multiple interrupts execution exist• Blocked interrupts

– Processor ignores other interrupts while the current interrupt is processed

– Interrupts are queued and after the current interrupt is processed, the next one (if exists) is processed

– Interrupts are executed in the sequence they occured

• Priorities– Execution of the low priority interrupt can be suspended

by the higher priority interrupt– After execution of the higher priority interrupt the

execution of the low priority interrupt is continued

Page 24: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Multiple interrupts execution

User program Interrupt nr 1

Interrupt nr 2

User program Interrupt nr 1

Interrupt nr 2

Sequential execution Priority execution

Page 25: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Example of the interrupts assignment

Page 26: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Data flow in the computer modules

MEMORY

N words

INPUT / OUTPUT MODULE

M ports

PROCESSOR

ADRESS

DATA

DATA

DATA DATA

ADRESS

ADRESSINSTR.

readwrite

writeread

Internal data

External data

Internal data

External data

INT. INT.

INT.

Page 27: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

BUS

• The highway to allow communication between the devices

• Includes multiple trails of the three types: data, address and control

• Breadth of the bus is the maximum number of bits, which can be transferred between the modules

Page 28: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

The main buses

• ISA (1985)• PCI (1993)• AGP 1x/2x (1997-1998)• AGP 4x (1999)• AGP 8x (2002)• PCI Express (2004)• SCSI (1979)• Industrial busses (PROFIBUS, IEC-625)

Page 29: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Buses bandwidth

Page 30: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

How does it work?

Communication between the two modules

Sending data:

1. Accessing the bus

2. transferring the data

Receiving data:

3. Accessing the bus

4. Informing about the need to acquire data (using control lines)

5. Awaiting the incoming data

Page 31: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

„Flat” bus structure (ISA)

Page 32: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Hierarchical bus structure

Page 33: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Buses categories

Application• Specialized• MultiplexedArbitration method• Centralized• DistributedTime synchronization• Synchronous• Asynchronous

Page 34: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Synchronous coordination

Page 35: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Asynchronous coordination

Read

Page 36: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

Asynchronous coordination

Write

Page 37: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

PCI bus

• Proposed by Intel in 1990 • Work frequency: 66 MHz• Works in 32 or 64-bit configuration• Communication between the processor and the

memory using bridges• Valid signal lines:

– system (np. clock, reset)– Address and data (32)– Interface control– Arbitration (individual!)– Error information

Page 38: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

PCI bus read

Page 39: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

PCI bus arbitrage

Page 40: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

PCI Express bus

• Parallel bus architecture

• Introducing switches

• Backward compatibility with PCI

• Scaleable bandwidth of the bus – from 1x to 32x (depending on the used channels/slots)

• Speed of 250 MB/s for the single slot (for the graphic card 16x PCIe it is 4 GB/s)

Page 41: Computer Architecture Lecture 2: Processor, program cycle, interrupts, system bus Piotr Bilski

PCI Express computer architecture