unit 6 input-output-organization

25
1 Input-Output Organization Computer Organization Computer Architectures Lab Peripheral Devices Input-Output Interface Modes of Transfer Priority Interrupt Direct Memory Access Input-Output Processor INPUT-OUTPUT ORGANIZATION

Upload: saranya-priyanka

Post on 28-Mar-2015

209 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: UNIT 6 Input-Output-Organization

1Input-Output Organization

Computer Organization Computer Architectures Lab

• Peripheral Devices

• Input-Output Interface

• Modes of Transfer

• Priority Interrupt

• Direct Memory Access

• Input-Output Processor

INPUT-OUTPUT ORGANIZATION

Page 2: UNIT 6 Input-Output-Organization

2Input-Output Organization

Computer Organization Computer Architectures Lab

PERIPHERAL DEVICES

Input Devices

• Keyboard• Optical input devices - Card Reader - Paper Tape Reader - Bar code reader - Digitizer - Optical Mark Reader• Magnetic Input Devices - Magnetic Stripe Reader• Screen Input Devices - Touch Screen - Light Pen - Mouse• Analog Input Devices

Output Devices

• Card Puncher, Paper Tape Puncher• CRT• Printer (Impact, Ink Jet, Laser, Dot Matrix)• Plotter• Analog• Voice

Peripheral Devices

Page 3: UNIT 6 Input-Output-Organization

3Input-Output Organization

Computer Organization Computer Architectures Lab

INPUT/OUTPUT INTERFACEInput/Output Interfaces

• Provides a method for transferring information between internal storage (such as memory and CPU registers) and external I/O devices

• Resolves the differences between the computer and peripheral devices

– Peripherals - Electromechanical Devices

– CPU or Memory - Electronic Device

– Data Transfer Rate

» Peripherals - Usually slower

» CPU or Memory - Usually faster than peripherals• Some kinds of Synchronization mechanism may be needed

– Unit of Information

» Peripherals – Byte, Block, …

» CPU or Memory – Word

– Data representations may differ

Page 4: UNIT 6 Input-Output-Organization

4Input-Output Organization

Computer Organization Computer Architectures Lab

I/O BUS AND INTERFACE MODULES

Each peripheral has an interface module associated with it

Interface

- Decodes the device address (device code)- Decodes the commands (operation)- Provides signals for the peripheral controller- Synchronizes the data flow and supervises the transfer rate between peripheral and CPU or Memory

Typical I/O instruction

(Command)

Op. code Device address Function code

Input/Output Interfaces

Processor

Interface

Keyboardand

displayterminal

Magnetictape

Printer

Interface Interface Interface

DataAddressControl

Magneticdisk

I/O bus

Page 5: UNIT 6 Input-Output-Organization

5Input-Output Organization

Computer Organization Computer Architectures Lab

CONNECTION OF I/O BUS

Connection of I/O Bus to One Interface

Connection of I/O Bus to CPU

Input/Output Interfaces

I/Obus

Op.code

Deviceaddress

Functioncode

Accumulatorregister

ComputerI/O

control

Sense lines

Data lines

Function code lines

Device address lines

CPU

I/Obus

Device address

Commanddecoder

Function code

Data lines

Buffer register

Peripheralregister

Statusregister

Sense lines

Outputperipheral

deviceand

controller

AD = 1101 InterfaceLogic

Page 6: UNIT 6 Input-Output-Organization

6Input-Output Organization

Computer Organization Computer Architectures Lab

I/O BUS AND MEMORY BUS

* MEMORY BUS is for information transfers between CPU and the MM

* I/O BUS is for information transfers between CPU and I/O devices through their I/O interface

* Many computers use a common single bus system for both memory and I/O interface units

- Use one common bus but separate control lines for each function - Use one common bus with common control lines for both functions

* Some computer systems use two separate buses, one to communicate with memory and the other with I/O interfaces

- Communication between CPU and all interface units is via a common I/O Bus- An interface connected to a peripheral device may have a number of data registers , a control register, and a status register- A command is passed to the peripheral by sending to the appropriate interface register- Function code and sense lines are not needed (Transfer of data, control, and status information is always via the common I/O Bus)

