UNIT 5
UNIT 5
UNIT 5
Peripheral Devices
A Peripheral Device is defined as the device which provides input/output functions for a
computer. It communicate with the outside world microcomputers use peripherals (I/O
devices). Commonly used peripherals are: A/D converter, D/A converter, CRT, printers, Hard
disks, floppy disks, magnetic tapes etc. A peripheral device is a device that is connected to a
computer system but is not part of the core computer system architecture.
Classification of Peripheral devices:
It is generally classified into 3 basic categories which are given below:
1. Input Devices:
The input devices is defined as it converts incoming data and instructions into a pattern
of electrical signals in binary code that are comprehensible to a digital computer.
Example:
Keyboard, mouse, scanner, microphone etc.
2. Output Devices:
An output device is generally reverse of the input process and generally translating the
digitized signals into a form intelligible to the user. The output device is also performed
for sending data from one computer system to another. For some time punched-card and
paper-tape readers were extensively used for input, but these have now been supplanted
by more efficient devices.
Example:
Monitors, headphones, printers etc.
3. Storage Devices:
Storage devices are used to store data in the system which is required for performing
any operation in the system. The storage device is one of the most requirement devices
and also provide better compatibility.
Example:
Hard disk, magnetic tape, Flash memory etc
Advantage of Peripherals Devices:
It is helpful for taking input very easily.
It is also provided a specific output.
It has a storage device for storing information or data
It also improves the efficiency of the system.
1
Input-Output Interface ( I/O interface.)
Input-output interface provides a method for transferring information between internal
storage and external I/0 devices.
Peripherals connected to a computer need special communication links for interfacing
them with the central processing unit.
The purpose of the communication link is to resolve the differences that exist between
the central computer and each peripheral
The major differences are: (Why I/O interface are needed)
1. Peripherals are electromechanical and electromagnetic devices and their manner of
operation is different from the operation of the CPU and memory, which are
electronic devices. Therefore, a conversion of signal values may be required.
2. The data transfer rate of peripherals is usually slower than the transfer rate of the
CPU, and consequently, a synchronization mechanism may be needed.
3. Data codes and formats in peripherals differ from the word format in the CPU and
memory.
4. The operating modes of peripherals are different from each other and each must be
controlled so as not to disturb the operation of other peripherals connected to the CPU
To resolve these differences, computer systems include special hardware components
between the CPU and peripherals to supervise and synchronize all input and output transfers.
These components are called interface units.
I/O BUS and Interface Module
The I/O bus consists of data lines, address lines, and control lines.
The I/O bus from the processor is attached to all peripherals interface.
To communicate with a particular device, the processor places a device address on
address lines.
Each Interface decodes the address and control received from the I/O bus, interprets them
for peripherals and provides signals for the peripheral controller.
It is also synchronizes the data flow and supervises the transfer between peripheral and
processor. Each peripheral has its own controller.
For example, the printer controller controls the paper motion, the print timing
The I/O bus is linked to all peripheral interfaces from the processor. The processor locates
a device address on the address line to interact with a specific device.
Each interface contains an address decoder attached to the I/O bus that monitors the
address lines.
When the address is recognized by the interface, it activates the direction between the bus
lines and the device that it controls.
The interface disables the peripherals whose address does not equivalent to the address in
the bus.
2
An interface receives any of the following four commands (I/O command.) –
1. Control Command: A command control is given to activate the peripheral and to
inform its next task. This control command depends on the peripheral, and each
peripheral receives its sequence of control commands, depending on its mode of
operation.
2. Status Command: A status command is used to test various status conditions in
the interface and the peripheral. For example, the computer may wish to check the
status of the peripheral before a transfer is initiated.
3. Output data : A data output command creates the interface counter to the
command by sending data from the bus to one of its registers.
4. Input Data − The data input command is opposite to the data output command. In
data input, the interface gets an element of data from the peripheral and places it
in its buffer
I/O versus Memory Bus
In addition to communicating with VO, the processor must communicate with the
memory unit.
There are three ways that computer buses can be used to communicate with memory
and I/O:
1. Separate set of address, control and data bus to I/O and memory.
In This case it is simple because both have different set of address space and
instruction but require more buses. This is done by using separate I/O
Processor (IOP) in addition to CPU.
2. Have common bus (data and address) for I/O and memory but separate control
lines. (Isolated I/O)
3. Have common bus (data, address, and control) for I/O and memory. (Memory
Mapped I/O)
3
Isolated I/O
It has common bus (data and address) for I/O and memory but separate read and write
control lines for I/O
when CPU decode instruction then if data is for I/O then it places the address on the
address line and set I/O read or write control line on due to which data transfer occurs
between CPU and I/O.
The address for I/O here is called ports.
The isolated 110 method isolates memory and 110 addresses so that memory address
values are not affected by interface address assignment since each has its own address
space.
In Memory mapped I/O , the CPU uses same address space for both memory and I/O.
The computers that employ only one set of read and write signals and do not distinguish
between memory and I/O addresses.
The computer treats an interface register as being part of the memory system.
The assigned addresses for interface registers cannot be used for memory words, which
reduces the memory address range available.
4
Example of I/O Interface
5
Data Transfer:
The internal operations in a digital system are synchronized by means of clock pulses
supplied by a common pulse generator. Clock pulses are applied to all registers within
a unit and all data transfers among internal registers occur simultaneously during the
occurrence of a clock pulse.
Two units, such as a CPU and an VO interface, are designed independently of each
other.
Two type of Data Transfer takes place between peripherals:
Advantages –
1. The design procedure is easy. The master does not wait for any acknowledges signal from the slave,
though the master waits for a time equal to slave’s response time.
6
2. The slave does not generate an acknowledge signal, though it obeys the timing rules as per the protocol
set by the master or system designer.
Disadvantages –
1. If a slow speed unit connected to a common bus, it can degrade the overall rate of transfer in the system.
2. If the slave operates at a slow speed, the master will be idle for some time during data transfe r and vice
versa
A. Strobe control
The strobe control method of asynchronous data transfer employs a single control line
to time each transfer.
The strobe may be activated by either the source (source-initiated transfer) or the
destination unit (Destination initiated transfer).
In A source initiated transfer, the source unit first places the data on the data bus.
After a brief delay to ensure that the data settle to a steady value, the source activates
the strobe pulse. The information on the data bus and the strobe signal remain in the
active state for a sufficient time period to allow the destination unit to receive the
data.
The source removes the data from the bus a brief period after it disables its strobe
pulse.
7
In Destination Initiated Strobe, data transfer initiated by the destination unit. In this
case the destination unit activates the strobe pulse, informing the source to provide the
data.
The source unit responds by placing the requested binary information on the data bus.
The data must be valid and remain in the bus long enough for the destination unit to
accept it.
The destination unit then disables the strobe. The source removes the data from the
bus after a predetermined time interval
B. Handshaking Control
The disadvantage of the strobe method is that the source unit that initiates the transfer has
no way of knowing whether the destination unit has actually received the data item that
was placed in the bus.
Similarly, a destination unit that initiates the transfer has no way of knowing whether the
source unit has actually placed the data on the bus.
The handshake method solves this problem by introducing a second control signal that
provides a reply to the unit that initiates the transfer.
The basic principle of the two-wire handshaking method of data transfer is as follows.
1. One control line is in the same direction as the data flow in the bus from the source to
the destination. It is used by the source unit to inform the destination unit whether
there are valid data in the bus.
2. The other control line is in the other direction from the destination to the source. It is
used by the destination unit to inform the source whether it can accept data.
The two handshaking lines are data valid, which is generated by the source unit, and data
accepted, generated by the destination unit.
8
In a Source initiated Transfer, the source unit initiates the transfer by placing the data
on the bus and enabling its data valid signal.
The data accepted signal is activated by the destination unit after it accepts the data from
the bus.
The source unit then disables its data valid signal, which invalidates the data on the bus.
The destination unit then disables its data accepted signal and the system goes into its
initial state.
In a Destination initiated Transfer, the source unit in this case does not place data on
the bus until after it receives the ready for data signal from the destination unit.
Here Data accept line of Source initiated Transfer is replaced by ready for data signal.
9
Advantage of the Handshaking method:
1. The Handshaking scheme provides degree of flexibility and reliability because the
successful completion of data transfer relies on active participation by both units.
2. If any of one unit is faulty, the data transfer will not be completed. Such an error
can be detected by means of a Timeout mechanism which provides an alarm if the
data is not completed within time
10
Modes of data Transfer (I/O Techniques)
Binary information received from an external device is usually stored in memory for later
processing. Information transferred from the central computer into an external device
originates in the memory unit.
The CPU merely executes the instructions and may accept the data temporarily, but the
ultimate source or destination is the memory unit.
Data transfer between the central computer and 110 devices may be handled in a variety
of modes, these are:
1. Programmed I/O
2. Interrupt-initiated I/O
3. Direct memory access (DMA)
11
A flowchart of the program that must be written for the CPU is shown. It is assumed that
the device is sending a sequence of bytes that must be stored in memory. The transfer of
each byte requires three instructions:
1. Read the status register.
2. Check the status of the flag bit and branch to step 1 if not set or to step if set.
3. Read the data register
12
Interrupt-Initiated I/O
An alternative to the CPU constantly monitoring the flag is to let the interface inform the
computer when it is ready to transfer data. This mode of transfer uses the interrupt
facility.
While the CPU is running a program, it does not check the flag. However, when the flag
is set, The CPU momentarily interrupted from proceeding with the current program.
The CPU responds to the interrupt signal by storing the return address from the program
counter into a memory stack and then control branches to a service routine that processes
the required I/O transfer.
There are two ways of choosing the branch address:
1. Vectored Interrupt
2. Non-vectored Interrupt
In vectored interrupt the source that interrupt the CPU provides the branch information.
This information is called interrupt vectored.
In non-vectored interrupt, the branch address is assigned to the fixed address in the
memory.
13
Programmed I/O Interrupt Initiated I/O
Priority Interrupt
14
The program that takes care of interrupts begins at the branch address and polls the
interrupt sources in sequence. The order in which they are tested determines the
priority of each interrupt.
The highest-priority source is tested first, and if its interrupt signal is ON, control
branches to a service routine for this source. Otherwise, the next-lower-priority source
is tested, and so on.
The disadvantage of the software method is that if there are many interrupts, the time
required to poll them can exceed the time available to service the I/O device. In this
situation a hardware priority-interrupt unit can be used to speed up the operation
Hardware Procedure
Hardware priority system function as an overall manager.
It accepts interrupt request and determine the priorities.
To speed up the operation each interrupting devices has its own interrupt vector.
No polling is required, all decision are established by hardware priority interrupt unit.
It can be established by serial (Daisy-Chaining Priority) or parallel (Parallel Priority
Interrupt) connection of interrupt lines.
Daisy-Chaining Priority
Device with highest priority is placed first.
Device that wants the attention send the interrupt request to the CPU.
CPU then sends the INTACK signal which is applied to PI (priority in) of the first
device.
If it had requested the attention, it place its VAD (vector address) on the bus. And it
block the signal by placing 0 in PO (priority out)
If not it pass the signal to next device through PO (priority out) by placing 1.
This process is continued until appropriate device is found.
The device whose PI is 1 and PO is 0 is the device that send the interrupt request.
15
Priority is established according to the position of the bits in the register
Mask register is used to provide facility for the higher priority devices to interrupt when
lower priority device is being serviced or disable all lower priority devices when higher is
being serviced.
Corresponding interrupt bit and mask bit are ANDed and applied to priority encoder.
Priority encoder generates two bits of vector address.
Another output from it sets IST(interrupt status flip flop)
16
The CPU may be placed in an idle state in a variety of ways. One common method
extensively used in microprocessor is to disable the buses through special control
signals such as:
A. Bus Request: The Bus Request (BR) input is used by the DMA controller to
request the CPU to stop having control of bus. When this input is active, the CPU
terminates the execution of the current instruction and place the address bus, the
DATA bus and the read and write line into high impedance state.
B. Bus Grant: The CPU activates the bus Grant (BG) output to inform the external
DMA that the buses are in high impedance state. The DMA that originated the bus
request can now take control of the buses to conduct memory transfers without
processor intervention.
These two control signals in the CPU that facilitates the DMA transfer.
When this input is active, the CPU terminates the execution of the current instruction
and places the address bus, data bus and read write lines into a high Impedance state.
High Impedance state means that the output is disconnected.
When DMA terminates the transfer, it disables the bus request line. The CPU disables
the Bus Grant (BG), takes control of the bus, and returns to its normal operation.
17
DMA Controller
The DMA controller needs the usual circuits of an interface to communicate with the
CPU and I/O device. In addition, it need address register, a word count register and a set
of address lines.
The Address register and address lines are used for direct communication with the
memory.
The data transfer may be done directly between the device and memory under control of
the DMA.
The DMA unit communicates with the CPU via the data bus and control lines.
The DMA controller has three registers:
1. Address Register
2. Word Count Register
3. Control Register
Address Register: - Address Register contains an address to specify the desired location
in memory.
Word Count Register: - WC holds the number of words to be transferred. The register is
increase/decrease by one after each word transfer and internally tested for zero
Control Register :- Control Register specifies the mode of transfer
The unit communicates with the CPU via the data bus and control lines. The registers in
the DMA are selected by the CPU through the address bus by enabling the DS (DMA
select) and RS (Register select) inputs. The RD (read) and WR (write) inputs are
bidirectional.
When the BG (Bus Grant) input is 0, the CPU can communicate with the DMA registers
through the data bus to read from or write to the DMA registers.
When BG =1, the DMA can communicate directly with the memory by specifying an
address in the address bus and activating the RD or WR control.
18
DMA Transfer
The CPU communicates with the DMA through the address and data buses as with
any interface unit. The DMA has its own address, which activates the DS and RS
lines. The CPU initializes the DMA through the data bus.
Once the DMA receives the start control command, it can start the transfer between
the peripheral device and the memory
When the peripheral device sends a DMA request, the DMA controller activates the
BR line, informing the CPU to stop control on the buses.
The CPU responds with its BG line, informing the DMA that its buses are
disabled.
The DMA then puts the current value of its address register into the address bus,
Initiates the RD or WR signal, and sends a DMA acknowledge to the peripheral
device.
The direction of transfer depends on the status of the BG line.
When BG = 0, the RD and WR are input lines allowing the CPU to communicate with
the internal DMA registers.
When BG= 1, the RD and WR are output lines from the DMA controller to the
random-access memory to specify the read or write operation for the data.
For each word that is transferred, the DMA increments its address register and
decrements its word count register.
If the word count register reaches zero, the DMA stops any further transfer and
removes its bus request. It also informs the CPU of the termination by means of
interrupt.
19
Input-Output Processor (IOP)
Instead of having each interface communicate with the CPU, a computer may
incorporate one or more external processors and assign them the task of communicating
directly with all I/O devices.
An input-output processor (IOP) may be classified as a processor with direct memory
access capability that communicates with I/O devices.
The IOP is similar to a CPU except that it is designed to handle the details of I/O
processing.
Unlike the DMA controller that must be set up entirely by the CPU, the IOP can
fetch and execute its own instructions, which is specifically designed for I/O
transfer.
The block diagram indicated two processor (CPU and IOP), which can
communicate with Memory unit directly.
The CPU is responsible for processing data needed in the solution of
computational tasks.
The IOP provides the path for transfer of data between various peripherals devices and
memory unit.
The data formats of peripheral devices differ from memory and CPU data formats.
After the input data are assembled into a memory word, they are transferred from lOP
directly into memory by "stealing" one memory cycle from the CPU.
Instructions that are read from memory by an IOP are sometimes called commands, to
distinguish them from instructions that are read by the CPU.
CPU-IOP Communication
In most cases the memory unit acts as a message centre where each processor leaves
information for the other.
The sequence of operations may be carried out as shown in the flowchart for the
communication between CPU and IOP.
20
The CPU sends an instruction to test the IOP path.
The IOP responds by inserting a status word in memory for the CPU to check. The bits of
the status word indicate the condition of the IOP and I/O device, such as IOP overload
condition, device busy with another transfer, or device ready for I/O transfer.
The CPU refers to the status word in memory to decide what to do next. If all is in order,
the CPU sends the instruction to start I/O transfer.
The memory address received with this instruction tells the IOP where to find its program
The CPU can now continue with another program while the IOP is busy with the I/O
program.
When the IOP terminates the execution of its program, it sends an interrupt request to the
CPU.
The CPU responds to the interrupt by issuing an instruction to read the status from the IOP.
The IOP responds by placing the contents of its status report into a specified memory
location.
21
Serial Communication
Serial communication is the process of sequentially transferring the information/bits on the
same channel. Due to this, the cost of wire will be reduced, but it slows the transmission
speed.
In serial communication, binary pulses are used to show the data
The serial communication can either be asynchronous or synchronous.
Synchronous Communication
In the synchronous communication scheme, after a fixed number of data bytes, a special bit
pattern called SYNC is sent as shown Figure. There is no gap between adjacent characters in the
synchronous communication. There is a continuous stream of data bits coming at a fixed speed
in a synchronous communication scheme. Synchronous communication is used generally when
two computers are communicating to each other or when a buffered terminal is communicating
to the computer
2. Half duplex communication link: In half duplex, the communication link can be used for either
transmission or reception. Data is transmitted in only one direction at a time.
22
3. Full duplex communication link: If the data is transmitted in both ways at the same time,
it is a full duplex i.e. transmission and reception can proceed simultaneously. This
communication link requires two wires for data, one for transmission and one for reception
Interrupt
An interrupt is a signal to the processor emitted by hardware or software indicating an
event that needs immediate attention. It alerts the processor to a high priority process
requiring interruption of the current working process. In I/O devices one of the bus control
lines is dedicated for this purpose and is called the Interrupt Service Routine (ISR).
An interrupt in computer architecture is a signal that requests the processor to suspend its
current execution and service the occurred interrupt. To service the interrupt the processor
executes the corresponding interrupt service routine (ISR). After the execution of the
interrupt service routine, the processor resumes the execution of the suspended program.
TYPES OF INTERRUPTS
There are many type of interrupts but basic type of interrupts are –
1. Hardware and software interrupts
2. Vectored and Non- vectored Interrupts
3. Mask able and non-maskable interrupts
1.TRAP(RST 4.5):-
Non maskable
23
Edge and level triggered .
Edge and level triggered means that the TRAP must go high and remain high
until it is acknowledged
Highest priority
vectored interrupt.
In the case of sudden power failure, it executes a ISR (Interrupt service routine)
and send the data from main memory to backup memory.
2.RST 7.5:-
Second highest priority.
Maskable
edge triggered interrupt.
Edge sensitive means input goes high and no need to maintain high state until it is
recognized.
2. Software Interrupts are those which are inserted in between the program which
means these are mnemonics of microprocessor.
There are 8 software interrupts. They are – RST 0, RST 1, RST 2, RST 3, RST 4,
RST 5, RST 6, RST 7.
24
as maskable interrupts. These interrupts are either edge-triggered or level-
triggered, so they can be disabled.
INTR, RST 7.5, RST 6.5, RST 5.5 are maskable interrupts.
Non Maskable Interrupt: The hardware interrupts that can neither be ignored
nor delayed and must immediately be serviced by the processor are termed as
non-maskable interrupts. It consists of both level as well as edge triggering and is
used in critical power failure conditions.
25
Step 3: The program counter is now loaded with the address of interrupt service
routine.
Step 4: Once the interrupt service routine is completed the address on the processes
stack is pop and place back in the program counter.
Step 5: Execution resumes from (i + 1)th line of compute routine
INTERRUPT HARDWARE
Many computers have facility to connect two or more input and output devices to it like
laptop may have 3 USB slots. All these input and output devices are connected via
switches as shown -
So there is a common interrupt line for all N input/output devices and the
interrupt handling works in the following manner ->
1. When no interrupt is issued by the input/output devices then all the switches are
open and the entire voltage from Vdd is flown through the single line INTR and
reaches the processor. Which means the processor gets a voltage of 1V.
2. When the interrupt is issued by the input/output devices then the switch
associated with the input/output device is closed, so the entire current now passes
via the switches which means the hardware line reaching the processes
i.e INTR line gets 0 voltage. This is an indication for the processor that an
interrupt has occurred and the processor needs to identify which input/output
device has triggered the interrupt
3. The value of INTR is a logical NOT of the requests from individual devices.
4. The resistor R is called as a pull up resistor because it pulls the line voltage to
high voltage state when all switches are open( no interrupt state).
26
27