Input-Output Organization
Input-Output Organization
Input-Output Organization
Outline
Peripheral Devices
Input-output Interface
Asynchronous Data Transfer
Modes of Transfer
Priority Interrupt
Direct Memory Access
Input-output Processor
Serial Communication
Peripheral Devices – Input Devices
Keyboard
Optical Input Device
Card reader
Paper tape reader
Bar code reader
Digitizer
Optical Mark reader
Magnetic Input Device
Magnetic Stripe Reader
Screen Input Device
Touch Screen
Light Pen
Mouse
Analog Input Device
Peripheral Devices – Output Devices
Card Puncher
Paper Tape Puncher
CRT
Printer
Impact, Ink Jet, Laser, Dot Matrix
Plotter
Analog
Voice - Speakers
Input – Output Interfaces
Provides a method for transferring information
between internal storage (Such as Memory and CPU
registers) and external I/O devices
Resolves the differences between the computer and
peripheral devices
Peripherals – Electromechanical Devices
CPU or Memory – Electronic devices
Data Transfer Rate
Peripherals – usually slower
CPU or Memory – usually faster than peripherals
Some kinds of synchronization mechanism may be needed
Input – Output Interfaces
Unit of Information
Peripherals – Byte
CPU or Memory - Word
Operating Modes
Peripherals – Autonomous, Synchronous
CPU or Memory - Synchronous
I/O Bus
Communication with in a computer via a single
shared bus
I/O Bus Data
Address
processor
Control
Keyboard
Magnetic Magnetic
and Display Printer
Disk Tape
terminal
Interface Module
Each peripheral has an interface module associated
with it
Interface
Decodes the device address (device code)
Decodes the commands (operation)
Provides signals for the peripheral controller
Synchronizes the data flow and supervises the transfer rate
between peripheral and CPU or Memory
Typical I/O Instruction
Sense Lines
Data Lines I/O
Bus
Function Code Lines
Device Address Lines
Connection of I/O Bus to One Interface
Use one common bus with common control lines for both
functions
Some computer systems use two separate buses, one to communicate
with memory and the other with I/O Interface
I/O Bus
Communication between CPU and all interface units
is via a common I/O bus
An interface connected to a peripheral device may
have a number of data registers, a control register,
and a status register
A command is passed to the peripheral by sending to
the appropriate interface register
Function code and sense lines are not needed
Transfer of data, control and status information is always
via the common I/O Bus
Isolated I/O (I/O Mapped I/O)
Separate I/O read/write control lines in addition to
memory read/write control lines
Separate (isolated) memory and I/O address spaces
Distinct input and output instructions
IN and OUT Instructions
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
All instruction directly access memory location and can
manipulate
Programmed I/O Interface
Data Bus
Source Destination
Unit Strobe Unit
Timing Diagram
Data Valid data
Strobe
Strobe Control
Destination-initiated Strobe for Data Transfer
Data Bus
Source Destination
Unit Strobe Unit
Timing Diagram
Strobe
Handshaking Data Transfer
Strobe Methods
Source Initiated:
The source unit that initiates the transfer has no way of
Timing Diagram
Data bus Valid data
Data Valid
Data Accepted
Handshaking: Sequence of Events
Allows arbitrary delays from one state to the next
Permits each unit to respond at its own data transfer rate
The rate of transfer is determined by the slower unit
Timing Diagram
Ready for data
Data Valid
Destination Unit
Source Unit
Ready to accepted data;
Place data on bus; Enable ready for data
Enable data Valid
1 1 0 0 0 1 0 1
Stop
Character bits
bit
(at least 1 bit)
Start bit (1 bit)
Asynchronous Serial Transfer
A character can be detected by the receiver from the
knowledge of 4 rules
When data are not being sent, the line is kept in the 1-
state
The initiation of a character transmission is detected by a
Start Bit, which is always a ‘0’
The character bits always follow the Start Bit
After the last character, a Stop Bit is detected when the
line returns to the 1-state for at least 1 bit time.
The receiver knows in advance the transfer rate of
the bits and the number of information bits to expect
UART
UART: Universal asynchronous receiver-transmitter
A typical asynchronous communication interface available as
an IC
Transmit
Transmitter Shift Data
Bidirectional Register Register
Data Bus Bus
Buffers Transmitter
Internal Bus Control Tx Control Clock
Register & Clock
Receiver
Chip Select
CS Status Rx Control Clock
Register Select Register & Clock
RS Timing
I/O Read And Receive
RD Control
I/O Write Receiver Shift Data
WR Register Register
UART
CS RS Operation Register Selected
0 X X None: Data bus in high-impedence
1 0 WR Transmitter Register
1 1 WR Control Register
1 0 RD Receiver Register
1 1 RD Status Register
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
UART
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.
FIFO (First-In-First-Out) Buffer:
Input data and output data at two different rates
Output data are always in the same order in which the
data entered the buffer
Useful in some applications when data is transferred
asynchronously
Data Transfer Modes between CPU & Peripherals
Interface
Data Bus I/O Bus
Polling or
Status check
=0
Flag
=1
Read data Register
Transfer data to Memory
Polling or Status Checking
Continuous CPU involvement No Operation
CPU slowed down to I/O speed Complete
Simple
Least hardware Yes
Continue with
Program
Interrupt Initiated I/O
Polling takes valuable CPU time
Open communication only when some data has to be passed
Interrupt
I/O interface, instead of the CPU, monitors the I/O device
When the interface determines that the I/O device is ready
for data transfer
it generates an interrupt request to the CPU
Upon detecting an interrupt,
CPU stops momentarily the task it is doing,
branches to the services routine to process the data transfer, and
then returns to the task it was performing
DMA (Direct Memory Access)
Large blocks of data transferred at a high speed to or
from high speed devices
Magnetic drums, disks, tapes, etc.,
DMA Controller
Interface that provides I/O transfer of data directly to and
from the memory and the I/O device
CPU initializes the DMA controller by sending a
memory address and the number of words to be
transferred
Actual transfer of data is done directly between the
device and memory through DMA controller
Freeing CPU for other tasks
Interrupts
Interrupt Request Line
Interrupt-request signal
Interrupt-acknowledge signal
Interrupt Service Routine
Similar to subroutine
May have no relationship to program being executed at
time of interrupt
Program info must be saved
Interrupt latency
Handling Interrupts
Many situations where the processor should ignore
interrupt requests
Interrupt-disable
Interrupt-enable
Typical scenario
Device raises interrupt request
Processor interrupts program being executed
Processor disables interrupts and acknowledges interrupt
Interrupt-service routine executed
Interrupts enabled and program execution resumed
Interrupt from N Devices
An equivalent circuit for an open-drain bus used to
implement a common interrupt-request line.
Vdd
Processor
R
I NTR
INTR
devices
Privileged instructions executed in supervisor mode
EN, DEN
Interrupt Priority
Implementation of interrupt priority using individual
interrupt-request and acknowledge lines
Processor
INTR2 INTRp
INTR1
Device 1 Device 2 Device p
INTA1 INTA2 INTAp
Interrupt Request
INT
CPU
Interrupt Acknowledge
INTACK
2 Interrupt
To CPU
3 INTACK from CPU
Parallel Priority Interrupt
IEN: Set or Clear by instructions ION or IOF
IST: Represents an unmasked interrupt has occurred
(IEN. IST). INTACK enables tri-state Bus Buffer to load
VAD generated by the priority logic
Interrupt Register:
Each bit is associated with an interrupt request from
different interrupt source – different priority level
Each bit can be cleared by a program instruction
Mask Register:
Mask register is associated with interrupt register
Each bit can be set or cleared by an instruction
Interrupt Priority Encoder
Determines the highest priority interrupt when more than
one interrupts take place
IRQ Done
IE R/W
Starting Address
Word Count
Registers in a DMA interface
31 30 1 0
IRQ Done
IE R/W
Main
Processor
Memory
System Bus
Disk/DMA DMA
Printer Keyboard
Controller Controller
Network
DISK DISK Interface
DMA
Processor and DMA controller(s) must “interweave”
memory accesses
DMA controllers have higher priority for obvious
reason, i.e., higher speed devices need higher
priority
DMA
If DMA gets a cycle at a time, then
CPU gets a memory cycle (uses bus)
processor
CPU gets a memory cycle (uses bus) gets most
CPU gets a memory cycle (uses bus) cycles
CPU gets a memory cycle (uses bus)
“cycle
DMA gets a memory cycle (uses bus) stealing”
CPU gets a memory cycle (uses bus)
CPU gets a memory cycle (uses bus)
CPU gets a memory cycle (uses bus)
DMA
Or
. to transfer a
block of
DMA gets a memory cycle (uses bus) data without
interruption
CPU gets a memory cycle (uses bus)
Sharing the Bus
Bus master: the device currently allowed to transfer
data on the bus (CPU or DMA)
Bus arbitration: choosing the next bus master
Bus busy: BBSY set by current bus master to show
that the line is in use
Bus request: BR set when device wants to become
bus master
When it gets BG (bus granted), waits for BBSY to become
inactive, then assumes mastership of the bus and sets
BBSY
Bus Arbitration
Determination of the order in which requests for the
bus are serviced
Fixed priority – each device has a priority rating
Rotating priority – devices are assigned a rotating priority
value
Central arbitration – arbiter circuit determines
Distributed arbitration – all devices share in the
determination
Centralized arbitration
BBSY
BR
Processor
DMA
DMA
Controller
BG1 Controller 1 BG2 2
BR
BG1
BG2
B BSY
Bus
master
Processor DMA controller 2 Processor
BG1
BG2
B BSY
Bus
master
Processor DMA controller 2 Processor
BG1
BG2
B BS Y
Bus
master
Processor DMA controller 2 Processor
BR
BG1
BG2
B BS Y
Bus
master
Processor DMA controller 2 Processor
BR
Processor turns off
BG signals
BG1
BG2
B BS Y
Bus
master
Processor DMA controller 2 Processor
Sequence of signals during transfer of bus mastership for the devices
Centralized Arbitration
DMA device 2 completes transfer, releases bus mastership Time
BR
BG1
BG2
B BS Y
Bus
master
Processor DMA controller 2 Processor
O.C.
Data Bus
Data Bus Address Bus
Buffers Buffers
DMA
DS
Internal Bus
Select Address Register
Registe
r Select RS
Read RD Word Count Register
Write WR
Control
Bus Request BR Logic Control Register
Bus Grant BG
Interrupt Interrupt
DMA Request
To I/O Device
DMA Acknowledge
DMA I/O Operation
Starting an I/O
CPU executes instruction to
Load Memory Address Register
Issue a GO command
Data Bus
Address Bus
Address
Select
Central
Processing Unit
(CPU)
Memory Bus
Peripheral Devices
Memory PD PD PD PD
Unit
Input-Output
Processor
(IOP) I/O Bus
Channel/CPU Communication
CPU Operations IOP Operations
Send instruction
Transfer status word to
to test IOP. path
memory
If status OK, then
send start I/O Access memory for IOP
instruction to IOP program
Continue
Computer System With Different Interface
Standards
Processor Main
memory
Processor bus
Bridge
PCI bus
Host
Main
PCI bridge
memory
PCI b us
Ethernet
Disk Printer interf ace
USB Interface
Need for high transfer rates
Need devices at some distance
High rate wide bus?
Problem over distance because of skew
Serial transmission
Low cost and flexible
No skew, so high rates OK, distance OK
USB Interface
Hubs have multiple ports
Devices connect to a port
Hubs connect to a port
“Tree structure”
Universal Serial Bus tree structure
Host Computer
Root
Hub
Hub Hub
I/O I/O
device device
USB Interface
Message from host copied to all hubs, to all ports, to
all devices
Only the addressed device responds
Message from device only goes “upstream”--up the
tree
Makes possible a large number of devices through a
few ports at the root hub.
High speed, long distances possible
Split bus operation
Host computer
HS- High speed
Root
F / LS- Full/Lo
w speed Hub
HS H
S
Hub A
Hub B
Message for D
HS F / LS
goes high speed
to A, low speed to Hub A can
D operate in split
Device Device
C D traffic mode,
alternately
sending HS
messages to C
while sending
parts of LS
message to D
USB
Data is transmitted in packets of one or more bytes
First field is always a PID (packet id)
A 4 bit ID plus the complement for verification
Therefore, 16 different packet types
Control packets such as ACK are PID only
Token packets used for control
Data packets
USB Packet Format
ACK
Time Token
Data0
ACK
Token
Data1
ACK
Token
Data1
ACK
USB
Software (in host computer) sends packets to devices
(hubs just forward them)
Host software periodically polls each hub
New device when connected has address 0
If a new device has been added, host collects info about
the device from the memory of the device and assigns it a
7 bit address
Locations within the device (registers) are identified
by a 4 bit endpoint address
Reference
Chapter 4: Computer Organization by Carl
Hamacher, Zvonko Vranesic and Safwat Zaky, 5
edition, McGraw Hill Publications.
Chapter 11: Computer Systems Architecture by M
Morris Mano, 3 edition, Pearson Publications.
Thank You!!