Professional Documents
Culture Documents
Chapter 1: Introduction
1 2 3 4
2
digital
signal
analog
signal
Possible values: Possible values:
1.00, 1.01, 2.0000009, 4
value
value
0, 1, 2, 3, or 4.
... infinite possibilities 3 That’s it.
2
1
0
time time
Digital Design
Copyright © 2007
Frank Vahid 3
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
– We’ll only consider binary digital signals 1
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
Copyright © 2007
Frank Vahid 4
Example of Digitization Benefit
• Analog signal (e.g., audio)
lengthy transmission
Volts
lengthy transmission
particular rate, save
3
3 V: “11” but higher sampling
rate and more bits per 2
encoding brings closer. 1
Digital Design
Copyright © 2007 0 time
Frank Vahid 5
Digitized Audio: Compression Benefit
• Digitized audio can be Example compression scheme:
compressed 00 --> 0000000000
01 --> 1111111111
– e.g., MP3s 1X --> X
– A CD can hold about 20
songs uncompressed, 0000000000 0000000000 0000001111
but about 200 1111111111
compressed 00 00 10000001111
01
• Compression also done
on digitized pictures
(jpeg), movies (mpeg),
and more
• Digitization has many
other benefits too
Digital Design
Copyright © 2007
Frank Vahid 6
How Do We Encode Data as Binary for Our Digital
System?
a
analo button
phenomen
g • Some inputs inherently
a 0 1
binary
sensors
other
and – Button: not pressed (0), re blu gree blac
d e n k
electri inputs digita pressed (1)
csigna dat 0 0 0
l
l
a
• Some inputs inherently
A2D digital re blu gree blac
d e n k
digita
l dat – Just need encoding in 0 0 1
a binary
Digital re blu gree blac
– e.g., multi-button input: d e n k
System
digita digita encode red=001, blue=010, 0 1 0
l dat dat
l ... air 33
a D2A a
• Some inputs analog degrees
electri
csigna – Need analog-to-digital temperature
l actuators conversion sensor
other
and
outputs
– As done in earlier slide --
sample and encode with
Digital Design bits 0 0 1 0 0 0 0 1
Copyright © 2007
Frank Vahid 7
How to Encode Text: ASCII, Unicode
• ASCII: 7- (or 8-) bit Symbo E codin Symbo E codin
l n g l n g
encoding of each letter, R
S
101001
0
101001
r
s
111001
0
111001
number, or symbol T 101010 t 111010
L 0
100110 l 0
110110
• Unicode: Increasingly N 0
100111 n 0
110111
E 0
100010 e 0
110010
popular 16-bit bit encoding 0 1
011000 9 1
011100
– Encodes characters from . 010111 ! 1
010000
<tab 000100 <sp ce 1
010000
various world languages > 1 a > 0
Question:
What does this ASCII bit sequence represent?
1010010 1000101 1010011 1010100
REST
Digital Design
Copyright © 2007 Note: small red “a” (a) in a slide indicates animation
Frank Vahid 8
How to Encode Numbers: Binary Numbers
• Each position represents a
quantity; symbol in position
means how many of that
quantity 5 2 3
– Base ten (decimal)
1 4 1 3 1 2 1 1 1 0
• Ten symbols: 0, 1, 2, ..., 8, and 9 0 0 0 0 0
• 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) 1 0 1 Q: How much?
• Two symbols: 0 and 1 24 23 22 21 20 + =
a
• More than 1 -- next position
– So each position power of 2
4+ 1= 5
Digital Design
Copyright © 2007
Frank Vahid 9
How to Encode Numbers: Binary Numbers
• Working with binary numbers
– In base ten, helps to know
powers of 10 29 28 27 26 25 24 23 22 21 20
• one, ten, hundred, thousand, ten
thousand, ... 51 25 12 6 3 1 8 4 2 1
– In base two, helps to know 2 6 8 4 2 6
powers of 2
• one, two, four, eight, sixteen,
thirty two, sixty four, one
hundred twenty eight
– (Note: unlike base ten, we don’t
have common names, like
“thousand,” for each position in
base ten -- so we use the base
ten name)
• Q: count up by powers of two 51 25 12 6 3 1 8 4 2 1 a
2 6 8 4 2 6
Digital Design
Copyright © 2007
Frank Vahid 10
Converting from Decimal to Binary Numbers:
Subtraction Method (Easy for Humans)
• Goal Desired decimal number: 12
– Get the binary weights to add up
to the decimal quantity 32 16 8 4 2 1
• Work from left to right 1 =32
• (Right to left – may fill in 1s that 32 16 8 4 2 1 too much
shouldn’t have been there – try it). =16
0 1
32 16 8 4 2 1 too much
a
0 0 1 =8
32 16 8 4 2 1 ok, keep going
0 0 1 1 =8+4=12
32 16 8 4 2 1 DONE
0 0 1 1 0 0 answer
32 16 8 4 2 1
Digital Design
Copyright © 2007
Frank Vahid 11
Converting from Decimal to Binary Numbers:
Subtraction Method (Easy for Humans)
• Subtraction method Remaining quantity: 12
– To make the job easier (especially
for big numbers), we can just 32 16 8 4 2 1
subtract a selected binary weight 1 32 is
from the (remaining) quantity 32 16 8 4 2 1
too much
0 0 1 1 4-4=0
32 16 8 4 2 1 DONE
0 0 1 1 0 0 answer
32 16 8 4 2 1
Digital Design
Copyright © 2007
Frank Vahid 12
Converting from Decimal to Binary Numbers:
Subtraction Method Example
• Q: Convert the number “23” from decimal to binary
A: Remaining quantity Binary Number
23 0 0 0 0 0 0
32 16 8 4 2 1
23 0 1 0 0 0 0
-16 32 16 8 4 2 1
a
7
7 0 1 0 1 0 0
-4 32 16 8 4 2 1
3 8 is more than 7, can’t use
4 0 1 0 1 1 0
-2 32 16 8 4 2 1
1
1 0 1 0 1 1 1
-1 32 16 8 4 2 1
Digital Design 0
Copyright © 2007 Done! 23 in decimal is 10111 in binary.
Frank Vahid 13
Converting from Decimal to Binary Numbers:
Division Method (Good for Computers)
• Divide decimal number by 2 and insert remainder into new binary
number.
– Continue dividing quotient by 2 until the quotient is 0.
• Example: Convert decimal number 12 to binary
Decimal Number Binary Number
6
2 12 divide by 2 0
-12 1
0
insert remainder
Digital Design
Copyright © 2007
Frank Vahid 15
Base Sixteen: Another Base Sometimes Used by
Digital Designers
8 A F • Nice because each position
1 4 1 3 1 2 1 1 1 0 represents four base two positions
6 6 6 6 6
8 A F – Used as compact means to write
100 101 111
binary numbers
0 0 1 • Known as hexadecimal, or just hex
hex bin ry hex bin ry
a a
0 000 8 100
1 0
000 9 0
100
2 1
001 A 1
101
3 0
001 B 0
101
4 1
010 C 1
110
5 0
010 D 0
110 Q: Write 11110000 in hex
6 1
011 E 1
111
7 0
011 F 0
111
1 1 F0 a
Digital Design
Copyright © 2007
Frank Vahid 16
cMp
ro 1.3
Implementing Digital Systems: Programming
Microprocessors Vs. Designing Digital Circuits
Programmed Custom designed
Desired motion-at-night detector • Microprocessors a
microprocessor digital circuit
common choice to
implement a digital
system
– Easy to program
– Cheap (as low as
$1)
– Available now
I0 P0 void main() 1
I1 P1 { a
0
I2 P2 while (1) { 1
I3 P3 P0 = I0 && !I1; b 0
I4 P4 // F = a and !b,
I5 P5 1
} F
I6 P6 0
I7 P7 }
6:0 7:0 7:0 9:0 9:0 tim
0 5 6 0 1 e
Digital Design
Copyright © 2007
Frank Vahid 17
Digital Design: When Microprocessors Aren’t Good
Enough
• With microprocessors so easy, Q: How long for each
cheap, and available, why Image
Sensor
Micro- implementation option?
processo
design a digital circuit? r
– Microprocessor may be too (a) (Read, 5+8+1
Compress
slow Memor , =14 sec
y and Store)
– Or too big, power hungry, or
costly Image Sensor Read Compres
circui s
t circuit
.1+.5+.8
Sample digital camera task execution times (in
seconds) on a microprocessor versus a digital (b) =1.4 sec
Store a
circuit: Memor
circui
y
t
Task Microprocessor Custom
Digital Circuit Image Sensor Read Compres
Read 5 0.1 circui s
t circuit .1+.5+1
Compress 8 0.5 (c) =1.6 sec
Microprocessor
Store 1 0.8 Memory (Store) Good
compromise
Digital Design
Copyright © 2007
Frank Vahid 18
Chapter Summary
• Digital systems surround us
– Inside computers
– Inside huge variety of other electronic devices (embedded
systems)
• Digital systems use 0s and 1s
– Encoding analog signals to digital can provide many benefits
• e.g., audio -- higher-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 enough -- need custom digital circuits
Digital Design
Copyright © 2007
Frank Vahid 19