Functions of Buses

Physical Organizations

I/O Bus

Input/Output Interfaces

Page 7: UNIT 6 Input-Output-Organization

7Input-Output Organization

Computer Organization Computer Architectures Lab

ISOLATED vs MEMORY MAPPED I/O

- Separate I/O read/write control lines in addition to memory read/write control lines

- Separate (isolated) memory and I/O address spaces

- Distinct input and output instructions

Isolated I/O

Memory-mapped I/O

- A single set of read/write control lines (no distinction between memory and I/O transfer)

- Memory and I/O addresses share the common address space

-> reduces memory address range available

- No specific input or output instruction

-> The same memory reference instructions can be used for I/O transfers

- Considerable flexibility in handling I/O operations

Input/Output Interfaces

Page 8: UNIT 6 Input-Output-Organization

8Input-Output Organization

Computer Organization Computer Architectures Lab

I/O INTERFACE

- Information in each port can be assigned a meaning depending on the mode of operation of the I/O device → Port A = Data; Port B = Command; Port C = Status

- CPU initializes(loads) each port by transferring a byte to the Control Register → Allows CPU can define the mode of operation of each port → Programmable Port: By changing the bits in the control register, it is possible to change the interface characteristics

CS RS1 RS0 Register selected 0 x x None - data bus in high-impedence 1 0 0 Port A register 1 0 1 Port B register 1 1 0 Control register 1 1 1 Status register

Programmable Interface

Input/Output Interfaces

Chip select

Register select

Register select

I/O read

I/O write

CS

RS1

RS0

RD

WR

Timingand

Control

Busbuffers

Bidirectionaldata bus

Port Aregister

Port Bregister

Controlregister

Statusregister

I/O data

I/O data

Control

Status

Inte

rna

l b

us

CPU I/ODevice

Page 9: UNIT 6 Input-Output-Organization

9Input-Output Organization

Computer Organization Computer Architectures Lab

MODES OF TRANSFER - PROGRAM-CONTROLLED I/O -

3 different Data Transfer Modes between the central computer(CPU or Memory) and peripherals; Program-Controlled I/O

Interrupt-Initiated I/O Direct Memory Access (DMA)

Program-Controlled I/O(Input Dev to CPU)

Modes of Transfer

Polling or Status Checking

• Continuous CPU involvement• CPU slowed down to I/O speed• Simple• Least hardware

Read status registerCheck flag bit

flag

Read data registerTransfer data to memory

Operationcomplete?

Continue withprogram

= 0

= 1

yes

no

CPU

Data bus

Address bus

I/O read

I/O write

Interface

Data register

Statusregister F

I/O bus

Data valid

Data accepted

I/Odevice

Page 10: UNIT 6 Input-Output-Organization

10Input-Output Organization

Computer Organization Computer Architectures Lab

MODES OF TRANSFER - INTERRUPT INITIATED I/O & DMA

DMA (Direct Memory Access)

- Large blocks of data transferred at a high speed to or from high speed devices, magnetic drums, disks, tapes, etc.- DMA controller Interface that provides I/O transfer of data directly to and from the memory and the I/O device- CPU initializes the DMA controller by sending a memory address and the number of words to be transferred- Actual transfer of data is done directly between the device and memory through DMA controller -> Freeing CPU for other tasks

- Polling takes valuable CPU time- Open communication only when some data has to be passed -> Interrupt.- I/O interface, instead of the CPU, monitors the I/O device- When the interface determines that the I/O device is ready for data transfer, it generates an Interrupt Request to the CPU - Upon detecting an interrupt, CPU stops momentarily the task it is doing, branches to the service routine to process the data transfer, and then returns to the task it was performing

Interrupt Initiated I/O

Modes of Transfer

Page 11: UNIT 6 Input-Output-Organization

11Input-Output Organization

Computer Organization Computer Architectures Lab

PRIORITY INTERRUPT

Priority Interrupt by Software(Polling) - Priority is established by the order of polling the devices(interrupt sources) - Flexible since it is established by software - Low cost since it needs a very little hardware - Very slow

