COA Unit-5 Notes
COA Unit-5 Notes
UNIT-5
Faculty Name:- Mr. Karan Siwach
Input-Output interface
The I/O bus consists of data lines, address lines and control lines.
I/O commands that the interface may receive:
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 which reduces
memory address range available
● No specific input or output instruction so the same memory reference
instructions can be used for I/O transfers
Asynchronous Data Transfer:
Two units, such as a CPU and an I/O interface, are designed independently of each other.
If the registers in the interface share a common clock with the CPU registers, the
transfer between the two units is said to be synchronous.
In most cases, the internal timing in each unit is independent from the other in that
each uses its own private clock for internal registers. In that case, the two units are said
to be asynchronous to each other. This approach is widely used in most computer
systems.
Asynchronous data transfer between two independent units requires that control
signals be transmitted between the communicating units to indicate the time at which
data is being transmitted.
A strobe pulse supplied by one of the units to indicate to the other unit when the
transfer has to occur.
Another method commonly used is to accompany each data item being transferred with
a control signal that indicates the presence of data in the bus. The unit receiving the
data item responds with another control signal to acknowledge receipt of the data. This
type of agreement between two independent units is referred to as handshaking.
Strobe Control: The strobe may be activated by either the source or the destination
unit. The data bus carries the binary information from source unit to the destination
unit. Typically, the bus has multiple lines to transfer an entire byte or word. The strobe
is a single line that informs the destination unit when a valid data word is available in
the bus.
In this case the destination unit activates the strobe pulse, informing the source to
provide the data. The source unit responds by placing the requested binary information
on the data bus. The data must be valid and remain in the bus long enough for the
destination unit to accept it. The destination unit. Then disables the strobe.
Handshaking:
The disadvantage of the strobe method is that the source unit that initiates the transfer
has no way of knowing whether the destination unit has actually received the data item
that was placed in the bus. The handshake method solves this problem by introducing a
second control signal that provides a reply to the unit that initiates the transfer.
Fig: Source initiated
Programmed I/O
Programmed I/O operations are the result of I/O instructions written in the computer
program.
In programmed I/O, each data transfer in initiated by the instructions in the CPU and
hence the CPU is in the continuous monitoring of the interface.
Input instruction is used to transfer data from I/O device to CPU, store instruction is
used to transfer data from CPU to memory and output instruction is used to transfer
data from CPU to I/O device.
This technique is generally used in very slow speed computer and is not a efficient
method if the speed of the CPU and I/O is different.
Interrupt-driven I/O
In the programmed I/O method, the CPU stays in a program loop until the I/O unit
indicates that it is ready for data transfer. This is a time-consuming process since it
keeps the processor busy needlessly. It 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. In the meantime the CPU can proceed to execute
another program. The interface meanwhile keeps monitoring the device. When the
interface determines that the device is ready for data transfer, it generates an interrupt
request to the computer. Upon detecting the external interrupt signal, the CPU
momentarily stops the task it is processing, branches to a service program to process
the I/O transfer, and then returns to the task it was originally performing.
DMA (DIRECT MEMORY ACCESS):
Transfer of data under programmed I/O is between CPU and peripheral. In direct
memory access (DMA), the interface transfers data into and out of the memory unit
through the memory bus. The CPU initiates the transfer by supplying the interface with
the starting address and the number of words needed to be transferred and then
proceeds to execute other tasks. When the transfer is made, the DMA requests memory
cycles through the memory bus. When the request is granted by the memory controller,
the DMA transfers the data directly into memory. The CPU merely delays its memory
access operation to allow the direct memory I/O transfer. Since peripheral speed is
usually slower than processor speed, I/O-memory transfers are infrequent compared to
processor access to memory.
DMA controller Interface that provides I/O transfer of data directly to and from the
memory and the I/O device
CPU initializes the DMA controller by sending a memory address and the number of
words to be transferred
Actual transfer of data is done directly between the device and memory through DMA
controller -> Freeing CPU for other tasks
The transfer of data between the peripheral and memory without the interaction of CPU
and letting the peripheral device manage the memory bus directly is termed as Direct
Memory Access (DMA).
The two control signals Bus Request and Bus Grant are used to fascinate the DMA
transfer. The bus request input is used by the DMA controller to request the CPU for the
control of the buses. When BR signal is high, the CPU terminates the execution of the
current instructions and then places the address, data, read and write lines to the high
impedance state and sends the bus grant signal. The DMA controller now takes the
control of the buses and transfers the data directly between memory and I/O without
processor interaction. When the transfer is completed, the bus request signal is made
low by DMA. In response to which CPU disables the bus grant and again CPU takes the
control of address, data, read and write lines.
The transfer of data between the memory and I/O of course facilitates in two ways
which are DMA Burst and Cycle Stealing.
DMA Burst: The block of data consisting a number of memory words is transferred at a
time.
Cycle Stealing: DMA transfers one data word at a time after which it must return
control of the buses to the CPU.
CPU is usually much faster than I/O (DMA), thus CPU uses the most of the memory
cycles.
DMA Controller
The DMA controller communicates with the CPU through the data bus and control lines.
DMA select signal is used for selecting the controller, the register select is for selecting
the register. When the bus grant signal is zero, the CPU communicates through the data
bus to read or write into the DMA register. When bus grant is one, the DMA controller
takes the control of buses and transfers the data between the memory and I/O.
The address register specifies the desired location of the memory which is incremented
after each word is transferred to the memory. The word count register holds the
number of words to be transferred which is decremented after each transfer until it is
zero. When it is zero, it indicates the end of transfer. After which the bus grant signal
from CPU is made low and CPU returns to its normal operation. The control register
specifies the mode of transfer which is Read or Write.
DMA Transfer
DMA request signal is given from I/O device to DMA controller.
DMA sends the bus request signal to CPU in response to which CPU disables its current
instructions and initialize the DMA by sending the following information.
● The starting address of the memory block where the data are available (for
read) and where data to be stored (for write)
● The word count which is the number of words in the memory block
● Control to specify the mode of transfer
● Sends a bust grant as 1 so that DMA controller can take the control of the buses
DMA sends the DMA acknowledge signal in response to which peripheral device puts
the words in the data bus (for write) or receives a word from the data bus (for read).
DMA Operation
I/O Processors:
Processor with direct memory access capability that communicates with I/O
devices Channel accesses memory by cycle stealing.
A computer may incorporate one or more external processors and assign them the task
of communicating directly with the I/O devices so that no each interface need to
communicate with the CPU. An I/O processor (IOP) is a processor with direct memory
access capability that communicates with I/O devices. IOP instructions are specifically
designed to facilitate I/O transfer. The IOP can perform other processing tasks such as
arithmetic logic, branching and code translation.
The memory unit occupies a central position and can communicate with each processor
by means of direct memory access. The CPU is responsible for processing data needed
in the solution of computational tasks. The IOP provides a path for transferring data
between various peripheral devices and memory unit.
In most computer systems, the CPU is the master while the IOP is a slave processor. The
CPU initiates the IOP and after which the IOP operates independent of CPU and transfer
data between the peripheral and memory.
Interrupts:
An interrupt is a condition that halts the microprocessor temporarily to work on a
different task and then return to its previous task. Interrupt is an event or signal that
request to attention of CPU. This halt allows peripheral devices to access the
microprocessor.
Whenever an interrupt occurs the processor completes the execution of the current
instruction and starts the execution of an Interrupt Service Routine (ISR) or Interrupt
Handler. ISR is a program that tells the processor what to do when the interrupt occurs.
After the execution of ISR, control returns back to the main routine where it was
interrupted.
The different types of interrupts present in processor are given by:
Handling Multiple Devices:
When more than one device raises an interrupt request signal, then additional
information is needed to decide which which device to be considered first. The
following methods are used to decide which device to select: Polling, Vectored
Interrupts, and Interrupt Nesting. These are explained as following below.
1. Polling:
In polling, the first device encountered with with IRQ bit set is the device that is to
be serviced first. Appropriate ISR is called to service the same. It is easy to
implement but a lot of time is wasted by interrogating the IRQ bit of all devices.
2. Vectored Interrupts:
3. Interrupt Nesting:
A program interrupt refers to the transfer of program control from a currently running
program to another service program as a result of an external or internal generated
request.
There are mainly three types of interrupts:
1. External interrupts: It arises due to external call from I/O devices. For e.g. I/O
devices requesting transfer of data, power failure, etc.
2. Internal interrupts: It arises due to illegal and erroneous use of an instruction
or data. For e.g. stack overflow, division by zero, invalid opcode, etc. These are
also called traps.
3. Software interrupts: It is initiated by executing an instruction. It can be used
by the programmer to initiate an interrupt at the desired point in the program.
External and internal interrupts are initiated from signals that occur in the hardware of
the CPU whereas Software interrupts occur from the instructions.
Hardware Interrupt:
The interrupt signal is coming from a device external to the CPU.
Example: keyboard interrupt, timer interrupt, etc.
• TRAP: They are special instructions used to request services from the
operating system. Also called system calls.