Date post: | 12-Nov-2015 |
Category: |
Documents |
Upload: | joseph-garado-acebo |
View: | 30 times |
Download: | 3 times |
Digital Design 2eCopyright 2010Frank Vahid
1
Digital DesignChapter 1: Introduction
Slides to accompany the textbook Digital Design, with RTL Design, VHDL, and Verilog, 2nd Edition,
by Frank Vahid, John Wiley and Sons Publishers, 2010. http://www.ddvahid.com
Copyright 2010 Frank VahidInstructors of courses requiring Vahid's Digital Design textbook (published by John Wiley and Sons) have permission to modify and use these slides for customary course-related activities, subject to keeping this copyright notice in place and unmodified. These slides may be posted as unanimated pdf versions on publicly-accessible course websites.. PowerPoint source (or pdf with animations) may not be posted to publicly-accessible websites, but may be posted for students on internal protected sites or distributed directly to students by other electronic means. Instructors may make printouts of the slides available to students for a reasonable photocopying charge, without incurring royalties. Any other use requires explicit permission. Instructors may obtain PowerPoint source or obtain special use permissions from Wiley see http://www.ddvahid.com for information.
Some Useful Information Where can I get help
www.cse.nd.edu/courses/cse20221/www/ TAs during lab time: M,T,W,T,F 3:00 5:20 email [email protected] 325 D Cushing Hall 108 Stinson-Remick on Tues. & Thurs. during lab
What will make the lab easier If there is a video for the lab, view it before you come to lab Download the Xilinx software for lab on your personal computer Review the lab assignment before you come to lab Complete the design work before you come to lab
2
Questions? Is there lab this week? No Are there copies of the lecture? Yes, on course web site. When are the lectures updated? 30 minutes before class. Do I have to come to my assigned lab time? Yes Can I demo my lab work at another lab time? Yes Can I get late homework or lab work graded? No Is digital logic design really all that important? Only if you
want things like an iPhone, iPod, computer, CDs or CD players
Is this course difficult. No Is this course fun? Absolutely!
3
Digital Design 2eCopyright 2010Frank Vahid
4
Why Study Digital Design? Look under the hood of computers
Solid understanding --> confidence, insight, even better programmer when aware of hardware resource issues
Electronic devices becoming digital Enabled by shrinking and more capable chips Enables:
Better devices: Sound recorders, cameras, cars, cell phones, medical devices,...
New devices: Video games, PDAs, ... Known as embedded systems
Thousands of new devices every year Designers needed: Potential career direction
1995
Portablemusic players
1997
Satellites
1999
Cell phones
2001
DVDplayers
Videorecorders
Musicalinstruments
2003
Cameras TVs ???
2005 2007 Years shown above indicate when digital version began to dominate
(Not the first year that a digital version appeared)
1.1
Digital Design 2eCopyright 2010Frank Vahid
5
What Does Digital Mean? Analog signal
Infinite possible values Ex: voltage on a wire
created by microphone
valu
e
timeva
lue
time
microphone
Sound waves
which movesthe magnet,
which createscurrent in the nearby wire
move themembrane,
analog signal
3 421
2 digital signal
Digital signal Finite possible values
Ex: button pressed on a keypad
01234
Possible values:1.00, 1.01, 2.0000009, ... infinite possibilities
Possible values:0, 1, 2, 3, or 4.Thats it.
1.2
a
a
Digital Design 2eCopyright 2010Frank Vahid
6
Digital Signals with Only Two Values: Binary Binary digital signal -- only two
possible values Typically represented as 0 and 1 One binary digit is a bit Well only consider binary digital signals Binary is popular because
Transistors, the basic digital electric component, operate using two voltages (more in Chpt. 2)
Storing/transmitting one of two values is easier than three or more (e.g., loud beep or quiet beep, reflection or no reflection)
valu
e
time
10
Digital Design 2eCopyright 2010Frank Vahid
7
Example of Digitization Benefit
Analog signal (e.g., audio, video) may lose quality
Voltage levels not saved/copied/transmitted perfectly
Digitized version enables near-perfect save/cpy/tran.
Sample voltage at particular rate, save sample using bit encoding
Voltage levels still not kept perfectly
But we can distinguish 0s from 1s
time
Volts
0123
original signal
leng
thy
trans
mis
sion
(e.g
, cel
l pho
ne)
time0123
received signal
How fix -- higher, lower, ?
leng
thy
trans
mis
sion
(e.g
, cel
l pho
ne)
01 10 11 10 11
01 10 11 10 11
Volts
digitized signal
time01
a2d
Volts
0123
d2aLet bit encoding be: 1 V: 012 V: 103 V: 11
timeCan fixdistinguish 0s/1s, restore
01
Higher sampling rate and more bits per encoding improves re-creation
a
Not a perfect re-creation due to a2d and d2a
Digital Design 2eCopyright 2010Frank Vahid
8
Digitization Benefit: Can Store on Digital Media
10 100100 11 11 11 01 10 10 0001
2
3
Volts
analog signalon wire
time
0001101011111101101000
analog-to-digitalconverter
samples
digitized signalmicrophone
wire
(a)
0001101011111101101000 read from tape, CD, etc.
digital-to-analogconverter
wire
speaker
10 100100 11 11 11 01 10 10 0001
3
Volts
analog signalreproduced fromdigitized signal
time
2
(b)
a
Store on CD, USB drive, etc. No deterioration.
Digital Design 2eCopyright 2010Frank Vahid
9
Digitized Audio: Compression Benefit Digitized audio can be
compressed e.g., MP3s A CD can hold about 20
songs uncompressed, but about 200 compressed
Compression also done on digitized pictures (jpeg), movies (mpeg), and more
Digitization has many other benefits too
0000000000 0000000000 0000001111 1111111111
10000001111
Example compression scheme:00 means 000000000001 means 11111111111X means X
a00 00 01
Digital Design 2eCopyright 2010Frank Vahid
10
How Do We Encode Data as Binary for Our Digital System?
Some inputs inherently binary Button: not pressed (0),
pressed (1) Some inputs inherently
digital Just need encoding in
binary e.g., multi-button input:
encode red=001, blue=010, ...
Some inputs analog Need analog-to-digital
conversion As done in earlier slide --
sample and encode with bits
0
button
1
green blackbluered
0 00
red
0 10
green blackblue
1 00
green blackbluered
temperaturesensor
air
0 0 1 10 0 0 0
33 degrees
a
sensors andother inputs
Digital System
actuators andother outputs
A2D
D2A
analogphenomena
electricsignal
digitaldata
digitaldata
electricsignal
digitaldata
digitaldata
Digital Design 2eCopyright 2010Frank Vahid
11
How to Encode Text: ASCII, Unicode ASCII: 7- (or 8-)
bit encoding of each letter, number, or symbol
Unicode: Increasingly popular 16-bit encoding Encodes
characters from various world languages
Question: What does this ASCII bit sequence represent?
1010010 1000101 1010011 1010100
R E S Ta
Sample ASCII encodingsSymbolEncoding
010 0000 010 0001 !010 0010 "010 0011 #010 0100 $010 0101 %010 0110 &010 0111 '010 1000 (010 1001 )010 1010 *010 1011 +010 1100 ,010 1101 -010 1110 .010 1111 /
SymbolEncoding100 1110 N100 1111 O101 0000 P101 0001 Q101 0010 R101 0011 S101 0100 T101 0101 U101 0110 V101 0111 W101 1000 X101 1001 Y101 1010 Z
100 0001 A100 0010 B100 0011 C100 0100 D100 0101 E100 0110 F100 0111 G100 1000 H100 1001 I100 1010 J100 1011 K100 1100 L100 1101 M
SymbolEncoding
SymbolEncoding
011 0000 0011 0001 1011 0010 2011 0011 3011 0100 4011 0101 5011 0110 6011 0111 7011 1000 8011 1001 9
110 0001 a110 0010 b ...111 1001 y111 1010 z
Digital Design 2eCopyright 2010Frank Vahid
12
How to Encode Numbers: Binary Numbers Each position represents a
quantity; symbol in position means how many of that quantity Base ten (decimal)
Ten symbols: 0, 1, 2, ..., 8, and 9 More than 9 -- next position
So each position power of 10 Nothing special about base 10 --
used because we have 10 fingers Base two (binary)
Two symbols: 0 and 1 More than 1 -- next position
So each position power of 2
24 23 22
1 0 1
21 20
104 103 102
5 2 3
101 100
Q: How much?+ =
4 1 5+ =
a
Digital Design 2eCopyright 2010Frank Vahid
13
Using Digital Data in a Digital System
temperature sensor
0 0 1 10 0 0 0 "33"
Digital System
display N
"N"1 0 00 1 1 1
if (input = "11010100") // "212"
output = "1000010" // "B"
else
output = "1001110" // "N"
A temperature sensor outputs temperature in binary
The system reads the temperature, outputs ASCII code: F for freezing (0-32) B for boiling (212 or more) N for normal
A display converts its ASCII input to the corresponding letter
a
Digital Design 2eCopyright 2010Frank Vahid
14
Converting from Binary to Decimal Just add weights
12 is just 1*20, or 110. 1102 is 1*22 + 1*21 + 0*20, or 610. We might think of this using
base ten weights: 1*4 + 1*2 + 0*1, or 6. 100002 is 1*16 + 0*8 + 0*4 + 0*2 + 0*1, or 1610. 100001112 is 1*128 + 1*4 + 1*2 + 1*1 = 13510. Notice this time
that we didnt bother to write the weights having a 0 bit. 001102 is the same as 1102 above the leading 0s dont change
the value.
a
24 23 22 21 2029 28 27 26 25
16 8 4 2 1512 256 128 64 32
16 8 4 2 1512 256 128 64 32Practice counting up by powers of 2:
Useful to know powers of 2:a
Digital Design 2eCopyright 2010Frank Vahid
15
Converting from Decimal to Binary
Put 1 in leftmost place without sum exceeding number
Track sum
16 18 4 20
16 18 4 28
1
16 18 4 212 1 1
16 18 4 2done 1 1 00
016 > 12, too big;Put 0 in 16s place
8
Digital Design 2eCopyright 2010Frank Vahid
16
Converting from Decimal to Binary
Example using a more compact notation 16 18 4 20
1
Desired decimalnumber: 23
Binarynumber
(a)
(d)(c)
(b)
sum:16
0
1620
1 1
2223
1
(e)
a
Digital Design 2eCopyright 2010Frank Vahid
17
Example: DIP-Switch Controlled Channel Ceiling fan
receiver should be set in factory to respond to channel 73
Convert 73 to binary, set DIP switch accordingly
channel receiver
Ceiling fanmodule
0
if (InA = InB)Out = 1
elseOut = 0
0 1 0 10 1 0 0"73"
DIP switch
10
0 0 1 00 0 0 1
InA InB
Out
Desired value: 73
4
0 02
1116
08
132
064
1128
0
64 72 73sum:
"34"
(b)(a)
(c)
a
Q:
Digital Design 2eCopyright 2010Frank Vahid
18
Base Sixteen: Another Base Used by Designers
Nice because each position represents four base-two positions Compact way to write binary numbers
Known as hexadecimal, or just hex
164 163 162
8 A F
8
1000 1010 1111
A F
161 160
00000001001000110100010101100111
01234567
hex binary
10001001101010111100110111101111
89ABCDEF
hex binary
Q: Write 11110000 in hex
F 0 a
Q: Convert hex A01 to binary
1010 0000 0001
a
Digital Design 2eCopyright 2010Frank Vahid
19
Decimal to Hex Easy method: convert to binary first, then binary to hex
Convert 99 base 10 to hex
First convert to binary: 0 1 10 0114 2 116 83264128
0
Then binary to hex:6 3
(Quick check: 6*16 + 3*1 = 96+3 = 99)
a
a
a
Digital Design 2eCopyright 2010Frank Vahid
20
Hex Example: RFID Tag Batteryless tag powered by radio field
Transmits unique identification number Example: 32 bit id
8-bit province number, 8-bit country number, 16-bit animal number Tag contents are in binary But programmers use hex when writing/reading
RFIDtag
Province # City # Animal #
Province: 7 City: 160 Animal: 513
1010000000000111 00000010 00000001A007 02 01
Tag ID in hex: 07A00201
(a)
(b)
(c)(d)
(f)
(e)
Digital Design 2eCopyright 2010Frank Vahid
21
Converting To/From Binary by Hand: Summary
BinaryDecimal
16 8 4
0 1 0
2 1
1 1
16 + 8 + 2
To decimal
To hex
1 1010
= 2610
= 1A16
To octal
11 010= 328
2610
To binary
4
0 1
2
0
116
1
8
1
1616+8= 24 24 --24+2
= 26
Digital Design 2eCopyright 2010Frank Vahid
22
Divide-By-2 Method Common in Automatic Conversion Repeatedly divide decimal number by 2, place remainder
in current binary digit (starting from 1s column)
1. Divide decimal number by 2 Insert remainder into the binary number Continue since quotient (6) is greater than 0
2. Divide quotient by 2 Insert remainder into the binary number Continue since quotient (3) is greater than 0
01
18
14
02
01
14
02
01
01
02
Decimal Binary
12212
0
6
6260
3
3. Divide quotient by 2 Insert remainder into the binary number Continue since quotient (1) is greater than 0
3221
1
4. Divide quotient by 2 Insert remainder into the binary number Quotient is 0, done
1201
0
(current value: 12)
(current value: 4)
(current value: 0)
(current value: 0)
Note: Works for any base Njust divide by N instead
Dibble-Dabble Algorithm2|12 r = 0 least significant bit2|6 r = 0 2|3 r = 1 2|1 r = 1 most significant bit
12 10 = 11002
23
Digital Design 2eCopyright 2010Frank Vahid
24
Bytes, Kilobytes, Megabytes, and More Byte: 8 bits Common metric prefixes:
kilo (thousand, or 103), mega (million, or 106), giga (billion, or 109), and tera (trillion, or 1012), e.g., kilobyte, or KByte
BUT, metric prefixes also commonly used inaccurately 216 = 65536 commonly written as 64 Kbyte Typical when describing memory sizes
Also watch out for KB for kilobyte vs. Kb for kilobit
Digital Design 2eCopyright 2010Frank Vahid
25
Implementing Digital Systems: Programming Microprocessors Vs. Designing Digital Circuits
Microprocessors a common choice to implement a digital system
Easy to program Cheap (as low as
$1) Readily available
I3I4I5I6I7
I2I1I0
P3P4P5P6P7
P2P1P0 void main()
{while (1) {
P0 = I0 && !I1; // F = a and !b,
}} 0
F
b
a
10101
6:00 7:057:06 9:009:01 time
Desired motion-at-night detectorProgrammed
microprocessorCustom designed
digital circuit
1.3
Digital Design 2eCopyright 2010Frank Vahid
26
Digital Design: When Microprocessors Arent Good Enough
With microprocessors so easy, cheap, and available, why design a digital circuit? Microprocessor may be too
slow Or too big, power hungry, or
costly
Wing controller computation task:
50 ms on microprocessor
5 ms as custom digital circuit
If must execute 100 times per second:
100 * 50 ms = 5000 ms = 5 seconds
100 * 5 ms = 500 ms = 0.5 seconds
Microprocessor too slow, circuit OK.
Digital Design 2eCopyright 2010Frank Vahid
27
Digital Design: When Microprocessors Arent Good Enough
Commonly, designers partition a system among a microprocessor and custom digital circuits (a)
Micro-processor
(Read,Compress,and Store)Memory
Image Sensor
(b)
(c)
Sample digital camera task execution times (in seconds) on a microprocessor versus a digital circuit:
Q: How long for each implementation option?
a
5+8+1=14 sec
.1+.5+.8=1.4 sec
.1+.5+1=1.6 sec
Good compromise
Readcircuit
Compresscircuit
Memory Storecircuit
Image Sensor
Compresscircuit
Microprocessor(Store)Memory
Image Sensor Readcircuit
Task Microprocessor Custom Digital Circuit
Read 5 0.1
Compress 8 0.5
Store 1 0.8
28
Chapter 1 Summary Digital systems surround us
Inside computers Inside many other electronic devices (embedded systems)
Digital systems use 0s and 1s Encoding analog signals to digital can provide many benefits
e.g., audiohigher-quality storage/transmission, compression, etc. Encoding integers as 0s and 1s: Binary numbers
Microprocessors (themselves digital) can implement many digital systems easily and inexpensively But often not good enoughneed custom digital circuits
Digital Design 2eCopyright 2010Frank Vahid
29
Chapter 2 Introduction Lets learn to design digital circuits, starting with a
simple form of circuit: Combinational circuit
Outputs depend solely on the present combination of the circuit inputs values
2.1
Note: Slides with animation are denoted with a small red "a" near the animated items
DigitalSystem
b=0 F=0
DigitalSystem
if b=0, then F=0if b=1, then F=1
b=1 F=1
DigitalSystem
b=0 F=0
(a)
DigitalSystem
b=1 F=1
Vs. sequential circuit: Has memory that impacts outputs too
a
Motionsensor Digital
System
Lightsensor
Lamp
a
b
F
if a=0 and b=0, then F=0if a=0 and b=1, then F=0if a=1 and b=0, then F=1if a=1 and b=1, then F=0(b)
a
DigitalSystem
b=0 F=1
Cannot determine value ofF solely from presentinput value
(c)a
Digital Design 2eCopyright 2010Frank Vahid
30
Switches Electronic switches are the basis of
binary digital circuits Electrical terminology
Voltage: Difference in electric potential between two points (volts, V)
Analogous to water pressure Resistance: Tendency of wire to resist
current flow (ohms, ) Analogous to water pipe diameter
Current: Flow of charged particles (amps, A) Analogous to water flow
V = I * R (Ohms Law) 9 V = I * 2 ohms I = 4.5 A
4.5 A
4.5
A
4.5 A
2 ohms
9 V
0V 9V
+
2.2
If a 9V potential difference is appliedacross a 2 ohm resistor, then 4.5 A of current will flow.
a
Digital Design 2eCopyright 2010Frank Vahid
31
Switches A switch has three parts
Source input, and output Current tries to flow from source
input to output Control input
Voltage that controls whether that current can flow
The amazing shrinking switch 1930s: Relays 1940s: Vacuum tubes 1950s: Discrete transistor 1960s: Integrated circuits (ICs)
Initially just a few transistors on IC Then tens, hundreds, thousands...
off
on
outputsourceinput
outputsourceinput
controlinput
controlinput
(b)
relay vacuum tube
discrete transistor
IC
quarter(to see the relative size)
a
Digital Design 2eCopyright 2010Frank Vahid
32
Moores Law IC capacity doubling about every 18 months
for several decades Known as Moores Law after Gordon Moore,
co-founder of Intel Predicted in 1965 predicted that components
per IC would double roughly every year or so Book cover depicts related phenomena
For a particular number of transistors, the IC area shrinks by half every 18 months
Consider how much shrinking occurs in just 10 years (try drawing it)
Enables incredibly powerful computation in incredibly tiny devices
Todays ICs hold billions of transistors The first Pentium processor (early 1990s)
needed only 3 million
An Intel Pentium processor IChaving millions of transistors
Digital Design 2eCopyright 2010Frank Vahid
33
The CMOS Transistor CMOS transistor
Basic switch in modern ICs
does notconduct
0
conducts
1gate
nMOS
does notconduct
1gate
pMOS
conducts
0
Silicon -- not quite a conductor or insulator:Semiconductor
2.3
a
gate
source drainoxide
A positive voltage here...
(a)
IC package
IC
...attracts electrons here, turning the channel betweenthe source and drain intoa conductor
Digital Design 2eCopyright 2010Frank Vahid
34
CMOS Transistor Analogy
gatesource
draindrain
sourcegate
Digital Design 2eCopyright 2010Frank Vahid
35
Boolean Logic GatesBuilding Blocks for Digital Circuits
(Because Switches are Hard to Work With)
Logic gates are better digital circuit building blocks than switches (transistors) Why?...
2.4
Digital Design 2eCopyright 2010Frank Vahid
36
Boolean Algebra and its Relation to Digital Circuits To understand the benefits of logic gates vs. switches,
we should first understand Boolean algebra Traditional algebra
Variables represent real numbers (x, y) Operators operate on variables, return real numbers (2.5*x + y - 3)
Boolean Algebra Variables represent 0 or 1 only Operators return 0 or 1 only Basic operators
AND: a AND b returns 1 only when both a=1 and b=1 OR: a OR b returns 1 if either (or both) a=1 or b=1 NOT: NOT a returns the opposite of a (1 if a=0, 0 if a=1)
a0011
b0101
AND0001 a
0011
b0101
OR0111a
01
NOT10
a
Digital Design 2eCopyright 2010Frank Vahid
37
Boolean Algebra and its Relation to Digital Circuits Developed mid-1800s by George Boole to formalize human thought
Ex: Ill go to lunch if Mary goes OR John goes, AND Sally does not go. Let F represent my going to lunch (1 means I go, 0 I dont go) Likewise, m for Mary going, j for John, and s for Sally Then F = (m OR j) AND NOT(s)
Nice features Formally evaluate
m=1, j=0, s=1 --> F = (1 OR 0) AND NOT(1) = 1 AND 0 = 0 Formally transform
F = (m and NOT(s)) OR (j and NOT(s)) Looks different, but same function Well show transformation techniques soon
Formally prove Prove that if Sally goes to lunch (s=1), then I dont go (F=0) F = (m OR j) AND NOT(1) = (m OR j) AND 0 = 0
a0011
b0101
AND0001
a0011
b0101
OR0111
a01
NOT10
Digital Design 2eCopyright 2010Frank Vahid
38
Evaluating Boolean Equations Evaluate the Boolean equation F = (a AND b) OR (c
AND d) for the given values of variables a, b, c, and d: Q1: a=1, b=1, c=1, d=0.
Answer: F = (1 AND 1) OR (1 AND 0) = 1 OR 0 = 1. Q2: a=0, b=1, c=0, d=1.
Answer: F = (0 AND 1) OR (0 AND 1) = 0 OR 0 = 0. Q3: a=1, b=1, c=1, d=1.
Answer: F = (1 AND 1) OR (1 AND 1) = 1 OR 1 = 1.
a
a0011
b0101
AND0001
a0011
b0101
OR0111
a01
NOT10
Digital Design 2eCopyright 2010Frank Vahid
39
Converting to Boolean Equations Convert the following English
statements to a Boolean equation Q1. a is 1 and b is 1.
Answer: F = a AND b Q2. either of a or b is 1.
Answer: F = a OR b Q3. a is 1 and b is 0.
Answer: F = a AND NOT(b) Q4. a is not 0.
Answer: (a) Option 1: F = NOT(NOT(a)) (b) Option 2: F = a
a
Homework Chapter 1: 2,10,16,18, 21 Due date: Thursday, January 27
40
Digital DesignSome Useful InformationQuestions?Why Study Digital Design?What Does Digital Mean?Digital Signals with Only Two Values: BinaryExample of Digitization BenefitDigitization Benefit: Can Store on Digital MediaDigitized Audio: Compression BenefitHow Do We Encode Data as Binary for Our Digital System?How to Encode Text: ASCII, UnicodeHow to Encode Numbers: Binary NumbersUsing Digital Data in a Digital SystemConverting from Binary to DecimalConverting from Decimal to BinaryConverting from Decimal to BinaryExample: DIP-Switch Controlled ChannelBase Sixteen: Another Base Used by DesignersDecimal to HexHex Example: RFID TagConverting To/From Binary by Hand: SummaryDivide-By-2 Method Common in Automatic ConversionDibble-Dabble AlgorithmBytes, Kilobytes, Megabytes, and MoreImplementing Digital Systems: Programming Microprocessors Vs. Designing Digital CircuitsDigital Design: When Microprocessors Arent Good EnoughDigital Design: When Microprocessors Arent Good EnoughChapter 1 SummaryChapter 2 IntroductionSwitchesSwitchesMoores LawThe CMOS TransistorCMOS Transistor AnalogyBoolean Logic GatesBuilding Blocks for Digital Circuits (Because Switches are Hard to Work With)Boolean Algebra and its Relation to Digital CircuitsBoolean Algebra and its Relation to Digital CircuitsEvaluating Boolean EquationsConverting to Boolean EquationsHomework