Priority Interrupt by Hardware - Require a priority interrupt manager which accepts all the interrupt requests to determine the highest priority request - Fast since identification of the highest priority interrupt request is identified by the hardware - Fast since each interrupt source has its own interrupt vector to access directly to its own service routine

Priority - Determines which interrupt is to be served first when two or more requests are made simultaneously - Also determines which interrupts are permitted to interrupt the computer while another is being serviced - Higher priority interrupts can make requests while servicing a lower priority interrupt

Priority Interrupt

Page 12: UNIT 6 Input-Output-Organization

12Input-Output Organization

Computer Organization Computer Architectures Lab

HARDWARE PRIORITY INTERRUPT - DAISY-CHAIN -

One stage of the daisy chain priority arrangement

Interrupt Request from any device(>=1) -> CPU responds by INTACK <- 1 -> Any device receives signal (INTACK) 1 at PI puts the VAD on the bus Among interrupt requesting devices the only device which is physically closest to CPU gets INTACK=1, and it blocks INTACK to propagate to the next device

Priority Interrupt

Device 1PI PO

Device 2PI PO

Device 3PI PO

INT

INTACK

Interrupt request

Interrupt acknowledge

To nextdevice

CPU

VAD 1 VAD 2 VAD 3Processor data bus

* Serial hardware priority function* Interrupt Request Line

- Single common line* Interrupt Acknowledge Line

- Daisy-Chain

Page 13: UNIT 6 Input-Output-Organization

13Input-Output Organization

Computer Organization Computer Architectures Lab

PARALLEL PRIORITY INTERRUPT

IEN: Set or Clear by instructions ION or IOFIST: Represents an unmasked interrupt has occurred. INTACK enables

tristate Bus Buffer to load VAD generated by the Priority Logic

Interrupt Register: - Each bit is associated with an Interrupt Request from different Interrupt Source - different priority level - Each bit can be cleared by a program instructionMask Register: - Mask Register is associated with Interrupt Register - Each bit can be set or cleared by an Instruction

Priority Interrupt

Maskregister

INTACKfrom CPU

Priorityencoder

I0

I1

I 2

I 3

0

1

2

3

y

x

ISTIEN0

1

2

3

0

0

0

0

0

0

Disk

Printer

Reader

Keyboard

Interrupt register

Enable

Interruptto CPU

VADto CPU

BusBuffer

Page 14: UNIT 6 Input-Output-Organization

14Input-Output Organization

Computer Organization Computer Architectures Lab

INTERRUPT PRIORITY ENCODER• Priority encoder is used if two or more inputs arrive at the same time , and the input having the highest priority will be taken precedence.• Determines the highest priority interrupt whenmore than one interrupts take place • Input Io has the highest priority so the values of other inputs when this input is 1, the output generates an output xy = 00. and so on •The interrupt status IST is set only when one or more inputs are equal to 1.•If all the inputs are 0 the IST is cleared to 0 and other outputs are marked with don’t care conditions.•Because the vector address is not transferred to the CPU when IST =0.•The Boolean function listed in the table specify the internal logic of the encoder

Priority Encoder Truth table:

Priority Interrupt

1 d d d0 1 d d0 0 1 d0 0 0 10 0 0 0

I0 I1 I2 I3

0 0 10 1 11 0 11 1 1d d 0

x y IST

x = I0' I1'y = I0' I1 + I0’ I2’

(IST) = I0 + I1 + I2 + I3

Inputs Outputs

Boolean functions

Page 15: UNIT 6 Input-Output-Organization

15Input-Output Organization

Computer Organization Computer Architectures Lab

INTERRUPT CYCLE• The interrupt enable flip-flop IEN can be set or cleared by program instruction.

• When IEN is cleared the interrupt request coming from IST is neglected by the CPU

• The IEN Bit allows the programmer to choose whether to use the interrupt facility

• If an instruction to clear IEN has been inserted in the program means that the user does not want his program to be interrupted.

• An Instruction to set IEN indicated that the interrupt facility will be used while the current program is running.

• It includes internal hardware that clears IEN to 0 every time an interrupt is acknowledged by the processor.

• At the end of each instruction cycle the CPU checks IEN and the interrupt signal from the IST

• If either is equal to 0, control is continues with next instruction.

