Part VI
Input/Output and Interfacing
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 1
About This Presentation
This presentation is intended to support the use of the textbook
Computer Architecture: From Microprocessors to Supercomputers,
Oxford University Press, 2005, ISBN 0-19-515455-X. It is updated
regularly by the author as part of his teaching of the upper-division
course ECE 154, Introduction to Computer Architecture, at the
University of California, Santa Barbara. Instructors can use these
slides freely in classroom teaching and for other educational
purposes. Any other use is strictly prohibited. © Behrooz Parhami
Edition
Released
Revised
Revised
Revised
First
July 2003
July 2004
July 2005
Mar. 2007
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Revised
Slide 2
VI Input/Output and Interfacing
Effective computer design & use requires awareness of:
• I/O device types, technologies, and performance
• Interaction of I/O with memory and CPU
• Automatic data collection and device actuation
Topics in This Part
Chapter 21 Input/Output Devices
Chapter 22 Input/Output Programming
Chapter 23 Buses, Links, and Interfacing
Chapter 24 Context Switching and Interrupts
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 3
21 Input/Output Devices
Learn about input and output devices as categorized by:
• Type of data presentation or recording
• Data rate, which influences interaction with system
Topics in This Chapter
21.1 Input/Output Devices and Controllers
21.2 Keyboard and Mouse
21.3 Visual Display Units
21.4 Hard-Copy Input/Output Devices
21.5 Other Input/Output Devices
21.6 Networking of Input/Output Devices
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 4
Section 21.1: Introduction
Section 21.3
Section 21.4
Section 21.2
Mar. 2007
Section 21.5: Other devices
Section 21.6: Networked I/O
Computer Architecture, Input/Output and Interfacing
Slide 5
21.1 Input/Output Devices and Controllers
Table 3.3
Some input, output, and two-way I/O devices.
Input type
Prime examples
Other examples
Data rate (b/s)
Main uses
Symbol
Keyboard, keypad
Music note, OCR
10s
Ubiquitous
Position
Mouse, touchpad
Stick, wheel, glove
100s
Ubiquitous
Identity
Barcode reader
Badge, fingerprint
100s
Sales, security
Sensory
Touch, motion, light
Scent, brain signal
100s
Control, security
Audio
Microphone
Phone, radio, tape
1000s
Ubiquitous
Image
Scanner, camera
Graphic tablet
1000s-106s
Photos, publishing
Video
Camcorder, DVD
VCR, TV cable
1000s-109s
Entertainment
Output type
Prime examples
Other examples
Data rate (b/s)
Main uses
Symbol
LCD line segments
LED, status light
10s
Ubiquitous
Position
Stepper motor
Robotic motion
100s
Ubiquitous
Warning
Buzzer, bell, siren
Flashing light
A few
Safety, security
Sensory
Braille text
Scent, brain stimulus
100s
Personal assistance
Audio
Speaker, audiotape
Voice synthesizer
1000s
Ubiquitous
Image
Monitor, printer
Plotter, microfilm
1000s
Ubiquitous
Video
Monitor, TV screen
Film/video recorder
1000s-109s
Entertainment
Two-way I/O
Prime examples
Other examples
Data rate (b/s)
Main uses
Mass storage
Hard/floppy disk
CD, tape, archive
106s
Ubiquitous
Network
Modem, fax, LAN
Cable, DSL, ATM
1000s-109s
Ubiquitous
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 6
Simple Organization for Input/Output
Interrupts
CPU
M a in
memory
C a ch e
S y stem bus
I/O co n tro lle r
D is k
Figure 21.1
Mar. 2007
D is k
I/O co n tro lle r
I/O co n tro lle r
G ra p h ics
d isp la y
N e tw o rk
Input/output via a single common bus.
Computer Architecture, Input/Output and Interfacing
Slide 7
I/O Organization for Greater Performance
CPU
Inter r upts
M a in
memory
C a ch e
M em o ry bus
Proprietary
Bus
adapter
AGP
P C I bus
In te rm e dia te
b u ses / p o rts
Standard
Bus
adapter
I/O bus
I/O co n tro lle r
G ra p h ics
d isp la y
Bus
adapter
I/O co n tro lle r
N e tw o rk
I/O co n tro lle r
D is k
D is k
I/O co n tro lle r
C D /D VD
Figure 21.2 Input/output via intermediate and dedicated I/O buses
(to be explained in Chapter 23).
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 8
21.2 Keyboard and Mouse
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 9
Keyboard Switches and Encoding
Key
ca p
c
d
e
f
8
9
a
b
4
5
6
7
0
1
2
3
S p rin g
(a ) M e c ha nica l switc h
with a p lu ng e r
C o n d u cto r-co a te d m em b ran e
C o n ta cts
(b ) M e m b ra ne s witc h
(c) L o g ica l a r ra ng e m e nt o f ke ys
Figure 21.3 Two mechanical switch designs and the
logical layout of a hex keypad.
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 10
Pointing Devices
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 11
How a Mouse Works
y rolle r
x rolle r
M ous e pa d
y ax is
x ax is
B a ll to u ch ing th e ro lle rs
ro ta te s th em via frictio n
(a ) M e c ha nica l m o use
Figure 21.4
Mar. 2007
P h o to se ns o r d e te cts
cro ss in g o f g rid lines
(b ) O p tica l m o use
Mechanical and simple optical mice.
Computer Architecture, Input/Output and Interfacing
Slide 12
21.3
Visual Display Units
D e flec tion c oils
E lec tron
beam

