Chapter 5
Chapter 5
Chapter 5
– Device Communication
– Data Buffering
– Error Detection
Device Communication
Specific to each device (commands, status, data)
Data Buffering
Due to the differences in speed (device is usually orders of magnitude
slower) the I/O module needs to buffer data to keep from tying up the CPU's
bus with slow reads or writes
Error Detection
− Distribute the error handling to the module
o Malfunctions by device (paper jam)
o Data errors (parity checking at the device level)
o Internal errors to the I/O module such as buffer overruns
I/O Module Structure
6
Asynchronous Data Transfer
Synchronous data transfer:
• if the internal operations in a digital system are synchronized by means of
clock pluses supplied by a common pluses generator
• Clock pluses are applied to all registers within a unit and all data transfer
among internal registers occur simultaneously during the occurrences of a
clock pluses.
• Example two units CPU and an I/O interface design independently each other,
but the registers in the interface share a common clock with the CPU register,
then the transfer b/n the two units said to be Synchronous
• But, the internal timing in each unit is independent from the other, in that
case each uses its own private clock for the internal registers, and the two
units said to be asynchronous to each others. 7
• Asynchronous data transfer wide approach used in most computer system
• Asynchronous data transfer between two independent units requires Control
signals to indicates the time at which data is being transmitted.
• the data transfer in asynchronous mechanism may done either parallel or serials
ways
• In parallel data transmissions, each bit of message/ information has its own
path and the total message/information is transmitted at the same time.
o i.e. n- bit message must to be transmitted through n separate conductor
paths
o It is faster, but requires more wire
o It is used in short distances and its speed is important
• Serial transmission: each bit in the message is sent in sequences one at a time.
o it uses one pair of conductor or one conductor and a common ground
8
o It is slower , but less expensive since require only one pair of conductor
Modes of Transfer
• Binary information received from an external devices is usually stored in
memory for later processing.
• Data transfer between the central computer and I/O devices may be
handled in a variety of modes.
• Some modes use the CPU as an intermediate path, others transfer the data
directly to and from the memory unit
• Data transfer to and from peripheral can be handled one of the three
possible modes
I. Programmed I/O
II. Interrupt -initiated I/O
III. Direct Memory Access (DMA)
Modes of Transfer
10
1. Programmed I/O
The CPU handles the transfers, which take place between registers and the
devices.
The main hardware components required for communications between the
processor and I/O devices.
Programmed I/O operation are the result of I/O instructions written in the
computer program.
Each data item transfer is initiated by an instruction in the program.
Usually the transfer is to and from a CPU register and peripherals
And other instructions needed to transfer the data to and from a CPU and
memory
2. Interrupt-initiated I/O
An alternative to the CPU constantly monitoring the flag is to let the
interface inform the computer when it is ready to transfer data. This mode of
transfer uses the interrupt facility.
While the CPU is running a program, it does not check the flag.
However, when the flag is set, the computer is momentarily interrupted from
proceeding with the current program and is informed of the fact that the flag
has been set.
The CPU deviates from what it is doing to take care of the input or output
transfer. After the transfer is completed, the computer returns to the previous
program to continue what it was doing before the interrupt.
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 when two or more
requests arrive simultaneously.
The system may also determine which conditions are permitted to interrupt
the computer while another interrupt is being serviced.
Higher-priority interrupt levels are assigned to requests, which, if delayed or
interrupted, could have serious consequences.
Devices with high-speed transfers such as magnetic disks are given high
priority, and slow devices such as keyboards receive low priority.
When two devices interrupt the computer at the same time, the computer
services the device, with the higher priority first.
How the priority is determined? a polling procedure is used to identify the
highest-priority source by software means.
Direct Memory Access (DMA)
The main idea of direct memory access (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.
Having peripheral devices access memory directly would allow the CPU to do
other work, which would lead to improved performance, especially in the cases
of large transfers.
The DMA controller is a piece of hardware that controls one or more peripheral
devices.
It allows devices to transfer data to or from the system’s memory without the
help of the processor.
In a typical DMA transfer, some event notifies the DMA controller that data
needs to be transferred to or from memory.
Both the DMA and CPU use memory bus and only one or the other can use the
memory at the same time.
The DMA controller then sends a request to the CPU asking its permission to use
the bus.
The CPU returns an acknowledgment to the DMA controller granting it bus
access.
The DMA can now take control of the bus to independently conduct memory
transfer.
When the transfer is complete the DMA relinquishes its control of the bus to the
CPU.
Processors that support DMA provide one or more input signals that the bus
requester can assert to gain control of the bus and one or more output signals that
the CPU asserts to indicate it has relinquished the bus.
Figure 7. 4 shows how the DMA controller shares the CPU’s memory bus.
Fig DMA controller shares the CPU’s memory bus
A DMA controller has
I. an address register,
II. a word count register, and
III. a control register.
I. The 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.
II. The word count register : holds the number of words to be transferred.
The word count is decremented by one after each word transfer.