Está en la página 1de 25

Chapter 1: Introduction

Instructor: Dr. Hyunyoung Lee

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 Vahid


Instructors 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
Digital
2e
with animations)
may Design
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.
Copyright
2010of the slides available to students for a reasonable photocopying charge, without incurring royalties. Any other use requires explicit permission. Instructors
1
Instructors may
make printouts
Frank Vahid
may obtain PowerPoint
source or obtain special use permissions from Wiley see http://www.ddvahid.com for information.

1.1

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
Satellites
Portable
music players
Digital Design 2e
Copyright 2010
Frank Vahid

1995

DVD
players

Cell phones

1997

1999

Video
recorders
Cameras

2001

2003

Musical
instruments
TVs

2005

2007

Years shown above indicate when digital version began to dominate

(Not the first year that a digital version appeared)

???

1.2

What Does Digital Mean?


Analog signal
Infinite possible values
Ex: voltage on a wire
created by microphone

Digital signal
Finite possible values
Ex: button pressed on a
keypad

digital
signal
a

Possible values:
1.00, 1.01, 2.0000009,
... infinite possibilities
a

time
Digital Design 2e
Copyright 2010
Frank Vahid

value

value

analog
signal
4
3
2
1
0

Possible values:
0, 1, 2, 3, or 4.
Thats it.

time
3

Digital Signals with Only Two Values: Binary

Typically represented as 0 and 1


One binary digit is a bit
Well only consider binary digital signals
Binary is popular because

value

Binary digital signal -- only two


possible values

1
0

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
Frank Vahid

Digitized version enables


near-perfect save/cpy/tran.

01 10 11 10 11

a2d
1
0

digitized signal
time

time
How fix -- higher, lower, ?

1
0
time
Can fixdistinguish 0s/1s, restore

m
e

Not a perfect re-creation


due to a2d and d2a

01 10 11 10 11

Let bit encoding be:


1 V: 01
2 V: 10
3 V: 11
Digital Design 2e
Copyright 2010
Frank Vahid

received signal

sa

Sample voltage at
particular rate, save
sample using bit encoding
Voltage levels still not kept
perfectly
But we can distinguish 0s
from 1s

time

3
2
1
0

Higher sampling
rate and more bits per
encoding improves re-creation

Volts

original signal

lengthy transmission
(e.g, cell phone)

Voltage levels not saved/


copied/transmitted
perfectly

3
2
1
0

lengthy transmission
(e.g, cell phone)

Analog signal (e.g., audio,


video) may lose quality
Volts

Volts

Example of Digitization
Benefit

3
2
1
0

d2a

!"#"$"%&$"'()*+(+,"$-).&()/$'0+)'()!"#"$&1)2+3"&
Digitization Benefit: Can Store on Digital Media

Store on CD, USB drive,


etc. No deterioration.

a
a

Digital Design 2e
Digital
Design 2e
Copyright
2010
2010
Frank Copyright
Vahid
Frank Vahid

Digitized Audio: Compression Benefit


Digitized audio can be
compressed

Example compression scheme:


00 means 0000000000
01 means 1111111111
1X means X

e.g., MP3s
A CD can hold about 20
songs uncompressed,
but about 200
0000000000 0000000000 0000001111 1111111111
compressed
a

Compression also done


on digitized pictures
(jpeg), movies (mpeg),
and more
Digitization has many
other benefits too
Digital Design 2e
Copyright 2010
Frank Vahid

00 00 10000001111 01

How Do We Encode Data as Binary for Our Digital


System?
analog
phenomena

sensors and
other inputs
electric
digital
signal
data
A2D
digital
data

Digital Design 2e
Copyright 2010
Frank Vahid

Some inputs inherently


digital
Just need encoding in
binary
e.g., multi-button input:
encode red=001,
blue=010, ...

digital
data

D2A
electric
signal
actuators and
other outputs

Some inputs inherently


binary
Button: not pressed (0),
pressed (1)

Digital System
digital
data

button

Some inputs analog


Need analog-to-digital
conversion
As done in earlier slide -sample and encode with
bits

red

blue green

black

0 0 0
red

blue green

black

0 0 1
red

blue green

black

0 1 0

air

33
degrees

temperature
sensor

0 0 1 0 0 0 0 1

