Input Output Operations

kdisthere 13,990 views 36 slides Nov 04, 2012
Slide 1
Slide 1 of 36
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36

About This Presentation

No description available for this slideshow.


Slide Content

IN
P
U
T -O
U
T P
U
T O
R
G
A
N
IZ
A T IO
N

6.1, 6.2 Peripheral Devices
•Every time a key is depressed, the terminal sends a
binary coded character to the computer. When input
information is transferred to the processor via a
keyboard, the processor will be idle most of time while
waiting for info To arrive.
•Devices are said to be connected online that are
under the direct control of the computer. These
devices are designed to read information into or out of
memory unit when CPU gives a command. Input or
output devices connected to the computer are also
called peripherals.
•Common peripherals are keyboard, displays units and
printers.
•Peripherals that provide auxiliary storage for system
are magnetic disk

6.3INTERFACE – Difference between computer and
peripherals
A conversion of signal values may be required
» CPU (Electronics) / HDD (Electromechanical and Electromagnet)
A synchronization mechanism may be needed
» The data transfer rate of peripherals is usually slower than the transfer rate of
the CPU
Data codes and formats in peripherals differ from the word format in the CPU and
Memory
The operating modes of peripherals are different from each other : 4 modes
» Each peripherals must be controlled so as not to disturb the operation of other
peripherals connected to the CPU
•Special hardware components between the CPU and peripherals
•Supervise and Synchronize all input and output transfers

I/O BUS AND INTERFACE MODULES

I/O BUS VERSUS MEMORY BUS
Computer buses can be used to communicate with memory and
I/O
1)Use two separate buses, one for memory and the other for I/O
•I/O Processor : separate memory bus and I/O bus
2) Use one common bus for both memory and I/O but have separate
control lines for each : Isolated I/O or I/O Mapped I/O
•IN, OUT : I/O Instruction
• MOV or LD : Memory read/write Instruction
3) Use one common bus for memory and I/O with common control lines :
Memory
Mapped I/O
•MOV or LD : I/O and Memory read/write Instruction
4 I/O port : Data port A, Data port B, Control,Status
•8255 PIO ( port A, B, C, Control/Status )
Address Decode :
•CS, RS1, RS0
E
x a
m
p
le
:

EXAMPLE OF I/O INTERFACE

6.4 Data Transfer Techniques

ASYNCHRONOUS DATA TRANSFER
Synchronous Data Transfer
•All data transfers occur simultaneously during the occurrence of
a clock pulse
•Registers in the interface share a common clock with CPU
registers
Asynchronous Data Transfer
•Internal timing in each unit (CPU and Interface) is independent
•Each unit uses its own private clock for internal registers

STROBE
Strobe : Control signal to indicate the time at which data is being transmitted
1) Source-initiated strobe 2) Destination-initiated strobe
D
e
s
t
in
a
t
io
n
-
in
it
ia
t
e
d

s
t
r
o
b
e
S
o
u
r
c
e
-
in
it
ia
t
e
d

s
t
r
o
b
e

HANDSHAKING
•For data transfer between two computers, the sending and receiving
speeds on both ends are often different. Therefore, a mechanism is
needed to make sure that the sender does not send a new byte before
the previously sent byte is received by the receiver.
•Even when the sender and receiver operate at the same speed, the
sender may still want to know whether the receiver has indeed received
the information. Handshaking provides a mechanism for addressing this
issue. 
• Handshaking usually uses two additional hardware lines, one is called
“strobe” and the other is called “acknowledge”. The sender provides the
signal to the strobe line and the receiver provides the signal to the
acknowledge line.
•Handshaking can be used in both parallel data transfer and serial data
transfer.

ASYNCHRONOUS SERIAL TRANSFER
Synchronous transmission :
» The two unit share a common clock frequency
» Bits are transmitted continuously at the rate dictated by the clock
pulses
?????? Asynchronous transmission :
» Special bits are inserted at both ends of the character code
» Each character consists of three parts :
?????? 1) start bit : always “0”, indicate the beginning of a character
?????? 2) character bits : data
?????? 3) stop bit : always “1”

