Co Module 1 B
Co Module 1 B
Co Module 1 B
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.
This variety of I/O devices exchange information in varied format, having different word length, transfer
speed is different, but is connected to the same system and exchange information with the same
computer. Computer must be capable of handling this 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
Source destination
The data is written from R0 to DATAOUT location (address of output buffer)
I/O INTERFACE
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.
The program checks the status of I/O register and reads or displays data. Here the I/O operation
is controlled by program.
WAITK TestBit #0, STATUS (Checks SIN flag)
Branch = 0 WAITK
Move DATAIN, R0 (Read character)
[*Code to read a character from DATAIN to R0]
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,
WAITD TestBit #0, STATUS (Checks SOUT flag)
Branch = 0 WAITD
Move R0, DATAOUT (Send character for display)
The code checks the SOUT flag, and if it is set to 1 (ie. If no character in DATAOUT Buffer),
then move back to WAITK label. This loop continues until SOUT flag is set to 0. When SOUT is
0, data is moved from R0 register to DATAOUT (ie. Sent by processor).
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:
The following steps takes place when ‘return’ instruction is executed in ISR -
It transfers the execution control from ISR to user program.
It retrieves the content of stack memory location whose address is stored in SP into the PC.
After retrieving the return address from stack memory location into the PC it increments the
Content of SP by 4 memory location.
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.
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.
VECTORED INTERRUPT
• A device requesting an interrupt identifies itself by sending a special-code to processor over bus.
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.
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.
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 this technique, devices are organizes in a group and each group is connected to the processor at a
different priority level.
Dept of ECE, GCEM 12
Computer Organization & ARM Controller ( 21EC52) Module-1
• 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
i)
Trace
• 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
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.
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.
In the sample architecture shown above, the DMA controller connects two external devices
namely disk 1 and disk 2 to system bus.
The DMA controller also interconnects high speed network devices to system bus as shown
in the above fig.
Let us consider direct data transfer operation by means of DMA controller without the
involvement of CPU in between main memory and disk 1.
To establish direct data transfer operation between main memory and disk 1. DMA controller
request the processor to obtain 3 parameters namely:
1) Starting address of the memory block.
2) No of words to be transferred.
3) Type of operation (Read or Write).
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.
• During, clock cycle-1, master sends address/command info the bus requesting a “read‟ operation.
• The slave receives & decodes address/command information.
• At the active edge of the clock i.e. the beginning of clock cycle-2, it makes access to
respond immediately.
• The data become ready & are placed in the bus at clock cycle-3.
• At the same times, the slave asserts a control signal called slave-ready.
• The master strobes the data to its input-buffer at the end of clock cycle-3.
• The bus transfer operation is now complete.
• And the master sends a new address to start a new transfer in clock cycle4.
• The slave-ready signal is an acknowledgement from the slave to the master.
ASYNCHRONOUS BUS
• This method uses handshake-signals between master and slave for coordinating data-transfers.
• There are 2 control-lines:
1) Master-Ready (MR) is used to indicate that master is ready for a transaction.
2) Slave-Ready (SR) is used to indicate that slave is ready for a transaction.
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 output of the encoder consists of
→ bits representing the encoded character and
→ one signal called valid, which indicates the key is pressed.
The information is sent to the interface-circuits
• Interface-circuits contain
1) Data register DATAIN &
2) Status-flag SIN.
• When a key is pressed, corresponding signals is sent to the encoder circuit and the circuit generates
the ASCII code for the corresponding key. The Valid signal changes from 0 to1.
Then, SIN=1 , when ASCII code is loaded into DATAIN.
SIN = 0 , when processor reads the contents of the DATAIN.
• The interface-circuit is connected to the asynchronous bus.
• Data transfers on the bus are controlled using the handshake signals:
1) Master ready &
2) Slave ready.
• Processor uses
→ memory-mapped I/O and
→ asynchronous bus protocol.
• On the processor-side of the interface, we have:
Dept of ECE,GCEM 25
Computer Organization & ARM Controller ( 21EC52) Module-1
→ 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.
Dept of ECE,GCEM 27
Computer Organization & ARM Controller ( 21EC52) Module-1
• 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
Dept of ECE,GCEM 28
Computer Organization & ARM Controller ( 21EC52) Module-1
Dept of ECE,GCEM 29
Computer Organization & ARM Controller ( 21EC52) Module-1
• 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
Dept of ECE,GCEM 30
Computer Organization & ARM Controller ( 21EC52) Module-1
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.
Dept of ECE,GCEM 32
Computer Organization & ARM Controller ( 21EC52) Module-1
• 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.
Dept of ECE,GCEM 33
Computer Organization & ARM Controller ( 21EC52) Module-1
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
Tree structure of a USB is shown fig below
Dept of ECE,GCEM 35
Computer Organization & ARM Controller ( 21EC52) Module-1
USB ADDRESSING
• Each device may be a hub or an I/O device.
USB PROTOCOL
• All information transferred over the USB is organized in packets.
Dept of ECE,GCEM 36
Computer Organization & ARM Controller ( 21EC52) Module-1
Dept of ECE,GCEM 37