• If Both IEN and IST are equal to 0, the cpu goes to interrupt cycle

Page 16: UNIT 6 Input-Output-Organization

16Input-Output Organization

Computer Organization Computer Architectures Lab

At the end of each Instruction cycle

- CPU checks IEN and IST

- If IEN IST = 1, CPU -> Interrupt Cycle

INTERRUPT CYCLE

SP SP - 1 Decrement stack pointerM[SP] PC Push PC into stackINTACK 1 Enable interrupt acknowledgePC VAD Transfer vector address to PCIEN 0 Disable further interruptsGo To Fetch to execute the first instruction in the interrupt service routine

Priority Interrupt

Page 17: UNIT 6 Input-Output-Organization

17Input-Output Organization

Computer Organization Computer Architectures Lab

INTERRUPT SOFTWARE ROUTINE• A priority interrupt system is a combination of hardware and software

techniques.• Now we will discuss the software routines for servicing the interrupt requests

and for controlling the interrupt hardware registers.• It shows the program that must reside in memory for handling the interrupt

system.• Each device has its own service program that can be reached through a JMP.• Each routine represents the starting address of the service program.• Example:• Taking keyboard sets interrupt bit while cpu is executing the instruction in

location 749 of the main program. At the end of the instruction cycle , the computer goes to the interrupt cycle.

• It stores the return address 750 in the stack and accept the vector address 00000011 from the bus and transfer it to Pc. The instruction in location 3 is executed next, resulting in transfer of control to the KBD routine.

• Suppose the disk sets an interrupt bit when the instruction at address 255 in the KBD program, the address 256 is pushed into the stack and the control is transferred to Disk service program.

• At the end the KBD program the return control to the KBD routine to continue servicing the key board.

• Mostly the higher priority device can interrupt a lower priority device.

Page 18: UNIT 6 Input-Output-Organization

18Input-Output Organization

Computer Organization Computer Architectures Lab

INTERRUPT SERVICE ROUTINEPriority Interrupt

addressMemory

KBDinterrupt

VAD=00000011

I/O service programs

6 9 10

JMP PTR

JMP RDR

JMP KBD

JMP DISK0

1

2

3

Program to servicemagnetic disk

Program to serviceline printer

Program to servicecharacter reader

Program to servicekeyboard

DISK

PTR

RDR

KBD

255256

750

256750

Stack

Main program

current instr.749

2

3

4

Diskinterrupt

5

7

8

11

1

Fi

Page 19: UNIT 6 Input-Output-Organization

19Input-Output Organization

Computer Organization Computer Architectures Lab

Initial and Final Operations• Each interrupt service routine must have an initial and final set of operations for controlling

the registers in the hardware interrupt system.• Interrupt enable IEN is cleared at the end of an interrupt cycle .• The flip flops must be set again to enable higher priority interrupt requests, but not before

the lower priority interrupts are disabled. • Initial Sequence of each interrupt service routine must have instructions to control the

interrupt hardware in the following manner• [1] Clear lower level Mask reg. bits• [2]clear interrupt status bit (IST = 0)(bit it is cleared so it can set when a higher priority )• [3] Save contents of CPU registers (because it may be needed by the program )• [4]set interrupt enable bit ( IEN =1)(IEN is used to allow the other interrupts)• [5] Go to Interrupt Service Routine• Final Sequence• [1] clear the interrupt enable bit( IEN = 0)(it is cleared because it can be available for src to

interrupt)• [2] Restore CPU registers• [3] Clear the bit in the Interrupt Reg• [4] Set lower level Mask reg. bits• [5] Restore return address, IEN =1

Page 20: UNIT 6 Input-Output-Organization

20Input-Output Organization

Computer Organization Computer Architectures Lab

DIRECT MEMORY ACCESS

High-impedence(disabled)

when BG isenabled

CPU bus signals for DMA transfer

Block diagram of DMA controller

* Block of data transfer from high speed devices, Drum, Disk, Tape* DMA controller - Interface which allows I/O transfer directly between

Memory and Device, freeing CPU for other tasks* CPU initializes DMA Controller by sending memory address and the block size(number of words)

Address bus

Data bus

Read

Write

