Professional Documents
Culture Documents
Unit 4 IO Interfacing Hamacher
Unit 4 IO Interfacing Hamacher
Input/Output
Organization
Jin-Fu Li
Department of Electrical Engineering
National Central University
Jungli, Taiwan
Outline
Accessing I / O Devices
Interrupts
Direct Memory Access
Buses
Interface Circuits
Standard I / O
Interfaces
Address Data/Instruction
Counter
Control Unit
Input/Output System
Processor Memory
Bus
Input device
DATAOUT
7 6 5 4 3 2 1 0
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 9
An Example
A program that reads one line from the keyboard,
stores it in memory buffer, and echoes it back to the
display
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 character
WAITD TestBit #1,STATUS Test SOUT
Branch=0 WAITD Wait for display to become ready
Move R1,DATAOUT Send character to display
Move R1,(R0)+ Store character and advance pointer
Compare #$0D,R1 Check if Carriage Return
Branch=0 WAITK If not, get another character
Move #$0A,DATAOUT Otherwise, send Line Feed
Call PROCESS Call a subroutine to process the
input line
Program 1 Program 2
COMPUTE routine PRINT routine
1
2
Interrupt occurs
here i
i+1
Processor
R
INTR INTR
INTR=INTR1+INTR2+…+INTRn
INTR1 INTRp
Processor
Priority arbitration
circuit
INTRp
Priority arbitration
circuit
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 22
Direct Memory Access
To transfer large blocks of data at high speed, a
special control unit may be provided between an
external device and the main memory, without
continuous intervention by the processor. This
approach is called direct memory access
(DMA)
DMA transfers are performed by a control circuit that
is part of the I / O device in terface. We refer to this
circuit as a DMA controller.
Since it has to transfer blocks of data, the DMA
controller must increment the memory address for
successive words and keep track of the number of
transfers
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 23
DMA Controller
Although a DMA controller can transfer data
without intervention by the processor, its
operation must be under the control of a program
executed by the processor
An example
31 30
Status and control 1
0
IRQ Done
IE R/W
Starting address
Word count
Main
Processor memory
System bus
Disk Network
Disk
Interface
Processor BR
DMA DMA
BG1 Controller 1 BG2 Controller 2
BR
BG1
BG2
BBSY
Vcc
ARB3
ARB2
ARB1
O.C.
ARB0
Start
-
Arbit
0 1 0 1 0 1 1 1 ratio
n
Interface circuit for device A
Bus clock
Address and
command
Data
t0 t1 t2
Bus Cycle
Bus clock
Seen by master
tAM
Address and
command
Data
tDM
Seen by slave Slave send the
tAS requested
data
Address and
command
Data
tDS
t1 t2
t1
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 33
Input Transfer Using Multiple Clock Cycles
1 2 3 4
Clock
Address
Command
Data
Slave-ready
Master-ready
Slave-
ready
Data
t0 t1 t2 t3 t4 t5
Bus cycle
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 35
Asynchronous Bus
Handshake control of data transfer during an
output operation
Address
and command
Dat
a
Master-ready
Slave-ready
t0 t1 t2 t3 t4 t5
Bus cycle
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 36
Discussion
The choice of a particular design involves trade-offs
among factors such as
Simplicity of the device interface
Ability to accommodate device interfaces that introduce different
amounts of delay
Total time required for bus transfer
Ability to detect errors results from addressing a nonexistent
device or from an interface malfunction
Asynchronous bus
The handshake process eliminates the need for
synchronization of the sender and receiver clock, thus
simplifying timing design
Synchronous bus
Clock circuitry must be designed carefully to ensure
proper
synchronization, and delays must be kept within strict bounds
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 37
Interface Circuits
Keyboard to processor connection
When a key is pressed, the Valid signal changes from 0
o 1, causing the ASCII code to be loaded into DATAIN
and SIN to be set to 1
The status flag SIN is cleared to 0 when the processor
reads the contents of the DATAIN register
Data
DATAIN Data
Address
Encoder
SIN Keyboard
Processor and
R/W Debouncing
circuit switches
Master-ready Valid
Input
Slave-ready Interface
D7 Q7 D7
Keyboard
data
D0 Q0 D0
SIN Valid
Status
Slave- 1 flag
Read-
ready Read-
status data
R/W
Master-
ready
A
31 Address
A1
decoder
A0
Advanced Reliable Systems (ARES) Lab. Jin-Fu Li, EE, NCU 39
Circuit for the Status Flag Block
SIN
Read-data
Master-ready
Q D 1
Q Valid
Clear
DATAOUT Data
Address
SOUT
Processor Printer
R/W
Valid
Master-ready
Output
Slave-ready Interface Idle
R/W
Master-
rea
dy
A Address
31A1
decoder
Advanced Reliable
A0 Systems (ARES) Lab. Jin-Fu Li, EE, NCU 42
A General 8-Bit Parallel Interface
D7 P7
DATAIN
D0 P0
DATAOUT
Data
Direction
Register
A0
Clock Reliable Systems (ARES) Lab.
Advanced Jin-Fu Li, EE, NCU 44
Timing Diagram for an Output Operation
Time
1 2
3
Clock
Address
R/W
Go
Data
Slave-ready
DATAIN
D7
D0
DATAOUT
Host
PCI Main
bridge memory
PCI Bus
Ethernet
Disk Printer
interface
Name Function
CLK A 33-MHz or 66MHz clock
DEVSEL# A response from the device indicating that it has recognized its
Address and is ready for a data transfer transaction
CLK
Frame#
AD Address #1 #2 #3 #4
IRDY#
TRDY#
DEVSEL#
Root
hub
Hub Hub
I/O I/O
device device