ASYNCHRONOUS TRANSMISSION RULES : NO
PARITY
» When a character is not being sent, the line is kept in
the 1-state
»The initiation of a character transmission is detected
from the start bit, which is
always “0”
»The character bits always follow the start bit
» After the last bit of the character is transmitted, a stop
bit is detected when the line
returns to the 1-state for at least one bit time (stop bits :
1, 1.5, 2)

Asynchronous Communication Interface
•On Board ..

Mode of Transfer
•Information transferred from central computer into an
external device initiates in memory unit. CPU only executes
I/O instructions and may accept data temporarily, but the
ultimate source or destination is memory unit. Data transfer
between central computer and I/O devices may be handled
in variety of modes.
•Data transfer to and from peripherals may be done in either
of three modes:
Programmed I/O
Interrupt – initiated I/O
Direct Memory Access (DMA)

•Binary information received from an external
device is usually stored in memory.
• Information transferred from the central
computer into an external device also is
originally from the memory.
•Data transfer between the central computer
and input and output devices may be handled
in a variety of modes
Introduction

Programmed I/O
•These operations are a results of I/O instructions
written in the computer program. Data transfer is
initiated by an instruction in the program.
•Usually the data transfer data between CPU register
and peripheral device. Other instructions are used to
transfer data transfer data between CPU and memory.
• The peripheral has to be constantly monitored. Once
a data transfer is initiated, the CPU is required to
monitor the interface to see when a transfer can again
be made.

Applications of programmed I/O
method
Useful in small low speed computers.
Used in systems that are dedicated to monitor a device
continuously.
Used in the data register.
Used to check the status of the flag bit and branch.

•in this scheme, CPU may allow devices to send a
signal when input is waiting to be processed. The
signal is used to interrupt the CPU.
•Interrupt signal are seen directly (using hardware) to
micro-processor which may or may not ignore interrupt
request. When request is granted, CPU will suspend its
current program execution, execute an interrupt
handler program and then resume execution of the
interrupted program
Interrupt initiated I/O

•Interrupted initiated I/O can be avoided by using an
interrupt facility and special commands to inform the
interface to issue an interrupt request signal when the data
are available from the device.
•Meanwhile, CPU can proceed to execute another program.
The interfaces keeps monitoring the device.
•When the interface determines that the device is ready for
data transfer, it generates an interrupt request to the
computer.

Service routines of Interrupt
initiated I/O
Service routines of interrupt initiated I/O can be chosen
in two ways.
Vectored interrupt
Non-vectored interrupt

Direct Memory Access (DMA)
•The interface transfer data into and out of the memory unit through
the memory bus.
•The CPU initiates the transfer of supplying the interface with the
starting address and the number of words needed to be transferred
and then proceed to execute other tasks.
•When the request is granted by the memory controller, the DMA
transfer the data directly into memory. The CPU delays its memory
access operation to allow the direct memory I/O transfer.

I/O Processor
• Many computers combines the interface logic with the requirements
for direct memory access into one unit and call it an I/O processor.
The IOP can handle many peripherals through a DMA and interrupt
facility. The computer is divided into three separate modules in
such a system.
 Memory unit
 CPU
 IOP
•CPU is the master while the IOP is a slave processor. The CPU
performs the tasks of initiating all operations.
•The operations include
 Starting an I/O transfer
 Testing I/O status conditions needed for making decisions on
various I/O activities.

I/O Interrupts
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 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

HARDWARE PRIORITY INTERRUPT - DAISY-CHAIN -
One stage of the daisy chain priority arrangement
PI RF PO Enable
0 0 0 0
0 1 0 0
1 0 1 0
1 1 1 1
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
Device 1
PI PO
Device 2
PI PO
Device 3
PI PO
INT
INTACK
Interrupt request
Interrupt acknowledge
To next
device
CPU
VAD 1 VAD 2 VAD 3
Processor data bus
* Serial hardware priority function
* Interrupt Request Line
- Single common line
* Interrupt Acknowledge Line
- Daisy-Chain
S
R
Q
Interrupt
request
from device
PI
Priority in
RF
Delay
Vector address
VAD
PO
Priority out
Interrupt request to CPU
Enable

