it3002 computer architecture

33
IT3002 Computer Architecture INPUT/OUTPUT SYSTEM Lectured By: MH Mohamed Nafas Faculty of Applied Sciences South Eastern University of Sri Lanka [email protected] Mob:0718772276 1

Upload: edmund-osborne

Post on 17-Jan-2018

217 views

Category:

Documents


0 download

DESCRIPTION

Input/Output System In addition to: The processor and, A set of memory modules. Third key element of a computer system: A set of I/O modules. I/O system interfaces: The computer to the outside world. It consists of wide variety of peripherals: Eg: Keyboards, Monitors, Printers, Scanner, Modems, Buses, etc.

TRANSCRIPT

Page 1: IT3002 Computer Architecture

IT3002Computer Architecture

INPUT/OUTPUT SYSTEM

Lectured By:MH Mohamed NafasFaculty of Applied Sciences

South Eastern University of Sri [email protected]:0718772276

1

Page 2: IT3002 Computer Architecture

Input/Output System• In addition to:

• The processor and,• A set of memory modules.

• Third key element of a computer system:• A set of I/O modules.

• I/O system interfaces:• The computer to the outside world.

• It consists of wide variety of peripherals:• Eg:

• Keyboards, Monitors, Printers, Scanner, Modems, Buses, etc.

2

Page 3: IT3002 Computer Architecture

Input/Output System …• Wide variety of peripherals:

• With various methods of operations.• Impractical to connect directly to the computer.• Since:

• They are delivering different amounts of data:• At different speeds.• In different formats.

• All are slower than CPU and RAM.• External devices are not generally connected directly

into the computer bus structure.• And need I/ O modules.

3

Page 4: IT3002 Computer Architecture

Typical I/O Device Data Rates

4

Page 5: IT3002 Computer Architecture

Input/Output Modules• I/ O module:

• Interface to CPUand Memory.

• Via system bus,• Or central switch.

• Interface to one ormore peripherals:

• By data links.

5

Generic Model of an I/O Module

Page 6: IT3002 Computer Architecture

I/O Module Functions• Five major functions:

• Control & Timing.• CPU Communication.• Device Communication.• Data Buffering.• Error Detection.

6

Page 7: IT3002 Computer Architecture

I/O Module Functions …• Control & Timing:

• Main memory and system bus must be shared:• Processor may communicate with one more devices at a time.

• Need to coordinate the flow of traffic between internal resources and external devices.

• Eg:• The control of the transfer of data from an external device to

the processor might involve the following steps:• CPU checks I/O module device status.• I/O module returns status.• If ready, CPU requests data transfer.• I/O module gets data from device.• I/O module transfers data to CPU.

7

Page 8: IT3002 Computer Architecture

I/O Module Functions …• CPU Communication:

• I/O modules must communicate with the processor and with the external devices.

• CPU communication involves the following:• Command decoding:

• CPU commands are typically sent as signals on the control bus.• Data:

• Exchanged between CPU and I/O modules over the data bus.• Status Reporting:

• Important to know the status of the I/O modules.• Eg: BUSY, READY

• Address Recognition:• I/O module must recognize one unique address for each device it

controls.

8

Page 9: IT3002 Computer Architecture

I/O Module Functions …• Device Communication:

• I/O modules must be able to perform device communication.• This involves commands, status and data.

• Data Buffering:• Data coming from main memory are sent to an I/O module in a

rapid burst.• This data buffered in the I/O module and then sent to the device

at its rate. • In the opposite direction, data are buffered so as not to tie up the

memory in a slow transfer operation.

9

Page 10: IT3002 Computer Architecture

I/O Module Functions …• Error Detection:

• An I/O module is responsible for error detection and reporting them to the CPU.

• Two classes of errors:• Mechanical and electrical malfunctions reported by the device:

• Eg: Paper jam, Bad disk track etc.• Transmission errors:

