Professional Documents
Culture Documents
Module 5: Part 2
ra
Input/Output Organization – Introduction, Synchronous vs. asynchronous I/O, Programmed I/O, Interrupt
driven I/O, Direct Memory Access.
bu tha
Input/Output Organization
Ba tta
1) processor,
2) memory system and
3) input/output modules.
•
u
Any type of computer must offer some peripheral devices for interacting with other devices and
communicating with external world.
an g, M
y M rin
oj
d b inee
are ng
ep E
• The I/O module contains logic for performing a communication function between the peripheral
and the bus.
• All peripheral devices, which are externally interfaced with computer (sometimes called as host)
Pr of
through its chassis, have their own processors within the devices.
• Therefore, communication between a host and any one of its peripheral units is essentially the
communication between two processors.
ge
Computer Printer
I/O
Communication
Processor I/P Port I/P Port Processor
lle
Interface
Host Motherboard Peripheral PCB
Co
General structure of any link between a host and its peripheral unit
• This communication link is always established through the external world with the help of wire
connections.
• Certain special points may be observed in Figure.
• First, the processors in motherboard of the host (computer) and all other processors within
ra
peripherals are generally different and have their own operating frequencies.
• Second, these processors are never directly interconnected and but through some I/O ports.
All necessary signals and data between any two processors are transferred through these ports.
bu tha
• Third, and most important point is, the method of data communication between host and its
peripheral may be any one of the following three
1) Programmed I/O
2) Interrupt driven I/O
Ba tta
3) Direct Memory Access (DMA)
u
Let's take an example of the 8085 processor. It has 16 address lines i.e. addressing capacity of 64 KB
an g, M
memory. It supports I/O-mapped I/Os. It can address up to 256 I/Os.
y M rin
oj
d b inee
are ng
(System Bus)
Read
Write
Pr of
Processor
Memory
I/O Devices
ge
Devices
(System Bus)
Memory Read
Memory Write
Co
I/O Read
Processor I/O Write
Memory
I/O Devices
Devices
College of Engineering, Muttathara 199
Computer Architecture & Microcontrollers_ MODULE 5_S4 EC KTU
ra
I/O devices are mapped into I/O space I/O devices are mapped into memory space
I/O devices are allotted I/O addresses. I/O devices are allotted memory addresses.
Processor differentiates between I/O devices Processor does not differentiate between memory
bu tha
and memory. It isolates I/O devices. and I/O. Treats I/O devices also like memory devices.
I/O addresses are smaller than memory I/O addresses are as big as memory addresses. E.g.:
addresses. E.g.: in 8085, I/O addresses will be 8 in 8085, I/O addresses will be 16 bits as memory
bits though memory addresses are 16-bit addresses are also 16-bit
Ba tta
This allows us to access limited number of I/O This allows us to increase the number of I/O devices.
devices. E.g: in 8085, we can access up to 2 16 = 65536 I/O
E.g: in 8085, we can access only up to 28 = 256 devices.
I/O devices.
u
We can transfer data from I/O device using We can transfer data from I/O devices using any
an g, M
dedicated I/O instructions like IN and OUT only instruction like MOV etc.
Data can be transferred only using a fixed Data can be transferred using any register of the
register. E.g.: in 8085 only “Accumulator” processor.
register
We need four control signals: Memory Read, We need only two control signals in the system:
Memory Write and I/O Read and I/O Write Read and Write.
y M rin
I/O addresses are smaller so address decoding Memory addresses are big so address decoding will
oj
will be faster. be slower
Address decoding will be simpler and cheaper. Address decoding will be more complex and costly
Eg: 8085, 8086 microprocessor (default setting) Eg: 8051 microcontroller
d b inee
In this scheme, CPU execution waits while I/O proceeds concurrently with CPU execution
I/O proceeds
• Which is more efficient with respect to processor utilisation? Justify your answer
Co
Synchronous I/O − In this scheme CPU execution waits while I/O proceeds
hence system time wasted
Asynchronous I/O − I/O proceeds concurrently with CPU execution
hence system time is not wasted
Asynchronous I/O is more efficient with respect to processor utilisation
ra
• Processor periodically checks (polls) the status of every I/O device to know if it wants to perform a
data Transfer.
•
bu tha
For programmed I/O, a complete attention of the processor is essential for the data communication,
• Programmed I/O is also designated as polling method of data transfer or simply by the term polling.
• Processor is busy in constantly checking all I/O devices, hence system time wasted.
• Additional hardware not required
• System is cheaper and less complex.
Ba tta
Interrupt Driven I/O
• In interrupt driven I/O, the transfer is not initiated by the processor.
u
• Instead, an I/O device which wants to perform a data transfer with the processor, must give an
interrupt to the processor.
an g, M
• An interrupt is a condition that makes the processor execute an ISR (Interrupt Service Routine).
• In the ISR, processor will perform data Transfer with the I/O device.
• This relieves the processor from periodically checking the status of every I/O device thereby saves
as lot of time of the processor.
• The processor is free to carry on its own operations.
• Whenever a device wants to transfer data, it will interrupt the processor.
y M rin
• This is how many I/O devices Transfer data with the processor.
oj
• E.g.: Keyboard. Instead of the processor checking all the time, whether a key is pressed, the
keyboard interrupts the processor as an when we press a key. In the ISR of the keyboard, which is a
d b inee
part of the keyboard driver software, the processor will read the data from the keyboard.
• Hence interrupt driven I/O is much better than Polled I/O (Programmed I/O).
------------------------------------------------------------------------------
Note: Interrupt Driven I/O Vs Polling (Programmed I/O)
wants to perform a data Transfer. every I/O device to know if it wants to perform a
data Transfer.
Processor is free to carry on its own operations, Processor is busy in constantly checking all
ep E
hence saves system time. I/O devices, hence system time wasted.
Additional hardware required to handle interrupts. Additional hardware not required
E.g.: 8259 Programmable interrupt controller.
Pr of
Increases cost and complexity of the system. System is cheaper and less complex.
Interrupt priority has to be managed through No such issue.
software or through hardware.
Interrupt vector addresses (ISR Addresses) need to No such issue.
ge
Which is more efficient with respect to processor utilisation? Justify your answer
• In case of Programmed I/O, Processor is busy in constantly checking all I/O devices, hence system
lle
time wasted.
• In case of Interrupt Driven I/O, Processor is free to carry on its own operations, hence saves
Co
system time.
• E.g.: Keyboard. Instead of the processor checking all the time, whether a key is pressed, the
keyboard interrupts the processor as an when we press a key. In the ISR of the keyboard, which is a
part of the keyboard driver software, the processor will read the data from the keyboard.
• Hence interrupt driven I/O is much better than Polled I/O (Programmed I/O).
ra
• DMA means transferring data directly between memory and I/O.
• DMA transfers are very fast as compared to Processor based transfers due to two reasons.
bu tha
1) They are hardware based so no time is wasted in fetching and decoding instructions.
2) Transfers are directly between memory and I/O without data going via the Processor.
• To Perform a DMA transfer we need a DMA Controller like 8237/ 8257.
• It is capable of taking control of the system bus from the Processor.
Ba tta
System Bus Memory
Processor
u
an g, M
HLDA HRQ
DREQ
DMA Peripheral device
Controller DACK (disk controller)
y M rin
oj (Bus Master)
DACK = DMA acknowledge
d b inee
6) Processor releases control of the bus after finishing the current machine (bus) cycle.
7) Processor gives HLDA informing DMAC that it is now the bus master.
8) DMAC issues DACK# (by default active low, but can be changed) to I/O device indicating that the
transfer is about to begin.
ge
ra
8237 has four modes of data transfer:
bu tha
• In this mode, the DMAC is programmed to transfer ALL THE BYTES in one complete DMA
operation.
• After a byte is transferred, the CAR and CWCR are adjusted accordingly.
• The system bus is returned to the processor, ONLY after all the bytes are transferred.
Ba tta
• It is the fastest form of DMA but keeps the processor inactive for a long time.
2) Single Byte Transfer Mode/ Cycle Stealing
• Once the DMAC becomes the bus master, it will transfer only ONE BYTE and return the bus to
u
the processor. As soon as the processor performs one bus cycle, DMAC will once again take the
bus back from the processor.
an g, M
• Hence both DMAC and processor are constantly stealing bus cycles from each other.
• It is the most popular method of DMA, because it keeps the processor active in the background.
• After a byte is transferred, the CAR and CWCR are adjusted accordingly.
3) Demand Transfer Mode
• It is very similar to Block Transfer, except that the DREQ must remain active throughout the
DMA operation.
y M rin
• If during the operation DREQ goes low, the DMA operation is stopped and the busses are
oj
returned to the processor. #Please refer Bharat Sir's Lecture Notes for this ...
• In the meantime, the processor can continue with its own operations. Once DREQ goes high
again, the DMA operation continues from where it had stopped.
d b inee
• This means, the transfer happens on demand from the I/O device, hence the name.
4) Hidden Mode / Transparent Mode
• In this mode, once the processor programs all parameters inside the DMAC, the DMAC does
not request the processor for the control of the bus.
• Instead, it observes the processor. It waits for the processor to enter idle state.
• Once the processor is idle, the DMAC will take control of the bus and perform the Transfer.
are ng
• So, the Transfer is totally transparent to the processor or hidden from the processor.
ep E
Note: The technique of data transmission in programmed I/O and interrupt driven I/O is generally
asynchronous, and during DMA it is synchronous.
Pr of
ge
lle
Co