CS2253 Computer Organization and Architecture Lecture Notes
CS2253 Computer Organization and Architecture Lecture Notes
In practice# almost all computers use a "ariety of memory types# organi;ed in a storage
hierarchy around the CPU# as a tradeoff etween performance and cost. /enerally# the
lower a storage is in the hierarchy# the lesser its andwidth and the greater its access
latency is from the CPU. This traditional di"ision of storage to primary# secondary#
tertiary and off)line storage is also guided y cost per it.
/ierarch+ of stora$e
Seco"!ar+ stora$e
Seco"!ar+ stora$e &or e1ter"a% memor+' differs from primary storage in that it is not
directly accessile y the CPU. The computer usually uses its input:output channels to
access secondary storage and transfers the desired data using intermediate area in primary
storage. %econdary storage does not lose the data when the de"ice is powered down0it is
non)"olatile. Per unit# it is typically also an order of magnitude less e4pensi"e than
primary storage. Conse(uently# modern computer systems typically ha"e an order of
magnitude more secondary storage than primary storage and data is $ept for a longer time
there.
In modern computers# hard dis$ dri"es are usually used as secondary storage. The time
ta$en to access a gi"en yte of information stored on a hard dis$ is typically a few
thousandths of a second# or milliseconds. =y contrast# the time ta$en to access a gi"en
yte of information stored in random access memory is measured in illionths of a
second# or nanoseconds. This illustrates the "ery significant access)time difference which
distinguishes solid)state memory from rotating magnetic storage de"ices: hard dis$s are
typically aout a million times slower than memory. +otating optical storage de"ices#
such as CD and D1D dri"es# ha"e e"en longer access times. Dith dis$ dri"es# once the
dis$ read:write head reaches the proper placement and the data of interest rotates under it#
suse(uent data on the trac$ are "ery fast to access. !s a result# in order to hide the initial
see$ time and rotational latency# data are transferred to and from dis$s in large
contiguous loc$s.
Dhen data reside on dis$# loc$ access to hide latency offers a ray of hope in designing
efficient e4ternal memory algorithms. %e(uential or loc$ access on dis$s is orders of
magnitude faster than random access# and many sophisticated paradigms ha"e een
de"eloped to design efficient algorithms ased upon se(uential and loc$ access .
!nother way to reduce the I:O ottlenec$ is to use multiple dis$s in parallel in order to
increase the andwidth etween primary and secondary memory.
%ome other e4amples of secondary storage technologies are: flash memory &e.g. U%=
flash dri"es or $eys'# floppy dis$s# magnetic tape# paper tape# punched cards# standalone
+!- dis$s# and Iomega Yip dri"es.
Characteristics of stora$e
! 1/= DD+ +!- memory module
%torage technologies at all le"els of the storage hierarchy can e differentiated y
e"aluating certain core characteristics as well as measuring characteristics specific to a
particular implementation. These core characteristics are "olatility# mutaility#
accessiility# and addressiility. 9or any particular implementation of any storage
technology# the characteristics worth measuring are capacity and performance.
Po%ati%it+
Non)"olatile memory
Dill retain the stored information e"en if it is not constantly supplied with electric
power. It is suitale for long)term storage of information. Nowadays used for
most of secondary# tertiary# and off)line storage. In 1LS8s and 1L68s# it was also
used for primary storage# in the form of magnetic core memory.
1olatile memory
+e(uires constant power to maintain the stored information. The fastest memory
technologies of today are "olatile ones ¬ a uni"ersal rule'. %ince primary
storage is re(uired to e "ery fast# it predominantly uses "olatile memory.
#iffere"tiatio"
Dynamic random access memory
! form of "olatile memory which also re(uires the stored information to e
periodically re)read and re)written# or refreshed# otherwise it would "anish.
%tatic memory
! form of "olatile memory similar to D+!- with the e4ception that it ne"er
needs to e refreshed.
Mutabi%it+
+ead:write storage or mutale storage
!llows information to e o"erwritten at any time. ! computer without some
amount of read:write storage for primary storage purposes would e useless for
many tas$s. -odern computers typically use read:write storage also for secondary
storage.
+ead only storage
+etains the information stored at the time of manufacture# and 0rite o"ce stora$e
&Drite Once +ead -any' allows the information to e written only once at some
point after manufacture. These are called immutab%e stora$e. Immutale storage
is used for tertiary and off)line storage. *4amples include CD)+O- and CD)+.
%low write# fast read storage
+ead:write storage which allows information to e o"erwritten multiple times# ut
with the write operation eing much slower than the read operation. *4amples
include CD)+D and flash memory.
Accessibi%it+
+andom access
!ny location in storage can e accessed at any moment in appro4imately the same
amount of time. %uch characteristic is well suited for primary and secondary
storage.
%e(uential access
The accessing of pieces of information will e in a serial order# one after the
otherB therefore the time to access a particular piece of information depends upon
which piece of information was last accessed. %uch characteristic is typical of off)
line storage.
A!!ressabi%it+
.ocation)addressale
*ach indi"idually accessile unit of information in storage is selected with its
numerical memory address. In modern computers# location)addressale storage
usually limits to primary storage# accessed internally y computer programs# since
location)addressaility is "ery efficient# ut urdensome for humans.
9ile addressale
Information is di"ided into files of "ariale length# and a particular file is selected
with human)readale directory and file names. The underlying de"ice is still
location)addressale# ut the operating system of a computer pro"ides the file
system astraction to ma$e the operation more understandale. In modern
computers# secondary# tertiary and off)line storage use file systems.
Content)addressale
*ach indi"idually accessile unit of information is selected ased on the asis of
&part of' the contents stored there. Content)addressale storage can e
implemented using software &computer program' or hardware &computer de"ice'#
with hardware eing faster ut more e4pensi"e option. ,ardware content
addressale memory is often used in a computer<s CPU cache.
Capacit+
+aw capacity
The total amount of stored information that a storage de"ice or medium can hold.
It is e4pressed as a (uantity of its or ytes &e.g. 18.E megaytes'.
-emory storage density
The compactness of stored information. It is the storage capacity of a medium
di"ided with a unit of length# area or "olume &e.g. 1.7 megaytes per s(uare inch'.
Performa"ce
.atency
The time it ta$es to access a particular location in storage. The rele"ant unit of
measurement is typically nanosecond for primary storage# millisecond for
secondary storage# and second for tertiary storage. It may ma$e sense to separate
read latency and write latency# and in case of se(uential access storage# minimum#
ma4imum and a"erage latency.
Throughput
The rate at which information can e read from or written to the storage. In
computer data storage# throughput is usually e4pressed in terms of megaytes per
second or -=:s# though it rate may also e used. !s with latency# read rate and
write rate may need to e differentiated. !lso accessing media se(uentially# as
opposed to randomly# typically yields ma4imum throughput.
Ma$"etic
Ma$"etic stora$e uses different patterns of magneti;ation on a magnetically coated
surface to store information. -agnetic storage is non-volatile. The information is
accessed using one or more read:write heads which may contain one or more recording
transducers. ! read:write head only co"ers a part of the surface so that the head or
medium or oth must e mo"ed relati"e to another in order to access data. In modern
computers# magnetic storage will ta$e these forms:
-agnetic dis$
o 9loppy dis$# used for off)line storage
o ,ard dis$ dri"e# used for secondary storage
-agnetic tape data storage# used for tertiary and off)line storage
/ar! #is6 Tech"o%o$+
Diagram of a computer hard dis$ dri"e
,DDs record data y magneti;ing ferromagnetic material directionally# to represent
either a 8 or a 1 inary digit. They read the data ac$ y detecting the magneti;ation of
the material. ! typical ,DD design consists of a spindle that holds one or more flat
circular dis$s called platters# onto which the data is recorded. The platters are made from
a non)magnetic material# usually aluminum alloy or glass# and are coated with a thin
layer of magnetic material# typically 18)78 nm in thic$ness with an outer layer of caron
for protection.
The platters are spun at "ery high speeds. Information is written to a platter as it rotates
past de"ices called read)and)write heads that operate "ery close &tens of nanometers in
new dri"es' o"er the magnetic surface. The read)and)write head is used to detect and
modify the magneti;ation of the material immediately under it. There is one head for
each magnetic platter surface on the spindle# mounted on a common arm. !n actuator
arm &or access arm' mo"es the heads on an arc &roughly radially' across the platters as
they spin# allowing each head to access almost the entire surface of the platter as it spins.
The arm is mo"ed using a "oice coil actuator or in some older designs a stepper motor.
The magnetic surface of each platter is conceptually di"ided into many small su)
micrometre)si;ed magnetic regions# each of which is used to encode a single inary unit
of information. Initially the regions were oriented hori;ontally# ut eginning aout 788S#
the orientation was changed to perpendicular. Due to the polycrystalline nature of the
magnetic material each of these magnetic regions is composed of a few hundred magnetic
grains. -agnetic grains are typically 18 nm in si;e and each form a single magnetic
domain. *ach magnetic region in total forms a magnetic dipole which generates a highly
locali;ed magnetic field neary. ! write head magneti;es a region y generating a strong
local magnetic field. *arly ,DDs used an electromagnet oth to magneti;e the region and
to then read its magnetic field y using electromagnetic induction. .ater "ersions of
inducti"e heads included metal in /ap &-I/' heads and thin film heads. !s data density
increased# read heads using magnetoresistance &-+' came into useB the electrical
resistance of the head changed according to the strength of the magnetism from the
platter. .ater de"elopment made use of spintronicsB in these heads# the magnetoresisti"e
effect was much greater than in earlier types# and was dued CgiantC magnetoresistance
&/-+'. In today<s heads# the read and write elements are separate# ut in close pro4imity#
on the head portion of an actuator arm. The read element is typically magneto)resisti"e
while the write element is typically thin)film inducti"e.
,D heads are $ept from contacting the platter surface y the air that is e4tremely close to
the platterB that air mo"es at# or close to# the platter speed. The record and playac$ head
are mounted on a loc$ called a slider# and the surface ne4t to the platter is shaped to
$eep it >ust arely out of contact. It<s a type of air earing.
In modern dri"es# the small si;e of the magnetic regions creates the danger that their
magnetic state might e lost ecause of thermal effects. To counter this# the platters are
coated with two parallel magnetic layers# separated y a I)atom)thic$ layer of the non)
magnetic element ruthenium# and the two layers are magneti;ed in opposite orientation#
thus reinforcing each other. !nother technology used to o"ercome thermal effects to
allow greater recording densities is perpendicular recording# first shipped in 788S# as of
788M the technology was used in many ,DDs.
The grain oundaries turn out to e "ery important in ,DD design. The reason is that# the
grains are "ery small and close to each other# so the coupling etween ad>acent grains is
"ery strong. Dhen one grain is magneti;ed# the ad>acent grains tend to e aligned parallel
to it or demagneti;ed. Then oth the staility of the data and signal)to)noise ratio will e
saotaged. ! clear grain oundary can wea$en the coupling of the grains and
suse(uently increase the signal)to)noise ratio. In longitudinal recording# the single)
domain grains ha"e unia4ial anisotropy with easy a4es lying in the film plane. The
conse(uence of this arrangement is that ad>acent magnets repel each other. Therefore the
magnetostatic energy is so large that it is difficult to increase areal density. Perpendicular
recording media# on the other hand# has the easy a4is of the grains oriented perpendicular
to the dis$ plane. !d>acent magnets attract to each other and magnetostatic energy are
much lower. %o# much higher areal density can e achie"ed in perpendicular recording.
!nother uni(ue feature in perpendicular recording is that a soft magnetic underlayer are
incorporated into the recording dis$.This underlayer is used to conduct writing magnetic
flu4 so that the writing is more efficient. This will e discussed in writing process.
Therefore# a higher anisotropy medium film# such as .18)9ePt and rare)earth magnets#
can e used.
Error ha"!%i"$
-odern dri"es also ma$e e4tensi"e use of *rror Correcting Codes &*CCs'# particularly
+eedH%olomon error correction. These techni(ues store e4tra its for each loc$ of data
that are determined y mathematical formulas. The e4tra its allow many errors to e
fi4ed. Dhile these e4tra its ta$e up space on the hard dri"e# they allow higher recording
densities to e employed# resulting in much larger storage capacity for user data. In 788L#
in the newest dri"es# low)density parity)chec$ codes &.DPC' are supplanting +eed)
%olomon. .DPC codes enale performance close to the %hannon .imit and thus allow for
the highest storage density a"ailale.
Typical hard dri"es attempt to CremapC the data in a physical sector that is going ad to a
spare physical sector0hopefully while the numer of errors in that ad sector is still
small enough that the *CC can completely reco"er the data without loss.
Architecture
! hard dis$ dri"e with the platters and motor hu remo"ed showing the copper colored
stator coils surrounding a earing at the center of the spindle motor. The orange stripe
along the side of the arm is a thin printed)circuit cale. The spindle earing is in the
center.
! typical hard dri"e has two electric motors# one to spin the dis$s and one to position the
read:write head assemly. The dis$ motor has an e4ternal rotor attached to the plattersB
the stator windings are fi4ed in place. The actuator has a read)write head under the tip of
its "ery end &near center'B a thin printed)circuit cale connects the read)write head to the
hu of the actuator. ! fle4ile# somewhat <U<)shaped# rion cale# seen edge)on elow
and to the left of the actuator arm in the first image and more clearly in the second#
continues the connection from the head to the controller oard on the opposite side.
Capacit+ a"! access spee!
PC hard dis$ dri"e capacity &in /='. The "ertical a4is is logarithmic# so the fit line
corresponds to e4ponential growth.
Using rigid dis$s and sealing the unit allows much tighter tolerances than in a floppy dis$
dri"e. Conse(uently# hard dis$ dri"es can store much more data than floppy dis$ dri"es
and can access and transmit it faster.
!s of !pril 788L# the highest capacity consumer ,DDs are 7 T=.
! typical Cdes$top ,DDC might store etween 178 /= and 7 T= although rarely
ao"e S88/= of data &ased on U% mar$et data rotate at S#E88 to 18#888 rpm# and
ha"e a media transfer rate of 1 /it:s or higher. &1 /= R 18
L
=B 1 /it:s R 18
L
it:s'
The fastest WenterpriseA ,DDs spin at 18#888 or 1S#888 rpm# and can achie"e
se(uential media transfer speeds ao"e 1.6 /it:s. and a sustained transfer rate up
to 1 /it:s. Dri"es running at 18#888 or 1S#888 rpm use smaller platters to
mitigate increased power re(uirements &as they ha"e less air drag' and therefore
generally ha"e lower capacity than the highest capacity des$top dri"es.
C-oile ,DDsC# i.e.# laptop ,DDs# which are physically smaller than their
des$top and enterprise counterparts# tend to e slower and ha"e lower capacity. !
typical moile ,DD spins at S#E88 rpm# with M#788 rpm models a"ailale for a
slight price premium. =ecause of physically smaller platter&s'# moile ,DDs
generally ha"e lower capacity than their physically larger counterparts.
The e4ponential increases in dis$ space and data access speeds of ,DDs ha"e enaled the
commercial "iaility of consumer products that re(uire large storage capacities# such as
digital "ideo recorders and digital audio players.
The main way to decrease access time is to increase rotational speed# thus reducing
rotational delay# while the main way to increase throughput and storage capacity is to
increase areal density. =ased on historic trends# analysts predict a future growth in ,DD
it density &and therefore capacity' of aout E8T per year. !ccess times ha"e not $ept up
with throughput increases# which themsel"es ha"e not $ept up with growth in storage
capacity.
The first I.Sc ,DD mar$eted as ale to store 1 T= was the ,itachi Des$star M_1888. It
contains fi"e platters at appro4imately 788 /= each# pro"iding 1 T= &LIS.S /i=' of
usale spaceB note the difference etween its capacity in decimal units &1 T= R 18
17
ytes'
and inary units &1 Ti= R 187E /i= R 7
E8
ytes'. ,itachi has since een >oined y
%amsung &%amsung %pinPoint 91# which has I d IIE /= platters'# %eagate and Destern
Digital in the 1 T= dri"e mar$et.
In %eptemer 788L# %howa Den$o announced capacity impro"ements in platters that they
manufacture for ,DD ma$ers. ! single 7.SC platter is ale to hold IIE /= worth of data#
and preliminary results for I.SC indicate a MS8 /= per platter capacity.
Optica%
Optica% stora$e# the typical Optical disc# stores information in deformities on the surface
of a circular disc and reads this information y illuminating the surface with a laser diode
and oser"ing the reflection. Optical disc storage is non-volatile. The deformities may e
permanent &read only media '# formed once &write once media' or re"ersile &recordale
or read:write media'. The following forms are currently in common use:
CD# CD)+O-# D1D# =D)+O-: +ead only storage# used for mass distriution of
digital information &music# "ideo# computer programs'
CD)+# D1D)+# D1D2+ =D)+: Drite once storage# used for tertiary and off)line
storage
CD)+D# D1D)+D# D1D2+D# D1D)+!-# =D)+*: %low write# fast read
storage# used for tertiary and off)line storage
Ultra Density Optical or UDO is similar in capacity to =D)+ or =D)+* and is
slow write# fast read storage used for tertiary and off)line storage.
Ma$"etooptica% !isc stora$e is optical disc storage where the magnetic state on a
ferromagnetic surface stores information. The information is read optically and written y
comining magnetic and optical methods. -agneto)optical disc storage is non-volatile#
sequential access# slow write# fast read storage used for tertiary and off)line storage.
! Compact #isc &also $nown as a C#' is an optical disc used to store digital data. It was
originally de"eloped to store sound recordings e4clusi"ely# ut later it also allowed the
preser"ation of other types of data. !udio CDs ha"e een commercially a"ailale since
Octoer 1L57. In 788L# they remain the standard physical storage medium for audio.
%tandard CDs ha"e a diameter of 178 mm and can hold up to 58 minutes of
uncompressed audio &M88 -= of data'. The -ini CD has "arious diameters ranging from
68 to 58 mmB they are sometimes used for CD singles or de"ice dri"ers# storing up to 7E
minutes of audio.
The technology was e"entually adapted and e4panded to encompass data storage CD)
+O-# write)once audio and data storage CD)+# rewritale media CD)+D# 1ideo
Compact Discs &1CD'# %uper 1ideo Compact Discs &%1CD'# PhotoCD# PictureCD# CD)
i# and *nhanced CD.
Ph+sica% !etai%s
Diagram of CD layers.
!. ! polycaronate disc layer has the data encoded y using umps.
=. ! shiny layer reflects the laser.
C. ! layer of lac(uer helps $eep the shiny layer shiny.
D. !rtwor$ is screen printed on the top of the disc.
*. ! laser eam reads the CD and is reflected ac$ to a sensor# which con"erts it into
electronic data.
! CD is made from 1.7 mm thic$# almost)pure polycaronate plastic and weighs
appro4imately 1SH78 grams. 9rom the center outward components are at the center
&spindle' hole# the first)transition area &clamping ring'# the clamping area &stac$ing ring'#
the second)transition area &mirror and'# the information &data' area# and the rim.
! thin layer of aluminium or# more rarely# gold is applied to the surface to ma$e it
reflecti"e# and is protected y a film of lac(uer that is normally spin coated directly on
top of the reflecti"e layer# upon which the lael print is applied. Common printing
methods for CDs are screen)printing and offset printing.
CD data are stored as a series of tiny indentations $nown as WpitsA# encoded in a spiral
trac$ molded into the top of the polycaronate layer. The areas etween pits are $nown as
WlandsA. *ach pit is appro4imately 188 nm deep y S88 nm wide# and "aries from 5S8 nm
to I.S em in length.
The distance etween the trac$s# the pitch# is 1.6 em. ! CD is read y focusing a M58 nm
wa"elength &near infrared' semiconductor laser through the ottom of the polycaronate
layer. The change in height etween pits &actually ridges as seen y the laser' and lands
results in a difference in intensity in the light reflected. =y measuring the intensity
change with a photodiode# the data can e read from the disc.
The pits and lands themsel"es do not directly represent the ;eros and ones of inary data.
Instead# Non)return)to);ero# in"erted &N+YI' encoding is used: a change from pit to land
or land to pit indicates a one# while no change indicates a series of ;eros. There must e
at least two and no more than ten ;eros etween each one# which is defined y the length
of the pit. This in turn is decoded y re"ersing the *ight)to)9ourteen -odulation used in
mastering the disc# and then re"ersing the Cross)Interlea"ed +eed)%olomon Coding#
finally re"ealing the raw data stored on the disc.
CDs are susceptile to damage from oth daily use and en"ironmental e4posure. Pits are
much closer to the lael side of a disc# so that defects and dirt on the clear side can e out
of focus during playac$. Conse(uently# CDs suffer more scratch damage on the lael
side whereas scratches on the clear side can e repaired y refilling them with similar
refracti"e plastic# or y careful polishing. Initial music CDs were $nown to suffer from
CCD rotC# or Claser rotC# in which the internal reflecti"e layer degrades. Dhen this occurs
the CD may ecome unplayale.
#isc shapes a"! !iameters
! -ini)CD is 5 centimetres in diameter.
The digital data on a CD egin at the center of the disc and proceeds toward the edge#
which allows adaptation to the different si;e formats a"ailale. %tandard CDs are
a"ailale in two si;es. =y far the most common is 178 mm in diameter# with a ME) or 58)
minute audio capacity and a 6S8 or M88 -= data capacity. This diameter has also een
adopted y later formats# including %uper !udio CD# D1D# ,D D1D# and =lu)ray Disc.
58 mm discs &C-ini CDsC' were originally designed for CD singles and can hold up to
71 minutes of music or 15E -= of data ut ne"er really ecame popular. Today# nearly
e"ery single is released on a 178 mm CD# called a -a4i single.
UNIT S
Input:Output Organi;ation
Input:Output -odule
Interface to CPU and -emory
GInterface to one or more peripherals
/eneric -odel of IO -odule
Interface for an IO De"ice:
CPU chec$s I:O module de"ice status GI:O module returns status
GIf ready# CPU re(uests data transfer GI:O module gets data from de"ice
GI:O module transfers data to CPU
I"put Output Tech"i;ues
Programmed
Interrupt dri"en
Direct -emory !ccess &D-!'
Programmed I:O
GCPU has direct control o"er I:O
H%ensing status
H+ead:write commands
HTransferring data
GCPU waits for I:O module to complete operation
GDastes CPU time
GCPU re(uests I:O operation
GI:O module performs operation
GI:O module sets status its
GCPU chec$s status its periodically
GI:O module does not inform CPU directly
GI:O module does not interrupt CPU
GCPU may wait or come ac$ later
GUnder programmed I:O data transfer is "ery li$e memory access &CPU "iewpoint'
G*ach de"ice gi"en uni(ue identifier
GCPU commands contain identifier &address'
I:O -apping
QMemor+ mappe! I:O
HDe"ices and memory share an address space
HI:O loo$s >ust li$e memory read:write
HNo special commands for I:O
G.arge selection of memory access commands a"ailale
QIso%ate! I:O
H%eparate address spaces
HNeed I:O or memory select lines
H%pecial commands for I:O
G.imited set
-emory -apped IO:
GInput and output uffers use same address spaceas memory locations
G!ll instructions can access the uffer
Interrupts
GInterrupt)re(uest line
HInterrupt)re(uest signal
HInterrupt)ac$nowledge signal
GInterrupt)ser"ice routine
H%imilar to suroutine
H-ay ha"e no relationship to program eing e4ecuted at time of interrupt
GProgram info must e sa"ed
GInterrupt latency
!ransfer of control through the use of interrupts
INTERRUPT /AN#LIN8
,andling Interrupts G -any situations where the processor should ignore
interrupt re(uestsHInterrupt)disaleHInterrupt)enale GTypical scenarioH
De"ice raises interrupt re(uestHProcessor interrupts program eing
e4ecutedHProcessor disales interrupts and ac$nowledges interruptH
Interrupt)ser"ice routine e4ecutedHInterrupts enaled and program e4ecution
resumed
!n e(ui"alent circuit for an open)drain us used to implement a common
interrupt)re(uest line.
,andling -ultiple De"ices
nterrupt ,riority
GDuring e4ecution of interrupt)ser"ice routine
HDisale interrupts from de"ices at the same le"el priority or lower
HContinue to accept interrupt re(uests from higher priority de"ices
HPri"ileged instructions e4ecuted in super"isor mode
GControlling de"ice re(uests
HInterrupt)enale
G_*N# D*N
Po%%e! i"terrupts,Priorit+ !etermi"e! b+ the or!er i" 0hich processor po%%s the
!e(ices &po%%s their status re$isters'Pectore! i"terrupts,Priorit+ !etermi"e! b+ the
or!er i" 0hich processor te%%s !e(iceto put its co!e o" the a!!ress %i"es &or!er of
co""ectio" i" the chai"'
#ais+ chai"i"$ of INTA,If !e(ice has "ot re;ueste! ser(ice. passes the INTA si$"a%
to "e1t !e(iceIf "ee!s ser(ice. !oes "ot pass the INTA. puts its co!e o" the a!!ress
%i"es Po%%e!
-ultiple Interrupts
GPriority in Processor %tatus Dord
H%tatus +egister ))acti"e program
H%tatus Dord ))inacti"e program
GChanged only y pri"ileged instruction
G-ode changes ))automatic or y pri"ileged instruction
GInterrupt enale:disale# y de"ice# system)wide
Common 9unctions of Interrupts
GInterrupt transfers control to the interrupt ser"ice routine# generally through
the interrupt vector table# which contains the addresses of all the ser"ice
routines.
GInterrupt architecture must sa"e the address of the interrupted instruction
and the contents of the processor status register.
GIncoming interrupts are disabledwhile another interrupt is eing processed
to pre"ent a lost interrupt.
G! software)generated interrupt may e caused either y an error or a user
re(uest &sometimes called a trap'.
G!n operating system is interruptdri"en.
,ardware interrupts0from I:O de"ices# memory# processor#
%oftware interrupts0/eneratedy a program.
Direct -emory !ccess &D-!'
GPolling or interrupt dri"en I:O incurs considerale o"erhead
H-ultiple program instructions
H%a"ing program state
HIncrementing memory addresses
H_eeping trac$ of word count
GTransfer large amounts of data at high speed without continuous
inter"ention y the processor
G%pecial control circuit re(uired in the I:O de"ice interface# called a D-!
controller
GD-! controller $eeps trac$ of memory locations# transfers directly to
memory &"ia the us' independent of the processor
Fi$ure2 Use of #MA co"tro%%ers i" a computer s+stem
D-! Controller
GPart of the I:O de"ice interface
HD-! Channels
GPerforms functions that would normally e carried out y the processor
HPro"ides memory address
H=us signals that control transfer
H_eeps trac$ of numer of transfers
GUnder control of the processor
=us aritration
In a single us architecture when more than one de"ice re(uests the us# a controller
called us ariter decides who gets the us# this is called the us aritration.
=us -aster:
In computing# bus masteri"$ is a feature supported y many us architectures that
enales a de"ice connected to the us to initiate transactions.
!he procedure in bus communication that chooses between connected devices
contending for control of the shared busG the device currently in control of the bus
memory
Processor
Keyboard
System bus
Main
Interface
Network
Disk/DMA
controller
Printer
DM
A
controller
Disk Disk
is often termed the bus master; $evices may be allocated differing priority levels
that will determine the choice of bus master in case of contention; 4 device not
currently bus master must re/uest control of the bus before attempting to initiate
a data transfer via the bus; !he normal protocol is that only one device may be
bus master at any time and that all other devices act as slaves to this master;
Cnly a bus master may initiate a normal data transfer on the busG slave devices
respond to commands issued by the current bus master by supplying data
re/uested or accepting data sent;
Centrali;ed aritration
Distriuted aritration
9igure. ! simple arrangement for us aritration using a daisy chain.
G The us ariter may e the processor or a separate unit connected to the us.
G One us)re(uest line and one us)grant line form a daisy chain.
G This arrangement leads to considerale fle4iility in determining the order.
Processor
DMA
controller
1
DMA
controller
2
BG1 BG2
BR
BBSY
Fi$2 Se;ue"ce of Si$"a%s !uri"$ tra"sfer of mastership for the !e(ices
Distriuted !ritration
BBSY
BG1
BG2
Bus
master
BR
Tim
e
Interface circuit
for device A
0 1 0 1 0 1 1 1
O.C.
V
cc
ARB0
ARB1
ARB2
ARB3
G !ll de"ices ha"e e(ual responsiility in carrying out the aritration process.
G *ach de"ice on the us assigned an identification numer.
G Place their ID numers on four open)collector lines.
G ! winner is selected as a result.
Types of =us
%ynchronous =us
G !ll de"ices deri"e timing information from a common cloc$ line.
G *ach of these inter"als constitutes a us cycle during which one data
transfer can ta$e place.
%ynchronous =us Input Transfer
Bus
cycle
Dat
a
Bus
clock
comman
d
Address
and
t
0
t
1
t
2
Tim
e
!synchronous =us
G Data transfers on the us is ased on the use of a handsha$e etween
the master and the sal"e.
G The common cloc$ is replaced y two timing control lines# -aster)
ready and %la"e)ready.
Fi$ure2 /a"!sha6e co"tro% of !ata tra"sfer !uri"$ a" i"put operatio"
Slave-ready
Data
Master-ready
and command
Address
Bus cycle
t
1
t
2
t
3
t
4
t
5
t
0
Time
Fi$ure2 /a"!sha6e co"tro% of !ata tra"sfer !uri"$ a" output operatio"
INT*+9!C* CI+CUIT%
G Circuitry re(uired to connect an I:O de"ice to a computer us
G Pro"ides a storage uffer for at least one word of data.
G Contains status flag that can e accessed y the processor.
G Contains address)decoding circuitry
G /enerates the appropriate timing signals re(uired y the us control
scheme.
G Performs format con"ersions
G Ports
H %erial port
H Parallel port
Bus cycle
Data
Master-ready
Slave-ready
and command
Address
t
1
t
2
t
3
t
4
t
5
t
0
Time
Fi$ure2 Re+boar! to processor co""ectio"
INPUT INT*+9!C* CI+CUIT
Valid
Data
Keyboard
switches
Encoder
and
debouncing
circuit
SIN
Input
interface
Data
Address
R /
Master-ready
Slave-ready
W
DATAIN
Processor
DATAI
N
Keyboar
d
dat
a
Vali
d
Stat
us
fla
g
Rea
d-
1
Sl
a
ve
-
Rea
d-
SI
N
read
y
A3
1
A
1
A
0
Addre
ss
decod
er
Q
7
D
7
Q
0
D
0
D
7
D
0
R/ W
dat
a
stat
us
read
y
Mast
er
-
9igure . !n e4ample of a computer system using different interface
standards.
PCI &Peripheral Component Interconnect'
G PCI stands for Perip!eral 1omponent Interconnect
G Introduced in 1LL7
G It is a .ow)cost us
G It is Processor independent
G It has Plug)and)play capaility
memory
Processor
Bridge
Processor bus
PCI bus
Main
memory
Additional
controller
CD-ROM
controller
Disk
Disk 1 Disk 2
ROM
CD-
SCSI
controller
USB
controller
Video
Keyboard Game
disk
IDE
SCSI bus
ISA
interface
Ethernet
interface
PCI bus tra"sactio"s
PCI us traffic is made of a series of PCI us transactions. *ach transaction is made up of
an address p!ase followed y one or more data p!ases. The direction of the data phases
may e from initator to target &write transaction' or "ice)"ersa &read transaction'# ut all
of the data phases must e in the same direction. *ither party may pause or halt the data
phases at any point. &One common e4ample is a low)performance PCI de"ice that does
not support urst transactions# and always halts a transaction after the first data phase.'
!ny PCI de"ice may initiate a transaction. 9irst# it must re(uest permission from a PCI
us ariter on the motheroard. The ariter grant permission to one of the re(uesting
de"ices. The initiator egins the address phase y roadcasting a I7)it address plus a E)
it command code# then waits for a target to respond. !ll other de"ices e4amine this
address and one of them responds a few cycles later.
6E)it addressing is done using a 7)stage address phase. The initiator roadcasts the low
I7 address its# accompanied y a special Cdual address cycleC command code. De"ices
which do not support 6E)it addressing can simply not respond to that command code.
The ne4t cycle# the initiator transmits the high I7 address its# plus the real command
code. The transaction operates identically from that point on. To ensure compatiility
with I7)it PCI de"ices# it is foridden to use a dual address cycle if not necessary# i.e. if
the high)order address its are all ;ero.
Dhile the PCI us transfers I7 its per data phase# the initiator transmits a E)it yte
mas$ indicating which 5)it ytes are to e considered significant. In particular# a mas$ed
write must affect only the desired ytes in the target PCI de"ice.
Arbitratio"
!ny de"ice on a PCI us that is capale of acting as a us master may initiate a
transaction with any other de"ice. To ensure that only one transaction is initiated at a
time# each master must first wait for a us grant signal# /NTf# from an ariter located on
the motheroard. *ach de"ice has a separate re(uest line +*Uf that re(uests the us# ut
the ariter may Cpar$C the us grant signal at any de"ice if there are no current re(uests.
The ariter may remo"e /NTf at any time. ! de"ice which loses /NTf may complete
its current transaction# ut may not start one &y asserting 9+!-*f' unless it oser"es
/NTf asserted the cycle efore it egins.
The ariter may also pro"ide /NTf at any time# including during another master<s
transaction. During a transaction# either 9+!-*f or I+DFf or oth are assertedB when
oth are deasserted# the us is idle. ! de"ice may initiate a transaction at any time that
/NTf is asserted and the us is idle.
A!!ress phase
! PCI us transaction egins with an address p!ase. The initiator# seeing that it has
/NTf and the us is idle# dri"es the target address onto the !DOI1:8P lines# the
associated command &e.g. memory read# or I:O write' on the C:=*OI:8Pf lines# and pulls
9+!-*f low.
*ach other de"ice e4amines the address and command and decides whether to respond as
the target y asserting D*1%*.f. ! de"ice must respond y asserting D*1%*.f within
I cycles. De"ices which promise to respond within 1 or 7 cycles are said to ha"e Cfast
D*1%*.C or Cmedium D*1%*.C# respecti"ely. &!ctually# the time to respond is 7.S
cycles# since PCI de"ices must transmit all signals half a cycle early so that they can e
recei"ed three cycles later.'
Note that a de"ice must latch the address on the first cycleB the initiator is re(uired to
remo"e the address and command from the us on the following cycle# e"en efore
recei"ing a D*1%*.f response. The additional time is a"ailale only for interpreting the
address and command after it is captured.
On the fifth cycle of the address phase &or earlier if all other de"ices ha"e medium
D*1%*. or faster'# a catch)all Csutracti"e decodingC is allowed for some address
ranges. This is commonly used y an I%! us ridge for addresses within its range &7E
its for memory and 16 its for I:O'.
On the si4th cycle# if there has een no response# the initiator may aort the transaction
y deasserting 9+!-*f. This is $nown as master abort termination and it is customary
for PCI us ridges to return all)ones data &8499999999' in this case. PCI de"ices
therefore are generally designed to a"oid using the all)ones "alue in important status
registers# so that such an error can e easily detected y software.
A!!ress phase timi"$
On the rising edge of cloc$ 8# the initiator oser"es 9+!-*f and I+DFf oth high# and
/NTf low# so it dri"es the address# command# and asserts 9+!-*f in time for the rising
edge of cloc$ 1. Targets latch the address and egin decoding it. They may respond with
D*1%*.f in time for cloc$ 7 &fast D*1%*.'# I &medium' or E &slow'. %utracti"e
decode de"ices# seeing no other response y cloc$ E# may respond on cloc$ S. If the
master does not see a response y cloc$ S# it will terminate the transaction and remo"e
9+!-*f on cloc$ 6.
T+DFf and %TOPf are deasserted &high' during the address phase. The initiator may
assert I+DFf as soon as it is ready to transfer data# which could theoretically e as soon
as cloc$ 7.
#ata phases
!fter the address phase &specifically# eginning with the cycle that D*1%*.f goes low'
comes a urst of one or more data p!ases. In all cases# the initiator dri"es acti"e)low yte
select signals on the C:=*OI:8Pf lines# ut the data on the !DOI1:8P may e dri"en y the
initiator &on case of writes' or target &in case of reads'.
During data phases# the C:=*OI:8Pf lines are interpreted as acti"e)low byte enables. In
case of a write# the asserted signals indicate which of the four ytes on the !D us are to
e written to the addressed location. In the case of a read# they indicate which ytes the
initiator is interested in. 9or reads# it is always legal to ignore the yte enale signals and
simply return all I7 itsB cacheale memory resources are re(uired to always return I7
"alid its. The yte enales are mainly useful for I:O space accesses where reads ha"e
side effects.
! data phase with all four C:=*f lines deasserted is e4plicitly permitted y the PCI
standard# and must ha"e no effect on the target &other than to ad"ance the address in the
urst access in progress'.
The data phase continues until oth parties are ready to complete the transfer and
continue to the ne4t data phase. The initiator asserts I+DFf &initiator ready' when it no
longer needs to wait# while the target asserts T+DFf &target ready'. Dhiche"er side is
pro"iding the data must dri"e it on the !D us efore asserting its ready signal.
Once one of the participants asserts its ready signal# it may not ecome un)ready or
otherwise alter its control signals until the end of the data phase. The data recipient must
latch the !D us each cycle until it sees oth I+DFf and T+DFf asserted# which mar$s
the end of the current data phase and indicates that the >ust)latched data is the word to e
transferred.
To maintain full urst speed# the data sender then has half a cloc$ cycle after seeing oth
I+DFf and T+DFf asserted to dri"e the ne4t word onto the !D us.
This continues the address cycle illustrated ao"e# assuming a single address cycle with
medium D*1%*.# so the target responds in time for cloc$ I. ,owe"er# at that time#
neither side is ready to transfer data. 9or cloc$ E# the initiator is ready# ut the target is
not. On cloc$ S# oth are ready# and a data transfer ta$es place &as indicated y the
"ertical lines'. 9or cloc$ 6# the target is ready to transfer# ut the initator is not. On cloc$
M# the initiator ecomes ready# and data is transferred. 9or cloc$s 5 and L# oth sides
remain ready to transfer data# and data is transferred at the ma4imum possile rate &I7
its per cloc$ cycle'.
In case of a read# cloc$ 7 is reser"ed for turning around the !D us# so the target is not
permitted to dri"e data on the us e"en if it is capale of fast D*1%*..
Fast #EPSEL5 o" rea!s
! target that supports fast D*1%*. could in theory egin responding to a read the cycle
after the address is presented. This cycle is# howe"er# reser"ed for !D us turnaround.
Thus# a target may not dri"e the !D us &and thus may not assert T+DFf' on the second
cycle of a transaction. Note that most targets will not e this fast and will not need any
special logic to enforce this condition.
E"!i"$ tra"sactio"s
*ither side may re(uest that a urst end after the current data phase. %imple PCI de"ices
that do not support multi)word ursts will always re(uest this immediately. *"en de"ices
that do support ursts will ha"e some limit on the ma4imum length they can support#
such as the end of their addressale memory.
The initiator can mar$ any data phase as the final one in a transaction y deasserting
9+!-*f at the same time as it asserts I+DFf. The cycle after the target asserts T+DFf#
the final data transfer is complete# oth sides deassert their respecti"e +DFf signals# and
the us is idle again. The master may not deassert 9+!-*f efore asserting I+DFf# nor
may it assert 9+!-*f while waiting# with I+DFf asserted# for the target to assert
T+DFf.
The only minor e4ception is a master abort termination# when no target responds with
D*1%*.f. O"iously# it is pointless to wait for T+DFf in such a case. ,owe"er# e"en
in this case# the master must assert I+DFf for at least one cycle after deasserting
9+!-*f. &Commonly# a master will assert I+DFf efore recei"ing D*1%*.f# so it
must simply hold I+DFf asserted for one cycle longer.' This is to ensure that us
turnaround timing rules are oeyed on the 9+!-*f line.
The target re(uests the initiator end a urst y asserting %TOPf. The initiator will then
end the transaction y deasserting 9+!-*f at the ne4t legal opportunity. If it wishes to
transfer more data# it will continue in a separate transaction. There are se"eral ways to do
this:
Disconnect with data
If the target asserts %TOPf and T+DFf at the same time# this indicates that the
target wishes this to e the last data phase. 9or e4ample# a target that does not
support urst transfers will always do this to force single)word PCI transactions.
This is the most efficient way for a target to end a urst.
Disconnect without data
If the target asserts %TOPf without asserting T+DFf# this indicates that the target
wishes to stop without transferring data. %TOPf is considered e(ui"alent to
T+DFf for the purpose of ending a data phase# ut no data is transferred.
+etry
! Disconnect without data efore transferring any data is a retry# and unli$e other
PCI transactions# PCI initiators are re(uired to pause slightly efore continuing
the operation. %ee the PCI specification for details.
Target aort
Normally# a target holds D*1%*.f asserted through the last data phase.
,owe"er# if a target deasserts D*1%*.f efore disconnecting without data
&asserting %TOPf'# this indiates a target abort# which is a fatal error condition.
The initiator may not retry# and typically treats it as a us error. Note that a target
may not deassert D*1%*.f while waiting with T+DFf or %TOPf lowB it must
do this at the eginning of a data phase.
!fter seeing %TOPf# the initiator will terminate the transaction at the ne4t legal
opportunity# ut if it has already signaled its desire to continue a urst &y asserting
I+DFf without deasserting 9+!-*f'# it is not permitted to deassert 9+!-*f until the
following data phase. ! target that re(uests a urst end &y asserting %TOPf' may ha"e
to wait through another data phase &holding %TOPf asserted without T+DFf' efore the
transaction can end.
Tab%e F2A2 #ata tra"sfer si$"a%s o" the PCI bus2
+ead operation on the PCI =us
1 2 3 4 5 6 7
CLK
Frame#
AD
C/BE#
IRDY#
TRDY#
DEVSEL#
Adres
s
#
1
#
4
Cmn
d
Byte
enable
#
2
#
3
+ead operation showing the role of the I+DFf# T+DFf
%C%I =us
G Defined y !N%I H KI.1I1
G "mall 1omputer "ystem Interface
G S8# 65 or 58 pins
G -a4. transfer rate H 168 -=:s# I78 -=:s.
1 2 3 4 5 6 7 8 9
CLK
Frame#
AD
C/BE#
IRDY#
TRDY#
DEVSEL#
Adres
s
#
1
#
2
#
3
#4
Cmn
d
Byte
enable
%C%I =us %ignals
U%=
G >niversal "erial Bus
G %peed
G .ow)speed&1.S -:s'
G 9ull)speed&17 -:s'
G ,igh)speed&E58 -:s'
G Port .imitation
G De"ice Characteristics
G Plug)and)play
Uni"ersal %erial =us Tree %tructure
USB &U"i(ersa% Seria% Bus' is a specification to estalish communication etween
de"ices and a host controller &usually personal computers'. U%= is intended to replace
many "arieties of serial and parallel ports. U%= can connect computer peripherals such as
mice# $eyoards# digital cameras# printers# personal media players# flash dri"es# and
e4ternal hard dri"es. 9or many of those de"ices# U%= has ecome the standard
connection method. U%= was designed for personal computers
Ocitation neededP
# ut it has
ecome commonplace on other de"ices such as smartphones# PD!s and "ideo game
consoles# and as a power cord etween a de"ice and an !C adapter plugged into a wall
plug for charging. !s of 7885# there are aout 7 illion U%= de"ices sold per year# and
appro4imately 6 illion total sold to date.
Host
computer
Root
hub
b
Hub
I/
O
device
Hub
I/O
de vice
I/
O
device
Hub
I/
O
device
I/
O
device
I/
O
device
The design of U%= is standardi;ed y the U%= Implementers 9orum &U%=)I9'# an
industry standards ody incorporating leading companies from the computer and
electronics industries. Notale memers ha"e included !gere &now merged with .%I
Corporation'# !pple Inc.# ,ewlett)Pac$ard# Intel# -icrosoft and N*C.
%plit =us Operation
Si$"a%i"$
U%= supports following signaling rates:
! %o0 spee! rate of 1.S -it:s is defined y U%= 1.8. It is "ery similar to Cfull
speedC operation e4cept each it ta$es 5 times as long to transmit. It is intended
primarily to sa"e cost in low)andwidth human interface de"ices &,ID' such as
$eyoards# mice# and >oystic$s.
The fu%% spee! rate of 17 -it:s is the asic U%= data rate defined y U%= 1.1.
!ll U%= hus support full speed.
! hispee! &U%= 7.8' rate of E58 -it:s was introduced in 7881. !ll hi)speed
de"ices are capale of falling ac$ to full)speed operation if necessaryB they are
ac$ward compatile. Connectors are identical.
! SuperSpee! &U%= I.8' rate of S.8 /it:s. The U%= I.8 specification was
released y Intel and partners in !ugust 7885# according to early reports from
CN*T news. The first U%= I controller chips were sampled y N*C -ay 788L
O11P
and products using the I.8 specification are e4pected to arri"e eginning in UI
788L and 7818.
O17P
U%= I.8 connectors are generally ac$wards compatile# ut
include new wiring and full duple4 operation. There is some incompatiility with
older connectors.
U%= signals are transmitted on a raided pair data cale with L8g h1ST Characteristic
impedance#
O1IP
laeled D2 and Di. Prior to U%= I.8# These collecti"ely use half)duple4
differential signaling to reduce the effects of electromagnetic noise on longer lines.
Transmitted signal le"els are 8.8H8.I "olts for low and 7.5HI.6 "olts for high in full speed
&9%' and low speed &.%' modes# and i18H18 m1 for low and I68HEE8 m1 for high in hi)
speed &,%' mode. In 9% mode the cale wires are not terminated# ut the ,% mode has
termination of ES g to ground# or L8 g differential to match the data cale impedance#
reducing interference of particular $inds. U%= I.8 introduces two additional pairs of
shielded twisted wire and new# mostly interoperale contacts in U%= I.8 cales# for
them. They permit the higher data rate# and full duple4 operation.
! U%= connection is always etween a host or hu at the C!C connector end# and a
de"ice or hu<s CupstreamC port at the other end. Originally# this was a C=< connector#
pre"enting erroneous loop connections# ut additional upstream connectors were
specified# and some cale "endors designed and sold cales which permitted erroneous
connections &and potential damage to the circuitry'. U%= interconnections are not as fool)
proof or as simple as originally intended.
The host includes 1S $g pull)down resistors on each data line. Dhen no de"ice is
connected# this pulls oth data lines low into the so)called Csingle)ended ;eroC state &%*8
in the U%= documentation'# and indicates a reset or disconnected connection.
! U%= de"ice pulls one of the data lines high with a 1.S $g resistor. This o"erpowers
one of the pull)down resistors in the host and lea"es the data lines in an idle state called
C3C. 9or U%= 1.4# the choice of data line indicates a de"ice<s speed supportB full)speed
de"ices pull D2 high# while low)speed de"ices pull Di high.
U%= data is transmitted y toggling the data lines etween the 3 state and the opposite _
state. U%= encodes data using the N+YI con"entionB a 8 it is transmitted y toggling the
data lines from 3 to _ or "ice)"ersa# while a 1 it is transmitted y lea"ing the data lines
as)is. To ensure a minimum density of signal transitions# U%= uses it stuffingB an e4tra 8
it is inserted into the data stream after any appearance of si4 consecuti"e 1 its. %e"en
consecuti"e 1 its is always an error. U%= I.88 has introduced additional data
transmission encodings.
! U%= pac$et egins with an 5)it synchroni;ation se(uence 88888881. That is# after the
initial idle state 3# the data lines toggle _3_3_3__. The final 1 it &repeated _ state'
mar$s the end of the sync pattern and the eginning of the U%= frame.
! U%= pac$et<s end# called *OP &end)of)pac$et'# is indicated y the transmitter dri"ing 7
it times of %*8 &D2 and Di oth elow ma4' and 1 it time of 3 state. !fter this# the
transmitter ceases to dri"e the D2:Di lines and the aforementioned pull up resistors hold
it in the 3 &idle' state. %ometimes s$ew due to hus can add as much as one it time
efore the %*8 of the end of pac$et. This e4tra it can also result in a Cit stuff "iolationC
if the si4 its efore it in the C+C are <1<s. This it should e ignored y recei"er.
! U%= us is reset using a prolonged &18 to 78 milliseconds' %*8 signal.
U%= 7.8 de"ices use a special protocol during reset# called CchirpingC# to negotiate the
high speed mode with the host:hu. ! de"ice that is ,% capale first connects as an 9%
de"ice &D2 pulled high'# ut upon recei"ing a U%= +*%*T &oth D2 and Di dri"en
.OD y host for 18 to 78 m%' it pulls the Di line high# $nown as chirp _. This indicates
to the host that the de"ice is high speed. If the host:hu is also ,% capale# it chirps
&returns alternating 3 and _ states on Di and D2 lines' letting the de"ice $now that the
hu will operate at high speed. The de"ice has to recei"e at least I sets of _3 chirps
efore it changes to high speed terminations and egins high speed signaling. =ecause
U%= I.8 use wiring separate and additional to that used y U%= 7.8 and U%= 1.4# such
speed negotiation is not re(uired.
Cloc$ tolerance is E58.88 -it:s hS88 ppm# 17.888 -it:s h7S88 ppm# 1.S8 -it:s
h1S888 ppm.
Though high speed de"ices are commonly referred to as CU%= 7.8C and ad"ertised as Cup
to E58 -it:sC# not all U%= 7.8 de"ices are high speed. The U%=)I9 certifies de"ices and
pro"ides licenses to use special mar$eting logos for either Casic speedC &low and full' or
high speed after passing a compliance test and paying a licensing fee. !ll de"ices are
tested according to the latest specification# so recently)compliant low speed de"ices are
also 7.8 de"ices.
#ata pac6ets
U%= communication ta$es the form of pac$ets. Initially# all pac$ets are sent from the
host# "ia the root hu and possily more hus# to de"ices. %ome of those pac$ets direct a
de"ice to send some pac$ets in reply.
!fter the sync field descried ao"e# all pac$ets are made of 5)it ytes# transmitted
least)significant it first. The first yte is a pac$et identifier &PID' yte. The PID is
actually E itsB the yte consists of the E)it PID followed y its itwise complement.
This redundancy helps detect errors. &Note also that a PID yte contains at most four
consecuti"e 1 its# and thus will ne"er need it)stuffing# e"en when comined with the
final 1 it in the sync yte. ,owe"er# trailing 1 its in the PID may re(uire it)stuffing
within the first few its of the payload.'
/a"!sha6e pac6ets
,andsha$e pac$ets consist of nothing ut a PID yte# and are generally sent in response
to data pac$ets. The three asic types are ACR# indicating that data was successfully
recei"ed# NAR# indicating that the data cannot e recei"ed at this time and should e
retried# and STALL# indicating that the de"ice has an error and will ne"er e ale to
successfully transfer data until some correcti"e action &such as de"ice initiali;ation' is
performed.
U%= 7.8 added two additional handsha$e pac$ets# NYET which indicates that a split
transaction is not yet complete. ! NF*T pac$et is also used to tell the host that the
recei"er has accepted a data pac$et# ut cannot accept any more due to uffers eing full.
The host will then send PIN/ pac$ets and will continue with data pac$ets once the
de"ice !C_<s the PIN/. The other pac$et added was the ERR handsha$e to indicate that
a split transaction failed.
The only handsha$e pac$et the U%= host may generate is !C_B if it is not ready to
recei"e data# it should not instruct a de"ice to send any.
To6e" pac6ets
To$en pac$ets consist of a PID yte followed y 7 payload ytes: 11 its of address and a
S)it C+C. To$ens are only sent y the host# ne"er a de"ice.
IN and OUT to$ens contain a M)it de"ice numer and E)it function numer &for
multifunction de"ices' and command the de"ice to transmit D!T!4 pac$ets# or recei"e
the following D!T!4 pac$ets# respecti"ely.
!n IN to$en e4pects a response from a de"ice. The response may e a N!_ or %T!..
response# or a D!T!4 frame. In the latter case# the host issues an !C_ handsha$e if
appropriate.
!n OUT to$en is followed immediately y a D!T!4 frame. The de"ice responds with
!C_# N!_# NF*T# or %T!..# as appropriate.
SETUP operates much li$e an OUT to$en# ut is used for initial de"ice setup. It is
followed y an 5)yte D!T!8 frame with a standardi;ed format.
*"ery millisecond &17888 full)speed it times'# the U%= host transmits a special SOF
&start of frame' to$en# containing an 11)it incrementing frame numer in place of a
de"ice address. This is used to synchroni;e isochronous data flows. ,igh)speed U%= 7.8
de"ices recei"e M additional duplicate %O9 to$ens per frame# each introducing a 17S es
CmicroframeC &68888 high)speed it times each'.
U%= 7.8 added a PIN8 to$en# which as$s a de"ice if it is ready to recei"e an
OUT:D!T! pac$et pair. The de"ice responds with !C_# N!_# or %T!..# as
appropriate. This a"oids the need to send the D!T! pac$et if the de"ice $nows that it
will >ust respond with N!_.
U%= 7.8 also added a larger I)yte SPLIT to$en with a M)it hu numer# 17 its of
control flags# and a S)it C+C. This is used to perform split transactions. +ather than tie
up the high)speed U%= us sending data to a slower U%= de"ice# the nearest high)speed
capale hu recei"es a %P.IT to$en followed y one or two U%= pac$ets at high speed#
performs the data transfer at full or low speed# and pro"ides the response at high speed
when prompted y a second %P.IT to$en. The details are comple4B see the U%=
specification.
#ata pac6ets
! data pac$et consists of the PID followed y 8H187I ytes of data payload &up to 187E
in high speed# at most 5 at low speed'# and a 16)it C+C.
There are two asic data pac$ets# #ATA4 and #ATA3. They must always e preceded
y an address to$en# and are usually followed y a handsha$e to$en from the recei"er
ac$ to the transmitter. The two pac$et types pro"ide the 1)it se(uence numer re(uired
y %top)and)wait !+U. If a U%= host does not recei"e a response &such as an !C_' for
data it has transmitted# it does not $now if the data was recei"ed or notB the data might
ha"e een lost in transit# or it might ha"e een recei"ed ut the handsha$e response was
lost.
To sol"e this prolem# the de"ice $eeps trac$ of the type of D!T!4 pac$et it last
accepted. If it recei"es another D!T!4 pac$et of the same type# it is ac$nowledged ut
ignored as a duplicate. Only a D!T!4 pac$et of the opposite type is actually recei"ed.
Dhen a de"ice is reset with a %*TUP pac$et# it e4pects an 5)yte D!T!8 pac$et ne4t.
U%= 7.8 added #ATA* and M#ATA pac$et types as well. They are used only y high)
speed de"ices doing high)andwidth isochronous transfers which need to transfer more
than 187E ytes per 17S es CmicroframeC &51L7 $=:s'.
PRE Kpac6etK
.ow)speed de"ices are supported with a special PID "alue# PRE. This mar$s the
eginning of a low)speed pac$et# and is used y hus which normally do not send full)
speed pac$ets to low)speed de"ices. %ince all PID ytes include four 8 its# they lea"e the
us in the full)speed _ state# which is the same as the low)speed 3 state. It is followed y
a rief pause during which hus enale their low)speed outputs# already idling in the 3
state# then a low)speed pac$et follows# eginning with a sync se(uence and PID yte# and
ending with a rief period of %*8. 9ull)speed de"ices other than hus can simply ignore
the P+* pac$et and its low)speed contents# until the final %*8 indicates that a new pac$et
follows.
U%= Pac$et 9ormat
Output Transfer
U%= 9+!-*%
&a' %O9 Pac$et
PI
D
Frame number CRC
5
8 1
1
5 Bit
s
S T3 D S
1-ms frame
T7 D T3 D
S - Start-of-frame packet
Tn- Token packet, address = n
D - Data packet
A - ACK packet
(b) Frame
example