unit 5 IO
unit 5 IO
• Peripheral Devices
• Input-Output Interface
• Modes of Transfer
• Priority Interrupt
• Input-Output Processor
• Serial Communication
Peripheral Devices
PERIPHERAL DEVICES
Input Devices Output Devices
• Keyboard • Card Puncher, Paper Tape Puncher
• Optical input devices • CRT
- Card Reader • Printer (Impact, Ink Jet,
- Paper Tape Reader Laser, Dot Matrix)
- Bar code reader • Plotter
- Digitizer • Analog
- Optical Mark Reader • Voice
• Magnetic Input Devices
- Magnetic Stripe Reader
• Screen Input Devices
- Touch Screen
- Light Pen
- Mouse
• Analog Input Devices
Input/Output Interfaces
INPUT/OUTPUT INTERFACE
Resolves
the differences between the
computer and peripheral devices
DIFFERENCES IN CPU AND PERIPHERALS
CPU and Memory are electronic in
nature while devices are
electromagnetic and
electromechanical.
Difference in data transfer rate
units.
Each device may have a device controller.
Input/Output Interfaces
Keyboard
and Printer Magnetic Magnetic
display disk tape
terminal
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
Op. code Device address Function code
(Command)
Each interface attached to the I/O bus has an
address decoder that monitors that address
lines.
When the interface detects its own address,
Physical Organizations
* 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
I/O Bus
- 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)
Input/Output Interfaces
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
I/O INTERFACE
Port A I/O data
register
Bidirectional Bus
data bus buffers
Port B I/O data
register
Internal bus
CPU Chip select CS
I/O
Register select RS1 Control Control Device
Timing register
Register select RS0 and
I/O read Control
RD Status Status
I/O write WR register
Handshaking
- A control signal is accompanied with each data
being transmitted to indicate the presence of data
- The receiving unit responds with another control
signal to acknowledge receipt of the data
STROBE CONTROL( SOURCE
INITIATED)
Employs a single control line to time each
transfer
The strobe may be activated by either the
on data bus.
After accepting the data the Dest. Unit
data bus.
ex. Memory read operation
Asynchronous Data Transfer
STROBE CONTROL
*
Strobe Strobe
Asynchronous Data Transfer
HANDSHAKING
Strobe Methods
Source-Initiated
Destination-Initiated
Valid data
Data bus
Timing Diagram
Data valid
Data accepted
Data valid
Valid data
Data bus
1 1 0 0 0 1 0 1
Start Character bits Stop
bit bits
(1 bit) (at least 1 bit)
second.
Each character has 11 bits
1 start
8 data
2 stop
access to memory.
The transfer operation between CPU and I/O
requires
Input device to CPU
PROGRAM-CONTROLLED I/O -
Program-Controlled I/O(Input Dev to CPU)
of I/O transfer.
After the transfer is completed the computer
CPU
Program
101
102 Service routine
103
I/O interrupt
104 104
stack
CPU responds to the interrupt signal by storing the return address from the PC
into a memory stack and then control branches to a service routine that
process the required I/O transfer.
Vectored interrupt The source that interrupts supplies the branch information
Non vectored interrupt the branch address is assigned to fixed location in
memory.
PRIORITY INTERRUPT
A priority interrupt is a system that establishes a
priority over the various sources to determine
which condition is to be serviced first.
Higher priority interrupt level are assigned to
by software or hardware.
POLLING
In this method there is one common branch
address for all interrupts. The program that
handles the interrupt polls the interrupt sources in
sequences.
The order in which they are tested determines
their priority.
The highest priority source is tested first, if its
first position.
The interrupt request line is common to all
devices.
When no interrupts are pending the interrupt line
2
Interrupt
to CPU
3
INTACK
from CPU
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
PARALLEL PRIORITY INTERRUPT
Each interrupt bit and its corresponding mask bit are applied
to an AND gate to produce the four inputs to a priority
encoder.
The priority encoder generates two bits of the vector
address which is transferred to the CPU.
IST (interrupt status flip flop)is enabled when an interrupt
occurs.
IEN (Interrupt enable flip flop) can be set or cleared to
provide an over-all control over the interrupt system.
The outputs of IST ANDed with IEN provide a common
interrupt signal for the CPU.
The INTACK signal from the CPU places the VAD onto the
data bus.
Priority Interrupt
Inputs Outputs
I0 I1 I2 I3 x y IST Boolean functions
1 d d d 0 0 1
0 1 d d 0 1 1
0 0 1 d 1 0 1 x = I 0' I 1'
0 0 0 1 1 1 1 y = I 0' I 1 + I 0’ I 2’
0 0 0 0 d d 0 (IST) = I0 + I1 + I2 + I3
The logic of the priority encoder is such that if two or more inputs arrive at the
same time, the input having the highest priority will take precedence.
IST is set only when one or more inputs are equal to 1.
If all inputs are 0, the IST is cleared to 0, and no Vector address will be
transferred on to the bus.
Priority Interrupt
INTERRUPT CYCLE
At the end of each Instruction cycle
- CPU checks IEN and IST
- If IEN IST = 1, CPU -> Interrupt Cycle
ABUS Address bus High-impedence
Bus request BR DBUS Data bus (disabled)
CPU when BG is
Bus granted BG RD Read
WR Write enabled
Internal Bus
DMA select DS Address register
Register select RS
Read RD Word count register
Write WR Control
logic
Bus request BR Control register
Bus grant BG
Interrupt Interrupt DMA request
DMA acknowledge to I/O device
DMA CONTROLLER
It needs the usual circuit of an interface.
In addition it needs an address register, a
RS.
When BG=0 the CPU can communicate with
DMA Transfer
When device sends a request the DMA controller activates the BR lines
CPU responds with its BG lines.
DMA then puts the current value of its address register into address bus
and initiates the RD or WR signals.
And sends a DMA acknowledge to the peripheral devices
When device receives an acknowledge, it puts the word on data busor
receives from data bus.
DMA increments its address register and decrements its word count
register.
If word count reaches to zero the stops any transfer and relinquishes the
buses.
Direct Memory Access
CYCLE STEALING
While DMA I/O takes place, CPU is also executing instructions
DMA Controller and CPU both access Memory -> Memory Access Conflict
Cycle Steal
DMA TRANSFER
Interrupt
Random-access
BG
CPU memory unit (RAM)
BR
RD WR Addr Data RD WR Addr Data
Read control
Write control
Data bus
Address bus
Address
select
RD WR Addr Data
DS DMA ack.
RS DMA I/O
Controller Peripheral
BR device
BG DMA request
Interrupt