Module 2 CO & CA
Module 2 CO & CA
Processor Memory
Bus
•Multiple I/O devices may be connected to the processor and the memory via a bus.
•Bus consists of three sets of lines to carry address, data and control signals.
•Each I/O device is assigned an unique address.
•To access an I/O device, the processor places the address on the address lines.
•The device recognizes the address, and responds to the control signals.
Accessing I/O devices (contd..)
Similarly if DATAOUT is the address of output buffer register of display unit or printer.
Then the instruction
Move R0, DATAOUT
I/O devices and the memory may have different address spaces:
Special instructions to transfer data to and from I/O devices.
I/O devices may have to deal with fewer address lines.
I/O address lines need not be physically separate from memory address lines.
In fact, address lines may be shared between I/O devices and memory, with a control signal to indicate
whether it is a memory address or an I/O address.
7
Accessing I/O devices (contd..)
Address lines
Bus Data lines
Control lines
Input device
•I/O device is connected to the bus using an I/O interface circuit which has:
- Address decoder, control circuit, and data and status registers.
•Address decoder decodes the address placed on the address lines thus enabling the
device to recognize its address.
•Data register holds the data being transferred to or from the processor.
•Status register holds information necessary for the operation of the I/O device.
•Data and status registers are connected to the data lines, and have unique addresses.
•I/O interface circuit coordinates I/O transfers.
Cntd..
Accessing I/O devices (contd..)
Recall that the rate of transfer to and from I/O devices is slower than
the speed of the processor. This creates the need for mechanisms to
synchronize data transfers between them.
Program-controlled I/O:
Processor repeatedly monitors a status flag to achieve the necessary synchronization.
Processor polls the I/O device.
• Processor can perform other useful tasks while it is waiting for the device
to be ready.
Example
• For example let us take a task that involves two activities
• Perform some computation
• Print the result
• Repeat the above two steps several times in the program, let the program contain 2
routines COMPUTE and PRINT routine.
• Method #1 :
• The COMPUTE routine passes N lines to the PRINT routine and the PRINT routine then
prints the N lines one by one on a printer.
• All this time the COMPUTE routine keeps on waiting and does not do anything useful.
• Method #2 :
• The COMPUTE routine passes N lines to the PRINT routine.
• The PRINT routine then sends one line to the printer and instead of printing that line it
execute itself and passes the control to the COMPUTE routine .
• The COMPUTE routine continuous it activity, once the line has been printed the printers
sends an interrupt to the processor of the computer.
• At this point the COMPUTE routine is suspended and the PRINT routine is activated and the
PRINT routine send second line to the printer so that the printer can keep on printing the lines
and the process continues.
Interrupts (contd..)
Program 1 Interrupt Service routine
1
2
Interrupt
occurs i
here
i + 1
Multiple I/O devices may be connected to the processor and the memory
via a bus. Some or all of these devices may be capable of generating
interrupt requests.
Each device operates independently, and hence no definite order can be imposed on how the devices
generate interrupt requests?
How does the processor know which device has generated an interrupt?
How does the processor know which interrupt service routine needs to
be executed?
When the processor is executing an interrupt service routine for one
device, can other device interrupt the processor?
If two interrupt-requests are received simultaneously, then how to break
the tie?
contd..
Interrupt service routine can poll the I/O devices connected to the bus.
The first device with IRQ equal to 1 is the one that is serviced.
Polling mechanism is easy, but time consuming to query the status bits
of all the I/O devices connected to the bus.
1.Vectored Interrupt
IN T R 1 IN T R p
Processor
Device 1 Device 2 Device p
INTA1 INTA p
Priority arbitration
Device Device
INTA1
Processor
IN T R p
Device Device
INTA p
Priority arbitration
circuit
•Devices are organized into groups.
•Each group is assigned a different priority level.
•All the devices within a single group share an interrupt-request line, and are
connected to form a daisy chain.
Controlling Device Request
Only those devices that are being used in a program should be allowed to generate
interrupt requests.
To control which devices are allowed to generate interrupt requests, the interface
circuit of each I/O device has an interrupt-enable bit.
If the interrupt-enable bit in the device interface is set to 1, then the device is allowed to generate an interrupt-
request.
Interrupt-enable bit in the device’s interface circuit determines whether the device
is allowed to generate an interrupt request.
Interrupt-enable bit in the processor status register or the priority structure of the
interrupts determines whether a given interrupt will be accepted.
Cntd..
Cntd..
Exceptions
• Trace mode:
• Exception occurs after the execution of every instruction.
• Debugging program is used as the exception-service routine.
• Breakpoints:
• Exception occurs only at specific points selected by the user.
• Debugging program is used as the exception-service routine.
Exceptions (contd..)
[1] Carl Hamacher, Zvonko Vranesic, SafwatZaky: Computer Organization, 5th Edition,
Tata McGraw Hill, 2017