2/15/2008 Pro g ra mming Anno unc e me nts FIT100 FIT100 FIT100 - - PDF document

2 15 2008
SMART_READER_LITE
LIVE PREVIEW

2/15/2008 Pro g ra mming Anno unc e me nts FIT100 FIT100 FIT100 - - PDF document

2/15/2008 Pro g ra mming Anno unc e me nts FIT100 FIT100 FIT100 FIT100 FIT100 FIT100 Why is pro g ra mming fun? No c la sse s a t UW o n Mo nda y Pre side nt s Da y F ina lly, the re is the de lig ht o f wo rking


slide-1
SLIDE 1

2/15/2008 1

FIT100 FIT100 FIT100

Pro g ra mming

  • Why is pro g ra mming fun?
  • F

ina lly, the re is the de lig ht o f wo rking in suc h a tra c ta b le me dium. T he pro g ra mme r, like the t k l li htl d f po e t, wo rks o nly slig htly re -mo ve d fro m pure tho ug ht-stuff. He b uilds his c a stle s in the a ir, fro m a ir, c re a ting b y e xe rtio n o f the ima g ina tio n. F e w me dia o f c re a tio n a re so fle xib le , so e a sy to po lish a nd re wo rk, so re a dily c a pa b le o f re a lizing g ra nd c o nc e ptua l struc ture s. Source: Frederick P. Brooks, Jr. The Mythical Man-Month Essays on Software Engineering.

FIT100 FIT100 FIT100

Anno unc e me nts

  • No c la sse s a t UW o n Mo nda y

∗ Pre side nt’ s Da y

  • Se e the c o urse c a le nda r fo r upda te s
  • Se e the c o urse c a le nda r fo r upda te s

to re a ding s

  • Ne w e xtra -c re dit la b 9 ha s b e e n

linke d

  • T

W la b s fo r the ne xt two we e ks: wo rk o n pro je c ts, whic h a re due o n We dne sda ys a t 11pm. FIT100 FIT100 FIT100

F

  • llo wing I

nstruc tio ns

Princ iple s o f Co mpute r Ope ratio n, o r H

  • w Co mpute rs

Wo rk FIT100 FIT100 FIT100

I nstruc tio n E xe c utio n E ng ine s

  • Wha t c o mpute rs c a n do

∗ Pe rfo rm o r e xe c ute instruc tio ns to pro c e ss info rma tio n

  • T

he c o mpute r must ha ve instruc tio ns to fo llo w

9-4

T he c o mpute r must ha ve instruc tio ns to fo llo w

Short list!

FIT100 FIT100 FIT100

I nstruc tio n E xe c utio n E ng ine s

  • Wha t c o mpute rs c a n't do

∗ Ha ve no ima g ina tio n o r c re a tivity ∗ Ha ve no intuitio n

9-5

∗ Ha ve no se nse o f iro ny, sub tle ty, pro po rtio n, de c o rum, o r humo r ∗ Are no t vindic tive o r c rue l ∗ Are no t purpo se ful ∗ Ha ve no fre e will ∗ Re c e nt mo vie s: T e rmina to r, Ma trix, AI Long list!

FIT100 FIT100 FIT100

Ana to my o f a Co mpute r

  • Co mpute rs ha ve five b a sic pa rts o r sub syste ms

∗ Me mo ry, c o ntro l unit, a rithme tic / lo g ic unit (AL U), input unit, o utput unit

9-6

slide-2
SLIDE 2

2/15/2008 2

FIT100 FIT100 FIT100

Me mo ry

  • Me mo ry sto re s the pro g ra m running a nd the

da ta o n whic h the pro g ra m o pe ra te s

  • Pro pe rtie s o f me mo ry:

9-7

∗ Disc re te lo c a tio ns—1 b yte pe r lo c a tio n! ∗ Addre sse s—F

  • r e ve ry me mo ry lo c a tio n (b yte )
  • who le numb e rs sta rting with ze ro

∗ Va lue s—Me mo ry lo c a tio ns sto re va lue s. ∗ F inite c a pa c ity—L imite d size —d a ta ma y no t "fit" in the me mo ry lo c a tio n.

  • Ove rflo w c o nditio ns, b uffe r o ve rruns

FIT100 FIT100 FIT100

Byte -Size Me mo ry L

  • c a tio n
  • A c o mmo nly use d dia g ra m o f c o mpute r