• Unintentional changes to the bit pattern as it is transmitted from device to I/O module.

• Error detecting codes are often used to detect the errors:• Eg: Even parity, Odd parity.

10

Page 11: IT3002 Computer Architecture

I/O Module Structure• There are varieties of I/O module structures:

• Depends on complexity and number of devices that they control.

• In generally a module consists of:• A set of signal lines:

• To connect the module to the computer.• Eg: System bus line.

• One or more data registers:• To buffer the data transferred to and from the module.

• One or more status registers:• To provide current status.• One can function as a control register:

• To accept detailed control information from the processor.

11

Page 12: IT3002 Computer Architecture

I/O Module Structure …• Block diagram of an I/O module:

12

Page 13: IT3002 Computer Architecture

I/O Module Structure …• I/O Logic:

• The logic inside the module.• Interacts the processor via a set of control lines.• Recognizes and generates address associated with the

external devices:• I/O module has a unique address or set of unique addresses if it

controls more than one device.• Interfaces with each device.

13

Page 14: IT3002 Computer Architecture

I/O Module Structure …• I/O Module:

• Allow the processor to view a wide range of devices in a simple-minded way.

• Hides the device properties to CPU.• Processor can function in terms of simple commands.• Eg: READ, WRITE, OPEN, CLOSE etc.

• Some I/O modules:• Take on most of the processing burden from CPU.

• Referred as I/O Channel or I/O processor.

14

Page 15: IT3002 Computer Architecture

Input Output Techniques• Three techniques are possible for I/O operations.

• Programmed (polling).• Interrupt driven.• Direct Memory Access (DMA).

15

Page 16: IT3002 Computer Architecture

Programmed I/O (Polling)• With programmed I/O:

• Data are exchanged between the CPU and I/O module.• CPU executes a program and issue command directly to the

appropriate I/O.• Ie: CPU has direct control over I/O:

• Sensing status.• Read/write commands.• Transferring data.

• I/O module performs the requested action and set the appropriate bits in the I/O status register.

• No further action to alert the CPU.• CPU waits for I/O module to complete operation.

• Periodically checks the I/O status register.• This wastes CPU time.

16

Page 17: IT3002 Computer Architecture

Programmed I/O …

17

Issue read command to I/O module

Read status of I/O module

Read word from I/O module

Write word into memory

Check status

Done ?

Next instruction

Not ready

No

Yes

Ready

Error Condition

CPU → I/O

I/O → CPU

I/O → CPU

CPU → Memory

Rea

d a

bloc

k of

dat

a fro

m a

dev

ice

into

m

emor

y.

Page 18: IT3002 Computer Architecture

Programmed I/O …• I/O Commands:

• To execute an I/O related instruction, CPU issues an address:• Identifies module (& device if more devices).

• CPU issues an I/O command:• Control - Telling module what to do.

• Eg: Spin up disk.• Test - Check status.

• Eg: Power?, Error?• Read:

• Takes data from the device and places it in internal buffer.• Write:

• Takes data from the data bus and transmits to the device.

18

Page 19: IT3002 Computer Architecture

Interrupt Driven I/O• With interrupt driven I/O:

• CPU:• Issues an I/O command to a module.• Continues to execute other instructions.

• I/O module:• Interrupts the CPU when completed the work.• Requests service to exchange data with the CPU.

• CPU then executes the data transfer.• This:

• Overcomes CPU waiting.• No repeated CPU checking of device.

19

Page 20: IT3002 Computer Architecture

Interrupt Driven I/O …

20

Rea

d a

bloc

k of

dat

a fro

m a

dev

ice

into

m

emor

y.

Issue read command to I/O module

Read status of I/O module

Read word from I/O module

Write word into memory

Check status

Done ?

Next instruction

No

Yes

Ready

Error Condition

CPU → I/O

I/O → CPU

I/O → CPU

CPU → Memory

Do something else.

Interrupt.

Page 21: IT3002 Computer Architecture

