Module - 4
Module - 4
Computer Organization
(BCS302)
Module – 4:
Input / Output Organization
Syllabus:
Input/output Organization: Accessing I/O Devices, Interrupts – Interrupt Hardware, Enabling and Disabling
Interrupts, Handling Multiple Devices, Direct Memory Access: Bus Arbitration, Speed, size and Cost of
memory systems. Cache Memories – Mapping Functions.
Text books:
1. M. Morris Mano & Michael D. Ciletti, "Digital Design With an Introduction to Verilog Design", 5e,
Pearson Education.
2. Carl Hamacher, ZvonkoVranesic, SafwatZaky, "Computer Organization", 5th Edition, Tata McGraw Hill
Any machine instruction that can access memory can be used to transfer data to or from an I/O
device.
For example, if DATAIN is the address of the input buffer associated with the keyboard, the instruction
Move DATAIN, R0 ; reads the data from DATAIN and stores them into processor
register R0.
Similarly, if DATOUT is the address of the output data buffer associated with a display unit or a printer, the
instruction
Move R0, DATAOUT ; sends the contents of register R0 to location DATAOUT, which may be the output
; data buffer of a display unit or a printer.
Some processors have special In and Out instructions to perform I/O transfer.
Mohan A R, VCET Puttur
Mechanisms used for Interfacing I/O Devices:
Program Controlled I/O:
Processor repeatedly checks a status-flag to achieve required synchronization between processor &
input/output device. (Processor polls the I/O device).
Main drawback: The processor wastes its time in checking the status of the device before actual data
transfer takes place.
Interrupt I/O:
Synchronization is achieved by having I/O device send a special signal over bus whenever it is ready
for a data transfer operation.
Direct Memory Access (DMA):
Technique used for high speed I/O devices.
It has a device-interface which transfer data directly to or from the memory without continuous
involvement by the processor.
Mohan A R, VCET Puttur
Program Controlled I/O - Example:
Consider a simple example of I/O operations involving a keyboard and a display device in a computer system.
Four registers are used in the data transfer operations.
Data from the keyboard are made available in the DATAIN register, and data sent to the display are stored in
the DATAOUT register.
Register STATUS contains
Two control flags, SIN and SOUT, which provide status information for the keyboard and the display
unit, respectively.
Two flags KIRQ and DIRQ are the
interrupt request bits.
The KEN and DEN bits in CONTROL register
used to enable keyboard and display interrupt
An alternate approach would be for the I/O device to alert the processor when it becomes ready.
At least one of the bus control lines, called an interrupt-request line is dedicated for this purpose.
Processor can perform other useful tasks while it is waiting for the device to be ready
3. All interrupts are disabled(by changing the control bits in the PS).
4. The device is informed that its request has been recognized, and in response, the device
6. Interrupts are enabled again and execution of the interrupted program is resumed.
interrupt-service routine.
The processor reads this address, called the interrupt vector, and loads it into the PC.
In most computers, I/O devices send the interrupt-vector code over the data bus.
The interrupting device must wait to put data on the bus only when the processor is ready to receive it.
When the processor is ready to receive the interrupt-vector code, it activates the interrupt-acknowledge line,
INTA.
The I/O device responds by sending its interrupt-vector code and turning off the INTR signal.
Cache Miss:
If the CPU was not able to find the entry for that particular data in the cache location then it is
a cache miss.
Cache miss occurs when,
The required word is not present in the cache memory. The page containing the required word
has to be mapped from the main memory.
Mohan A R, VCET Puttur
Cache Memory Mapping:
Cache mapping defines how a block from the main memory is mapped to the cache memory in case of
a cache miss.
OR
Cache mapping is a technique by which the contents of main memory are brought into the cache
memory.
The line number of cache to which a particular block can map is given by
Cache line number = ( Main Memory Block Address ) Modulo (Number of lines in Cache)
Consider cache memory is divided into 128 number of lines.
Block j of the main memory maps onto block j modulo 128 of
the cache. i.e. 0 maps to 0, 129 maps to 1.
Whenever one of the main memory blocks 0, 128, 256, . . . is
loaded into the cache, it is stored in cache block 0. Blocks 1,
129, 257, . . . are stored in cache block 1, and so on
Since more than one memory block is mapped onto a given
cache block position, contention may arise for that position
even when the cache is not full.
Mohan A R, VCET Puttur
Direct Mapping:
Placement of a block in the cache is determined by its memory address.
Memory address is divided into three fields: