Professional Documents
Culture Documents
Sesi 3
TEI302
I/O Bus and Interface
I/O bus
Data
Processor Address
Control
Keyboard
and Printer Magnetic Magnetic
display disk tape
terminal
Sense lines
Data lines
I/O
Function code lines
bus
Device address lines
Memory-mapped I/O
• A single set of read/write control lines
(no distinction between memory and I/O transfer)
• Memory and I/O addresses share the common address space
-> reduces memory address range available
• No specific input or output instruction
-> The same memory reference instructions can be used for I/O transfers
• Considerable flexibility in handling I/O operations
I/O Interface
Port A I/O data
Bidirectional register
Bus
data bus buffers
Port B I/O data
register
Chip select I/O
CPU CS
Register select
Control Control Device
RS1 Timing
Register select register
RS0 and
I/O read Control
RD Status Status
I/O write
WR register
Strobe Strobe
Handshaking
Strobe Methods
• Source-Initiated
The source unit that initiates the transfer has no way of knowing
whether the destination unit has actually received data
• Destination-Initiated
The destination unit that initiates the transfer no way of knowing
whether the source has actually placed the data on the bus
Valid data
Data bus
Timing Diagram
Data valid
Data accepted
Timing Diagram
Data valid
Valid data
Data bus
• Handshaking provides a high degree of flexibility and reliability because the successful
completion of a data transfer relies on active participation by both units
• If one unit is faulty, data transfer will not be completed
-> Can be detected by means of a timeout mechanism
Data Transfer Technique
• Microprocessor Controlled
– Data transfer from/to I/O to/from CPU or memory
– 2 schemes
• Programmed
• Interrupt Control
• Device Controlled
– I/O device controls data transfer between I/O and memory without
CPU intervention
• Faster transfer rate
• More efficient system
Programmed Data Transfer
• The control of programs are stored in memory
• Typically the transfer is between two programmable
registers, a CPU register and another attached to the IO Issue read command to IO module
device.
• Executed by the CPU for synchronous and asynchronous
mode of transfer Read status of IO module
• Types
– unconditional
– polling
– using Ready Signal Check
– with Handshake Signal status
rate.
Write word into memory
Next
done instruction
NO
Device Controlled Data Transfer
• The transfer of data between the mass storage device and a system
memory is often limited by the speed of microprocessor. Removing the
CPU during such a transfer and letting the peripheral manage the transfer
to or from memory would improve the speed of transfer and hence will
make the system more efficient.
• The technique is called Direct Memory Access (DMA) Data Transfer.
During DMA transfer the CPU is idle, so it has no longer control on the
system buses. A DMA Controller takes over the buses and manage the
transfer directly between the peripheral and the memory. The CPU regains
the control of buses after data transfer. DMA is faster than previous data
transfer scheme.
• CPU is free to perform operations that do not use system buses.
Block Diagram DMA Controller
Interrupt
RAM
BG
C.P.U
BR
RD WR ADD DATA
RD WR ADD DATA
READ CONTROL
DATA BUS
ADDRESS BUS
ADDR
RD WR ADD DATA
DMA
DS ACK IO
RS DMA CONTROLLER PERIPHERAL
BR (BusRelease) DMA DEVICE
BG (BusGrant)
INTERRUPT
Direct Memory Access
• 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 data lines
• Once the DMA receives the start control command it can start the transfer between the
peripheral devices and memory
• When the peripheral device sends a DMA request the DMA controller activates the BR
line, informing the CPU to relinquish the busses
• The CPU responds with its BG lines informing the DMA that its busses are disabled
• The DMA then puts the current value of its address register into the address bus,
initiates the WR or RD signal and then sends the DMA ACK to the peripheral device
• RD and WR lines are bi-directional
• When the peripheral device receives a DMA ACK it puts a word in the data bus or
receives a word from the data bus. For READ when BG=0 the RD and WR are input lines
and acts in master mode and when BG=1 it acts as an output line from the DMA
controller to the RAM. Thus the DMA controls the read and write operation and
supplies the address for the memory.
DMA Types
DMA types
• Burst mode of data transfer
– The IO device withdraws the DMA request only after it has transferred
all the bytes
– Block of data is transferred
– Used mainly in Magnetic Disk Drive
– The CPU is rendered inactive for relatively long periods of time
• Cycle Stealing mode of data transfer
– A long block of data is transferred by a sequence of DMA cycle
– After transferring one byte or several bytes the I/O device withdraws
DMA request
– Reduces interference in CPU activities
Universal Asynchronous Receiver-Transmitter (UART)
A typical asynchronous communication interface available as an IC
Transmit
Bidirectional Transmitter Shift data
data bus Bus register register
buffers
Transmitter Register
• Accepts a data byte(from CPU) through the data bus
• Transferred to a shift register for serial transmission
Receiver
• Receives serial information into another shift register
• Complete data byte is sent to the receiver register
Status Register Bits
• Used for I/O flags and for recording errors
Control Register Bits
• Define baud rate, no. of bits in each character, whether to generate and check parity, and
no. of stop bits
8251 USART Interface
8251 RS232
D[7:0] TxD
RD RD RxD
WR WR
A0 C/D
TxC
CLK CLK RxC
A7
A6
A5
A4
A3
A2
A1
IO/M
8251 Schematic
Programming 8251
8251 command register
7 6 5 4 3 2 1 0 Mode register
• Read • Write
start start
No No
Is it logic 1? Is it logic 1?
Yes Yes
Read data register* Write data register*
end end
* This clears RxRDY * This clears TxRDY
Errors