Module 2
Module 2
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page | 1
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
• Main drawback: The processor wastes its time in checking the status of the device before actual
data transfer takes place.
2) 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.
2.3 INTERRUPTS
• I/O device initiates the action instead of the processor. This is done by sending a special hardware
signal to the processor called as interrupt (INTR), on the interrupt-request line.
• The processor can be performing its own task without the need to continuously check the I/O
device.
• When device gets ready, it will "alert" the processor by sending an interrupt-signal (Figure 4.5).
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page | 2
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
• The speed of operation of the processor and I/O devices differ greatly. Also, since I/O devices are
manually operated in many cases (like pressing a key on keyboard), there may not be
synchronization between the CPU operations and I/O operations with reference to CPU clock. To
cater to the different needs of I/O operations, 3 mechanisms have been developed for interfacing
I/O devices. 1) Program controlled I/O 2) Interrupt I/O 3) Direct memory access (DMA).
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page | 3
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
• Saving registers increases the delay between the time an interrupt request is received and the
start of execution of the ISR. This delay is called interrupt latency.
• Since interrupts can arrive at any time, they may alter the sequence of events. Hence, facility must
be provided to enable and disable interrupts as desired.
• Consider the case of a single interrupt request from one device. The device keeps the interrupt
request signal activated until it is informed that the processor has accepted its request. This
activated signal, if not deactivated may lead to successive interruptions, causing the system to enter
into an infinite loop.
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page | 4
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
• To prevent the system from entering into an infinite-loop because of interrupt, there are 3
possibilities:
1) The first possibility is to have the processor-hardware ignore the interrupt-request line until the
execution of the first instruction of the ISR has been completed.
2) The second option is to have the processor automatically disable interrupts before starting the
execution of the ISR.
3) In the third option, the processor has a special interrupt-request line for which the interrupt-
handling circuit responds only to the leading edge of the signal. Such a line is said to be edge-
triggered.
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
deactivates the interrupt-request signal.
5) The action requested by the interrupt is performed by the ISR.
6) Interrupts are enabled again and execution of the interrupted program is resumed.
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page | 5
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
2.6.1 Polling
• Information needed to determine whether a device is requesting an interrupt is available in its
status-register.
• When a device raises an interrupt-request, it sets IRQ bit to 1 in its status-register (Figure 4.3).
• KIRQ and DIRQ are the interrupt-request bits for keyboard & display.
• Simplest way to identify interrupting device is to have ISR poll all I/O devices connected to bus.
• The first device encountered with its IRQ bit set is the device that should be serviced. After
servicing this device, next requests may be serviced.
• Main advantage: Simple & easy to implement.
Main disadvantage: More time spent polling IRQ bits of all devices (that may not be requesting any
service).
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page | 6
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
• A device requesting an interrupt identifies itself by sending a special-code to processor over bus.
(This enables processor to identify individual devices even if they share a single interrupt-request
line).
• The code represents starting-address of ISR for that device.
• ISR for a given device must always start at same location.
• The address stored at the location pointed to by interrupting-device is called the interrupt-vector.
• Processor
→ loads interrupt-vector into PC &
→ executes appropriate ISR
• Interrupting-device must wait to put data on bus only when processor is ready to receive it.
• When processor is ready to receive interrupt-vector code, it activates INTA line.
• I/O device responds by sending its interrupt-vector code & turning off the INTR signal.
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page | 7
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page | 8
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
• Device 1 passes signal on to device 2 only if it does not require any service.
• If device 1 has a pending-request for interrupt, it blocks INTA signal and proceeds to put its
identifying code on data lines.
• Device that is electrically closest to processor has highest priority.
• Main advantage: This allows the processor to accept interrupt-requests from some devices but
not from others depending upon their priorities.
2.8 EXCEPTIONS
• An interrupt is an event that causes
→ Execution of one program to be suspended &
→ Execution of another program to begin.
• Exception refers to any event that causes an interruption. I/O interrupts are one example of an
exception.
2.8.1 Recovery from Errors
• Computers use a variety of techniques to ensure that all hardware-components are operating
properly. For e.g. many computers include an error-checking code in main-memory which allows
detection of errors in stored-data.
• If an error occurs, control-hardware detects it & informs processor by raising an interrupt.
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page | 9
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page |
10
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
• DMA controller performs the functions that would normally be carried out by processor
• In controller, 3 registers are accessed by processor to initiate transfer operations (Figure 4.18):
1) Two registers are used for storing starting-address & word-count
2) Third register contains status- & control-flags
• The R/W bit determines direction of transfer.
When R/W=1, controller performs a read operation(i.e. it transfers data from memory to I/O),
Otherwise it performs a write operation (i.e. it transfers data from I/O device to memory).
• When done=1, controller
→ completes transferring a block of data &
→ is ready to receive another command.
• When IE=1, controller raises an interrupt after it has completed transferring a block of data
(IE=Interrupt Enable).
• Finally, when IRQ=1, controller requests an interrupt. (Requests by DMA devices for using the bus
are always given higher priority than processor requests).
• There are 2 ways in which the DMA operation can be carried out:
1) In one method, processor originates most memory-access cycles. DMA controller is said to
"steal" memory cycles from processor. Hence, this technique is usually called cycle stealing.
2) In second method, DMA controller is given exclusive access to main-memory to transfer a block
of data without any interruption. This is known as block mode (or burst mode).
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page |
11
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page |
12
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
• The signal on the BR line is the logical OR of bus-requests from all devices connected to it.
• When BR is activated, processor activates Bus-Grant signal(BG1) indicating to DMA controllers
that they may use bus when it becomes free. (This signal is connected to all DMA controllers using a
daisy-chain arrangement).
• If DMA controller-1 is requesting the bus, it blocks propagation of grant-signal to other devices.
Otherwise, it passes the grant downstream by asserting BG2.
• Current bus-master indicates to all devices that it is using bus by activating Bus-Busy line (BBSY).
• Arbiter circuit ensures that only one request is granted at any given time according to a
predefined priority scheme
A conflict may arise if both the processor and a DMA controller try to use the bus at the same time
to access the main memory. To resolve these conflicts, a special circuit called the bus arbiter is
provided to coordinate the activities of all devices requesting memory transfers
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page |
13
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
2.11 BUSES
• Bus
→ is used to inter-connect main-memory, processor & I/O devices
→ includes lines needed to support interrupts & arbitration
• Primary function: To provide a communication-path for transfer of data.
• Bus protocol is set of rules that govern the behaviour of various devices connected to the buses.
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page |
14
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page |
15
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page |
16
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page |
17
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page |
18
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
Output lines of DATAIN are connected to the data lines of the bus by means of 3 state drivers
• Drivers are turned on when the processor issues a read signal and the address selects this
register.
• SIN signal is generated using a status flag circuit.
• It is connected to line D0 of the processor bus using a three-state driver.
• Address decoder selects the input interface based on bits A1 through A31.
• Bit A0 determines whether the status or data register is to be read, when Master-ready is
• active.
• In response, the processor activates the Slave-ready signal, when either the Read-status or Read-data
is equal to 1, which depends on line A0.
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page |
19
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page |
20
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
• Data lines of the processor bus are connected to the DATAOUT register of the interface.
• The status flag SOUT is connected to the data line D1 using a three-state driver.
• The three-state driver is turned on, when the control Read-status line is 1.
• Address decoder selects the output interface using address lines A1 through A31.
• Address line A0 determines whether the data is to be loaded into the DATAOUT register or status
flag is to be read.
• If the Load-data line is 1, then the Valid line is set to 1.
• If the Idle line is 1, then the status flag SOUT is set to 1.
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page |
21
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
• Address bits A2 through A31, that is 30 bits are used to select the overall interface.
• Address bits A1 through A0, that is, 2 bits select one of the three registers, namely, DATAIN,
DATAOUT, and the status register.
• Status register contains the flags SIN and SOUT in bits 0 and 1.
• Data lines PA0 through PA7 connect the input device to the DATAIN register.
• DATAOUT register connects the data lines on the processor bus to lines PB0 through PB7 which
connect to the output device.
• Separate input and output data lines for connection to an I/O device.
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page |
22
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
● Serial port is used to connect the processor to I/O devices that require transmission of data
one bit at a time.
● Serial port communicates in a bit-serial fashion on the device side and bit parallel fashion on
the bus side.
● Transformation between the parallel and serial formats is achieved with shift registers that
have parallel access capability.
● Input shift register accepts input one bit at a time from the I/O device. Refer fig no.4.37
● Once all the 8 bits are received, the contents of the input shift register are loaded in parallel
into DATAIN register.
● Output data in the DATAOUT register are loaded into the output shift register.
● Bits are shifted out of the output shift register and sent out to the I/O device one bit at a
time.
• As soon as data from the input shift registers are loaded into DATAIN, it can start accepting
another 8 bits of data.
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page |
23
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
• Input shift register and DATAIN registers are both used at input so that the input shift register can
start receiving another set of 8 bits from the input device after loading the contents to DATAIN,
before the processor reads the contents of DATAIN. This is called as double-buffering.
• Serial interfaces require fewer wires, and hence serial transmission is convenient for connecting
devices that are physically distant from the computer.
• Speed of transmission of the data over a serial interface is known as the “bit rate”.
• Bit rate depends on the nature of the devices connected.
• In order to accommodate devices with a range of speeds, a serial interface must be able to use a
range of clock speeds.
• Several standard serial interfaces have been developed:
• Universal Asynchronous Receiver Transmitter (UART) for low-speed serial devices.
• RS-232-C for connection to communication links.
2.14 STANDARD I/O INTERFACES
● I/O device is connected to a computer using an interface circuit.
● Do we have to design a different interface for every combination of an I/O device and a
computer? A practical approach is to develop standard interfaces and protocols.
● A personal computer has:
● A motherboard which houses the processor chip, main memory and some I/O interfaces.
● A few connectors into which additional interfaces can be plugged.
● Processor bus is defined by the signals on the processor chip.
● Devices which require high-speed connection to the processor are connected directly to this
bus.
● Because of electrical reasons only a few devices can be connected directly to the processor
bus.
● Motherboard usually provides another bus that can support more devices.
● Processor bus and the other bus (called as expansion bus) are interconnected by a circuit
called “bridge”.
● Devices connected to the expansion bus experience a small delay in data transfers.
● Design of a processor bus is closely tied to the architecture of the processor.
● No uniform standard can be defined.
● Expansion bus however can have uniform standard defined.
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page |
24
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page |
25
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
● The bus supports three independent address spaces: memory, I/O, and configuration.
● we assumed that the master maintains the address information on the bus until data
transfer is completed. But, the address is needed only long enough for the slave to be selected. Thus,
the address is needed on the bus for one clock cycle only, freeing the address lines to be used for
sending data in subsequent clock cycles. The result is a significant cost reduction.
● A master is called an initiator in PCI terminology. The addressed device that responds to
read and write commands is called a target.
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page |
26
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page |
27
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
● To send a command to a target, an initiator requests control of the bus and, after winning
arbitration, selects the controller it wants to communicate with and hands control of the bus over
to it.
● Then the controller starts a data transfer operation to receive a command from the initiator.
● Assume that processor needs to read block of data from a disk drive and that data are stored
in disk sectors that are not contiguous.
● The processor sends a command to the SCSI controller, which causes the following sequence
of events to take place:
● The SCSI controller, acting as an initiator, contends for control of the bus.
● When the initiator wins the arbitration process, it selects the target controller and hands
over control of the bus to it.
● The target starts an output operation (from initiator to target); in response to this, the
initiator sends a command specifying the required read operation.
● The target, realizing that it first needs to perform a disk seek operation, sends a message to
the initiator indicating that it will temporarily suspend the connection between them. Then it
releases the bus.
● The target controller sends a command to the disk drive to move the read head to the first
sector involved in the requested read operation. Then, it reads the data stored in that sector and
stores them in a data buffer. When it is ready to begin transferring data to the initiator, the target
requests control of the bus. After it wins arbitration, it reselects the initiator controller, thus
restoring the suspended connection.
● The target transfers the contents of the data buffer to the initiator and then suspends the
connection again
● The target controller sends a command to the disk drive to perform another seek operation.
Then, it transfers the contents of the second disk sector to the initiator as before. At the end of this
transfers, the logical connection between the two controllers is terminated.
● As the initiator controller receives the data, it stores them into the main memory using the
DMA approach.
● The SCSI controller sends as interrupt to the processor to inform it that the requested
operation has been completed
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page |
28
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
2.14.5 USB
● Universal Serial Bus (USB) is an industry standard developed through a collaborative effort
of several computer and communication companies, including Compaq, Hewlett-Packard, Intel,
Lucent, Microsoft, Nortel Networks, and Philips.
● Speed
Low-speed (1.5 Mb/s)
Full-speed (12 Mb/s)
High-speed (480 Mb/s)
● Port Limitation
● Device Characteristics
● Plug-and-play
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page |
29
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
● To accommodate a large number of devices that can be added or removed at any time, the
USB has the tree structure as shown in the figure.
● Each node of the tree has a device called a hub, which acts as an intermediate control point
between the host and the I/O devices. At the root of the tree, a root hub connects the entire tree to
the host computer. The leaves of the tree are the I/O devices being served (for example, keyboard,
Internet connection, speaker, or digital TV)
● In normal operation, a hub copies a message that it receives from its upstream connection to
all its downstream ports. As a result, a message sent by the host computer is broadcast to all I/O
devices, but only the addressed device will respond to that message. However, a message from an
I/O device is sent only upstream towards the root of the tree and is not seen by other devices.
Hence, the USB enables the host to communicate with the I/O devices, but it does not enable these
devices to communicate with each other.
● When a USB is connected to a host computer, its root hub is attached to the processor bus,
where it appears as a single device. The host software communicates with individual devices
attached to the USB by sending packets of information, which the root hub forwards to the
appropriate device in the USB tree.
● Each device on the USB, whether it is a hub or an I/O device, is assigned a 7-bit address. This
address is local to the USB tree and is not related in any way to the addresses used on the processor
bus.
● A hub may have any number of devices or other hubs connected to it, and addresses are
assigned arbitrarily. When a device is first connected to a hub, or when it is powered on, it has the
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page |
30
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
address 0. The hardware of the hub to which this device is connected is capable of detecting that
the device has been connected, and it records this fact as part of its own status information.
Periodically, the host polls each hub to collect status information and learn about new devices that
may have been added or disconnected.
● When the host is informed that a new device has been connected, it uses a sequence of
commands to send a reset signal on the corresponding hub port, read information from the device
about its capabilities, send configuration information to the device, and assign the device a unique
USB address. Once this sequence is completed the device begins normal operation and responds
only to the new address.
USB protocols
● All information transferred over the USB is organized in packets, where a packet consists of
one or more bytes of information. There are many types of packets that perform a variety of control
functions.
● The information transferred on the USB can be divided into two broad categories: control
and data.
● Control packets perform such tasks as addressing a device to initiate data transfer,
acknowledging that data have been received correctly, or indicating an error.
● Data packets carry information that is delivered to a device.
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page |
31
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
● A packet consists of one or more fields containing different kinds of information. The first
field of any packet is called the packet identifier, PID, which identifies the type of that packet.
● They are transmitted twice. The first time they are sent with their true values, and the
second time with each bit complemented
● The four PID bits identify one of 16 different packet types. Some control packets, such as
ACK
● (Acknowledge), consist only of the PID byte.
ELECTRICAL CHARACTERISTICS
● The cables used for USB connections consist of four wires.
● Two are used to carry power, +5V and Ground.
● Thus, a hub or an I/O device may be powered directly from the bus, or it may have its own
external power connection.
● The other two wires are used to carry data.
● Different signaling schemes are used for different speeds of transmission.
● At low speed, 1s and 0s are transmitted by sending a high voltage state (5V) on one or the
other o the two signal wires. For high-speed links, differential transmission is used.
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page |
32
Regulation – 2018 (CBCS Scheme) Computer Organization – 18CS34
Prepared by: SWETHA HIREMATH Sri Sairam College of Engineering Anekal. Page |
33