INPUT/OUTPUT SYSTEM
Nguyen Hong Son, PhD
HCM PTIT
1
Introduction
The third key element of a computer system.
A set of I/O modules.
2
External Devices
External devices are hardware components that can
be connected to a computer to expand its
functionality or provide additional features.
An external device attaches to the computer by a link
to an I/O module.
An external device connected to an I/O module is
often referred to as a peripheral device or, simply, a
peripheral
Keyboard/Monitor, Disk Drive
3
Status signals to
I/O module
Control signals
from I/O module Data
Buffer
Control
logic
Transducer
Data (device-unique)
to and from environment
Peripheral device
4
Three categories
Human-readable
Machine-readable
Communication
5
I/O module
An entity located in the computer that controls the
attachment of one or more peripheral devices to the
computer at the same time
Controls the exchange of data between the
peripheral and the main memory and registers of
the CPU I/O module has two interfaces on either
side.
6
Address bus
System bus
Data bus
Control bus
I/O module
Links to
peripheral
devices
Generic Model of an I/O Module
7
I/O module is a logical component
An I/O module is not simply a set of
mechanical connectors that wire a device into
the system bus. Rather, the I/O module
contains logic for performing a communication
function between the peripheral and the bus
8
Interface to Interface to
system bus external device
External Data
Data registers device
Status
Data bus interface
logic
Conrol
Status/Control registers
Addr bus
I/O
Control bus logic Data
External
device Status
interface
logic Conrol
Block Diagram of an I/O Module
9
The major functions or requirements
for an I/O module
Control and timing
Processor communication
Device communication
Data buffering
Error detection
For Examples: Reality I/O modules
10
I/O operations
Three techniques are possible for I/O
operations.
Programmed I/O
Interrupt-driven I/O
Direct memory access (DMA)
11
Programmed I/O
CPU executes an I/O instruction by issuing a
command to the appropriate I/O module.
The I/O module will perform the requested action
and then set the appropriate bits in the I/O status
register.
The I/O module takes no further action to alert the
processor. In particular, it does not interrupt the
processor. Thus, it is the responsibility of the
processor to periodically check the status of the I/O
module until it finds that the operation is complete.
12
Programmed I/O: I/O Instructions
I/O command and I/O instruction
To execute an I/O-related instruction, the processor
issues an address, specifying the particular I/O
module and external device, and an I/O command
I/O instruction = I/O command + address
There are four types of I/O commands
Control
Test
Read
Write
13
Programmed I/O: two modes
of addressing
Memory-mapped I/O: There is a single address
space for memory locations and I/O devices.
Processor uses the same machine instructions to
access both memory and I/O devices
Isolated I/O: The full range of addresses may be
available for both and the address space for I/O is
isolated from that for memory. The command line
specifies whether the address refers to a memory
location or an I/O device
14
7 6 5 4 3 2 1 0 Keyboard input data
500 register
7 6 5 4 3 2 1 0 Keyboard input status
501 and control register
sign:1 = ready
Set to 1 to start
0 = busy read
Addr Instruction operand
200 Ld AC “1”
Store AC 501
202 Ld AC 501
Branch if Sign=0 202
Ld AC 500
(a) Memory-mapped I/O
Addr Instruction operand
200 Start I/O 4
201 Test I/O 4
Branch Not Ready 201
In 4
(b) Isolated I/O 15
Interrupt-driven I/O
The processor to issue an I/O command to a
module and then go on to do some other useful
work.
The I/O module will then interrupt the processor
to request service when it is ready to exchange
data with the processor.
Interrupt controller
For more information see Lesson 6
16
Direct Memory Access (DMA)
No requires the active intervention of the processor to
transfer data between memory and an I/O module
I/O Module Main Memory
I/O
Using DMA module
Control
unit
Processing
MM unit 17
Typical DMA Block Diagram
Data count
Data
lines Data register
Addr
lines Addr register
DMA REQ
DMA ACK
INTR
Control logic
Read
Write
How DMA works
When the processor wishes to read or write a block of data, it
issues a command to the DMA module that includes the
following information:
Whether a read or write is requested;
The address of the I/O device involved;
The starting location in memory to read from or write to;
The number of words to be read or written.
The processor then continues with other work. It has delegated
this I/O operation to the DMA module.
When the transfer is complete, the DMA module sends an
interrupt signal to the processor 19
DMA: A problem arises
The DMA module is capable of mimicking the
processor and, indeed, of taking over control of the
system from the processor. It needs to do this to transfer
data to and from memory over the system bus.
The DMA module must use the bus only when the
processor does not need it, or it must force the
processor to suspend operation temporarily
The latter technique is more common and is referred to
as cycle stealing, because the DMA module in effect
steals a bus cycle.
20
Where the processor pauses for one
bus cycle
Instruction Cycle
Processor Processor Processor Processor Processor Processor Processor
Cycle Cycle Cycle Cycle Cycle Cycle Cycle
Fetch Decode Fetch Execute Store Process
instruction instruction operand instruction result interrupt
Interrupt
DMA breakpoint
breakpoints
21
Alternative DMA Configurations: 1
All modules share the same system bus. The DMA module,
acting as a surrogate processor, uses programmed I/O to
exchange data between memory and an I/O module through
the DMA module
DMA
CPU module I/O I/O Memory
22
Alternative DMA Configurations: 2
The DMA logic may actually be a part of an I/O
module, or it may be a separate module that controls
one or more I/O modules
DMA DMA
CPU module module Memory
I/O
I/O I/O
23
Alternative DMA Configurations: 3
Connecting I/O modules to the DMA module
using an I/O bus
System bus
DMA
CPU module
Memory
I/O bus
I/O I/O I/O
24
The Evolution of the I/O Function
1. The CPU directly controls a peripheral device.
2. A controller or I/O module is added.
3. The same configuration as in step 2 is used, but now interrupts
are employed.
4. The I/O module is given direct access to memory via DMA.
5. The I/O module is enhanced to become a processor in its own
right, with a specialized instruction set tailored for I/O.
6. The I/O module has a local memory of its own and is, in fact, a
computer in its own right. The I/O processor takes care of most of
the tasks involved in controlling the terminals
25
I/O channel
An I/O channel is an I/O module that has its own
processor and performs most of the processing
involved in I/O operations and implements a high-
level protocol.
I/O instructions are stored in main memory to be
executed by a special-purpose processor in the I/O
channels
The I/O channel represents an extension of the DMA
concept.
26
I/O Channel Architecture
Data and address channel
to main memory
Selector
Control signal
path to CPU I/O I/O
controller controller
Multiplexor
(a) Selector
I/O
controller
I/O
controller
I/O
controller
I/O
controller
(b) Multiplexor 27
External interface standards to
support I/O
Consistent with the operating nature of the peripheral
The most important characteristic is serial or parallel
The I/O module must interact with peripheral devices
to arrange data transmission
A general interaction is as follows:
I/O module sends control signal to request data
transmission
Peripheral reply with ACK
I/O module receives ACK, proceeds to transmit data
immediately
Peripheral receives data and sends notification by ACK
28
Common Interface Standards
Universal Serial Bus (USB), USB 3.1 (SuperSpeed+) up
to 10 Gbps
SCSI (Small Computer System Interface) Speeds range
from 5 Mbps on the original SCSI-1 specification to 160
Mbps on SCSI-3 U3.
1394 Serial Bus (25 Mbps to 3.2 Gbps)
Thunderbolt, up to 10 Gbps
PCI Express
Serial ATA (Serial Advanced Technology Attachment),
up to 6 Gbps. 29
The End
30