Interrupt Driven I/O Basic Operation

• I/O module:• Receives a READ command from CPU.• Proceeds to read data from the external device.• Signals an interrupt to the CPU over control line:

• When the data are in the module’s data register.• Waits until its data are requested by the CPU.• Places its data on the data bus:

• When the CPU request is made.• Ready for another I/O operation.

21

Page 22: IT3002 Computer Architecture

Interrupt Driven I/O Basic Operation …

• CPU:• Issues a READ command.• Goes off and does other work.• Checks for interrupt at the end of each instruction cycle.• If interrupted:

• Save the context (PC and CPU registers) of current program.• Process the interrupt:

• Reads the data from the I/O module and stores it in memory.• Restores the saved context and resumes interrupted

program execution.

22

Page 23: IT3002 Computer Architecture

Direct Memory Access• Interrupt driven and programmed I/O require active

CPU intervention:• Every word of data from memory to I/O or from I/O to

memory must pass through the CPU.• Both I/Os suffer from two inherent drawbacks:

• I/O transfer rate is limited by the speed with which CPU service a device.

• CPU is tied up in managing I/O transfers.• The solution is DMA.

23

Page 24: IT3002 Computer Architecture

Direct Memory Access …• DMA Function:

• DMA involves an additional (hardware) module on the system bus.

• DMA module can takes over control of the system from the CPU.• To transfer data to and from memory over system bus.

• To do this:• DMA must use the bus only when the CPU does not need it or,• DMA must force the CPU to suspend operation temporarily.

• Referred to as cycle stealing since DMA steals the bus cycle.• Slows down CPU but not as much as CPU doing transfer.

24

Page 25: IT3002 Computer Architecture

Direct Memory Access …• Typical DMA Module:

25

Page 26: IT3002 Computer Architecture

Direct Memory Access …• DMA Operation:

• When CPU need to read or write a block of data,• CPU tells DMA controller:

• Required operation (Read/Write).• Device address.• Starting address of memory block for data.• Amount of data to be transferred.

• CPU carries on with other work.• DMA controller deals with transfer:

• Directly to or from memory without going through CPU.• DMA controller sends interrupt when finished.

• CPU is involved only at the beginning and the end of the data transfer.

26

Page 27: IT3002 Computer Architecture

Direct Memory Access…

• DMA and Interrupt Breakpoints during Instruction Cycle• The processor is suspended just before it needs to use

the bus.• The DMA module transfers one word and returns control

to the processor.• Since this is not an interrupt the processor does not have

to save context.• The processor executes more slowly, but this is still far

more efficient that either programmed or interrupt-driven I/O.

27

Page 28: IT3002 Computer Architecture

Direct Memory Access…DMA and Interrupt Breakpoints during Instruction Cycle

28

Page 29: IT3002 Computer Architecture

Direct Memory Access …• DMA Configuration:

• DMA mechanism can be configured in a variety of ways.• Eg:

• Single-bus, detached DMA.• Single-bus, integrated DMA-I/O.• I/O bus.

29

Page 30: IT3002 Computer Architecture

Direct Memory Access …• Single-bus, detached DMA:

• Each transfer uses bus twice:• I/O to DMA then DMA to memory.

• CPU is suspended twice.• Inexpensive but inefficient.

30

Page 31: IT3002 Computer Architecture

Direct Memory Access …• Single-bus, integrated DMA-I/O:

• DMA controller may support more than one device.• May be a part of an I/O module.• May be separate module that controls one or more I/Os.

• Each transfer uses bus once:• DMA to memory.

• CPU is suspended once.

31

Page 32: IT3002 Computer Architecture

Direct Memory Access …• I/O bus:

• Separate I/O Bus.• Bus supports all DMA enabled devices.• Each transfer uses bus once:

• DMA to memory.• CPU is suspended once.

32

Page 33: IT3002 Computer Architecture

Block Diagram of I/O Module

33