Professional Documents
Culture Documents
1 I semester MCA
PESIT
Input/ Output Organization
The processor memory and all the I/O devices are connected to Js common
bus. The bus consists of three sets of lines address, data and control lines. Since
there is a common bus, if more than one device is enabled at a time, the data on
the bus will be ambiguous and results in a problem called bus contention. Hence,
to avoid this condition, each I/O device is assigned a unique address. Only the
addressed device is enabled and responds to the commands issued on the control
lines. The processor can request either a read or write operation.
As discussed in the beginning, the type and number of 1/0 devices vary in a
system. As is evident, the physical and electrical characteristics of these devices
are also not compatible with that of the processor. Hence, in order to have an
efficient and organized data transfer, an intermediary is required between the
processor and I/O devices. This is called as an I/O interface. The I/O interface
consists of all the logic required to ensure proper operation by acting as a format
translator. If the designed interface can work on different types of I/O devices, it is
called a general purpose interface. In some cases like to access hard disk in a
system, we need a specialized interface to control and coordinate the data transfer.
They are called special purpose I/O interfaces. Nowadays, the complete interface
circuitry is available as single integrated circuit (IC) chip. For example, Intel has
produced a chip called 8255 PPI (Programmable Peripheral Interface) which can
be used to interface an Analog-to-Digital Converter (ADC) or Digital-to-Analog
Converter (DAC) or a printer to the bus. There are special interface ICs like Intel
8275 CRT controller, 8251 USART (Universal Synchronous Asynchronous
Receiver Transmitter used for serial communication of data over telephone lines)
and so on.
Fig above shows a simple I/O interface to connect an input device to the
bus. The address decoder decodes the address sent on the bus so as to enable the
input device. The data register holds the data being transferred to or from the
processor. The status register contains flags to indicate conditions like buffer full,
buffer empty etc., which are used by the processor to verify the status of the
device.
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 the 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, three mechanisms have been developed for interfacing I/O devices.
They are: 1) Program Controlled I/O
2) Interrupt I/O
3) Hardware Controlled I/O or Direct Memory Access (DMA).
The complete circuitry for each device is connected to the processor via a bus. The
keyboard needs a buffer register to store the code of the key pressed. Similarly the
display unit is required to store the character sent from the processor. These
registers are called DATAIN and DATAOUT, respectively.
Our task is to read a character from keyboard and display it on the screen.
Input data transfer rate is limited by the typing speed of the user, whereas, the
output data transfer rate is very high, since the computer can send thousands of
characters per second to the output unit. But, the display unit may not be able to
accept characters at that rate. Hence, when I/O devices are connected to the
processor, there will be speed mismatch and mechanisms are needed to
synchronize data transfer between them.
One solution to the problem is to use Program Controlled I/O technique. On the
input side, processor waits for user to key-in a character and its availability in the
buffer register of the keyboard is indicated to the processor using a status flag
called SIN. Then the processor reads the character code. On the output side, the
processor sends the first character to the display unit and waits for a signal. The
display sends the signal that the character has been received using a status flag
called SOUT. Now, the processor can send the next character.
The operation of reading a character from the keyboard and displaying it on the
output screen can now be formally stated as below:
We illustrate the idea using memory mapped I/O instructions.
Write a program to monitor the status of SIN. When SIN is 1, a valid
character is present in DATAIN register and processor can read this
register. When the character is transferred to the processor register,
say Ri, SIN is automatically cleared to 0. If a second character is
entered, SIN is again set to 1 and the process repeats. Thus, SIN = 0
is the condition when processor waits and when SIN = 1, it can read
the data.
This operation can be written as,
READWAIT Branch to READWAIT if SIN = 0
Input from DATAIN to R1
3 I semester MCA
PESIT
Input/ Output Organization
Using this arrangement, it would be easy to check the status of these flags.
The I/O operation can be written more syntactically as below:
(i) Read (input) operation
RWAIT Testbit #0, STATUS
Branch=0 RWAIT
MoveByte DATAIN, R1
Interrupts
In Program Controlled I/O technique, the processor initiates the action by
checking the status of the device by entering into a wait loop. During this time, the
processor would have performed other tasks instead of simply waiting for the
device to get ready. Hence, another method was developed wherein the I/O device
4 I semester MCA
PESIT
Input/ Output Organization
initiates the action instead of the processor. This is done by sending a special
hardware signal to the processor called as interrupt, on the interrupt request line.
The processor can be performing its own task without the need to continuously
check the I/O device. When the device gets ready, it will “alert” the processor by
sending an interrupt signal. Thus, by using interrupts, processor waiting cycles can
be eliminated.
To illustrate the idea of Interrupt I/O, consider a task that requires some
computations and the results to be printed on a printer. Let the program consists of
two routines, COMPUTE and PRINT. COMPUTE produces a set of n lines as
output, to be printed by the PRINT routine.
As per the previous scheme, the COMPUTE routine repeats the actions of sending
one line of text to the printer, waiting for it to get printed by the PRINT routine,
till all the lines are printed. The printer accepts only one line of text at a time.
Hence, the processor spends a considerable amount of time waiting for the printer
to become ready. So, we try to speed up the process by overlapping computing and
printing process. Initially, the COMPUTE routine is executed to produce the first n
lines of output. Then, the PRINT routine is executed to send the first line of text to
the printer. Now, instead of waiting for the line to be printed, PRINT routine is
suspended and execution of the COMPUTE routine is continued. Whenever the
printer becomes ready, it alerts the processor by sending an interrupt request
signal. In response, the processor temporarily suspends the execution of
COMPUTE routine and transfers control to the PRINT routine. The PRINT
routine sends the second line to the printer suspends itself and gives control back
to the COMPUTE routine. This process continues until all n lines have been
printed.
The situation is depicted in Fig shown below showing transfer of control between
the two routines.
Interrupt I/O:
The routine executed in response to an interrupt is called the Interrupt-
Service-Routine (ISR). In our example, PRINT routine is the ISR. Assume that an
interrupt request comes during the execution of instruction i as shown in Fig.
5 I semester MCA
PESIT
Input/ Output Organization
above. The processor first completes the execution of instruction i. Since, the
processor needs to come back to the COMPUTE routine, the contents of program
counter, PC, pointing to instruction at i + 1 is to be saved. This address is called
Return Address. The return address may be saved on the processor stack or in a
special register used for this purpose.
Then, the processor loads the PC with the address of the first instruction of the
ISR. This address can be hardwired in the processor or can be generated by the
device.
A Return-from-interrupt instruction at the end of ISR, reloads the return address
into PC, causing the execution to resume at instruction i + 1.
Once the interrupt request signal comes from the device, the processor has to
inform the device that its request has been recognized and will be serviced soon.
This is indicated by another hardware control signal on the processor bus called
interrupt-acknowledge signal. This is shown in the schematic of Fig below. After
receiving the interrupt-acknowledge signal, the external device will deactivate the
request signal.
6 I semester MCA
PESIT
Input/ Output Organization
Interrupt Hardware
Consider the case where all external devices request for a service over a
common interrupt-request line as shown in Fig below.
7 I semester MCA
PESIT
Input/ Output Organization
All devices are connected to the line via switches to ground. If all signals INTR1to
INTRn are inactive, (all switches are open), the voltage on the interrupt request
line will be Vdd and hence no interrupt signal is generated. To raise an interrupt
request, a device closes its switch. When a device closes its switch, the voltage on
the line drops to 0, causing INTR signal to go to 1. Hence, the value of INTR is
the logical OR of the requests from individual devices, that is,
INTR = INTR1 + ... + INTRn.
For implementation of the circuit in Fig above, open-collector (open-drain) gates
are used to drive the INTR line. The output of such a gate is equivalent to a switch
to ground that is open when the gate’s input is in the 0 state and closed when it is
in the 1 state. The voltage level at the output of the gate is determined by the data
applied to all the gates connected to the bus. Resistor R is called as pull-up register
because it pulls the line voltage up to the high-voltage state when the switches are
open.
When a request is received over a common interrupt request line as in Fig above
additional information is needed to identify the particular device that activated the
line. This information is available in the status register of the device as shown
below.
When a device raises an interrupt request, it sets one of the bits in its status
register, called IRQ bit. As shown, KIRQ and DIRQ are the interrupt request bits
for keyboard and display. If any of these bits are 1, that particular device has
requested the service. Also, if two or more devices have activated the line at the
same time, then the tie is to be broken and one of them will get the service at a
time.
The simplest way to identify the interrupting device is to have the interrupt-
service-routine (ISR) poll all the I/O devices connected to the bus. The first device
encountered with its IRQ bit set, is the device that should be serviced. After
servicing this device, the next requests may be serviced.
The polling method is simple and easy to implement. Also, it gives a sort of
priority for simultaneously made interrupt requests. The disadvantage is the time
spent n polling the IRQ bits of all devices. So, another approach is used to solve
this problem.
8 I semester MCA
PESIT
Input/ Output Organization
One way to assign priority is to use software polling approach. Let us assume that
each device has an interrupt request (IR) flip-flop which will be set to 1 if the
device wants to make a request. All these interrupt request flip-flops are grouped
together into an interrupt-request status register where each bit corresponds to one
device request as shown below.
In the software polling approach, we can use logical shift instructions to check
each bit. If we use right shift instruction, device 1 gets highest priority,
whereas, for a shift left instruction, device m gets highest priority.
The polling is done at regular intervals under program control. When the processor
is executing the interrupt-service-routine of a device, and it finds that a higher
priority device is requesting service, the current interrupt service routine is
suspended and the program control is transferred to the interrupt service routine of
the higher priority device. The software polling method is flexible, but efficiency
of the processor is reduced, since it may result in a long delay in responding to an
interrupt request.
For case (b), the implementation is based on hardware organization. To implement
this scheme, we can assign a priority level to the processor that can be changed.
The priority level of the processor is the priority of the program that is currently
being executed. The processor accepts interrupts only from devices that have
priorities higher than its own. This action disables interrupts from devices at the
same level or lower level of priority.
The processor’s priority is usually encoded in few bits of the processor status word
(PSW). It can be changed by program instructions called privileged instructions,
which write into the processor status word. These instructions can r e executed
only when the processor is running in supervisor mode, that is, while executing the
9 I semester MCA
PESIT
Input/ Output Organization
operating system routines. The processor switches to the user mode before
beginning to execute application programs. This will guarantee that a user
program cannot change the priority of the processor deliberately or accidentally.
A multiple priority scheme using hardware logic can be easily implemented by
using separate interrupt-request and interrupt-acknowledge lines for each device.
This is shown in Fig. below. The processor has a priority arbitration circuit, which
assigns a different priority level to the devices. The arbiter (or priority resolver)
gets requests on different lines, evaluates them and issues an acknowledge signal
to the highest priority device amongst the currently requesting devices. Later, a
request is accepted only if it has a higher priority level than that currently assigned
to the processor.
Fig G
A simplest possible priority arbiter may consist of a single priority encoder.
Suppose, we have 8 devices, then we can use a 8-to-3 priority encoder to encode
the priority as a 3-bit binary number from 000 to 111.
Simultaneous Requests
When multiple requests are received over a single interrupt request line at the
same time, polling the status request is a straightforward but time consuming
method. So, another method called as daisy-chain is a commonly used hardware
arrangement for handling many requests over a single interrupt request line. The
structure is shown in Fig. below. The interrupt-request line, (INTR)’ is common to
all devices The interrupt-acknowledge line, INTA is connected in a daisy-chain
fashion. The INTA signal propagates serially through the devices.
When several devices raise an interrupt request and (INTR)’ line is activated
the processor responds by setting the INTA line to 1. This signal is received by
device 1. If device 1 has requested the interrupt, it blocks the INTA signal and
sends its identifying interrupt vector on the data bus. If device 1 has not requested
the service, it passes the INTA signal to device 2 and so on. Hence, in the daisy-
chain arrangement, the device that is etricl1y closer to the processor
10 I semester MCA
PESIT
Input/ Output Organization
as the highest priority. This arrangement requires fewer wires than that required in
the Fig. G.
The two schemes discussed can be combined to produce a general structure, which
is shown in Fig(b).
Devices are organized into groups and each group connected at a different priority
level. Within a group, devices are connected in daisy-chain.
Computer systems use specialized interface circuitry to handle multiple interrupt
requests from the devices. For example, Intel has developed an interface called
Programmable Interrupt Controller 8259 (PIC) which can handle up to 8 interrupt
requests at a time. Also, by cascading such PICs, more number of requests can be
handled.
11 I semester MCA
PESIT
Input/ Output Organization
The keyboard interrupt enable KEN and display interrupt enable DEN bits of the
CONTROL register are used for controlling. If either of these flags is set, the
interface circuit generates an interrupt request whenever the corresponding status
flag in register STATUS is set.
At the same time, the interrupt circuit sets bit KIRQ or DIRQ to indicate that the
keyboard or display unit is requesting an interrupt. If an interrupt enable bit is
equal to 0, the interface circuit will not generate an interrupt request, regardless of
the state of the status flag.
Thus, at the device end, a terrupt-enab1e bit in a control register determines
whether the device is allowed to generate an interrupt request. At the processor
end, either an interrupt-enable bit in the processor status (PS) word register or a
priority structure determine whether a given interrupt request will be accepted.
Exceptions
The term ‘exception’ is used to refer to any event that causes an
interruption. (I/O interrupts are one example of an exception). An interrupt is any
event that causes the execution of one program to be suspended and of another
program to begin.
In a computer system, large number of I/O operations like data transfer,
operations, file handling and so on are handled using interrupt technique.
The operating system performs these operations on behalf of application programs
written by user. Thus, an interrupt need not always be caused by an external
device.
Intel literature uses the term ‘exception’ to refer to any internal condition caused
due to software or hardware. For example, as discussed earlier, processor will
have privileged instructions to be run in the supervisor mod. An attempt to execute
a privileged instruction in the user mode causes an interrupt called privilege
exception.
Generally, exceptions occur when some invalid operation or malfunction of the
system happens. The interrupt-service-routines written for these cases are used to
protect the computer system as well as to inform the user about the problem. For
example, when a divide-by-zero operation happens, the operating system raises an
exception and prompts the user about this malfunction. We now consider a few
kinds of exceptions.
12 I semester MCA
PESIT
Input/ Output Organization
Debugging:
The system software usually includes a program called debugger, which
helps the programmer to find errors in the program. The debugger uses exceptions
to provide two important capabilities: trace mode and breakpoints.
When a processor is operating in trace mode, an exception occurs after
execution of every instruction. This uses the debugging program as the exception
service routine, which enables the user to examine the contents of registers,
memory locations etc. After the processor returns from the debugging program,
the next instruction in the main program is executed and the debugging program is
activated again. During the execution of the debugging program, the trace
exception is disabled.
Break points provide a facility to interrupt the program at specific points
selected by the user. An instruction called Trap or Software interrupt is usually
provided for this purpose. The execution of this instruction causes the same
actions as when a hardware interrupt occurs. While debugging a program, the user
may wish to interrupt program execution after say, instruction i, in the program.
The debugging routine saves instruction i + 1 and replaces it with a software-
interrupt instruction. When the program reaches this point, the debugging routine
is activated. This gives the user a chance to examine contents of register and
memory.
When the user is ready to continue executing his/her program, the debugging
routine restores the instruction that was at location i + 1 and executes a Return-
from-interrupt instruction.
High Level Languages like ‘C’, give options for breakpoints like set break point”
or “clear break point, as well as for trace mode operation. Trace mode operation is
also known as single stepping.
Privilege Exception:
To protect the operating system from being corrupted by user programs,
certain instructions can be executed only when the processor is in the supervisor
(monitor) mode. These instructions are called privileged instructions. When the
processor is running in the user mode, it cannot execute an instruction that changes
13 I semester MCA
PESIT
Input/ Output Organization
the priority level of the processor or enables a user program to access areas in the
main memory that have been allocated to other users. An attempt to execute such
an instruction will produce a privilege exception. As a result, the processor
switches to the supervisor mode and begins to execute an appropriate routine in
the operating system (OS). The implementation details vary from one OS to
another OS.
14 I semester MCA
PESIT
Input/ Output Organization
interrupt request. In response, the OS puts the suspended program in the running
state.
DMA Operation:
Fig. below shows an example of registers in a DMA controller that are
accessed by the processor to initiate operations. Two registers are used for storing
the starting address and the word count. The third register contains status and
control flags. The R/W’ bit determine the direction of the transfer. When this bit is
set to 1 by a program instruction, the controller performs a read operation, that is,
it transfers data from memory to I/O device. When R/W’ = 0, DMA controller
performs a write operation, i.e., transfers data from I/O device to memory. When
the controller has completed transferring a block of data and is ready to receive
another command, it sets the ‘Done’ flag to 1. When interrupt-enable (IE) flag is
set to 1, this flag causes the DMA controller to raise an interrupt after it has
completed transferring a block of data. Finally, the controller sets the IRQ bit to 1
when it has requested an interrupt.
Fig. below shows how DMA controllers are used in a computer system. A DMA
controller connects a high speed network to the computer bus. The disk controller
which controls two disks also has DMA capability and provides two DMA
channels. It can perform two independent DMA operations.
15 I semester MCA
PESIT
Input/ Output Organization
To start a DMA transfer of a block of data from main memory to one of the disks,
a routine in the OS writes the following information into the registers of the
corresponding channel of the disk controller:
• Memory address
• Word count
• Function to be performed (Read or Write)
Now, the DMA controller proceeds independently to implement the specified
function. When the DMA transfer is completed, this information is recorded in the
status and control register of the DMA controller by setting the ‘Done’ bit.
Memory accesses by the processor and the DMA controllers are inter- leaved.
Requests by DMA devices for using the bus are always given high priority than
the processor requests. Among different DMA devices, top priority is given to
high-speed peripherals such as a disk, or a network interface.
There are two ways in which the DMA operation can be carried out:
In one method, the DMA controller is given exclusive access to the memory to
transfer a block of data without any interruption. This is known as block or burst
mode DMA transfer. The draw back of this method is that, processor may have to
wait for longer time duration to access memory.
In the second method, the processor originates most memory access cycles The
DMA controller is said to steal memory cycles from the processor. When the
processor is not accessing the main memory, the cycles are taken by the DMA
controller. This method is known as cycle stealing DMA.
Buses
16 I semester MCA
PESIT
Input/ Output Organization
The primary function of a bus connecting main memory, processor and I/O
devices, is to provide a communication path for the transfer of data. In addition,
the bus includes the lines needed to support interrupts and to implement arbitration
functions. In this Section, we discuss features of bus protocols used for
transferring data. A bus protocol is the set of rules that govern the behavior and
data transmission of various devices connected to the bus. The protocol specifies
parameters such as: asserting control signals, timing of placing the information on
the bus, rate of data transfer and so on. We also describe some details of I/O
interface circuits.
A typical bus consists of three pets of lines: address, data and control lines. The
control signals specify whether a read or a write operation is to be performed.
A single R/W’ line specifies a Read operation when set to 1 and Write operation,
when set to 0. The bus control signals also carry timing information, it specify the
times at which the processor and the I/O devices may place data n the bus or
receive data from the bus.
In any data transfer operation, one device plays the role of a bus master, which
initiates data transfers by issuing Read or Write commands on the bus. The master
is also called as initiator. The device addressed by the master is referred to as slave
or target.
The timing of data transfers over a bus is classified into two types:
Synchronous.
Asynchronous.
17 I semester MCA
PESIT
Input/ Output Organization
Fig S
Timing of an input transfer on a synchronous bus
Input (Read) Operation:
At time to, the processor places the device address on the address lines and
sends an appropriate command on the control lines to indicate an input operation.
Information gets transmitted over the bus at a speed determined by its physical and
electrical characteristics. The clock pulse width t1 — t0 must be greater than the
maximum propagation delay between the processor and any device connected to
the bus. It also has to be long enough to allow all devices to decode the address
and control signals so that the addressed device (slave) can respond at time t1. The
information on the bus during the period t0 to t1 is unreliable. The slave places the
requested input data on the data lines at time t1. At the end of the clock cycle, at
time t2, the processor (master) strobes (captures) the data on the data lines into its
input buffer. For proper data loading, the period t2 - t1 must be greater than the
maximum propagation time on the bus plus the setup time of the input buffer
register of the processor.
18 I semester MCA
PESIT
Input/ Output Organization
Multiple-Cycle Transfers:
19 I semester MCA
PESIT
Input/ Output Organization
The timing diagram of Fig. below shows synchronous bus operation using
multiple-cycle transfer. During clock cycle 1, the master sends address and
command information on the bus, requesting a read operation. The slave receives
this information and decodes it. On the next clock edge, at the beginning of clock
cycle 2, slave begins to access the requested data. The data become ready and are
placed on the bus in clock cycle 3. At the same time, the slave asserts a control
signal called Slave-ready. After receiving this signal, the master strobes the data
into its input buffer at the end of clock cycle 3. The bus transfer is complete and
the master may send a new address to start a new transfer.
20 I semester MCA
PESIT
Input/ Output Organization
Fig. below shows the timing for an output operation using Handshake control. In
this case, the master places the output data on the data lines and at the same time it
sends the address and command information. The selected slave, when it receives
the Master-ready signal, strobes the data into its output buffer and indicates so by
setting the Slave-ready signal to 1.
Interface Circuits
An I/O interface c9nsists of logic circuitry required to connect an I/O
device to a computer bus. On one side of the interface, we have the bus signals for
address, data and control. Another side of the interface has a data path with its
associated controls to transfer data between the interface and the I/O device. This
side is called a port which can be classified as either a parallel or serial port.
An I/O interface generally provides the following functionalities:
A) Provides a storage buffer for at least one word of data.
B) Contains status flags that can be accessed by the processor to determine
whether the buffer is full (for input) or empty (for output).
C) Contains address-decoding circuitry to determine when it is being addressed by
the processor.
22 I semester MCA
PESIT
Input/ Output Organization
D) Generates the appropriate timing signals required for data transfer the bus.
E) Performs any format conversion (for example, parallel-to-serial or serial-to-
parallel conversion in case of a serial port) that may be necessary to transfer data
between the bus and the I/O device.
Parallel Interface
We start with the discussion of design of a parallel interface for a keyboard.
We describe circuits for an 8-bit input port, 8-bit output port and a combined
general purpose 8-bit parallel port. The interface circuit is assumed to be
connected to 32-bit processor that uses memory-mapped I/O and the asynchronous
bus protocol.
Input Interface:
A simple hardware organization for connecting a keyboard to a processor is
shown in Fig below. The keyboard consists of mechanical switches that are
normally open. When a key is pressed, its switch closes forming a path for
electrical signal. This signal is detected by an encoder circuit that generates the
ASCII code for the corresponding character.
The output of the encoder consists of the bits that represent the encoded character
and one control signal called valid, which indicates that a key is being pressed.
This information is sent to the interface circuit, which contains a data register
DATAIN and a status flag SIN. When a key is pressed, the valid signal changes
from 0 to 1, causing the ASCII code to be loaded into DATAIN and SIN will be
set to 1. When the processor reads the character from DATAIN, SIN is cleared to
0. The asynchronous handshake signals control the data transfer on the bus. The
R/W’ signal distinguishes between Read or Write operation.
23 I semester MCA
PESIT
Input/ Output Organization
Fig. above shows a detailed circuit for an input interface. The output lines of the
DATAIN register are connected to the data lines of the bus using tri-state drivers.
The SIN signal is generated by a status flag circuit. This signal is sent to the bus
through a tri-state driver. SIN is connected to bit D0, that is, it is bit 0 of the status
register. An address decoder is used to select the input interface, using high-order
31 bits of the address. Address bit A0 determines whether the status or the data
register is to be read when the Master-ready signal is active. The Slave-ready
signal is activated when either Read-status or Read-data signal is 1.
A simple implementation of the status flag circuit is shown in Fig. below
edge-triggered D flip-flop is set to 1 by a rising edge on the ‘Valid signal line’.
This changes the state of the NOR latch such that SIN is set to 1.
24 I semester MCA
PESIT
Input/ Output Organization
The circuit ensures that SIN can be set only while Master-ready is equal to 0. Both
the flip-flop and the latch are reset to 0 when Read-data is set to 1 to read
DATAIN register.
Output Interface:
Fig. below shows the interface diagram to interface an output device like a
printer to a processor. The printer uses two handshake signals ‘Idle’ and ‘Valid’
for controlling the operation. When it is ready to accept a character, it asserts its
Idle signal. The interface circuit places a new character on the data lines and
activates, the Valid signal. Now, the printer removes the Idle signal and starts
printing the character it has received.
25 I semester MCA
PESIT
Input/ Output Organization
26 I semester MCA
PESIT
Input/ Output Organization
27 I semester MCA
PESIT
Input/ Output Organization
Fig (l) shows the timing diagram for an output operation. In clock cycle 1,
the processor sends the address and data. The timing logic sets Go to 1 at the
beginning of clock cycle 2, and the rising edge of that signal loads the output data
into register DATAOUT. Normally, the Slave-ready signal is an open-drain signal
called Slave-ready. This line must have a pull-up resistor connected to ensure that
it is always in the negated (high-voltage) state except when it is asserted (pulled
down) by some device.
28 I semester MCA
PESIT
Input/ Output Organization
Serial Interface
A serial port is used to connect the processor to I/O devices that require
transmission of data one bit at a time. The serial interface circuit is communicating
in bit-serial way on the device side and in bit-parallel format on the bus side. The
serial-to-parallel and parallel-to-serial conversion is performed using shift
registers. Fig (m) shows a serial interface circuit. The input shift register accepts
bit-serial input from the input device. When all 8 bits of data are received, the
contents of the shift register are transferred to DATAIN register, in parallel.
The output data in the DATAOUT register are loaded into the output shift
register parallel. The bits are shifted out serially and sent to the output device.
The chip and register select logic has the control signals whose functions
are similar to that described for parallel interface. The status flag SIN is set to 1
when new data are loaded in DATAIN; it is cleared to 0 when the processor reads
the contents of DATAIN.
The SOUT flag related to output buffer DATAOUT is set to 1 when data
are transferred from DATAOUT into the output shift register and is cleared to 0
when the processor writes new data into the DATAOUT register.
If DATAIN and DATAOUT themselves are shift registers, then input and
output shift registers shown in Fig (m) could be eliminated. But, this will
introduce delays when transferring data. After receiving one character from the
serial input, the device can read the next character only after the processor reads
the contents of DATAIN. So, a delay is introduced between the reading of two
successive characters.
The double buffering method shown in the Fig (m) provides some
advantages. As soon as the data are transferred from the input shift register into
29 I semester MCA
PESIT
Input/ Output Organization
the DATAIN register, the shift register can start accepting the next character from
the device. In the meantime, the processor would be reading the first character
from DATAIN register parallel. Thus, the interface can receive a continuous
stream of serially transferred data. The same analogy works at the output path of
the interface.
Since serial transmission requires fewer wires, the serial interface is the
most convenient way of connecting devices that are physically far apart. For
example, two computers could be connected using a co-axial cable. Similarly, for
long distance communication, telephone line is used as a medium. The
disadvantage of the serial communication is that it is not as fast as parallel data
transfer. The speed of transmission, given as bit rate, depends on the nature of the
devices connected. So, a serial interface should be able to handle wide range of
clock speeds. The circuit of Fig (m) shows the use of separate transmitter and
receiver clocks, to provide flexibility in operations. The serial interface plays an
important role in connecting I/O devices. Different standards like RS-232-C, RS-
422 and RS429 have been developed for serial communication.
A standard circuit that includes the features shown in Fig (m) is known as a
Universal Asynchronous Receiver Transmitter (UART). It is intended to be used
with low speed devices.