CH 01
CH 01
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
1995 1997 1999 2001 2003 2005 2007 2009 2011 2013 2015
Digital Design 2e • Years shown above indicate when digital version began to dominate
Copyright © 2010
– (Not the first year that a digital version appeared)
2
Frank Vahid
1.2
2
which moves digital
the magnet,
signal
microphone
analog a
value
0, 1, 2, 3, or 4.
... infinite possibilities 3 That’s 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
We’ll 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
a2d
Volts
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
1
Digital Design 2e encoding improves re-creation
Copyright © 2010 0 5
Frank Vahid
Digitization Benefit: Can Store on Digital Media
analog signal
on wire
3
2
Volts
1 samples
wire 0
00 01 10 10 11 11 11 01 10 10 00 time
analog-to-
microphone digital digitized signal
converter
Store on CD, USB drive,
(a) 0001101011111101101000
etc. No deterioration.
wire
1
0
00 01 10 10 11 11 11 01 10 10 00 time
(b)
speaker
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
sensors and
other inputs – Button: not pressed (0), red blue gr een black
electric digital pressed (1)
signal data 0 0 0
• Some inputs inherently
A2D
digital red blue gr een black
digital
data – Just need encoding in 0 0 1
binary
Digital System red blue gr een black
– e.g., multi-button input:
digital digital encode red=001, blue=010, 0 1 0
data data ... air 33
D2A
• Some inputs analog degrees
electric
signal – Need analog-to-digital temperature
sensor
actuators and conversion
other outputs
– As done in earlier slide --
sample and encode with
Digital Design 2e
bits 0 0 1 0 0 0 0 1
Copyright © 2010 8
Frank Vahid
How to Encode Text: ASCII, Unicode
Sample ASCII encodings
• ASCII: 7- (or 8-)
Encoding Symbol Encoding Symbol
010 0000 <space>␠ 110 0001 a
Encoding Symbol Encoding Symbol 110 0010 b
bit encoding of
010 0001 !
010 0010 " 100 0001 A 100 1110 N ...
010 0011 # 100 0010 B 100 1111 O 111 1001 y
each letter, 010 0100
010 0101
$
%
100
100
0011
0100
C
D
101 0000
101 0001
P
Q
111 1010 z
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 16’s place 16 8 4 2 1
sum
exceeding 8 <= 12, so put 0 1
(b) 1 in 8’s place, 8
number 16 8 4 2 1
current sum is 8
• Track sum
8+4=12 <= 12, so put 0 1 1
a
Digital Design 2e
Copyright © 2010 13
Frank Vahid
Converting from Decimal to Binary
Digital Design 2e
Copyright © 2010 14
Frank Vahid
Base Sixteen: Another Base Used by Designers
8 A F • Nice because each position
16 4 16 3 162 16 1 16 0 represents four base-two positions
8 A F – Compact way to write binary numbers
1000 1010 1111 • Known as hexadecimal, or just hex
h ex binary h ex 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
128 64 32 16 8 4 2 1
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
Decimal Binary
1 1 0 1 0
26 10
16 8 4 2 1
To binary
To decimal
1 1 0 1 0 To hex To octal
16 8 4 2 1 16 + 8 + 2
16+8 = 26 10
16 24 24+2 --
= 24
= 26 1 1010 11 010
= 1A16 = 32 8
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 N—just
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
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)
– Readily available
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:05 7:06 9:00 9:01 time
Digital Design 2e
Copyright © 2010 22
Frank Vahid
Digital Design: When Microprocessors Aren’t 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 Aren’t 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