PARALLEL PRIORITY INTERRUPT
IEN: Set or Clear by instructions ION or IOF
IST: 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 instruction
Mask Register:
- Mask Register is associated with Interrupt Register
- Each bit can be set or cleared by an Instruction
Mask
register
INTACK
from CPU
Priority
encoder
I
0
I
1
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
Interrupt
to CPU
VAD
to CPU
Bus
Buffer

INTERRUPT PRIORITY ENCODER
Determines the highest priority interrupt when
more than one interrupts take place
Priority Encoder Truth table
1 d d d
0 1 d d
0 0 1 d
0 0 0 1
0 0 0 0
I
0
I
1
I
2
I
3
0 0 1
0 1 1
1 0 1
1 1 1
d d 0
x y IST
x = I
0
' I
1
'
y = I
0
' I
1
+ I
0
’ I
2

(IST) = I
0
+ I
1
+ I
2
+ I
3

Inputs Outputs
Boolean functions

At the end of each Instruction cycle
- CPU checks IEN and IST
- If IEN · IST = 1, CPU -> Interrupt Cycle
INTERRUPT CYCLE
SP ¬ SP - 1Decrement stack pointer
M[SP] ¬ PCPush PC into stack
INTACK ¬ 1Enable interrupt acknowledge
PC ¬ VAD Transfer vector address to PC
IEN ¬ 0 Disable further interrupts
Go To Fetch to execute the first instruction
in the interrupt service routine

INTERRUPT SERVICE ROUTINE
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
Initial Sequence
[1] Clear lower level Mask reg. bits
[2] IST <- 0
[3] Save contents of CPU registers
[4] IEN <- 1
[5] Go to Interrupt Service Routine
Final Sequence
[1] IEN <- 0
[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
address Memory
JMP PTR
JMP RDR
JMP KBD
JMP DISK0
1
2
3
I/O service programs
Program to service
magnetic disk
Program to service
line printer
Program to service
character reader
Program to service
keyboard
DISK
PTR
RDR
KBD
255
256
750
256
750
Stack
Main program
current instr.749
KBD
interrupt
2
VAD=00000011
3
4
Disk
interrupt
5
6
7
8
9 10
11
1

DIRECT MEMORY ACCESS
High-impedence
(disabled)
when BG is
enabled
CPU bus signals for DMA transfer
* 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
ABUS
DBUS
RD
WR
Bus request
Bus granted
BR
BG
CPU

Block Diagram Of DMA Controller
Address bus
Data bus
DMA select
Register select
Read
Write
Bus request
Bus grant
Interrupt
DS
RS
RD
WR
BR
BG
Interrupt
Data bus
buffers
Address bus
buffers
Address register
Word count register
Control register
DMA request
DMA acknowledge
to I/O device
Control
logic
I
n
t
e
r
n
a
l

B
u
s

DMA I/O OPERATION
Starting 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/O
operation 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]

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

DMA TRANSFER
BG
BR
CPU
RDWR AddrData
Interrupt
Random-access
memory unit (RAM)
RDWR AddrData
BR
BG
RDWR AddrData
Interrupt
DS
RS
DMA
Controller
I/O
Peripheral
device
DMA request
DMA ack.
Read control
Write control
Data bus
Address bus
Address
select

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
PD PD PD PD
Peripheral devices
I/O bus
Input-output
processor
(IOP)
Central
processing
unit (CPU)
Memory
unit
M
e
m
o
r
y

B
u
s

CHANNEL / CPU COMMUNICATION
Send instruction
to test IOP.path
If status OK, then send
start I/O instruction
to IOP.
CPU continues with
another program
Transfer status word
to memory
Access memory
for IOP program
Conduct I/O transfers
using DMA;
Prepare status report.
I/O transfer completed;
Interrupt CPU
Request IOP status
Transfer status word
to memory locationCheck status word
for correct transfer.
Continue
CPU operations IOP operations
Tags