2025-01-05
FPGA/ASIC Design with Verilog
Chapter 1: Introduction
Duong Ngoc Phap, Ph.D
Faculty of Computer Engineering and Electronics
Slides to accompany the textbook Digital Design, First Edition,
by Frank Vahid, John Wiley and Sons Publishers, 2007.
http://www.ddvahid.com
January 5, 2025
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: Better 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 DVD Video Musical
players recorders instruments
Portable
music players Cell phones Cameras TVs ???
1995 1997 1999 2001 2003 2005 2007
• Years shown above indicate when digital version began to dominate
– (Not the first year that a digital version appeared)
Note: Slides with animation are denoted with a small red "a" near the animated items 2
1
2025-01-05
1.2
What Does “Digital” Mean?
Analog signal • Digital signal
• Inifinite possible values – Finite possible values
Ex: voltage on a wire • Ex: button pressed on a
created by microphone keypad
Sound waves
move the
membrane, 1 2 3 4
which moves
2
digital
the magnet,
signal
microphone
analog
which creates
signal
current in the nearby wire
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 Signals with Only Two Values: Binary
Binary digital signal -- only two
possible values
• Typically represented as 0 and 1
value
• One binary digit is a bit
1
• We’ll only consider binary digital 0
signals time
• 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)
4
2
2025-01-05
Example of Digitization Benefit
Analog signal (e.g., audio) may
lengthy transmission
Volts
lose quality
(e.g, cell phone)
3 3
• Voltage levels not 2 2
saved/copied/transmitted
perfectly 1 original signal 1 received signal
0 0
Digitized version enables near- time time
perfect save/cpy/trn. How fix -- higher, lower, ?
• “Sample” voltage at particular 01 10 11 10 11
rate, save sample using bit
lengthy transmission
a2d
(e.g, cell phone)
encoding
Volts
a
• Voltage levels still not kept
perfectly 1 digitized signal 1
• But we can distinguish 0s 0
from 1s 0
time time
Can fix -- easily distinguish 0s
Let bit encoding be: 01 10 11 10 11 and 1s, restore
1 V: “01” Digitized signal not d2a
2 V: “10” perfect re-creation, 3
Volts
3 V: “11” but higher sampling
rate and more bits per 2
encoding brings closer. 1
0 time
5
Digitized Audio: Compression Benefit
Digitized audio can be Example compression scheme:
compressed 00 --> 0000000000
• e.g., MP3s 01 --> 1111111111
1X --> X
• A CD can hold about
20 songs
uncompressed, but 0000000000 0000000000 0000001111 1111111111
about 200 compressed 00 00 10000001111 01
Compression also done
on digitized pictures
(jpeg), movies (mpeg),
and more
Digitization has many
other benefits too
6
3
2025-01-05
How Do We Encode Data as Binary for
Our Digital System?
a
analog button
phenomena Some inputs inherently binary
0 1
• Button: not pressed (0),
sensors and
other inputs pressed (1) red blue green black
electric digital
signal data
Some inputs inherently digital 0 0 0
A2D • Just need encoding in binary red blue green black
digital • e.g., multi-button input:
data encode red=001, blue=010, ... 0 0 1
Digital System Some inputs analog red blue green black
digital digital • Need analog-to-digital 0 1 0
data data conversion air 33
D2A
• As done in earlier slide -- degrees
electric
signal sample and encode with bits temperature
actuators and sensor
other outputs
0 0 1 0 0 0 0 1
How to Encode Text: ASCII, Unicode
ASCII: 7- (or 8-) bit Symbol Encoding Symbol Encoding
encoding of each
R 1010010 r 1110010
S 1010011 s 1110011
letter, number, or
T 1010100 t 1110100
L 1001100 l 1101100
symbol
N 1001110 n 1101110
E 1000101 e 1100101
0 0110000 9 0111001
Unicode: Increasingly .
<tab>
0101110
0001001
!
<space>
0100001
0100000
popular 16-bit bit
encoding Question:
What does this ASCII bit sequence represent?
• Encodes characters 1010010 1000101 1010011 1010100
from various world
languages a
REST
Note: small red “a” (a) in a slide indicates animation
8
4
2025-01-05
How to Encode Numbers: Binary
Numbers
Each position represents a
quantity; symbol in
position means how many
of that quantity
• Base ten (decimal) 5 2 3
Ten symbols: 0, 1, 2, ..., 8, 104 103 102 101 100
and 9
More than 9 -- next position
• So each position power of 10
Nothing special about base
10 -- used because we have
10 fingers 1 0 1 Q: How much?
• Base two (binary) 24 23 22 21 20 + =
Two symbols: 0 and 1 a
More than 1 -- next position
• So each position power of 2 4+ 1= 5
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, ... 512 256 128 64 32 16 8 4 2 1
• In base two, helps to know
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 512 256 128 64 32 16 8 4 2 1 a
10
5
2025-01-05
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 32 16 8
1
4 2 1
=32
quantity 32 16 8 4 2 1
too much
Work from left to right 0 1 =16
too much
(Right to left – may fill in 1s 32 16 8 4 2 1
a
that shouldn’t have been 0 0 1 =8
there – try it). 32 16 8 4 2 1
ok, keep going
0 0 1 1 =8+4=12
DONE
32 16 8 4 2 1
0 0 1 1 0 0 answer
32 16 8 4 2 1
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 subtract a 32 16 8 4 2 1
selected binary weight from 1 32 is
too much
the (remaining) quantity 32 16 8 4 2 1
Then, we have a new 0 1 16 is
remaining quantity, and we 32 16 8 4 2 1
too much
start again (from the present a
binary position) 0 0 1 12 – 8 = 4
Stop when remaining quantity 32 16 8 4 2 1
is 0
0 0 1 1 4-4=0
DONE
32 16 8 4 2 1
0 0 1 1 0 0 answer
32 16 8 4 2 1
12
6
2025-01-05
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
0
Done! 23 in decimal is 10111 in binary.
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
Continue dividing since quotient (6) is greater than 0
3
2 6 divide by 2 0 0
-6 2 1
0
insert remainder
Continue dividing since quotient (3) is greater than 0
14
7
2025-01-05
Converting from Decimal to Binary
Numbers: Division Method (Good for
Computers)
Example: Convert decimal number 12 to binary (continued)
Decimal Number Binary Number
1 1 0 0
2 3 divide by 2 4 2 1
-2
1
insert remainder
Continue dividing since quotient (1) is greater than 0
0 1 1 0 0
2 1 divide by 2 8 4 2 1
-0
1
insert remainder
Since quotient is 0, we can conclude that 12 is 1100 in binary
15
Base Sixteen: Another Base Sometimes
Used by Digital Designers
8 A F Nice because each position represents
16 4 16 3 16 2 16 1 16 0 four base two positions
8 A F • Used as compact means to write binary
numbers
1000 1010 1111
Known as hexadecimal, or just hex
hex bina ry hex bina ry
0 0000 8 1000
1 0001 9 1001
2 0010 A 1010
3 0011 B 1011
4 0100 C 1100
5 0101 D 1101 Q: Write 11110000 in hex
6 0110 E 1110
7 0111 F 1111
F0 a
16
8
2025-01-05
1.3
Implementing Digital Systems:
Programming Microprocessors Vs. Designing Digital Circuits
Programmed Custom designed
Desired motion-at-night detector microprocessor Microprocessors a
digital circuit common choice to
implement a digital
system
• Easy to program
• Cheap (as low as $1)
• Available now
MI0 P0 void main() 1
ropI1 P1 { a
ro
c I2 P2
0
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
17
Digital Design: When Microprocessors Aren’t Good
Enough
• With microprocessors so easy, cheap, and Q: How long for each
available, why design a digital circuit? Image Sensor Micro- implementation option?
processor
• Microprocessor may be too slow
• Or too big, power hungry, or costly (a) (Read, 5+8+11
Compress,
Memory and Store) =24 sec
Image Sensor Read Compress
circuit circuit
.1+.5+.8
Sample digital camera task execution times (in seconds) on
(b) =1.4 sec
a microprocessor versus a digital circuit:
Store a
Memory
circuit
Task Microprocessor Custom
Digital Circuit Image Sensor Read Compress
circuit circuit
Read 5 0.1 .1+.5+1
Compress 8 0.5 (c) =1.6 sec
Microprocessor
Store 1 0.8 Memory (Store) Good
compromise
18
9
2025-01-05
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
19
Q&A
January 5, 2025
10