Escolar Documentos
Profissional Documentos
Cultura Documentos
Chapter 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
1 2 3 4
2
digital
signal
analog a
signal
Possible values: Possible values:
1.00, 1.01, 2.0000009, 4
value
value
0, 1, 2, 3, or 4.
... infinite possibilities 3 Thats it.
2
a 1
0
time time
Digital Design 2e
Copyright 2010 3
Frank Vahid
Digital Signals with Only Two Values: Binary
Binary digital signal -- only two
possible values
value
Typically represented as 0 and 1
One binary digit is a bit
1
Well only consider binary digital signals 0
Binary is popular because time
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)
Digital Design 2e
Copyright 2010 4
Frank Vahid
lengthy transmission
Example of Digitization
Volts
lengthy transmission
saved/copied/transmitted
Volts
perfectly a
01 10 11 10 11
Let bit encoding be:
1 V: 01
2 V: 10 d2a
Volts
3
3 V: 11
Higher sampling 2
rate and more bits per
Digital Design 2e 1
encoding improves re-creation 5
Copyright 2010
Frank Vahid
0
Digitization Benefit: Can Store on Digital Media
Digital Design 2e
Copyright 2010 6
Frank Vahid
Digitized Audio: Compression Benefit
Digitized audio can be Example compression scheme:
compressed 00 means 0000000000
01 means 1111111111
e.g., MP3s 1X means X
A CD can hold about 20
songs uncompressed, 0000000000 0000000000 0000001111 1111111111
but about 200
compressed a
00 00 10000001111 01
Compression also done
on digitized pictures
(jpeg), movies (mpeg),
and more
Digitization has many
other benefits too
Digital Design 2e
Copyright 2010 7
Frank Vahid
How Do We Encode Data as Binary for Our Digital
System?
a
analog button
100 0101 E
number, or 010 0110
010 0111
&
' 100 0110 F
101 0010
101 0011
R
S
011 0000
011 0001
0
1
010 1000 ( 100 0111 G 101 0100 T
symbol 010 1001 ) 100 1000
100 1001
H
I
101 0101 U
011 0010
011 0011
2
3
010 1010 * 101 0110 V 011 0100 4
Unicode: 010 1011
010 1100
+
,
100
100
1010
1011
J
K
101 0111
101 1000
W
X
011 0101
011 0110
5
6
010 1101 - 100 1100 L 101 1001 Y
Increasingly 010 1110 . 100 1101 M 101 1010 Z
011 0111
011 1000
7
8
010 1111 / 011 1001 9
popular 16-bit Question:
encoding What does this ASCII bit sequence represent?
Encodes 1010010 1000101 1010011 1010100
characters from
various world a
languages REST
Digital Design 2e
Copyright 2010 9
Frank Vahid
How to Encode Numbers: Binary Numbers
Each position represents a
quantity; symbol in position
means how many of that
quantity 5 2 3
Digital Design 2e
Copyright 2010 10
Frank Vahid
Using Digital Data in a Digital System
A temperature sensor
outputs temperature in temperature sensor
binary 0 0 1 0 0 0 0 1 "33"
Digital Design 2e
Copyright 2010 11
Frank Vahid
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 a
Digital Design 2e
Copyright 2010 12
Frank Vahid
Converting from Decimal to Binary
Desired decimal Current Binary
Put 1 in number: 12 sum number
leftmost 0
16 > 12, too big; 0
place without (a)
Put 0 in 16s place 16 8 4 2 1
sum
exceeding 8 <= 12, so put 0 1
number (b) 1 in 8s place, 8
16 8 4 2 1
current sum is 8
Track sum
8+4=12 <= 12, so put 0 1 1
a
(c) 1 in 4s place, 12
16 8 4 2 1
current sum is 12
Reached desired 12,
(d) 0 1 1 0 0
so put 0s in remaining done
16 8 4 2 1
places
Digital Design 2e
Copyright 2010 13
Frank Vahid
Converting from Decimal to Binary
Digital Design 2e
Copyright 2010 14
Frank Vahid
Example: DIP-Switch Controlled Channel
Ceiling fan
receiver
Desired value: 73
should be a
0 1 0 0 1 0 0 1
set in (a) Q: (b)
128 64 32 16 8 4 2 1
factory to sum: 64 72 73
respond to
DIP switch
channel
1
73 0
channel receiver
Convert 73 "34" 0 0 1 0 0 0 1 0 "73" 0 1 0 0 1 0 0 1
to binary,
set DIP
switch InA
if (InA = InB)
InB
accordingly Out = 1
else
Ceiling fan Out = 0
module Out (c)
0
Digital Design 2e
Copyright 2010 15
Frank Vahid
Base Sixteen: Another Base Used by Designers
8 A F Nice because each position
164 163 162 161 160 represents four base-two positions
8 A F Compact way to write binary numbers
1000 1010 1111 Known as hexadecimal, or just hex
hex binary hex bina ry
0 0000 8 1000
1 0001 9 1001
2 0010 A 1010 Q: Write 11110000 in hex
3 0011 B 1011
4 0100 C 1100
5 0101 D 1101 F0 a
6 0110 E 1110
7 0111 F 1111
Q: Convert hex A01 to binary
a
Digital Design 2e
Copyright 2010 17
Frank Vahid
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
(b)
Province # City # Animal #
Digital Design 2e
Copyright 2010 18
Frank Vahid
Converting To/From Binary by Hand: Summary
Digital Design 2e
Copyright 2010 19
Frank Vahid
Divide-By-2 Method Common in Automatic Conversion
Repeatedly divide decimal number by 2, place remainder
in current binary digit (starting from 1s column)
Decimal Binary
6
1. Divide decimal number by 2 2 12 0
Insert remainder into the binary number 12 1
Continue since quotient (6) is greater than 0 0 (current value: 0)
3
2. Divide quotient by 2 2 6 0 0
Insert remainder into the binary number 6 2 1
Continue since quotient (3) is greater than 0 0 (current value: 0)
1
3. Divide quotient by 2 2 3 1 0 0
Insert remainder into the binary number 2 4 2 1 Note:
Continue since quotient (1) is greater than 0 1 (current value: 4) Works for
any base
0
4. Divide quotient by 2 1 1 0 0 Njust
2 1
Insert remainder into the binary number 0 8 4 2 1 divide by
Quotient is 0, done 1 (current value: 12) N instead
Digital Design 2e
Copyright 2010 20
Frank Vahid
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 2e
Copyright 2010 21
Frank Vahid
Implementing Digital Systems: Programming
1.3
I0 P0 void main() 1
I1 P1 a
{ 0
I2 P2 while (1) { 1
I3 P3 P0 = I0 && !I1; b
I4 P4 0
// F = a and !b,
I5 P5 1
I6 P6 } F
0
I7 P7 }
6:00 7:057:06 9:009:01 time
Digital Design 2e
Copyright 2010 22
Frank Vahid
Digital Design: When Microprocessors Arent Good
Enough
With microprocessors so easy,
cheap, and available, why
design a digital circuit?
Microprocessor may be too
slow Wing controller computation task:
Or too big, power hungry, or 50 ms on microprocessor
costly
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 2e
Copyright 2010 23
Frank Vahid
Digital Design: When Microprocessors Arent Good
Enough
Commonly, designers partition Q: How long for each
a system among a Image Sensor Micro- implementation option?
processor
microprocessor and custom
digital circuits (a) (Read, 5+8+1
Compress,
Memory and Store) =14 sec
Digital Design 2e
Copyright 2010 25
Frank Vahid