ABUSDBUS

RDWR

Bus request

Bus granted

BR

BGCPU

Address bus

Data bus

DMA select

Register select

Read

Write

Bus request

Bus grant

Interrupt

DS

RS

RD

WR

BR

BG

Interrupt

Data busbuffers

Address busbuffers

Address register

Word count register

Control register

DMA request

DMA acknowledge to I/O device

Controllogic

Direct Memory Access

Inte

rnal

Bu

s

Page 21: UNIT 6 Input-Output-Organization

21Input-Output Organization

Computer Organization Computer Architectures Lab

DMA I/O OPERATIONStarting an I/O - CPU executes instruction to Load Memory Address Register Load Word Counter Load Function(Read or Write) to be performed Issue a GO command

Upon receiving a GO Command DMA performs I/Ooperation as follows independently from CPU

Input [1] Input Device <- R (Read control signal) [2] Buffer(DMA Controller) <- Input Byte; and assembles the byte into a word until word is full [4] M <- memory address, W(Write control signal) [5] Address Reg <- Address Reg +1; WC(Word Counter) <- WC - 1 [6] If WC = 0, then Interrupt to acknowledge done, else go to [1]

Output [1] M <- M Address, R M Address R <- M Address R + 1, WC <- WC - 1 [2] Disassemble the word [3] Buffer <- One byte; Output Device <- W, for all disassembled bytes [4] If WC = 0, then Interrupt to acknowledge done, else go to [1]

Direct Memory Access

Page 22: UNIT 6 Input-Output-Organization

22Input-Output Organization

Computer Organization Computer Architectures Lab

CYCLE STEALING

While DMA I/O takes place, CPU is also executing instructions

DMA Controller and CPU both access Memory -> Memory Access Conflict

Memory Bus Controller

- Coordinating the activities of all devices requesting memory access - Priority System

Memory accesses by CPU and DMA Controller are interwoven, with the top priority given to DMA Controller

-> Cycle Stealing

Cycle Steal

- CPU is usually much faster than I/O(DMA), thus CPU uses the most of the memory cycles - DMA Controller steals the memory cycles from CPU - For those stolen cycles, CPU remains idle - For those slow CPU, DMA Controller may steal most of the memory

cycles which may cause CPU remain idle long time

Direct Memory Access

Page 23: UNIT 6 Input-Output-Organization

23Input-Output Organization

Computer Organization Computer Architectures Lab

DMA TRANSFER

BG

BRCPU

RD WR Addr Data

Interrupt

Random-accessmemory unit (RAM)

RD WR Addr Data

BR

BG

RD WR Addr Data

Interrupt

DS

RS DMAController

I/OPeripheral

deviceDMA request

DMA ack.

Read control

Write control

Data bus

Address bus

Addressselect

Direct Memory Access

Page 24: UNIT 6 Input-Output-Organization

24Input-Output Organization

Computer Organization Computer Architectures Lab

INPUT/OUTPUT PROCESSOR - CHANNEL -Channel

- Processor with direct memory access capability that communicates with I/O devices - Channel accesses memory by cycle stealing - Channel can execute a Channel Program - Stored in the main memory - Consists of Channel Command Word(CCW) - Each CCW specifies the parameters needed by the channel to control the I/O devices and perform data transfer operations - CPU initiates the channel by executing an channel I/O class instruction and once initiated, channel operates independently of the CPU

Input/Output Processor

PD PD PD PD

Peripheral devices

I/O bus

Input-outputprocessor

(IOP)

Centralprocessingunit (CPU)

Memoryunit

Me

mo

ry B

us

Page 25: UNIT 6 Input-Output-Organization

25Input-Output Organization

Computer Organization Computer Architectures Lab

CHANNEL / CPU COMMUNICATION

Send instructionto test IOP.path

If status OK, then sendstart I/O instruction

to IOP.

CPU continues withanother program

Transfer status wordto memory

Access memoryfor IOP program

Conduct I/O transfersusing DMA;

Prepare status report.

I/O transfer completed;Interrupt CPU

Request IOP status

Transfer status wordto memory locationCheck status word

for correct transfer.

Continue

CPU operations IOP operations

Input/Output Processor