Escolar Documentos
Profissional Documentos
Cultura Documentos
Input device
I/O device is connected to the bus using an I/O
interface circuit which has:
- Address decoder, control circuit, and data and
status registers.
Address decoder decodes the address placed on
the address lines thus enabling the device to
recognize its address.
Data register holds the data being transferred to or
from the processor.
Status register holds information necessary for the
operation of the I/O device.
Data and status registers are connected to the data
lines, and have unique addresses.
I/O interface circuit coordinates I/O transfers.
The rate of transfer to and from I/O devices is
slower than the speed of the processor.
This creates the need for mechanisms to
synchronize data transfers between them.
Program-controlled I/O:
Processor repeatedly monitors a status flag to achieve the necessary
synchronization- Processor polls the I/O device.
DATAIN
DATAOUT
CONTROL DEN
7 6 5 4 3 2 1 0
The program reads a line of characters from the
keyboard and stores it in a memory buffer starting
at a location LINE.
A subroutine SUB is called to process input line.
As the character is read, it is echoed back to the
display.
Register R0 is used as a pointer to the buffer area,
contents are updated using autoincrement mode.
Each character is checked to see if Carriage
Return character(0D) and Line feed character
(0A) is entered to move the cursor down.
Example for programmed control I/O
Move #Line, R0 // Initialize memory pointer.
Waitk TestBit #0, STATUS //Test SIN
Branch =0 Waitk // Wait for character to be entered
Move DATAIN, R1 // read the character
Waitd TestBit #1, STATUS // Test SOUT
Branch =0 Waitd // Wait for display
Move R1, DTATAOUT // Send character for display
Move R1, (R0)+ // Store character and advance
Compare #$0D, R1 // Check for \r
Branch 0 Waitk // if not read another character
Move #$0A, DATAOUT // send \n to DATAOUT
Call SUB
Interrupts
In program-controlled I/O, when the processor
continuously monitors the status of the device, it does
not perform any useful tasks.
An alternate approach would be for the I/O device to
alert the processor when it becomes ready.
Do so by sending a hardware signal called an interrupt to the processor.
At least one of the bus control lines, called an interrupt-request line is
dedicated for this purpose.
Processor can perform other useful tasks while it is
waiting for the device to be ready.
One line of bus control lines carries interrupt called as
interrupt request line
Program Interrupt Service Routine
1
Interrupt
occurs i
here
i +1
INTR1 I NTRp
Processor
INTA1 INTA p
Priority arbitration
4. If two interrupt-requests are received
simultaneously, then how to break the tie?
The processor must have some means of deciding
which request to service first.
If the I/O devices are organized in a priority
structure, the processor accepts the interrupt
request from a device with higher priority.
Each device has its own interrupt request and interrupt
acknowledge line.
A different priority level is assigned to the interrupt
request line of each device.
If the devices share an interrupt request line, then
how does the processor decide which interrupt
request to accept?
Polling scheme:
If the processor uses a polling mechanism to
poll the status registers of I/O devices to
determine which device is requesting an
interrupt.
In this case the priority is determined by the
order in which the devices are polled.
The first device with status bit set to 1 is the
device whose interrupt request is accepted.
Commonly used schemes to connect devices.
1. Daisy chain scheme
I NTR
Processor
Device Device
INTA1 All the devices within a single
group share an interrupt-
INTR p
request line, and are
connected to form a daisy
Device Device
INTA p chain.
Priority arbitration
circuit
Main
Processor
memory
System bus
B BS Y
BR
Processor
DMA DMA
controller controller
BG1 1 BG2 2
Bus arbiter may be the processor or a separate unit
connected to the bus.
The processor is the bus master, unless it grants bus
membership to one of the DMA controllers.
DMA controller requests the control of the bus by asserting
the Bus Request (BR) line.
In response, the processor activates the Bus-Grant1 (BG1)
line, indicating that the controller may use the bus when it
is free.
BG1 signal is connected to all DMA controllers in a daisy
chain fashion.
The current bus master indicates to all devices that it is
using the bus by activating Bus Busy signal.
BBSY signal is 0, it indicates that the bus is busy.
When BBSY becomes 1, the DMA controller which
asserted BR can acquire control of the bus.
Sequence of signals during transfer of bus master ship for the
device in centralized arbitration
DMA controller 2
asserts the BR signal. Time
Processor asserts
BR
the BG1 signal
BBSY
Bus
master
Processor DMA controller 2 Processor
Time
Bus clock
Address and
command
Data
t0 t1 t2
Bus cycle
Master places the
device address and Addressed slave places
command on the bus, data on the data lines Master strobes the data
and indicates that on the data lines into its
it is a Read operation. input buffer, for a Read
operation.
In case of a Write operation, the master places the data on the bus along with the
address and commands at time t0.
The slave strobes the data into its input buffer at time t2.
At the end of the clock cycle, at time t2, the
master strobes the data on the data lines into its
input buffer if its a Read operation.
Strobe means to capture the values of the data and
store them into a buffer.
When data are to be loaded into a storage buffer
register, the data should be available for a period
longer than the setup time of the device.
Width of the pulse t2 - t1 should be longer than:
Maximum propagation time of the bus plus
Set up time of the input buffer register of the master.
Detailed timing diagram for input transfer
Time
Address & Bus clock
command Data reaches
Seen by
appear on the master t AM the master.
bus. Address and
command
Data
Address & t DM
command reach
Seen by slave
the slave. tAS
Address and Data appears
command on the bus.
Data
tDS
t0 t1 t
2
Signals do not appear on the bus as soon as they are placed on the bus, due to the
propagation delay in the interface circuits.
Signals reach the devices after a propagation delay which depends on the
characteristics of the bus.
Data must remain on the bus for some time after t2 equal to the hold time of the buffer.
Multiple cycle transfer
Disadvantage of previous approach:
1. Data transfer has to be completed within one clock
cycle.
2. Clock period t2 - t0 must be such that the longest
propagation delay on the bus and the slowest device
interface must be accommodated.
3. Forces all the devices to operate at the speed of the
slowest device.
4. The processor has no way of determining whether the
addressed device has actually responded.
At t2, it simply assumes that the input data are available
on the data lines in a Read operation, or that the output
data have been received by the I/O device in a Write
operation.
If, because of a malfunction, a device does not operate
correctly, the error will not be detected.
To overcome these limitations
Most buses have control signals to represent a
response from the slave.
Control signals serve two purposes:
Inform the master that the slave has recognized the
address, and is ready to participate in a data transfer
operation.
Enable to adjust the duration of the data transfer
operation based on the speed of the participating
slaves.
This is often accomplished by allowing a
complete data transfer operation to span several
clock cycles.
The number of clock cycles involved can vary
from one device to another.
An input transfer using multiple clock cycles.
Address & command Time
requesting a Read
operation appear on 1 2 3 4
the bus.
Clock
Address
Command
Master strobes data
into the input buffer.
Data
Slave-ready
Slave places the data on the bus, Clock changes are seen by all the devices
and asserts Slave-ready signal. at the same time.
Asynchronous Bus
An alternative scheme for controlling data transfers on
a bus is based on the use of a handshake protocol
between the master and the slave.
Common clock in the synchronous bus case is replaced
by two timing control lines:
Master-ready,
Slave-ready.
Master-ready signal is asserted by the master to
indicate to the slave that it is ready to participate in a
data transfer.
Slave-ready signal is asserted by the slave in response
to the master-ready from the master, and it indicates
to the master that the slave is ready to participate in a
data transfer.
Handshake control of data transfer during an
input operation.
Data transfer using the handshake protocol:
Master places the address and command
information on the bus.
Asserts the Master-ready signal to indicate to the
slaves that the address and command
information has been placed on the bus.
All devices on the bus decode the address.
Address slave performs the required operation,
and informs the processor it has done so by
asserting the Slave-ready signal.
Master removes all the signals from the bus, once
Slave-ready is asserted.
If the operation is a Read operation, Master also
strobes the data into its input buffer.
Handshake control of data transfer during an input operation.
Time
Address
and command
Master-ready
Slave-ready
Data
t0 t1 t2 t3 t4 t5
Bus cycle
t0 - Master places the address and command information on the bus.
t1 - Master asserts the Master-ready signal. Master-ready signal is asserted at t1 instead of t0
t2 - Addressed slave places the data on the bus and asserts the Slave-ready signal.
t3 - Slave-ready signal arrives at the master.
t4 - Master removes the address and command information.
t5 - Slave receives the transition of the Master-ready signal from 1 to 0. It removes the data
and the Slave-ready signal from the bus.
Asynchronous vs. Synchronous bus