me mo ry re pre se nts the disc re te lo c a tio ns a s b o xe s (1 b yte e a c h).

9-8

  • Addre ss o f lo c a tio n is displa ye d a b o ve

the b o x.

  • Va lue o r c o nte nts o f lo c a tio n is sho wn in

the b o x.

FIT100 FIT100 FIT100

Me mo ry (c o nt'd)

  • 1-b yte me mo ry lo c a tio ns c a n sto re
  • ne ASCI

I c ha ra c te r, o r a numb e r le ss tha n 256 (0 - 255)

9-9

  • Pro g ra mme rs use a se q ue nc e o f

me mo ry lo c a tio ns to g e the r, ig no ring the fa c t tha t the y a ll ha ve diffe re nt a ddre sse s

∗ Blo c ks o f fo ur b yte s a re use d a s a unit so fre q ue ntly tha t the y a re c a lle d me mo ry "wo rds"

FIT100 FIT100 FIT100

Ra ndo m Ac c e ss Me mo ry (RAM)

  • "Ra ndo m a c c e ss" me a ns the c o mpute r

c a n re fe r to (a c c e ss) the me mo ry lo c a tio ns in a ny o rde r

9-10

  • Ofte n me a sure d in

me g a b yte s (MB) – millio ns o f b yte s o r g ig a b yte s (GB) – b illio ns o f b yte s

  • L

a rg e me mo ry is pre fe ra b le b e c a use the re is mo re spa c e fo r pro g ra ms a nd da ta (whic h usua lly e q ua te s to le ss I / O)

FIT100 FIT100 FIT100

Co ntro l Unit

  • I

ts c irc uitry fe tc he s a n instruc tio n fro m me mo ry, de c o de s the instruc tio n, a nd fe tc he s the

  • pe ra nds use d in it

∗ A typic a l instruc tio n mig ht ha ve the fo rm

9-11

yp g ADD 4000, 2000, 2080

  • p dest, sr

c1, sr c2 ∗ T his instruc tio n a sks tha t the numb e rs sto re d in lo c a tio ns 2000 a nd 2080 b e a d d e d to g e the r, a nd the re sult sto re d in lo c a tio n 4000 [4000] = [2000] + [2080] ∗ Da ta / Ope ra nd F e tc h ste p must g e t the se two va lue s a nd a fte r the y a re a dde d, Re sult Re turn/ Sto re ste p will sto re the a nswe r in lo c a tio n 4000

FIT100 FIT100 FIT100

9-12

slide-3
SLIDE 3

2/15/2008 3

FIT100 FIT100 FIT100

Arithme tic / L

  • g ic Unit

(AL U)

  • Pe rfo rms the ma th

∗ A c irc uit in the AL U c a n a d d two numb e rs ∗ Othe r c irc uits do multiplic a tio n, c o mpa riso ns, e tc .

i j f

9-13

  • I

nstruc tio ns tha t just tra nsfe r da ta usua lly do n't use the AL U

  • Da ta / Ope ra nd F

e tc h ste p o f the Cyc le g e ts the va lue s tha t the AL U ne e ds to wo rk o n (o pe ra nd s)

  • Afte r the AL

U c o mple te s a n o pe ra tio n, the a nswe r is mo ve d fro m the AL U to the de stina tio n me mo ry a ddre ss spe c ifie d in the instruc tio n

∗ ta xDue = ta xRa te [WA] * sub to ta l;

FIT100 FIT100 FIT100

I nput Unit a nd Output Unit (I / O)

  • T

he wire s a nd c irc uits thro ug h whic h info rma tio n mo ve s into a nd o ut o f a c o mpute r

9-14

  • Pe riphe rals

∗ Co nne c t to the c o mpute r input/ o utput po rts. ∗ No t c o nside re d pa rt o f the c o mpute r, b ut spe c ia lize d g a dg e ts tha t e nc o de o r de c o de info rma tio n b e twe e n the c o mpute r a nd the physic a l wo rld.

  • Mo de ms, mo nito rs, sc a nne rs, printe rs, ke yb o a rd,

mo use , dig itizing pa d, mic , spe a ke rs

FIT100 FIT100 FIT100

T he Pe riphe ra ls

  • K

e yb o a rd e nc o de s ke ystro ke s we type into b ina ry fo rm fo r the c o mpute r

  • Mo nito r de c o de s info rma tio n fro m the

9-15

c o mpute r's me mo ry a nd displa ys it o n a lig hte d, c o lo re d sc re e n

  • Disks drive s a re use d fo r b o th input a nd
  • utput—sto ra g e de vic e s whe re the

c o mpute r puts a wa y info rma tio n whe n it is no t ne e de d, a nd c a n re trie ve fro m whe n it is ne e de d a g a in

FIT100 FIT100 FIT100

A De vic e Drive r fo r E ve ry Pe riphe ra l

  • "Dumb " de vic e s pro vide b a sic physic a l

tra nsla tio n to o r fro m b ina ry sig na ls.

  • Additio na l info rma tio n fro m the c o mpute r

9-16

is ne e de d to ma ke it o pe ra te inte llig e ntly.

  • e .g ., c o mpute r re c e ive s info rma tio n tha t

use r type d shift a nd w a t the sa me time . I t c o nve rts to a c a pita l W. T he so ftwa re tha t c o nve rts is c a lle d the de vic e drive r.

FIT100 FIT100 FIT100 T he Pro g ra m Co unte r: T he Pc 's PC

  • Ho w do e s the c o mpute r de te rmine whic h ste p

to e xe c ute ne xt?

  • Addre ss o f the ne xt instruc tio n is sto re d in the

Co ntro l Unit in the pro gram c o unte r (PC)

9-17

Co ntro l Unit in the pro gram c o unte r (PC).

  • Be c a use instruc tio ns use 4 b yte s o f me mo ry, the

ne xt instruc tio n must b e a t PC + 4, 4 b yte s furthe r a lo ng in the se q ue nc e (in g e ne ra l).

  • Co mpute r a dds fo ur to the PC, so whe n the F

/ E Cyc le g e ts b a c k to I nstruc tio n F e tc h ste p , the PC is "po inting a t" the ne xt instruc tio n.

FIT100 FIT100 FIT100

Bra nc h a nd Jump I nstruc tio ns

  • T

he instruc tio n ma y inc lude a n a ddre ss to g o to ne xt. T his c ha ng e s the PC, so inste a d o f g o ing to PC +4 t ti ll th t "j "

9-18

a uto ma tic a lly, the c o mpute r "jumps"

  • r "b ra nc he s" to the spe c ifie d

lo c a tio n.

slide-4
SLIDE 4

2/15/2008 4

FIT100 FIT100 FIT100

I nstruc tio n I nte rpre ta tio n

  • Pro c e ss o f e xe c uting a pro g ra m

∗ Co mpute r is inte rpre ting o ur c o mma nds, b ut in its o wn la ng ua g e

9-19

  • Be fo re the F

/ E Cyc le b e g ins, so me o f the me mo ry lo c a tio ns a nd the PC a re visib le in the c o ntro l unit FIT100 FIT100 FIT100

9-20

FIT100 FIT100 FIT100

T he F e tc h/ E xe c ute Cyc le

  • A five -ste p c yc le :
  • 1. I

nstruc tio n F e tc h (I F ) 2 I nstruc tio n De c o de (I D)

9-21

  • 2. I

nstruc tio n De c o de (I D)

  • 3. Da ta F

e tc h (DF) / Ope ra nd F e tc h (OF )

  • 4. I

nstruc tio n E xe c utio n (E X)

  • 5. Re sult Re turn (RR) / Sto re (ST

)

FIT100 FIT100 FIT100

Anima tio n

  • F

e tc h/ E xe c ute Cyc le FIT100 FIT100 FIT100

Cyc ling the F / E Cyc le

  • Co mpute rs g e t the ir impre ssive

c a pa b ilitie s b y e xe c uting ma ny o f the se simple instruc tio ns pe r se c o nd

9-23

  • T

he Co mpute r Clo c k: De te rmine s ra te o f F / E Cyc le

∗ Me a sure d in g ig a he rtz (GHz), o r b illio ns

  • f c yc le s pe r se c o nd

FIT100 FIT100 FIT100

Ho w I mpo rta nt is Clo c k Spe e d?

  • Mo de rn c o mpute rs try to sta rt a n instruc tio n o n

e a c h c lo c k tic k

  • Pa ss o ff finishing instruc tio n to o the r c irc uitry

(pipe lining)

9-24

(pipe lining)

∗ F ive instruc tio ns c a n b e in pro c e ss a t the sa me time

  • Do e s a 1 GHz c lo c k re a lly e xe c ute a b illio n

instruc tio ns pe r se c o nd?

∗ No t a pre c ise me a sure me nt. Co mpute r ma y no t b e a b le to sta rt a n instruc tio n o n e a c h tic k, b ut ma y so me time s b e a b le to sta rt mo re tha n o ne instruc tio n a t a time

slide-5
SLIDE 5

2/15/2008 5

FIT100 FIT100 FIT100

9-25

FIT100 FIT100 FIT100

So ftwa re

  • A c o mpute r's vie w o f so ftwa re

∗ Se e s binary o bje c t file , a lo ng se q ue nc e o f 4- b yte wo rds (0's a nd 1's)

  • Asse mbly language

9-26

  • Asse mbly language

∗ Alte rna tive fo rm o f ma c hine la ng ua g e using le tte rs a nd no rma l numb e rs so pe o ple c a n unde rsta nd it ∗ Co mpute r sc a ns a sse mb le c o de , a s it e nc o unte rs wo rds it lo o ks the m up in a ta b le to c o nve rt to b ina ry, c o nve rts numb e rs to b ina ry, the n a sse mb le s the b ina ry pie c e s into a n instruc tio n

FIT100 FIT100 FIT100

9-27

FIT100 FIT100 FIT100

Ope ra ting Syste ms

  • Ba sic o pe ra tio ns tha t a re ne c e ssa ry fo r

the e ffe c tive use o f c o mpute r, b ut a re no t b uilt into the ha rdwa re T h t id l d O ti

9-28

  • T

hre e mo st wide ly use d Ope ra ting Syste ms:

∗ Mic ro so ft Windo ws ∗ Apple 's Ma c OS X ∗ Unix / L inux

  • OS pe rfo rms b o o ting , me mo ry

ma na g e me nt, de vic e ma na g e me nt, I nte rne t c o nne c tio n, file ma na g e me nt

FIT100 FIT100 FIT100

Pro g ra mming

  • Pro g ra mme rs b uild o n pre vio usly

de ve lo pe d so ftwa re to ma ke the ir jo b s e a sie r

9-29

j

  • E

xa mple : GUI So ftwa re

∗ F ra me a ro und windo w, slide r b a rs, b utto ns, po inte rs, e tc . a re pa c ka g e d fo r pro g ra mme rs a nd g ive n with OS

FIT100 FIT100 FIT100

I nte g ra te d Circ uits

  • Minia turiza tio n:

∗ Clo c k spe e ds a re so hig h b e c a use pro c e sso r c hips a re so tiny (e le c tric a l

9-30

p p y ( sig na ls c a n tra ve l a b o ut 1 fo o t in a na no se c o nd)

slide-6
SLIDE 6

2/15/2008 6

FIT100 FIT100 FIT100

I nte g ra te d Circ uits

  • Pho to litho g ra phy

∗ Printing pro c e ss. I nste a d o f ha nd-wiring c irc uits to g e the r, pho to g ra ph wha t is

9-31

c irc uits to g e the r, pho to g ra ph wha t is wa nte d a nd e tc h a wa y the spa c e s ∗ Re g a rdle ss o f ho w c o mplic a te d the wiring , c o st a nd a mo unt o f wo rk a re the sa me

FIT100 FIT100 FIT100

9-32

FIT100 FIT100 FIT100

9-33

FIT100 FIT100 FIT100

Ho w Se mi-Co nduc to r T e c hno lo g y Wo rks

  • I

nte g ra tio n:

∗ Ac tive c o mpo ne nts a nd the wire s tha t c o nne c t the m a re a ll ma de to g e the r o f simila r ma te ria ls in a sing le pro c e ss

9-34

ma te ria ls in a sing le pro c e ss ∗ Sa ve s spa c e a nd pro duc e s mo no lithic pa rt fo r the who le syste m, whic h is mo re re lia b le

  • Silic o n is a se mi-c o nduc to r—so me time s it

c o nduc ts e le c tric ity, so me time s no t

∗ Ab ility to c o ntro l whe n se mi-c o nduc to r c o nduc ts is the ma in to o l in c o mpute r c o nstruc tio n

FIT100 FIT100 FIT100

T he On-Ag a in, Off-Ag a in Be ha vio r o f Silic o n

  • A c irc uit is se t to c o mpute x a nd y fo r a ny

lo g ic a l va lue s x a nd y

  • I

f x is true , the x c irc uit c o nduc ts e le c tric ity

9-35

I f x is true , the x c irc uit c o nduc ts e le c tric ity a nd a sig na l pa sse s to the o the r e nd o f the wire ; if x is fa lse , no sig na l pa sse s

  • Sa me pro c e ss fo r y
  • I

f b o th c irc uits c o nduc t, x a nd y a re true — lo g ic a l AND ha s b e e n c o mpute d

FIT100 FIT100 FIT100

T he F ie ld E ffe c t

  • Co ntro ls the c o nduc tivity o f the

se mic o nduc to r

  • Ob je c ts c a n b e c o me c ha rg e d po sitive ly

9-36

  • r ne g a tive ly

∗ L ike c ha rg e s re pe l e a c h o the r, b ut o ppo site s a ttra c t. T his e ffe c t is c a lle d the fie ld e ffe c t.

slide-7
SLIDE 7

2/15/2008 7

FIT100 FIT100 FIT100

T he F ie ld E ffe c t (c o nt'd)

  • T

he g a p b e twe e n two wire s is tre a te d to impro ve its c o nduc ting a nd no n-c o nduc ting pro pe rtie s

  • T

his is c a lle d a c hanne l (pa th fo r e le c tric ity to tra ve l b e twe e n the two wire s)

9-37

a e b e e e e

  • e s)
  • An insula to r c o ve rs the c ha nne l
  • A wire c a lle d the gate pa sse s o ve r the insula to r
  • T

he g a te is se pa ra te d fro m the c ha nne l b y the insula to r—do e s no t ma ke c o nta c t with the wire s

  • r the c ha nne l
  • E

le c tric ity is no t c o nduc te d b e twe e n the two wire s unle ss the c ha nne l is c o nduc ting

FIT100 FIT100 FIT100

Ho w Do e s the Cha nne l Co nduc t?

  • T

he silic o n in the c ha nne l c o nduc ts e le c tric ity whe n it is in a c ha rg e d fie ld

9-38

∗ E le c tro ns a re a ttra c te d o r re pe lle d in the silic o n ma te ria l ∗ Cha rg ing the g a te po sitive ly c re a te s a fie ld o ve r the c ha nne l tha t c o nduc ts e le c tric ity b e twe e n the two wire s

FIT100 FIT100 FIT100

T ra nsisto rs

  • A c o nne c to r b e twe e n two wire s tha t

c a n b e c o ntro lle d to a llo w c ha rg e to flo w b e twe e n the two wire s, o r

9-39

, no t

  • We ha ve de sc rib e d a MOS tra nsisto r

(Me ta l Oxide Se mic o nduc to r) FIT100 FIT100 FIT100

9-40

FIT100 FIT100 FIT100

9-41

FIT100 FIT100 FIT100

Co mb ining the I de a s

  • Put a ll the se ide a s to g e the r:

∗ Sta rt with info rma tio n pro c e ssing ta sk ∗ T a sk is pe rfo rme d b y a pplic a tio n, imple me nte d a s pa rt o f a la rg e pro g ra m in a hig h-le ve l la ng ua g e like C o r Ja va

9-42

∗ Pro g ra m pe rfo rms spe c ific o pe ra tio ns; sta nda rd o pe ra tio ns like print o r sa ve a re do ne b y OS ∗ Pro g ra m's c o mma nds a re c o mpile d into a sse mb ly la ng ua g e instruc tio ns ∗ Asse mb ly instruc tio ns a re tra nsla te d into b ina ry c o de ∗ Bina ry instruc tio ns a re sto re d o n ha rd disk (se c o nda ry me mo ry) ∗ Applic a tio n instruc tio ns mo ve into RAM (prima ry me mo ry)

slide-8
SLIDE 8

2/15/2008 8

FIT100 FIT100 FIT100

Co mb ining the se I de a s (c o nt'd)

∗ F e tc h/ E xe c ute Cyc le e xe c ute s the instruc tio ns ∗ All the c o mpute r's instruc tio ns a re

9-43

pe rfo rme d b y the AL U c irc uits, using the tra nsisto r mo de l pre vio usly de sc rib e d, unde r the c o ntro l o f the Co ntro l Unit

FIT100 FIT100 FIT100

9-44