1K
P ix el info:
brightn es s ,
c olor, etc .
lin es
E lec tron
gun
y
x
S ens itive
s c reen

p e r lin e
(a) Im a ge for m ation on a C R T
Figure 21.5
Mar. 2007
F ram e bu ffe r
1 K p ixe ls
(b) D ata de fini ng the im a ge
CRT display unit and image storage in frame buffer.
Computer Architecture, Input/Output and Interfacing
Slide 13
How Color CRT Displays Work
R G B R G B R G B R G B R G B R G B
D ire ctio n o f
b lu e b eam
D ire ctio n o f
g re e n b eam
D ire ctio n o f
re d b e am
Shadow
mas k
R G B
Fa ce p la te
(a ) T he R G B co lo r strip e s
Figure 21.6
Mar. 2007
(b ) U se o f s ha d o w m a sk
The RGB color scheme of modern CRT displays.
Computer Architecture, Input/Output and Interfacing
Slide 14
Encoding Colors in RGB Format
Besides hue, saturation is used to affect the color’s appearance
(high saturation at the top, low saturation at the bottom)
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 15
Flat-Panel Displays
C o lum n pu ls es
C o lum n pu ls es
Row
lin es
Ad d re ss
p u ls e
C o lum n (da ta ) lin es
(a ) P a ssive d isp la y
Figure 21.7
Mar. 2007
C o lum n (da ta ) lin es
(b ) A cti ve d isp la y
Passive and active LCD displays.
Computer Architecture, Input/Output and Interfacing
Slide 16
Other Display Technologies
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 17
21.4 Hard-Copy Input/Output Devices
D oc um ent ( fac e d ow n )
F ilters
Lens
D etec tor:
c harg e-c o uple d
de vic e ( C C D )
M irro r
Light bea m
A/D
co n ve rte r
Light s ourc e
S ca n n ing
s o ftw a re
M irro r
Im a ge file
Figure 21.8
Mar. 2007
Scanning mechanism for hard-copy input.
Computer Architecture, Input/Output and Interfacing
Slide 18
oo oo o
oo oo o
Character Formation by Dot Matrices
o oo oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o oo oo
oo
oo
oo
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o oo ooo oo ooo oo o
o oo ooo oo ooo oo ooo o
oo
o oo o
oo
o oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
o
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
o
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
o oo
oo
o oo o
o oo ooo oo ooo oo ooo o
o oo ooo oo ooo oo o
Figure 21.9
Mar. 2007
o oo ooo oo o
o
oo
o
oo
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
o
oo
o
oo
o oo ooo oo o
Same dot matrix size,
but with greater resolution
o oo ooo oo ooo oo o
o oo ooo oo ooo oo ooo o
oo
o oo o
oo
o oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
o
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
o
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
oo
o oo
oo
o oo o
o oo ooo oo ooo oo ooo o
o oo ooo oo ooo oo o
Forming the letter “D” via dot matrices of varying sizes.
Computer Architecture, Input/Output and Interfacing
Slide 19
Simulating Intensity Levels via Dithering
Forming five gray levels on a device that supports
only black and white (e.g., ink-jet or laser printer)
Using the dithering patterns above on each of
three colors forms 5  5  5 = 125 different colors
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 20
Simple Dot-Matrix Printer Mechanism
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 21
Common Hard-Copy Output Devices
C le a nin g o f
e xce ss to n e r
S heet of
pape r
Fu s ing o f to n e r
Paper
m o ve m e n t
P rin t h e a d
m o ve m e n t
In k
d ro p le t
(a ) Ink je t p rin ting
Figure 21.10
Mar. 2007
L ig h t fro m
o p tica l
s ys tem
R olle rs
P rint
head
Ink
s upply
R o ta tin g
d ru m
H eate r
P rin t h e a d
a ss em b ly
C o ro n a w ire
fo r ch a rg in g
S heet of
pape r
T one r
(b ) L a se r p rin ting
Ink-jet and laser printers.
Computer Architecture, Input/Output and Interfacing
Slide 22
How Color Printers Work
Red
Green
The RGB scheme of color monitors is additive:
various amounts of the three primary colors
are added to form a desired color
Blue
Absence of green
Cyan
Magenta
The CMY scheme of color printers is subtractive:
various amounts of the three primary colors
are removed from white to form a desired color
Yellow
Mar. 2007
To produce a more satisfactory shade of black,
the CMYK scheme is often used (K = black)
Computer Architecture, Input/Output and Interfacing
Slide 23
The CMYK Printing Process
Illusion of
full color
created with
CMYK dots
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 24
Color Wheels
Artist’s color wheel,
used for mixing paint
Subtractive color wheel,
used in printing (CMYK)
Additive color wheel,
used for projection
Primary colors appear at center and equally spaced around the perimeter
Secondary colors are midway between primary colors
Tertiary colors are between primary and secondary colors
Source of this and several other slides on color: http://www.devx.com/projectcool/Article/19954/0/
(see also color theory tutorial: http://graphics.kodak.com/documents/Introducing%20Color%20Theory.pdf)
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 25
21.5 Other Input/Output Devices
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 26
Sensors and Actuators
Collecting info about the environment and other conditions
 Light sensors (photocells)
 Temperature sensors (contact and noncontact types)
 Pressure sensors
S
S
N
N
N
S
S
N
S
S
S
N
N
S
N
N
S
S
N
N
(a ) Initia l sta
te
(a ) A
r ro ta tio n
Figure 21.11
Stepper
motor principles
offteoperation.
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 27
21.6 Networking of Input/Output Devices
C om pute r 1
P rinter 2
C am er a
E thernet
C om pute r 3
P rinter 1
C om pute r 2
P rinter 3
Figure 21.12 With network-enabled peripherals,
I/O is done via file transfers.
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 28
Input/Output in Control and Embedded Systems
C P U an d
m em o ry
N e tw o rk
in te rfa ce
In te llig en t d e vice s ,
o th e r co m p u te rs ,
a rch iva l s to ra ge , ...
D ig ita l
o u tp u t
in te rfa ce
S ig n a l
co n ve rs ion
Dig ita l a c tua tor s :
s te p pe r m o to rs ,
re la ys , a la rm s , ...
D /A
o u tp u t
in te rfa ce
S ig n a l
co n ve rs ion
Ana lo g a c tua tor s :
va lve s , p u m ps ,
s p ee d re gu la to rs , ...
D ig ita l
in p u t
in te rfa ce
D ig ita l
s ign a l
co n d ition in g
Dig ita l s e ns or s :
d e te cto rs , co u n te rs ,
o n /o ff s w itch es , ...
A/D in p u t
in te rfa ce
An a lo g
s ign a l
co n d ition in g
Ana lo g s e ns or s :
th e rm o co u p les ,
p re ssu re s e ns o rs , ...
Figure 21.13 The structure of a closed-loop
computer-based control system.
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 29
22 Input/Output Programming
Like everything else, I/O is controlled by machine instructions
• I/O addressing (memory-mapped) and performance
• Scheduled vs demand-based I/O: polling vs interrupts
Topics in This Chapter
22.1 I/O Performance and Benchmarks
22.2 Input/Output Addressing
22.3 Scheduled I/O: Polling
22.4 Demand-Based I/O: Interrupts
22.5 I/O Data Transfer and DMA
22.6 Improving I/O Performance
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 30
22.1 I/O Performance and Benchmarks
Example 22.1: The I/O wall
An industrial control application spent 90% of its time on CPU
operations when it was originally developed in the early 1980s.
Since then, the CPU component has been upgraded every 5 years,
but the I/O components have remained the same. Assuming that
CPU performance improved tenfold with each upgrade, derive the
fraction of time spent on I/O over the life of the system.
Solution
Apply Amdahl’s law with 90% of the task speeded up by factors of
10, 100, 1000, and 10000 over a 20-year period. In the course of
these upgrades the running time has been reduced from the original
1 to 0.1 + 0.9/10 = 0.19, 0.109, 0.1009, and 0.10009, making the
fraction of time spent on input/output 52.6, 91.7, 99.1, and 99.9%,
respectively. The last couple of CPU upgrades did not really help.
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 31
Types of Input/Output Benchmark
Supercomputer I/O benchmarks
Reading large volumes of input data
Writing many snapshots for checkpointing
Saving a relatively small set of results
I/O data throughput, in MB/s, is important
Transaction processing I/O benchmarks
Huge database, but each transaction fairly small
A handful (2-10) of disk accesses per transaction
I/O rate (disk accesses per second) is important
File system I/O benchmarks
File creation, directory management, indexing, . . .
Benchmarks are usually domain-specific
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 32
22.2
M e m o r y lo ca tio n
(he x a d d re ss)
Input/Output Addressing
In te rru p t e n a b le
D e vice re a d y
I
ER
0 x ff f f0 00 0
31
0 x ff f f0 00 4
K e yb o a rd co n tro l
7 6 5 4 3 2 1 0
D a ta b yte
K e yb o a rd d a ta
3 2 -b it d e vice re g iste rs
I
ER
0 x ff f f0 00 8
31
0 x ff f f0 00 c
D isp la y co ntro l
7 6 5 4 3 2 1 0
D a ta b yte
D isp la y d a ta
Figure 22.1 Control and data registers for keyboard
and display unit in MiniMIPS.
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 33
Hardware for I/O Addressing
C ontr ol
A ddres s
D ata
M em o ry
bus
D e vice s ta tus
D e vice
a d d ress
D e vice d a ta
C om p a re
=
Figure 22.2
Mar. 2007
C ontr ol
logic
D e vic e
c ontrolle r
Addressing logic for an I/O device controller.
Computer Architecture, Input/Output and Interfacing
Slide 34
Data Input from Keyboard
Example 22.2
Write a sequence of MiniMIPS assembly language instructions to
make the program wait until the keyboard has a symbol to transmit
M e m o r y lo ca tio n
and then read the symbol into register
(he $v0.
x a d d re ss)
In te rru p t e n a b le
I
ER
0 x ff f f0 00 0
31
Solution
0 x ff f f0 00 4
D e vice re a d
K e yb o a rd
7 6 5 4 3 2 1 0
D a ta b yte
K e yb o a rd
3 2 -b it d e vice re g iste rs
The program must continually examine the keyboard control register,
0 x ff f f0 00 8
D isp la y co
ending its “busy wait” when the R bit has been asserted.
I
ER
31
0 x ff f f0 00 c
lui
idle: lw
andi
beq
lw
$t0,0xffff
$t1,0($t0)
$t1,$t1,0x0001
$t1,$zero,idle
$v0,4($t0)
#
#
#
#
#
7 6 5 4 3 2 1 0
D a ta b yte
put 0xffff0000 in $t0
get keyboard’s control word
isolate the LSB (R bit)
if not ready (R = 0), wait
retrieve data from keyboard
This type of input is appropriate only if the computer is waiting for a
critical input and cannot continue in the absence of such input.
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 35
D isp la y d a
Data Output to Display Unit
Example 22.3
M e m o r y lo ca tio n
In te rru p t e n a b le
D e vice re
(he x a d d re ss)
Write a sequence of MiniMIPS assembly
instructions to
0 x fflanguage
f f0 00 0
make the program wait until the display0 xunit
is ready to accept a new
ff f f0 00 4
symbol and then write the symbol from $a0 to the display
unit.
3 2 -b it d e vice
re g iste rs
I
ER
31
D a ta b yte
I
ER
0 x ff f f0 00 8
Solution
31
0 x ff f f0 00 c
$t0,0xffff
$t1,8($t0)
$t1,$t1,0x0001
$t1,$zero,idle
$a0,12($t0)
#
#
#
#
#
D a ta b yte
put 0xffff0000 in $t0
get display’s control word
isolate the LSB (R bit)
if not ready (R = 0), wait
supply data to display unit
This type of output is appropriate only if we can afford to have the
CPU dedicated to data transmission to the display unit.
Mar. 2007
Computer Architecture, Input/Output and Interfacing
K e yb o a r
D isp la y
7 6 5 4 3 2 1 0
The program must continually examine the display unit’s control
register, ending its “busy wait” when the R bit has been asserted.
lui
idle: lw
andi
beq
sw
K e yb o a r
7 6 5 4 3 2 1 0
Slide 36
D isp la y
22.3
Scheduled I/O: Polling
Examples 22.4, 22.5, 22.6
What fraction of a 1 GHz CPU’s time is spent polling the following
devices if each polling action takes 800 clock cycles?
Keyboard must be interrogated at least 10 times per second
Floppy sends data 4 bytes at a time at a rate of 50 KB/s
Hard drive sends data 4 bytes at a time at a rate of 3 MB/s
Solution
For keyboard, divide the number of cycles needed for 10
interrogations by the total number of cycles available in 1 second:
(10  800)/109  0.001%
The floppy disk must be interrogated 50K/4 = 12.5K times per sec
(12.5K  800)/109  1%
The hard disk must be interrogated 3M/4 = 750K times per sec
(750K  800)/109  60%
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 37
22.4
Demand-Based I/O: Interrupts
Example 22.7
Consider the disk in Example 22.6 (transferring 4 B chunks of data at
3 MB/s when active). Assume that the disk is active 5% of the time.
The overhead of interrupting the CPU and performing the transfer is
1200 clock cycles. What fraction of a 1 GHz CPU’s time is spent
attending to the hard disk drive?
Solution
When active, the hard disk produces 750K interrupts per second
0.05  (750K  1200)/109  4.5% (compare with 60% for polling)
Note that even though the overhead of interrupting the CPU is higher
than that of polling, because the disk is usually idle, demand-based
I/O leads to better performance.
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 38
Interrupt Handling
Upon detecting an interrupt signal, provided the particular
interrupt or interrupt class is not masked, the CPU acknowledges
the interrupt (so that the device can deassert its request signal)
and begins executing an interrupt service routine.
1. Save the CPU state and call the interrupt service routine.
2. Disable all interrupts.
3. Save minimal information about the interrupt on the stack.
4. Enable interrupts (or at least higher priority ones).
5. Identify cause of interrupt and attend to the underlying request.
6. Restore CPU state to what existed before the last interrupt.
7. Return from interrupt service routine.
The capability to handle nested interrupts is important in dealing with
multiple high-speed I/O devices.
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 39
22.5
I/O Data Transfer and DMA
O ther c ont rol
ReadW rite’
DataReady ’
S y stem
bus
A ddres s
D ata
Bus reques t
CP U
and
c ac he
Bus grant
D MA
co n tro lle r
M ain
Status Sourc e
m em o ry
Length Des t’n
Ty pic al
I/O
de vic e
Figure 22.3 DMA controller shares the system
or memory bus with the CPU.
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 40
DMA Operation
CP U
Bus Reques t
Bus Gr ant
DM A
(a) D M A trans fer in o ne c ontinu ous bu rs t
CP U
Bus Reques t
Bus Gr ant
DM A
(b) D M A trans fer in s e ver al s horte r bu rs ts
Figure 22.4 DMA operation and the associated
transfers of bus control.
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 41
22.6
Improving I/O Performance
Example 22.9: Effective I/O bandwidth from disk
Consider a hard disk drive with 512 B sectors, average access latency
of 10 ms, and peak throughput of 10 MB/s. Plot the variation of the
effective I/O bandwidth as the unit of data transfer (block) varies in
size from 1 sector (0.5 KB) to 1024 sectors (500 KB).
Solution
T hr oug hput (M B / s )
10
Figure 22.5
Mar. 2007
8
6
5 MB/s
4
2
0.05 MB/s
0
0
100
200
300
B loc k s iz e (K B )
Computer Architecture, Input/Output and Interfacing
400
500
Slide 42
Distributed Input/Output
C PU
C PU
C PU
C PU
Me m
HCA
Me m
HCA
HCA =
H os t
ch a n n el
a d a p te r
S w itch
Mo d u le w ith
b u ilt-in s witch
R o u te r
S w itch
S w itch
HCA
I/O
Figure 22.6
Mar. 2007
HCA
I/O
HCA
I/O
HCA
HCA
To o th e r s u bn e ts
I/O
I/O
Example configuration for the Infiniband distributed I/O.
Computer Architecture, Input/Output and Interfacing
Slide 43
23 Buses, Links, and Interfacing
Shared links or buses are common in modern computers:
• Fewer wires and pins, greater flexibility & expandability
• Require dealing with arbitration and synchronization
Topics in This Chapter
23.1 Intra- and Intersystem Links
23.2 Buses and Their Appeal
23.3 Bus Communication Protocols
23.4 Bus Arbitration and Performance
23.5 Basics of Interfacing
23.6 Interfacing Standards
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 44
23.1
Tre n ch w ith via
Intra- and Intersystem Links
Tre n ch
Me ta l la ye r 4
1 . E tch e d a n d ins u la ted
Me ta l
la ye r 3
2 . C o a te d w ith co p pe r
via
via
Me ta l
la ye r 2
Me ta l la ye r 1
C o n ta ct
3 . E xce s s co p pe r re m o ve d
(a) C ros s s ec tion o f lay ers
(b) 3 D vie w o f w ir es on m ultiple m etal lay ers
Figure 23.1 Multiple metal layers provide intrasystem connectivity
on microchips or printed-circuit boards.
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 45
Multiple Metal Layers on a Chip or PC Board
Cross section of metal layers
Active elements and
their connectors
Modern chips have
8-9 metal layers
Upper layers carry
longer wires as
well as those that
need more power
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 46
Intersystem Links
Computer
(a ) R S -2 3 2
(b ) E th e rn e t
Figure 23.2
Example intersystem connectivity schemes.
D T R : data term in al
rea dy
S ignal
gro und
5
C TS : c lear
to s end
Mar. 2007
T ra ns m it
data
4
9
Figure 23.3
(c) A TM
3
8
2
7
R ec ei ve
data
1
6
R TS : req ues t
to s end
D S R : data s et
rea dy
RS-232 serial interface 9-pin connector.
Computer Architecture, Input/Output and Interfacing
Slide 47
Intersystem Communication Media
Twis te d
p air
P las tic
Ins ul ator
C op pe r
c ore
C o axial
c ab le
O ute r
c onduc to r
R e fl ec tion
S ilic a
O p tic al
fibe r
Light
s ourc e
Figure 23.4 Commonly used communication media
for intersystem connections.
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 48
Comparing Intersystem Links
Table 23.1
Summary of three interconnection schemes.
Interconnection properties
RS-232
Ethernet
ATM
Maximum segment length (m)
10s
100s
1000s
Maximum network span (m)
10s
100s
Unlimited
Up to 0.02
10/100/1000
155-2500
1
100s
53
<1
10s-100s
100s
Input/Output
LAN
Backbone
Low
Low
High
Bit rate (Mb/s)
Unit of transmission (B)
Typical end-to-end latency (ms)
Typical application domain
Transceiver complexity or cost
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 49
23.2
Buses and Their Appeal
1
0
1
2
0
3
n–1
n–2
2
3
n–1
n–2
Point-to-point connections between n units require n(n – 1) channels,
or n(n – 1)/2 bidirectional links; that is, O(n2) links
Bus connectivity requires only one input and one output port per unit,
or O(n) links in all
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 50
Bus Components and Types
.
.
.
C ontr ol
.
.
.
A ddres s
.
.
.
Figure 23.5
D ata
H a n ds ha kin g ,
d ire ctio n ,
tra n s fe r m o d e ,
a rb itra tio n , ...
o n e b it (s e ria l)
to s e ve ra l b yte s ;
m a y b e s ha re d
The three sets of lines found in a bus.
A typical computer may use a dozen or so different buses:
1. Legacy Buses: PC bus, ISA, RS-232, parallel port
2. Standard buses: PCI, SCSI, USB, Ethernet
3. Proprietary buses: for specific devices and max performance
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 51
23.3
Bus Communication Protocols






C loc k
A ddress plac ed on the bus
A ddres s
D ata
W ait
Figure 23.6
W ait
W ait
Data
av ailability
ens ur ed
Synchronous bus with fixed-latency devices.
R eq ues t

A ddres s
or data





Ack




R ea dy
Figure 23.7 Handshaking on an asynchronous bus for an
input operation (e.g., reading from memory).
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 52
Example Bus Operation









C LK
F R A ME 
C /B E 
AD
I/O r ead
By te enable
A ddress
Data 0
Data 1
Data 2
IR D Y 
Data 3
W ait
TRDY 
W ait
DE V S E L
Tr ansf er A ddress AD tur ninitiat ion tr ansf er ar ound
Figure 23.8
Mar. 2007
Data
tr ansf er
W ait
c yc le
Data
tr ansf er
Data
tr ansf er
W ait
c yc le
Data
tr ansf er
I/O read operation via PCI bus.
Computer Architecture, Input/Output and Interfacing
Slide 53
23.4
R
0
R
1
R
2
R
Bus Arbitration and Performance
.
.
.
S
y
n
c
.
.
.
A rb ite r
.
.
.
G
0
G
1
G
2
G
n 1
n 1
B u s re le as e
Figure 23.9
Mar. 2007
General structure of a centralized bus arbiter.
Computer Architecture, Input/Output and Interfacing
Slide 54
Daisy Chaining
R
0
R
1
R
2
.
.
.
S
y
n
c
.
.
.
B u s re le as e
A rb ite r
.
.
.
Bus
g ra n t
G
0
G
1
G
2
Dev ic e
A
D ais y c hain of de vic es
Dev ic e
B
Dev ic e
C
Dev ic e
D
B u s re qu es t
Figure 23.9 Daisy chaining allows a small centralized arbiter to
service a large number of devices that use a shared resource.
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 55
23.5
N
W
Basics of Interfacing
G ro u n d
+5 V D C
C o n ta ct
p o in t
S
M ic roc ontroll er
w ith intern al
A /D c on ve rter
E
Pin x of por t y
Figure 23.11 Wind vane supplying an output voltage in
the range 0-5 V depending on wind direction.
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 56
23.6
Table 23.2
Attributes 
Interfacing Standards
Summary of four standard interface buses.
Name 
PCI
SCSI
FireWire
USB
Type of bus
Backplane
Parallel I/O
Serial I/O
Serial I/O
Standard designation
PCI
ANSI X3.131
IEEE 1394
USB 2.0
Typical application domain
System
Fast I/O
Fast I/O
Low-cost I/O
Bus width (data bits)
32-64
8-32
2
1
Peak bandwidth (MB/s)
133-512
5-40
12.5-50
0.2-15
Maximum number of devices
1024*
7-31#
63
127$
Maximum span (m)
<1
3-25
4.5-72$
5-30$
Arbitration method
Centralized
Self-select
Distributed
Daisy chain
Transceiver complexity or cost
High
Medium
Medium
Low
Notes:
Mar. 2007
* 32 per bus segment;
# One less than bus width;
$ With hubs (repeaters)
Computer Architecture, Input/Output and Interfacing
Slide 57
Standard Connectors
USB A
Hos t s ide
4 3 2 1
1
4
Ma x ca b le
le n g th : 5m
H os t
(co n tro lle r & h u b )
USB B
Dev ic e s ide
2
3
Hub
Hub
P in 1 :  5 V D C
P in 2 : D a ta 
P in 4 : G ro u n d
P in 3 : D a ta 
Figure 23.12
D e vice
Hub
D e vice
D e vice
D e vice
S in g le p ro d u ct
w ith h u b & d e vice
USB connectors and connectivity structure .
P in 1 : 8 -4 0 V D C , 1 .5 A
P in 2 : G ro u n d
P in 3 : Tw is te d pa ir B 
P in 4 : Tw is te d pa ir B +
P in 5 : Tw is te d pa ir A 
P in 6 : Tw is te d pa ir A +
S h e ll: O u te r s h ie ld
Figure 23.13 IEEE 1394 (FireWire) connector.
The same connector is used at both ends.
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 58
24 Context Switching and Interrupts
OS initiates I/O transfers and awaits notification via interrupts
• When an interrupt is detected, the CPU switches context
• Context switch can also be used between users/threads
Topics in This Chapter
24.1 System Calls for I/O
24.2 Interrupts, Exceptions, and Traps
24.3 Simple Interrupt Handling
24.4 Nested Interrupts
24.5 Types of Context Switching
24.6 Threads and Multithreading
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 59
24.1
System Calls for I/O
Why the user must be isolated from details of I/O operations
Protection: User must be barred from accessing some disk areas
Convenience: No need to learn details of each device’s operation
Efficiency: Most users incapable of finding the best I/O scheme
I/O abstraction: grouping of I/O devices into a small number of
generic types so as to make the I/O device-independent
Character stream I/O: get(●), put(●) – e.g., keyboard, printer
Block I/O: seek(●), read(●), write(●) – e.g., disk
Network Sockets: create socket, connect, send/receive packet
Clocks or timers: set up timer (get notified via an interrupt)
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 60
24.2
Interrupts, Exceptions, and Traps
Interrupt
Exception
Trap
Both general term for any diversion and the I/O type
Caused by an illegal operation (often unpredictable)
AKA “software interrupt” (preplanned and not rare)
S tudyin g P arh am i’s
b ook for tes t
6:55
7:40
8:01
9:46
Stomac h s ends
interrupt s ignal
E- mai l
arriv es
E ating dinne r
R ea ding/s en ding e -m ail
8:42
Telemarketer
c alls
8:53
9:20
Bes t friend
c alls
T alk ing on the phon e
Figure 24.1
Mar. 2007
The notions of interrupts and nested interrupts.
Computer Architecture, Input/Output and Interfacing
Slide 61
24.3
Simple Interrupt Handling
Acknowledge the interrupt by asserting the IntAck signal
Notify the CPU’s next-address logic that an interrupt is pending
Set the interrupt mask so that no new interrupt is accepted
In tA ck
In tR e q
S
y
n
c
In tD is ab le
S
S
FF
R
S ignals
fr om /to
de vic es
Q
Q
FF
Q
In te rru p t
a ckn o w le d ge
R
In tAle rt
Q
In te rru p t
m as k
S ignals
fr om /to
CP U
In tE n a b le
Figure 24.2
Mar. 2007
Simple interrupt logic for the single-cycle MicroMIPS.
Computer Architecture, Input/Output and Interfacing
Slide 62
Interrupt Timing






C loc k
IntR eq
Sy nc hroniz ed v ers ion
IntA ck
IntMas k
IntA lert
Figure 24.3
Mar. 2007
Timing of interrupt request and acknowledge signals.
Computer Architecture, Input/Output and Interfacing
Slide 63
Next-Address Logic with Interrupts Added
Inc rP C
O ld
PC
N ex tP C
/
30
0
1
0
/
30
1
2
3
/
30
/
30
/
30
/
30
/
30
IntA ler t
(P C )
31:28
| jta
(rs ) 31:2
Sy s CallA ddr
Int Handler A ddr
PCSr c
Figure 24.4 Part of the next-address logic for single-cycle
MicroMIPS, with an interrupt capability added (compare with
the lower left part of Figure 13.4).
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 64
24.4
Nested Interrupts
prog
PC
inst(a)
inst(b)
Inter r upts dis abled
and ( PC) s av ed
In t
d e te cte d
int1
Inte rru pt
handl er
Sav e s tate
Sav e int inf o
Enable int’s
PC
inst(c)
inst(d)
In t
d e te cte d
int2
Sav e s tate
Sav e int inf o
Inter r upts dis abled Enable int’s
and ( PC) s av ed
Res tor e s tate
Retur n
Figure 24.6
Mar. 2007
Inte rru pt
handl er
Res tor e s tate
Retur n
Example of nested interrupts.
Computer Architecture, Input/Output and Interfacing
Slide 65
24.5
S c anning e -m ail
m es s ages
Types of Context Switching
T ak ing n otes
T as k 1
T as k 2
T as k 3
Tim e
s lice
C o n te xt
s witch
T alk ing on tele pho ne
(a ) Hu m a n m ultita sking
Figure 24.7
Mar. 2007
(b ) C o m p ute r m u ltita ski ng
Multitasking in humans and computers.
Computer Architecture, Input/Output and Interfacing
Slide 66
24.6
Threads and Multithreading
T hr ead 1
T hr ead 2
T hr ead 3
S p a w n ad d ition a l th re ad s
S yn c
S yn c
(a ) Ta sk g ra p h o f a p ro g ra m
Figure 24.8
Mar. 2007
(b ) T hre a d str uc ture o f a ta sk
A program divided into tasks (subcomputations) or threads.
Computer Architecture, Input/Output and Interfacing
Slide 67
Multithreaded Processors
T hr eads in m e m ory
Is s ue pipeli nes
B ubble
R etire m ent a nd
c om m it pipeline
F unc tion units
Figure 24.9 Instructions from multiple threads as they make
their way through a processor’s execution pipeline.
Mar. 2007
Computer Architecture, Input/Output and Interfacing
Slide 68
Descargar

Adventures on the Sea of Interconnection Networks