!"#$%"$&'(")*$+*,%-$./0112$3'4(")*
!"#$%"$&'(")*$+*,%-$./0112$3'4(")*
!"#$%"$&'(")*$+*,%-$./0112$3'4(")*
How to Encode Text: ASCII, Unicode
Sample
ASCII
encodings
Sample
ASCII
encodings
Sample
ASCII
encodings

Encoding
Symbol
Sample ASCII encodings
Encoding
Symbol
Encoding
Symbol
Encoding
Sym
Encoding
Symbol
Encoding
Symbol
110
aa
010 0000
<space>
110 0001
a
1100001
0001
010 0000
0000
<space>
010
<space>
Encoding
Symbol
Encoding
Symbol
Encoding
Symbol
Encoding
Symbol
Encoding
Symbol
Encoding
Symbol
110
0010
b
010 0001
!
110 0010
110 0010b
b
010
!!
010 0001
0001
100 100
0001
A A A 100100
0001
1110
N
100
0001
1110
N
...
100
1110
N
010 0010
"
...
010
0010
"
...
010 0010
"
0010
0010
1111
O O O 111
1111
100
0010B B B 100100
yy
1111001
1001
100
1111
010 0011
#
010
## 100 100
111 1001
y
010 0011
0011
100
0011
C
100
0011
C
101
0000
P
101
0000
P
111
1010
z
100
0011
C
111
1010
z
010
0100
$
010 0100
$
101
0000
P
111
1010
z
010 0100
$
0100
100 100
0100
D D D 101101
0001
Q Q
0001
Q
010
0101
%
100
0100
010 0101
%
101
0001
010 0101
%
0101
0010
100 100
0101
0010
R R R 011
010
0110
&
0110000
0000
100
0101E E E 101101
010 0110
&
00
101
0010
010 0110
&
011 0000
0
100
0110
F
101
0011
S
100
0110
F
010 0111'
'
S
0110001
0001
100 0110
F 101 0011
010 0111
011
11
101
0011
S
010 0111
'
011
0001
1
0111
G
0100 T T
100 100
0111
010 1000(
(
0110010
0010
0100
100 0111G
G 101101
010 1000
22
101 0100
T 011
010 1000
(
011 0010
2
100
1000
H
101
0101
U
010
1001
)
011
0011
3
100
1000
H
U
100
1000 I H 101 0101
010 1001
)
011
0011
3
101
0101
U
010
1001
)
011
0011
3
100
1001
0110 V V
010 1010
*
011 0100
4
100 1001
I
101101
0110
100
1001
I
010 1010
*
011
0100
4
101
0110
V
010 1011
1010
100 1010
J
011 01005
4
101 0111
W
010
+*
011 0101
100 1010
0111
W
100
1010J K J 101101
010 1011
+
011 0101
5
101
0111
W
100
1011
010
1011
+
011
0101
5
1000
X
010 1100
,
011 0110
6
100 1011
1000
X
100
1011K L K 101101
010 1100
0110
6
101
1000
1100
1001
Y X 011
010 1101
1100,
011
0110
6
010
- , 100 100
011
0111
7
1100
L M L 101 1001
Y Z Y 011 0111
100
1100
010 1101
7
100
1101
101
1001
101
1010
010
1101
011
0111
7
010 1110
.
011 1000
8
100 1101
M
101 1010
Z
100
1101
M
010 1110
.
011
1000
8
101
1010
Z
010 1111
1110
010
/.
011 10009
8
011 1001
010 1111
011 1001
9
010 1111/
/
011 1001
9

7- 7(or
8-)
ASCII:
ASCII:
ASCII:
7(or
8-)
ASCII:
7-(or
(or8-)
8-)
bit bit
encoding
of of
bit
encoding
of
encoding
bit
encoding
of
each
letter,
each
letter,
each
letter,
each
letter,
number,
or
number,
or
number,
or or
number,
symbol
symbol
symbol
symbol
Unicode:
Unicode:
Unicode:
Unicode:
Increasingly
Increasingly
Increasingly
Increasingly
popular16-bit
16-bit
popular
popular
16-bit
popular
16-bit
encoding
encoding
encoding
encoding
Encodes
Encodes

characters from
Encodes
Encodes
characters
from
various
world
characters
from
characters
from
various
world
languages
various
world
various
world
languages
languages
languages
Digital Design 2e
Digital
Design2e
Copyright
2010
Copyright
2010
Frank Vahid
Digital Design
Frank2e
Vahid

Digital Design 2e
Copyright 2010

Question:
Question:

Question:
Question:
What does
does this
bit
What
this ASCII
ASCII
bitsequence
sequencerepresent?
represent?
What
does
thisthis
ASCII
bit1010011
sequence
represent?
What
does
ASCII
bit sequence
represen
1010010
1000101
1010100
1010010
1000101
1010011
1010100
1010010
1000101
1010011
1010100
1010010
1000101
1010011
1010100
RREESSTT

R ERS ET S T

How to Encode Numbers: Binary Numbers


Each position represents a
quantity; symbol in position
means how many of that
quantity
Base ten (decimal)

104 103 102 101 100

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
Digital Design 2e
Copyright 2010
Frank Vahid

24

23

22

21

20

Q: How much?
+ =
a

4 + 1= 5
10

Using Digital Data in a Digital System


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
Digital Design 2e
Copyright 2010
Frank Vahid

temperature sensor
0

"33"

Digital System
if (input <= "00100000") // "32"
output = "1000110" // "F"
else if (input >= "11010100") // "212"

output = "1000010" // "B"


else
output = "1001110" // "N"
1

display

"N"

11

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.
Useful to know powers of 2:

Practice counting up by powers of 2:


Digital Design 2e
Copyright 2010
Frank Vahid

29

28

27

26

25

512 256 128 64 32

24

23

16 8

22

21

20

512 256 128 64 32 16 8 4 2 1


12

Converting from Decimal to Binary

Put 1 in
leftmost
place without
sum
exceeding
number
Track sum

Digital Design 2e
Copyright 2010
Frank Vahid

Desired decimal
number: 12

Binary
number

Current
sum

(a)

16 > 12, too big;


Put 0 in 16s place

(b)

8 <= 12, so put


1 in 8s place,
current sum is 8

0
16 8

0 1
16 8

(c)

8+4=12 <= 12, so put


1 in 4s place,
current sum is 12

12

0 1
16 8

1
4 2

(d)

Reached desired 12,


so put 0s in remaining
places

done

0 1
16 8

1 0
4 2

0
1

13

Converting from Decimal to Binary

Example using
a more
compact
notation

Digital Design 2e
Copyright 2010
Frank Vahid

Desired decimal
number: 23

Binary
number
1 0

sum: 0 16 8 4 2 1
16
(a) 16
(b) 20
(c) 22
(d) 23
(e)

14

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

Digital Design 2e
Copyright 2010
Frank Vahid

Desired value: 73

Q:

(a)

0 1 0 0 1 0 0 1
128 64 32 16 8

sum:

64

72

(b)

73

DIP switch
channel receiver
"34" 0 0 1 0 0 0 1 0

1
0
"73" 0 1 0 0 1 0 0 1

InA

if (InA = InB)
Out = 1
else
Ceiling fan Out = 0
module
Out

InB

(c)

15

Base Sixteen: Another Base Used by Designers


164

163

162

161

160

Nice because each position


represents four base-two positions
Compact way to write binary numbers

1000 1010 1111


hex

binary

hex

binary

0
1
2
3
4
5
6
7

0000
0001
0010
0011
0100
0101
0110
0111

8
9
A
B
C
D
E
F

1000
1001
1010
1011
1100
1101
1110
1111

Known as hexadecimal, or just hex

Q: Write 11110000 in hex


F0

Q: Convert hex A01 to binary


a

1010 0000 0001


Digital Design 2e
Copyright 2010
Frank Vahid

16

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 1 0 0 0 1 1
128 64 32 16 8

1
a

Then binary to hex:

6 3

(Quick check: 6*16 + 3*1 = 96+3 = 99)

Digital Design 2e
Copyright 2010
Frank Vahid

17

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 #

(c) Province: 7

(a)
RFID
tag

Digital Design 2e
Copyright 2010
Frank Vahid

(d)
(e)
(f)

00000111
07

City #

Animal #

City: 160

Animal: 513

10100000

00000010 00000001

A0

02 01

Tag ID in hex: 07A00201


18

!"#$%&'(#)*+",-&".*/(#0&1*21*30#45*67..0&1
Converting To/From Binary by Hand: Summary

Digital Design
Digital
Design2e
2e
Copyright
Copyright
2010
2010
Frank Vahid
Frank Vahid

19

19

Divide-By-2 Method Common in Automatic Conversion


!"#"$%&'(&)*+%,-.$*/.00.1*"1*23,.04,"5*/.1#%67".1
Repeatedlydivide
dividedecimal
decimalnumber
numberbyby2,2,place
placeremainder
remainder
Repeatedly
currentbinary
binarydigit
digit(starting
(startingfrom
from1s1scolumn)
column)
inincurrent
1. Divide decimal number by 2
Insert remainder into the binary number
Continue since quotient (6) is greater than 0

Decimal
6
2 12

0

0
1
(current value: 0)

2. Divide quotient by 2
Insert remainder into the binary number
Continue since quotient (3) is greater than 0

3
2 6

0

0 0
2 1
(current value: 0)

3. Divide quotient by 2
Insert remainder into the binary number
Continue since quotient (1) is greater than 0

1
2 3

1

1 0 0
4 2 1
(current value: 4)

4. Divide quotient by 2
Insert remainder into the binary number
Quotient is 0, done

0
2 1

1

1 1 0 0
8 4 2 1
(current value: 12)

Digital
Design
2e 2e
Digital
Design
Copyright
2010
Copyright
2010
Frank
Vahid
Frank
Vahid

Binary

Note:
Note:
Works
for
Works for
any
base
any base
Njust
Njust
divide by
divide
by
instead
NN instead
20 20

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
Frank Vahid

21

Implementing Digital Systems: Programming

1.3

Microprocessors Vs. Designing Digital Circuits


Desired motion-at-night detector

Programmed Custom designed


microprocessor
digital circuit

Microprocessors a
common choice to
implement a digital
system

I0
I1
I2
I3
I4
I5
I6
I7

Digital Design 2e
Copyright 2010
Frank Vahid

P0
P1
P2
P3
P4
P5
P6
P7

Easy to program
Cheap (as low as
$1)
Readily available

void main()
1
a
{
0
while (1) {
1
P0 = I0 && !I1; b
0
// F = a and !b,
1
}
F
0
}
6:00

7:057:06

9:009:01

time

22

'LJLWDO'HVLJQ:KHQ0LFURSURFHVVRUV$UHQW*RRG
Digital Design: When Microprocessors Arent Good Enough
!"#$%&
With microprocessors so easy,

Withcheap,
microprocessors
so easy,
and available,
why
cheap,
and aavailable,
why
design
digital circuit?
design
digital circuit?may be too
aMicroprocessor

Wing controller computation task:


Microprocessor
may be too
slow
Wing controller computation task:
slow
Or too big, power hungry, or
50 ms on microprocessor
Or too
big, power hungry, or
costly
50 ms on microprocessor
costly
5 ms as custom digital circuit

5 ms as custom digital circuit


If must execute 100 times per second:
If must execute 100 times per second:
100 * 50 ms = 5000 ms = 5 seconds
100 * 50 ms = 5000 ms = 5 seconds
100 * 5 ms = 500 ms = 0.5 seconds
100Microprocessor
* 5 ms = 500 ms
0.5 seconds
too= slow,
circuit OK.
Microprocessor too slow, circuit OK.

Digital Design 2e
Copyright 2010
Digital Design
Frank2eVahid
Copyright 2010
Frank Vahid

23

23

Digital Design: When Microprocessors Arent Good Enough

Commonly, designers partition a


system among a
microprocessor and custom
digital circuits

Image Sensor Microprocessor


(a)
Memory

Image Sensor

Sample digital camera task execution times (in


seconds) on a microprocessor versus a digital (b)
circuit:
Task

Microprocessor

Custom
Digital Circuit

Read

0.1

Compress

0.5

Store

0.8

Digital Design 2e
Copyright 2010
Frank Vahid

(c)
Memory

5+8+1
=14 sec

(Read,
Compress,
and Store)

Read
circuit

Compress
circuit

.1+.5+.8
=1.4 sec

Store
circuit

Memory

Image Sensor

Q: How long for each


implementation option?

Read
circuit

Compress
circuit

Microprocessor
(Store)

.1+.5+1
=1.6 sec
Good
compromise
24

Chapter 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 2e
Copyright 2010
Frank Vahid

25

También podría gustarte