Digitl Design Chpter : Introduction Slides to ccompny the textbook Digitl Design, with RTL Design, VHDL, nd Verilog, 2nd Edition, by, John Wiley nd Sons Publishers, 2. http://www.ddvhid.com Copyright 2 Instructors of courses requiring Vhid's Digitl Design textbook (published by John Wiley nd Sons) hve permission to modify nd use these slides for customry course-relted ctivities, subject to keeping this copyright notice in plce nd unmodified. These slides my be posted s unnimted pdf versions on publicly-ccessible course websites.. PowerPoint source (or pdf with nimtions) Digitl my Design not be posted 2e to publicly-ccessible websites, but my be posted for students on internl protected sites or distributed directly to students by other electronic mens. Instructors my Copyright mke printouts 2 of the slides vilble to students for resonble photocopying chrge, without incurring roylties. Any other use requires explicit permission. Instructors my obtin PowerPoint source or obtin specil use permissions from Wiley see http://www.ddvhid.com for informtion.
Why Study Digitl Design?. Look under the hood of computers Solid understnding --> confidence, insight, even better progrmmer when wre of hrdwre resource issues Electronic devices becoming digitl Enbled by shrinking nd more cpble chips Enbles: Better devices: Sound recorders, cmers, crs, cell phones, medicl devices,... New devices: Video gmes, PDAs,... Known s embedded systems Thousnds of new devices every yer Designers needed: Potentil creer direction Stellites Portble music plyers Cell phones DVD plyers Video recorders Musicl instruments Cmers TVs??? Copyright 2 995 997 999 2 23 25 27 Yers shown bove indicte when digitl version begn to dominte (Not the first yer tht digitl version ppered) 2
Anlog signl Wht Does Digitl Men? Infinite possible vlues Ex: voltge on wire creted by microphone Digitl signl Finite possible vlues Ex: button pressed on keypd.2 Sound wves move the membrne, 2 3 4 microphone vlue Copyright 2 which moves the mgnet, which cretes current in the nerby wire nlog signl Possible vlues:.,., 2.9,... infinite possibilities time vlue 4 3 2 2 digitl signl time Possible vlues:,, 2, 3, or 4. Tht s it. 3
Digitl Signls with Only Two Vlues: Binry Binry digitl signl -- only two possible vlues Typiclly represented s nd One binry digit is bit We ll only consider binry digitl signls Binry is populr becuse Trnsistors, the bsic digitl electric component, operte using two voltges (more in Chpt. 2) Storing/trnsmitting one of two vlues is esier thn three or more (e.g., loud beep or quiet beep, reflection or no reflection) vlue time Copyright 2 4
Exmple of Digitiztion Benefit Anlog signl (e.g., udio, video) my lose qulity Voltge levels not sved/copied/trnsmitted perfectly Digitized version enbles ner-perfect sve/cpy/trn. Smple voltge t prticulr rte, sve smple using bit encoding Voltge levels still not kept perfectly But we cn distinguish s from s Volts Volts 3 2 originl signl time 2d digitized signl time Not perfect re-cretion due to 2d nd d2 lengthy trnsmission (e.g, cell phone) lengthy trnsmission (e.g, cell phone) 3 2 received signl time How fix -- higher, lower,? time Cn fix distinguish s/s, restore Let bit encoding be: V: 2 V: 3 V: Copyright 2 Higher smpling rte nd more bits per encoding improves re-cretion Volts 3 2 d2 5
Digitiztion Benefit: Cn Store on Digitl Medi () wire microphone nlog-todigitl converter Volts 3 2 smples digitized signl nlog signl on wire time Store on CD, USB drive, etc. No deteriortion. (b) Copyright 2 red from tpe, CD, etc. wire speker digitl-tonlog converter Volts 3 2 nlog signl reproduced from digitized signl time 6
Digitized Audio: Compression Benefit Digitized udio cn be compressed e.g., MP3s A CD cn hold bout 2 songs uncompressed, but bout 2 compressed Compression lso done on digitized pictures (jpeg), movies (mpeg), nd more Digitiztion hs mny other benefits too Exmple compression scheme: mens mens X mens X Copyright 2 7
How Do We Encode Dt s Binry for Our Digitl nlog phenomen electric signl A2D digitl dt digitl dt sensors nd other inputs Digitl System D2A electric signl ctutors nd other outputs Copyright 2 digitl dt digitl dt System? Some inputs inherently binry Button: not pressed (), pressed () Some inputs inherently digitl Just need encoding in binry e.g., multi-button input: encode red=, blue=,... Some inputs nlog Need nlog-to-digitl conversion As done in erlier slide -- smple nd encode with bits red red red button blue blue blue ir 8 green green green temperture sensor blck blck blck 33 degrees
How to Encode Text: ASCII, Unicode ASCII: 7- (or 8-) bit encoding of ech letter, number, or symbol Unicode: Incresingly populr 6-bit encoding Encodes chrcters from vrious world lnguges Encoding Symbol <spce>! Encoding Symbol " A # B $ C % D & E ' F ( G ) H * I + J, K - L. M / Smple ASCII encodings Encoding Symbol N O P Q R S T U V W X Y Z Question: Wht does this ASCII bit sequence represent? R E S T Encoding Symbol b... y z 2 3 4 5 6 7 8 9 Copyright 2 9
How to Encode Numbers: Binry Numbers Ech position represents quntity; symbol in position mens how mny of tht quntity Bse ten (deciml) Ten symbols:,, 2,..., 8, nd 9 More thn 9 -- next position So ech position power of Nothing specil bout bse -- used becuse we hve fingers Bse two (binry) Two symbols: nd More thn -- next position So ech position power of 2 5 2 3 4 3 2 2 4 2 3 2 2 2 2 Q: How much? + = 4 + = 5 Copyright 2
Using Digitl Dt in Digitl System A temperture sensor outputs temperture in binry The system reds the temperture, outputs ASCII code: F for freezing (-32) B for boiling (22 or more) N for norml A disply converts its ASCII input to the corresponding letter Digitl System temperture sensor "33" if (input <= "") // "32" output = "" // "F" else if (input >= "") // "22" output = "" // "B" else output = "" // "N" disply N "N" Copyright 2
Converting from Binry to Deciml Just dd weights 2 is just *2, or. 2 is *2 2 + *2 + *2, or 6. We might think of this using bse ten weights: *4 + *2 + *, or 6. 2 is *6 + *8 + *4 + *2 + *, or 6. 2 is *28 + *4 + *2 + * = 35. Notice this time tht we didn t bother to write the weights hving bit. 2 is the sme s 2 bove the leding s don t chnge the vlue. Useful to know powers of 2: 2 9 2 8 2 7 2 6 2 5 2 4 2 3 2 2 2 2 52 256 28 64 32 6 8 4 2 Prctice counting up by powers of 2: 52 256 28 64 32 6 8 4 2 Copyright 2 2
Converting from Deciml to Binry Put in leftmost plce without sum exceeding number Trck sum () (b) (c) Desired deciml number: 2 6 > 2, too big; Put in 6 s plce 8 <= 2, so put in 8 s plce, current sum is 8 8+4=2 <= 2, so put in 4 s plce, current sum is 2 Current sum 8 2 Binry number 6 8 4 2 6 8 4 2 6 8 4 2 (d) Reched desired 2, so put s in remining plces done 6 8 4 2 Copyright 2 3
Converting from Deciml to Binry Exmple using more compct nottion Desired deciml number: 23 sum: Binry number 6 8 4 2 6 () 6 (b) 2 (c) 22 (d) 23 (e) Copyright 2 4
Exmple: DIP-Switch Controlled Chnnel Ceiling fn receiver should be set in fctory to respond to chnnel 73 Convert 73 to binry, set DIP switch ccordingly Copyright 2 () "34" chnnel receiver InA Ceiling fn module Q: sum: "73" if (InA = InB) Out = else Out = Out Desired vlue: 73 28 64 32 6 8 4 2 64 72 73 DIP switch InB (c) (b) 5
Bse Sixteen: Another Bse Used by Designers 8 A F 6 4 6 3 6 2 6 6 8 A F Nice becuse ech position represents four bse-two positions Compct wy to write binry numbers Known s hexdeciml, or just hex hex binry hex binry 8 2 9 A Q: Write in hex 3 B 4 5 C D F 6 7 E F Q: Convert hex A to binry Copyright 2 6
Deciml to Hex Esy method: convert to binry first, then binry to hex Convert 99 bse to hex First convert to binry: 28 64 32 6 8 4 2 Then binry to hex: 6 3 (Quick check: 6*6 + 3* = 96+3 = 99) Copyright 2 7
Hex Exmple: RFID Tg Btteryless tg powered by rdio field Trnsmits unique identifiction number Exmple: 32 bit id 8-bit province number, 8-bit country number, 6-bit niml number Tg contents re in binry But progrmmers use hex when writing/reding (b) Province # City # Animl # () RFID tg (c) (d) (e) (f) Province: 7 City: 6 Animl: 53 7 A 2 Tg ID in hex: 7A2 Copyright 2 8
Converting To/From Binry by Hnd: Summry 6 6 Deciml 26 To binry 8 4 2 6+8 = 24 24 24+2 -- = 26 6 8 4 To deciml 6 + 8 + 2 = 26 Binry To hex = A 6 2 To octl = 32 8 Copyright 2 9
Divide-By-2 Method Common in Automtic Conversion Repetedly divide deciml number by 2, plce reminder in current binry digit (strting from s column). Divide deciml number by 2 Insert reminder into the binry number Continue since quotient (6) is greter thn Deciml 6 2 2 2 Binry (current vlue: ) 2. Divide quotient by 2 Insert reminder into the binry number Continue since quotient (3) is greter thn 3 2 6 6 2 (current vlue: ) 3. Divide quotient by 2 Insert reminder into the binry number Continue since quotient () is greter thn 4. Divide quotient by 2 Insert reminder into the binry number Quotient is, done 2 3 2 2 4 2 (current vlue: 4) 8 4 2 (current vlue: 2) Note: Works for ny bse N just divide by N insted Copyright 2 2
Bytes, Kilobytes, Megbytes, nd More Byte: 8 bits Common metric prefixes: kilo (thousnd, or 3 ), meg (million, or 6 ), gig (billion, or 9 ), nd ter (trillion, or 2 ), e.g., kilobyte, or KByte BUT, metric prefixes lso commonly used inccurtely 2 6 = 65536 commonly written s 64 Kbyte Typicl when describing memory sizes Also wtch out for KB for kilobyte vs. Kb for kilobit Copyright 2 2
Implementing Digitl Systems: Progrmming Microprocessors Vs. Designing Digitl Circuits Desired motion-t-night detector Progrmmed microprocessor Custom designed digitl circuit.3 Microprocessors common choice to implement digitl system Esy to progrm Chep (s low s $) Redily vilble I I I2 I3 I4 I5 I6 I7 P P P2 P3 P4 P5 P6 P7 void min() { while () { P = I &&!I; // F = nd!b, } } b F 6: 7:57:6 9:9: time Copyright 2 22
Digitl Design: When Microprocessors Aren t Good Enough With microprocessors so esy, chep, nd vilble, why design digitl circuit? Microprocessor my be too slow Or too big, power hungry, or costly Wing controller computtion tsk: 5 ms on microprocessor 5 ms s custom digitl circuit If must execute times per second: * 5 ms = 5 ms = 5 seconds * 5 ms = 5 ms =.5 seconds Microprocessor too slow, circuit OK. Copyright 2 23
Digitl Design: When Microprocessors Aren t Good Commonly, designers prtition system mong microprocessor nd custom digitl circuits Enough () Imge Sensor Memory Microprocessor (Red, Compress, nd Store) Q: How long for ech implementtion option? 5+8+ =4 sec Smple digitl cmer tsk execution times (in seconds) on microprocessor versus digitl circuit: (b) Imge Sensor Memory Red circuit Compress circuit Store circuit.+.5+.8 =.4 sec Tsk Microprocessor Custom Digitl Circuit Red 5. Compress 8.5 Store.8 Copyright 2 (c) Imge Sensor Memory Red circuit Compress circuit Microprocessor (Store).+.5+ =.6 sec Good compromise 24
Digitl systems surround us Chpter Summry Inside computers Inside mny other electronic devices (embedded systems) Digitl systems use s nd s Encoding nlog signls to digitl cn provide mny benefits e.g., udio higher-qulity storge/trnsmission, compression, etc. Encoding integers s s nd s: Binry numbers Microprocessors (themselves digitl) cn implement mny digitl systems esily nd inexpensively But often not good enough need custom digitl circuits Copyright 2 25