Computer Organization &
Architecture
Chapter Five
Input/ Output Organization
1 14 August 2023
Input/output Concepts
Peripherals cannot connect directly to the system bus, since:
A wide variety of peripherals with various methods of operation
• Delivering different amounts of data
• At different speeds
• In different formats and word lengths
The data transfer rate of peripherals is often much slower than
that of the memory or processor (i.e., needs high-speed system
bus to communicate directly)
Need I/O modules
2 14 August 2023
Cont…
I/O module is required for the purpose of:
Interface to CPU and Memory via the system bus/central switch
Interface to one or more peripheral devices by tailored data links
Figure 5.1: Generic
Model of an I/O
Module
3 14 August 2023
Cont…
Device
Interface External
I/O sensors
Processor Module and
Bus Device
controls
Interface
Device
Interface
Figure 5.2: I/O Module
4 14 August 2023
Peripheral Devices
I/O operations are accomplished between the external environment
and computer by means of exchanging data
An external device attaches to the computer by a link to an I/O
module and the link is used to exchange control, status, and data
between the I/O
module and the external device
Peripheral devices can be categorized:
Human readable: Suitable for communicating with the computer user
(e.g., printer, keyboard, mouse, monitor, etc….)
Machine readable: Suitable for communicating with equipment (e.g.,
hard drive, CDROM, sensors, and actuators)
Communication: Suitable for communicating with remote devices e.g.
5 14 August 2023
modem and NIC
Cont…
Figure 5.3: Block diagram of an external device
6 14 August 2023
Cont…
Figure 5.3 depicts as:
Control logic: is the I/O module's interface to the device
Data channel: passes the data from/to the device
• On the opposite end is the I/O module, but eventually it is the
processor
Transducer
• Acts as a converter between the digital data of the I/O module and the
signals of the outside world.
• Keyboard converts motion of key into data representing key pressed or
released
• Temperature sensor converts amount of heat into a digital value
7 14 August 2023
• Disk drive converts magnetic patterns on disk to bits in the device buffer
I/O Modules
I/O module is normally connected to the computer system on one
end and one or more I/O devices on the other end
I/O module is needed because of:
It helps as a mediator between the processor and an I/O devices
It controls the data exchange between the external device and the main
memory or external devices and CPU registers
It provides an interface internal to the computer which connects it to
CPU and main memory and an interface extended to the computer
connecting it to external device or peripherals
I/O module helps to communicate the information from CPU to I/O
device, facilitates as a buffered( storage area) and error detector
8 14 August 2023
Cont…
The basic functions of an I/O module are:
i. Control & Timing
ii. CPU Communication
iii. Device Communication
iv. Data Buffering
v. Error Detection
i. Control and Timing
Required because of multiple devices communicating on the same
channel, so it helps to coordinate the flow of traffic between internal
and external devices
For example- the control of the transfer of data from an external
device to the processor may involve the following sequence of
9 14 August 2023
steps:
Cont…
i. CPU checks I/O module device status
ii. I/O module returns the device status
iii. If the device is ready to transmit, CPU requests the transfer
data by means command to the I/O module
iv. I/O module gets data from external device
v. I/O module transfers data to CPU
10 14 August 2023
Cont…
i. CPU Communication – involves the following tasks
Command decoding - I/O modules accept commands from
processor, specifically sent as signals on the control bus
for examples I/O module for the disk derive may accept the
commands like: READ SECTOR, WRITE SECTOR, SEEK track
number etc.
Exchange data- between processor and I/O module through data
bus
Status reporting – the device must be able to report its status to
the processor, for example:
• Disk drive BUSY, READY and to reporting various errors
11 Address recognition 14 August 2023
Cont…
i. Device Communication
Each I/O module must be able to perform device communication
such as status report, commands and data
ii. Data Buffering
Due to the differences in data transfer speed between processor
and memory and the external devices, so the I/O module needs
to buffer data and then sent to the peripheral device at its rate
iii. Error Detection
The I/O module able to detect the errors and report them to the
processor.
The error may be malfunctioning device such as paper jam, bad
disk track, data errors (change bit pattern of transmitted
data/parity checking at the device level and internal errors to the
I/O module such as buffer overruns
12 14 August 2023
I/O Module Structure
Figure 5.4: Block Diagram of an I/O Module
13 14 August 2023
I/O Techniques
Three techniques are possible for I/O operations
i. Programmed I/O - data are exchanged between the processor and the I/O
module
The processor executes the program that gives and the I/O
operation such as sensing device status, sending read or write
command, and transferring the data are controlled directly by the
processor
The processor must continuously check an I/O device
ii. Interrupt Driven I/O - module calls for CPU when needed
the processor issues an I/O command, continues to execute other
instructions, and is interrupted by the I/O module when the latter
has completed its work
iii. Direct Memory Access (DMA) - I/O module has direct access to specified
14 block of memory 14 August 2023
The I/O module and main memory exchange data directly without
Cont…
Figure 5.5: Three Techniques for Input of a Block of
15 Data 14 August 2023
Programmed I/O
Programmed I/O Operation: When the processor is executing a
program and encounters an instruction relating to I/O, it executes that
instruction by issuing a command to the appropriate I/O module
CPU fetches I/O instruction from memory
CPU issues I/O command
I/O module performs operation
I/O module sets status bits
CPU checks status bits periodically
• I/O module does not inform CPU directly
• I/O module does not interrupt CPU
• CPU may wait or come back later
CPU wastes time because typically the processor is much faster than
16I/O 14 August 2023
Cont…
I/O commands (from CPU to I/O module)
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 module receives an I/O commands from processor are:
Control – telling module what to do
e.g. spin up disk
Test - check status
e.g. powered?, error?
Read/Write
Module transfers data via buffer from/to device
17 14 August 2023
Interrupt-Driven I/O
Overcomes CPU waiting, since in programmed I/O the processor
waits a long time for the I/O module of concern to be ready for either
reception or transmission of data
Helps to do useful works by interrupting the processor through I/O
modules
The operation from I/O module point of view
I/O module receives READ command from CPU
I/O module gets data from peripheral
Once data is in I/O module register, the module signals interrupts
a CPU
I/O module waits for CPU to request data
18 When requested by CPU, I/O module places data on data
14 August 2023 bus
Cont…
Operation from processor/CPU point of view - the action for input is
as follows
CPU issues read command
Does other work
Checks for interrupt at end of each instruction cycle
If interrupt occur from I/O module
The processor saves context (e.g., program counter and
processor registers) of the current program and process
interrupt
Processes fetches data from I/O module & stores it in
memory
19 Restores the context of the program it 14was working
August 2023 and
Interrupt Processing
Figure 5.6: Simple Interrupt Processing
20 14 August 2023
Direct Memory Access
Why needs Direct Memory Access?
Both programmed I/O and interrupt driven I/O require active CPU
intervention to transfer data between memory and an I/O module,
and any data transfer must traverse a path through the processor
But, this method eliminates the needs of continuous involvement of
the processor in the I/O operation
I/O suffer from two inherent drawbacks:
The I/O transfer rate is limited by the CPU's ability to service
the device
The processor is tied up in managing an I/O transfer, since a
number of instructions must be executed for each I/O transfers
21 14 August 2023
Cont…
Therefore, DMA is to enable peripheral devices to cut out the
“middle man” role of the CPU in data transfer
It allows peripheral devices to transfer data directly from and to
memory without the intervention of the CPU- this helps for CPU to
do other works and improves performance, especially in large
transfer files
The DMA controller is a piece of hardware that controls one or more
peripheral devices
Typically DMA transfer, some event notifies the DMA controller that
data needs to be transferred to or from memory
22 14 August 2023
Cont…
Figure 5.7: DMA controller shares the CPU’s memory bus
23 14 August 2023
DMA module
Figure 5.8: Typical DMA Block Diagram
24 14 August 2023
Cont…
DMA controller has an address register, word count register, and
control register
Address register
Contains an address that specifies the memory location of the
data to be transferred
It is typically possible to have the DMA controller automatically
increment the address register after each word transfer, so that
the next transfer will be from the next memory location.
Word count register
Holds the number of words to be transferred
Word count is decremented by one after each word transfer
25 14 August 2023
Cont…
Control register
specifies the transfer mode
Transfer mode can be performed either in burst mode or single
cycle mode
In burst mode
DMA controller keeps control of the bus until all the data has
been transferred to (from) memory from (to) the peripheral
device
It is needed for fast devices where data transfer cannot be
stopped until the entire transfer is done
26 14 August 2023
Cont…
In single-cycle mode (cycle stealing)
DMA controller relinquishes the bus after each transfer of one data
word
This mode minimizes the amount of time that the DMA controller
keeps the CPU from controlling the bus
but, it requires the bus request/acknowledge sequence be
performed for every single transfer
27 14 August 2023
DMA Configurations
Single bus, detached DMA controller
Each transfer uses bus twice
• I/O to DMA then DMA to memory
CPU is suspended twice, since there is CPU involvement
Figure 5.9: Single-bus, detached DMA
28 14 August 2023
Cont…
Single bus, DMA controller integrated into I/O module
Path between the DMA module and one or more I/O modules without the
system bus.
Controller may support one or more devices
Each transfer uses bus once
DMA to memory
CPU is suspended once
Figure 5.10: Single-bus, integrated DMA-I/O
29 14 August 2023
Cont…
Separate I/O Bus
Reduces number of I/O interfaces in DMA module to one and helps to
expand the configuration
Each transfer uses bus once
• DMA to memory
CPU is suspended once
Figure 5.11: I/O bus
30 14 August 2023
The I/O Interface
An interface is a data path between two separate devices in a
computer system
The basic characteristics of interface is either it is a serial or parallel
based on the number of bits that are transmitted at a given time
Serial Interface/port - there is only one line used to transmit data,
and only one bit of data is transferred at a time
Parallel Interface/port- there are multiple lines connecting the I/O
devices, and more than one bit if data are transferred
simultaneously at a time over the data bus
An example of I/O interfaces includes: PS/2, ISA, PCI, IDE, AGP,
USB, SCSI
31 14 August 2023