Module 5 Notes.docx
Module 5 Notes.docx
INPUT/OUTPUT ORGANIZATION
There are a number of input/output (I/O) devices, which can be connected to a computer. The input may
be from a keyboard, a sensor, switch, mouse etc. Similarly, output may be a speaker, monitor, printer, a
digital display etc.
These variety of I/O devices exchange information in varied format, having different word length,
transfer speed is different, but are connected to the same system and exchange information with the
same computer. Computer must be capable of handling these wide variety of devices.
ACCESSING I/O-DEVICES
A single bus-structure can be used for connecting I/O-devices to a computer. The simple arrangement
of connecting set of I/O devices to memory and processor by means of system bus is as shown in the
figure. Such an arrangement is called as Single Bus Organization.
● The system bus enables all the devices connected to it to involve in the data transfer operation.
● The system bus establishes data communication between I/O device and processor.
● Each I/O device is assigned a unique set of address.
● When processor places an address on address-lines, the intended-device responds to the
command.
● The processor requests either a read or write-operation.
● The requested data are transferred over the data-lines
Source destination
This instruction sends the contents of location DATAIN to register R0.
● Similarly output can be implemented as,
MOVE R0, DATAOUT
Source destination
The data is written from R0 to DATAOUT location (address of output buffer)
The hardware arrangement of connecting i/p device to the system bus is as shown in the fig.
This hardware arrangement is called as I/O interface. The I/O interface consists of 3 functional devices
namely:
1) Address Decoder:
o Its function is to decode the address, in-order to recognize the input device whose address is
available on the unidirectional address bus.
o The recognition of input device is done first, and then the control and data registers becomes
active.
o The unidirectional address bus of system bus is connected to input of the address decoder as
shown in figure
2) Control Circuit:
o The control bus of system bus is connected to control circuit as shown in the fig.
o The processor sends commands to the I/O system through the control bus.
o It controls the read write operations with respect to I/O device.
4) Data Register:
o The data bus carries the data from the I/O devices to or from the processor. The data bus is
connected to the data/ status register.
o The data register stores the data, read from input device or the data, to be written into output
device. There are 2 types:
DATAIN - Input-buffer associated with keyboard.
DATAOUT -Output data buffer of adisplay/printer.
Data buffering is an essential task of an I/O interface. Data transfer rates of processor and
memory are high, when compared with the I/O devices, hence the data are buffered at the I/O
interface circuit and then forwarded to output device, or forwarded to processor in case of input
devices.
DATAIN register is a part of input device. It is used to store the ASCII characters read from
keyboard.
DATAOUT register is a part of output device. It is used to store the ASCII characters to be
displayed on the output device.
Control registers
KEN (keyboard Enable) – Enables the keyboard for input operations.
DEN (Display Enable) – Enables the output device for input operations.
This code checks the SIN flag, and if it is set to 0 (ie. If no character in DATAIN Buffer), then
move back to WAITK label. This loop continues until SIN flag is set to 1. When SIN is 1, data is
moved from DATAIN to R0 register. Thus the program, continuously checks for input operation.
Similarly code for Output operation,
Interrupt
● It is an event which suspends the execution of one program and begins the execution of another
program.
● In program controlled I/O, a program should continuously check whether the I/O device is free.
By this continuous checking the processor execution time is wasted. It can be avoided by I/O
device sending an ‘interrupt’ to the processor, when I/O device is free.
● The interrupt invokes a subroutine called Interrupt Service Routine (ISR), which resolves the
cause of interrupt.
● The occurrence of interrupt causes the processor to transfer the execution control from user
program to ISR.
Program1 ISR
The following steps takes place when the interrupt related instruction is executed:
Interrupt Latency / interrupt response time is the delay between the time taken for receiving an
interrupt request and start of the execution of the ISR.
Generally, the long interrupt latency in unacceptable.
INTERRUPT HARDWARE
● The external device (I/O device) sends interrupt request to the processor by activating a bus line
and called as interrupt request line.
● All I/O device uses the same single interrupt-request line.
● One end of this interrupt request line is connected to input power supply by means of a register.
● The another end of interrupt request line is connected to INTR (Interrupt request) signal of
processor as shown in the fig.
● The I/O device is connected to interrupt request line by means of switch, which is grounded as
shown in the fig.
● When all the switches are open the voltage drop on interrupt request line is equal to the VDD and
INTR value at process is 0.
● This state is called as in-active state of the interrupt request line.
● The I/O device interrupts the processor by closing its switch.
● When switch is closed the voltage drop on the interrupt request line is found to be zero, as the
switch is grounded, hence INTR=0 and INTR=1.
● The signal on the interrupt request line is logical OR of requests from the several I/O devices.
Therefore, INTR=INTR1 + INTR2 + + INTRn
The arrival of interrupt request from external devices or from within a process, causes the suspension of
on-going execution and start the execution of another program.
● Interrupt arrives at any time and it alters the sequence of execution. Hence the interrupt to be
executed must be selected carefully.
● All computers can enable and disable interruptions as desired.
● When an interrupt is under execution, other interrupts should not be invoked. This is performed
in a system in different ways.
● The problem of infinite loop occurs due to successive interruptions of active INTR signals.
● There are 3 mechanisms to solve problem of infinite loop:
1) Processor should ignore the interrupts until execution of first instruction of the ISR.
2) Processor should automatically disable interrupts before starting the execution of the ISR.
3) Processor has a special INTR line for which the interrupt-handling circuit.
Interrupt-circuit responds only to leading edge of signal. Such line is called edge-
triggered.
• Sequence of events involved in handling an interrupt-request:
1) The device raises an interrupt-request.
2) The processor interrupts the program currently being executed.
3) Interrupts are disabled by changing the control bits in the processor status register (PS).
4) The device is informed that its request has been recognized.
In response, the device deactivates the interrupt-request signal.
5) The action requested by the interrupt is performed by the interrupt-service routine.
6) Interrupts are enabled and execution of the interrupted program is resumed.
HANDLING MULTIPLE DEVICES
While handling multiple devices, the issues concerned are:
● How can the processor recognize the device requesting an interrupt?
● How can the processor obtain the starting address of the appropriate ISR?
● Should a device be allowed to interrupt the processor while another interrupt is
being serviced?
● How should 2 or more simultaneous interrupt-requests be handled?
VECTORED INTERRUPT
• A device requesting an interrupt identifies itself by sending a special-code to processor over bus.
• Then, the processor starts executing the ISR.
• The special-code indicates starting-address of ISR.
• The special-code length ranges from 4 to 8 bits.
• The location pointed to by the interrupting-device is used to store the staring address to ISR.
• The staring address to ISR is called the interrupt vector.
• Processor
→ loads interrupt-vector into PC &
→ executes appropriate ISR.
• When processor is ready to receive interrupt-vector code, it activates INTA line.
• Then, I/O-device responds by sending its interrupt-vector code & turning off the INTR signal.
• The interrupt vector also includes a new value for the Processor Status Register
INTERRUPT NESTING
• A multiple-priority scheme is implemented by using separate INTR & INTA lines for each device
• Each INTR line is assigned a different priority-level as shown in Figure.
• Priority-level of processor is the priority of program that is currently being executed.
• Processor accepts interrupts only from devices that have higher-priority than its own.
• At the time of execution of ISR for some device, priority of processor is raised to that of the device.
• Thus, interrupts from devices at the same level of priority or lower are disabled.
Privileged Instruction
• Processor's priority is encoded in a few bits of PS word. (PS = Processor-Status).
• Encoded-bits can be changed by Privileged Instructions that write into PS.
• Privileged-instructions can be executed only while processor is running in Supervisor Mode.
• Processor is in supervisor-mode only when executing operating-system routines.
Privileged Exception
• User program cannot
→ accidently or intentionally change the priority of the processor &
→ disrupt the system-operation.
• An attempt to execute a privileged-instruction while in user-mode leads to a Privileged Exception.
SIMULTANEOUS REQUESTS
DAISY CHAIN
• The daisy chain with multiple priority levels is as shown in the figure.
● The interrupt request line INTR is common to all devices as shown in the fig.
● The interrupt acknowledge line is connected in a daisy fashion as shown in the figure.
● This signal propagates serially from one device to another device.
● The several devices raise an interrupt by activating INTR signal. In response to the signal,
processor transfers its device by activating INTA signal.
● This signal is received by device 1. The device-1 blocks the propagation of INTA signal to
device-2, when it needs processor service.
● The device-1 transfers the INTA signal to next device when it does not require the processor service.
● In daisy chain arrangement device-1 has the highest priority.
● Advantage: It requires fewer wires than the individual connections.
• In this technique, devices are organizes in a group and each group is connected to the processor at a
different priority level.
• Within a group device are connected in a daisy chain fashion as shown in the figure.
EXCEPTIONS
• Exception is an event that causes an interruption. These are the interrupts caused by the running
program. Such interrupts are called exceptions.
• Types of Exception
1. Recovery from Errors
• These are techniques to ensure that all hardware components are operating properly.
For ex: Many computers include an ECC in memory which allows detection of errors
in stored-data. (ECC = Error Checking Code, ESR= Exception Service Routine).
• If an error occurs, control-hardware
→ detects the errors &
→ informs processor by raising an interrupt.
• When exception processing is initiated (as a result of errors), processor -
→ suspends program being executed &
→ starts an ESR. This routine takes appropriate action to recover from the error.
Does the same steps as interrupt handling.
2. Debugging
Debugger is used to find errors in a program and uses exceptions to provide 2 important facilities:
i) Trace & ii) Breakpoints
Trace
i)
• When a processor is operating in trace-mode, an exception occurs after
execution of every instruction (using debugging-program as ESR).
• Debugging-program enables user to examine contents of registers, memory-locations
and so on.
• On return from debugging-program, next instruction in program being debugged is
executed, then debugging-program is activated again.
• The trace exception is disabled during the execution of the debugging-program.
ii) Breakpoints
• Here, the program being debugged is interrupted only at specific points selected by user.
• An instruction called Trap (or Software interrupt) is usually provided for this purpose.
• When program is executed & reaches breakpoint, the user can examine memory & register
contents.
3. Privilege Exception
• To protect OS from being corrupted by user-programs, Privileged Instructions
are executed only while processor is in supervisor-mode.
• For example, When processor runs in user-mode, it will not execute instruction that
change priority of processor.
• An attempt to execute privileged-instruction will produce a Privilege Exception.
• As a result, processor switches to supervisor-mode & begins to execute an appropriate
routine in OS.
Word-Count register:
The format of word count register is as shown in fig. It is used to store the no of words to be transferred
from main memory to external devices and vice versa.
Status and Controller register:
The format of status and controller register is as shown in fig.
a) DONE bit:
● The DMA controller sets this bit to 1 when it completes the direct data transfer between main
memory and external devices.
● This information is informed to CPU by means of DONE bit.
● The DMA controller requests the CPU for permission and data, to transfer new block of data
from source to destination by activating this bit.
● After receiving these 3 parameters from processor, DMA controller directly transfers block of
data between main memory and external devices (disk 1) depending on the operation.
● This information is informed to CPU by setting respective bits in the status and controller
register of DMA controller.
These are 2 types of request with respect to system bus
1). CPU request.
2). DMA request.
Highest priority will be given to DMA request.
● Actually the CPU generates memory cycles to perform read and write operations.
The DMA controller steals memory cycles from the CPU to perform read and write operations.
This approach is called as “Cycle stealing”.
● An exclusive option will be given for DMA controller to transfer block of data between external
devices and main memory. Only after the transfer of whole block, signal is sent to the processor.
This technique is called as “Burst mode of operation.”
● Conflict may arise, if CPU and multiple DMA controllers, request for bus, at the same time. This
is resolved by bus arbitration.
BUS ARBITRATION
● Any device which initiates data transfer operation on bus at any instant of time is called as Bus-
Master.
● When the bus mastership is transferred from one device to another device, the next device is
ready to obtain the bus mastership.
● The bus-mastership is transferred from one device to another device based on the principle of
priority system. There are two types of bus-arbitration technique:
In this technique CPU acts as a bus-master or any control unit connected to bus can be acts as a bus
master.
The following steps are necessary to transfer the bus mastership from CPU to one of the DMA
controller:
● The DMA controller request the processor to obtain the bus mastership by activating BR (Bus
request) signal
● In response to this signal the CPU transfers the bus mastership to requested devices DMA
controller1 in the form of BG (Bus grant).
● When the bus mastership is obtained from CPU the DMA controller1 blocks the propagation of bus
grant signal from one device to another device.
● The BG signal is connected to DMA controller2 from DMA controller1, and so on as in daisy
fashion style as shown in the figure.
● When the DMA controller1 has not sent BR request, it transfers the bus mastership to DMA
controller2 by unblocking bus grant signal.
● When the DMA controller1 receives the bus grant signal, it blocks the signal from passing to DMA
controller2 and enables BBSY signal. When BBSY signal is set to 1 the set of devices connected to
system bus doesn’t have any rights to obtain the bus mastership from the CPU.
● The external device requests the processor to obtain bus mastership by enabling start arbitration
signal.
● In this technique 4 bit code is assigned to each device to request the CPU in order to obtain bus
mastership.
● Two or more devices request the bus by placing 4 bit code over the system bus.
● The signals on the bus interpret the 4 bit code and produces winner as a result from the CPU.
● When the input to the one driver = 1, and input to the another driver = 0, on the same bus line,
this state is called as “Low level voltage state of bus”.
● Consider 2 devices namely A & B trying to access bus mastership at the same time.
Let assigned code for devices A & B are 5 (0101) & 6 (0110) respectively.
● The device A sends the pattern (0101) and device B sends its pattern (0110) to master. The
signals on the system bus interpret the 4 bit code for devices A & B produces device B as a
winner.
● The device B can obtain the bus mastership to initiate direct data transfer between external
devices and main memory.
BUSES
● The primary function of the bus is to inter connect 3 functional device namely CPU, memory and
I/O devices.
● It is defined as set of similar wires used to establish data transfer operation between CPU and
memory as well as CPU and I/O devices.
● It consists of 3 types:
a) Uni-directional address line.
b) Bi-directional data lines.
c) Control lines.
● The address bus of system bus is used to carry either the address of I/O device or the address of
memory.
● The bi-directional data bus is used to carry data to be returned into I/O device or read from I/O
device.
● The control bus of system bus is used to carry control signals as well as timing information. It is
designed to carry control signals as R/W.
The R/W = 1 for read operation.
= 0 for write operation.
The control bus also specifies the timing information to indicate when the processor and I/O
devices may place data or receive data from the bus.
● Based on this timing of placing the data to the bus, the bus can be categorized into two types –
o Synchronous bus
o Asynchronous bus
Note : The bus master is the device which has the control over the bus. It initiates the
data transfer by issuing read or write signal. It is also called as initiator. The device addressed by
the master is called as a slave or target.
Synchronous bus
● In case of Synchronous bus all the devices derive the timing information from common bus line.
● An equally placed pulses on this common bus line are called as timing intervals or timing
signals.
● Two or more timing intervals in which single data transfer takes place is called as ‘bus cycle’.
Timing Diagram for the Read-operation that shows a sequence of events during a read-
operation
• At time t0, the master (processor)
→ places the device-address on address-lines &
→ sends an appropriate command on control-lines as shown in Figure.
Disadvantages
• The device does not respond.
• The error will not be detected.
INTERFACE CIRCUITS
• An I/O Interface consists of the circuitry required to connect an I/O device to a computer-bus.
• On one side of the interface, we have bus signals.
• On the other side, we have a data path with its associated controls to transfer data between
the interface and the I/O device known as port.
• Two types are:
1. Parallel Port transmits and receives data in the form of a number of bits (8
or 16) simultaneously to or from the device.
2. Serial Port transmits and receives data one bit at a time.
• Communication with in the bus is the same for both formats.
• The conversion from the parallel to the serial format, and vice versa, takes place inside
the interface- circuit.
• In parallel-port, the connection between the device and the computer uses
→ a multiple-pin connector and
→ a cable with as many wires.
• This arrangement is suitable for devices that are physically close to the computer.
• In serial port, it is much more convenient and cost-effective where longer cables are needed.
Functions of I/O Interface
1) Provides a storage buffer for at least one word of data.
2) Contains status-flags that can be accessed by the processor to determine
whether the buffer is full or empty.
3) Contains address-decoding circuitry to determine when it is being
addressed by the processor.
4) Generates the appropriate timing signals required by the bus control scheme.
5) Performs any format conversion that may be necessary to transfer data between
the bus and the I/O device (such as parallel-serial conversion in the case of a serial
port).
Parallel Port
The hardware components needed for connecting a keyboard to a processor.
• Processor uses
→ memory-mapped I/O and
→ asynchronous bus protocol.
• On the processor-side of the interface, we have:
→ Data-lines
→ Address-lines
→ Control or R/W line
→ Master-Ready signal and
→ Slave-Ready signal.
The circuit of output interface,
– Slave-ready
– R/W
– Master-ready
– Address decoder
– Handshake control
• Interface-circuits contain
1) Data register DATAOUT &
2) Status-flag SOUT.
SOUT=1 , when device is ready to accept another character, ie. DATAOUT buffer is empty.
SOUT = 0 , when character is loaded in DATAOUT buffer.
The input and output interfaces can be combined into a single interface.
Serial Port
● A serial port is used to connect the processor to I/O devices that require transmission of data one
bit at a time.
● The key feature of an interface circuit for a serial port is that it is capable of communicating in a
bit-serial fashion on the device side and in a bit parallel fashion on the processor side.
● The transformation between the parallel and serial formats is achieved with shift registers that
have parallel access capability.
• During read-operation,
When the processor specifies an address, the memory responds by sending a
sequence of data-words from successive memory-locations.
• During write-operation,
When the processor sends an address, a sequence of data-words is written
into successive memory-locations.
• The master maintains the address information on the bus until data-transfer is completed.
• At any time, only one device acts as Bus-Master.
• A master is called “initiator” which is either processor or DMA.
• The addressed-device that responds to read and write commands is called a Target.
• A complete transfer operation on the bus, involving an address and burst of data is called a
transaction.
• Individual word transfers are called “phases’.
• Data transfer signals on PCI bus
• The PCI has a configuration ROM that stores information about that device.
• The configuration ROM’s of all devices are accessible in the configuration address-space.
• The initialization software read these ROM’s whenever the system is powered up or reset.
• In each case, it determines whether the device is a printer, keyboard or disk controller.
• Devices are assigned address during initialization process.
• Each device has an input signal called IDSEL# (Initialization device select) which has 21
address- lines (AD11 to AD31).
• During configuration operation,
The address is applied to AD input of the device and
The corresponding AD line is set to 1 and all other lines
are set to 0. AD11 - AD31 ,Upper address-line
A0 - A10 , Lower address-line: Specify the type of the operation and to
access the content of device configuration ROM.
• The configuration software scans all 21 locations. PCI bus has interrupt-request lines.
• Each device may requests an address in the I/O space or memory space
SCSI Bus
• SCSI stands for Small Computer System Interface.
• SCSI refers to the standard bus which is defined by ANSI (American National Standard Institute).
• SCSI bus the several options. It may be,
• Because of these various options, SCSI connector may have 50, 68 or 80 pins.
• The data transfer rate ranges from 5MB/s to 160MB/s 320Mb/s, 640MB/s. The transfer rate
depends on,
1) Length of the cable
2) Number of devices connected.
• To achieve high transfer rate, the bus length should be 1.6m for SE signaling and 12m
for LVD signaling.
• The SCSI bus us connected to the processor-bus through the SCSI controller.
• The data are stored on a disk in blocks called sectors. Each sector contains several hundreds of
bytes. These data will not be stored in contiguous memory-location.
• SCSI protocol is designed to retrieve the data in the first sector or any other selected sectors.
• Using SCSI protocol, the burst of data are transferred at high speed.
• The controller connected to SCSI bus is of 2 types.
They are1) Initiator
2) Target
1) Initiator
• It has the ability to select a particular target & to send commands specifying
the operation to be performed.
• They are the controllers on the processor side.
2) Target
• The disk controller operates as a target.
• It carries out the commands it receive from the initiator.
• The initiator establishes a logical connection with the intended target.
1) Arbitration
• When the –BSY signal is in inactive state,
→ the bus will be free &
→ any controller can request the use of bus.
• SCSI uses distributed arbitration scheme because each controller may generate requests at the
same time.
• Each controller on the bus is assigned a fixed priority.
• When BSY becomes active, all controllers that are requesting the bus
→ examines the data-lines &
→ determine whether highest priority device is requesting bus at the same
time.
• The controller using the highest numbered line realizes that it has won the arbitration-process.
• At that time, all other controllers disconnect from the bus & wait for –BSY to become inactive
again.
2) Information Transfer
• The information transferred between two controllers may consist of
→ commands from the initiator to the target
→ status responses from the target to the initiator or
→ data-transferred to/from the I/0 device.
• Handshake signaling is used to control information transfers, with the target
controller taking the role of the bus-master.
3) Selection
• Here, Device
→ wins arbitration and
→ asserts –BSY and –DB6 signals.
• The Select Target Controller responds by asserting –BSY.
• This informs that the connection that it requested is established.
4) Reselection
• The connection between the two controllers has been reestablished, with the target in
control of the bus as required for data transfer to proceed.
Universal Serial Bus (USB)
• USB stands for Universal Serial Bus.
• USB supports 3 speed of operation. They are,
1) Low speed (1.5 Mbps)
2) Full speed (12 mbps) &
3) High speed (480 mbps).
• The USB has been designed to meet the key objectives. They are,
1) Provide a simple, low-cost and easy to use interconnection system.
This overcomes difficulties due to the limited number of I/O ports available on a
computer.
2) Accommodate a wide range of data transfer characteristics for
I/O devices. For e.g. telephone and Internet connections
3) Enhance user convenience through a “plug-and-play” mode of operation.
• Advantage: USB helps to add many devices to a computer system at any time
without opening the computer-box.
Port Limitation
Normally, the system has a few limited ports.
To add new ports, the user must open the computer-box to gain access to
the internal expansion bus & install a new interface card.
The user may also need to know to configure the device & the s/w.
Plug & Play
The main objective: USB provides a plug & play capability.
The plug & play feature enhances the connection of new device at any time,
while the system is operation.
The system should
→ Detect the existence of the new device automatically.
→ Identify the appropriate device driver s/w.
→ Establish the appropriate addresses.
→ Establish the logical connection for communication.
USB architecture
A serial transmission format has been chosen for the USB because a serial bus satisfies the low-
cost and flexibility requirements
Clock and data information are encoded together and transmitted as a single signal ‹ Hence, there
are no limitations on clock frequency or distance, arising from data skew
To accommodate a large number of devices that can be added or removed at any time, the USB
has the tree structure.
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 device. At the root of the tree, a root hub connects the entire tree to
the host computer
To accommodate a large number of devices that can be added or removed at any time, the USB
has the tree structure. Each node has a device called a hub. Root hub, functions, split bus
operations – high speed (HS) and Full/Low speed
USB PROTOCOL
• All information transferred over the USB is organized in packets.
• 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 USB is divided into 2 broad categories: 1) Control and 2) Data.
• Control packets perform tasks such 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.
• 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 type of that packet.
• They are transmitted twice.
1) The first time they are sent with their true values and
2) 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.
• Control packets used for controlling data transfer operations are called Token Packets.