No Slide Title
Download
Report
Transcript No Slide Title
Leiden Embedded Research Center,
LIACS, Leiden University.
Monday: 1:30 – 2.50 p.m. 3:10 – 4:30 p.m.
Digital Design
Fundamentals
Ed Deprettere, Todor Stefanov, Hristo Nikolov
LIACS/LERC
Leiden University
www.liacs.nl/~cserc/DITE/DITE2004/
Course Organization
• Class lectures and hands-on are fully integrated.
• There is no ” practicum ” but:
towards the end of the course you get a final
design assignment for which you need
several small components you have been
designing during the course.
• Course is divided in two parts:
September-October : lectures/hands-on = 1
November-December : lectures/hands-on = .5
• Mid-term exam after first part; you must take
that exam.
• Several home works will be given. You must
turn them in.
Fall 2004
Digital Design Fundamentals Ed F.
Deprettere Leiden University
Course Organization (cont’d)
All you need to know, you’ll find on the course
website:
1. You must attend the classes,
2. You must make and turn-in the home works,
3. Home work instructions are posted on the
internet (We don’t tell you),
4. You must turn-in your hands-on assignments,
5. You must take the mid-term exam,
6. You must take the January exam.
See course website for all information and
instructions; again, We don’t tell you.
No compromises, No excuses. We teach, you learn.
Fall 2004
Digital Design Fundamentals Ed F.
Deprettere Leiden University
What is the course
teaching you?
All you need to know to understand the
•
•
•
What,
Why, and
How,
of digital processors, processor operation,
and processor design.
Fall 2004
Digital Design Fundamentals Ed F.
Deprettere Leiden University
Basic Digital System Structure
cpu: central processing unit
data path: arithmetic and
logic operations
storage
control
cpu unit
data
path
input/output
control unit: make sure
that the sequence of
data path operations is
correct
storage: no memory = no
system
input/output: keybord,
microphone/speaker,…
Fall 2004
Digital Design Fundamentals Ed F.
Deprettere Leiden University
For Modern Computers
Not only for computers
Fall 2004
Digital Design Fundamentals Ed F.
Deprettere Leiden University
Digital means digit-wise ?
Every language is based on an alphabet. The
Roman alphabet consists of 26 characters.
The decimal number system consists of 10 digits.
Characters and Digits are two examples of
Symbols.
Early digital computers were used mostly for
numeric computations: the digits were the
symbols used (and hence the name).
But that is not important: important is that a
digital
system manipulates discrete elements of
information
Fall 2004
Digital Design Fundamentals Ed F.
Deprettere Leiden University
The digital system alphabet is binary
your desktop, laptop, or mobile phone know
only one alphabet with symbols 0 and 1. Why?
Because they have a basic building block,
called a switch, that can only be on or off. The
physical switch is called the transistor.
drain
N
source
gate
drain
P
source
gate
Fall 2004
if g = 1 then switch is closed
else ( g = 0) switch is open
If g = 0 then switch is closed
else ( g = 1 ) switch is open
Digital Design Fundamentals Ed F.
Deprettere Leiden University
N-switch
o
P-switch
A simple example: Inverter
Physically: Voltages are used: H(igh) and L(ow)
Logically : Binary Numbers are used: 1 and 0.
An example: The Inverter
Vdd (1)
o
Vin
Pull up
Vout
Pull down
Vin
1
0
Vout
0
(from N)
(from P)
1
Vss (o)
Physical N-transistor passes a 0 well and a 1
poorly; P-transistor does the opposite; to have
both, use complementary switch (transmission
gate):
Fall 2004
Digital Design Fundamentals Ed F.
Deprettere Leiden University
Example: Transmission Gate
o
o
c
Vin
Through P
Fall 2004
Vin
Vout
1
0
1
0
Digital Design Fundamentals Ed F.
Deprettere Leiden University
Vout
g=1
Through N
Decimal – Binary - Decimal.
One step back: your desktop, laptop, cell phone,
do convert your decimal symbols immediately to
their binary symbols. How?
That is not too difficult, once we understand how
all number systems, not only the decimal one (09),
but also the binary one (0-1) have a similar formal
representation. Here is how.
Fall 2004
Digital Design Fundamentals Ed F.
Deprettere Leiden University
Familiar things first
555.5 is a decimal number in positional code.
The meaning of each 5 depends on its position.
five hundreds fifty five and five tenths
5x102 5x101 5x100 5x101
5 { 0, 1, 2, .. ,9 } the digit set
10 is base or radix
addition:
Fall 2004
subtraction:
11
325
+ 196
11
521
-196
521
325
Digital Design Fundamentals Ed F.
Deprettere Leiden University
Why not other base ?
you could take any base:
An1r n1 An2r r 2 ... A1r1 A0r 0 A1r 1 A2 r 2 ... Am1r m1 Amr m
base is r
digits are
Ai {0,1,...,r 1}
most significant digit
least significant digit
0 Ai r
( An1 An2 ...A1 A0 .A1 A2 ...Am1 Am )r
positional notation
Example:
36
2
1
(123)6 1x6 2x6 3x6 (51)10
Base 6
Fall 2004
6
1
Decimal Meaning
Digital Design Fundamentals Ed F.
Deprettere Leiden University
0
Base 10
Bits and Bytes and Words
A bit is a quantity b with a value in {0, 1}. A byte is a
sequence of eight bits. A word is a sequence of 2,3,4, .. bytes.
a bit: 1
a byte: 01110001
a word : 00111101 01001101
Digital systems read and write in a binary code called ASCII
(American Standard Code for Information Exchange). They are the
so-called alphanumeric characters. Each of them is represented by
a unique byte.
character
A
B
O
P
Z
(
ASCII code
a
b
o
p
z
0
1
2
3
9
0100 0001
0010
1111
0101 0000
1010
0110 0001
0010
1111
0111 0000
1010
0011 0000
0001
0010
0011
1001
[
{
0010 1000
0101 1011
0111 1100
0000 0000
0001 1011
0000 1010
NULL ESC LF
Fall 2004
Digital Design Fundamentals Ed F.
Deprettere Leiden University
What about the decimals?
The decimal digits can be represented by half a byte.
decimal digit
binary coded decimal digit
0
1
2
3
4
5
0000
0001
0010
0011
0100
0101
7
8
9
0111
1000
1001
6
0110
Does that make sense? It does:
6 0 x23 1x22 1x21 0 x20
Binary-Coded Decimals (BCD code)
Example: (19)10 = (0001 1001)BCD
Fall 2004
Digital Design Fundamentals1Ed F.
Deprettere Leiden University
9
The binary number system
bn1 2n1 bn2 2r 2 ... b1 21 b0 20 b1 21 b2 22 ... bm1 2m1 bm 2m
base is 2
digits are
bn {0,1}
most significant bit
least significant bit
0 bn 2
(bn1bn2 ...b1b0 .b1b2 ...bm1bm )r
positional notation
Example:
16
4
8
4
2
1
(10011)2 1x2 0x2 0x2 1x2 1x2 (19)10
Base 2
Fall 2004
3
2
Decimal Meaning
Digital Design Fundamentals Ed F.
Deprettere Leiden University
1
0
Base 10
Burn this table into your memory
n
2
0
n
n
2
1
5
1
2
2
n
n
2
32
10
1024
6
64
11
2048
4
7
128
12
4096
3
8
8
256
13
8192
4
16
9
512
14
16384
210 1,024 is 1K
(kilo)
Fall 2004
n
2 20 is 1M
(mega)
Digital Design Fundamentals Ed F.
Deprettere Leiden University
2 30 is 1G
(giga)
What about negative numbers?
Since we do not have anything but bits, we use a bit to identify the
sign of a binary number.
For example like this,
0 | 1001 (+9)
1 | 1001 (-9)
This is called the signed-magnitude representation.
But we can do it differently, using signed-complements.
Either r’s complement (2’s) or (r-1)’s complement (1’s).
An example: +9 and three representations of -9 encoded in a single byte:
+9
-9 signed magnitude
-9 signed-1’s complement
-9 signed-2’s complement
0000 1001
1000 1001
1111 0110 (how to get it?)
1111 0111 (how to get it?)
The signed-2’s complement system is the only one having only one
representation of zero (0| 0), which is always positive.
Fall 2004
Digital Design Fundamentals Ed F.
Deprettere Leiden University
More about negative numbers
1’s complement
1|11
1|10
1|01
1|00
Decimal Binary
0
1
2
3
4
0|00
0|01
0|10
0|11
2’s complement
0|00
1|11
-4 + 3
1|10
1|01
1|00
flip bits
1’s complement + 0 | 0 1
2’s complement system is not symmetric
3
2
1
0
-1
-2
-3
-4
Fall 2004
3+1=-4
- 4 –1 = + 3
Digital Design Fundamentals Ed F.
Deprettere Leiden University
Binary addition and subtraction
addition:
1
111
19
7
+
0| 10011
+0 | 0 0 1 1 1
26
0| 11010
subtraction: (7 - 19) = - (19 -7) = - 12 = 7 + (-100 + 81) = - 100 + 88 = -12
+
0 | 07
9 | 81
1111
0|00111
+ 1|01101
9 | 88
1|10100
- 12
Fall 2004
Digital Design Fundamentals Ed F.
Deprettere Leiden University
0|01100
Other useful number systems
Apart from the ordinary binary number system, computers do use also the
Octal number system
Hexadecimal number system
base 8
base 16
These systems have a more compact representation of binary quantities.
The octal system has digits in {0, 1, .., 7}, the hexadecimal system has digits
in {0, 1, .., 15}
warning: we don’t use the symbols 10, 11, .. ,15 in the base-16 system
we use the letters A, B, .. , F instead.
All what is left is:
Conversions
Fall 2004
Digital Design Fundamentals Ed F.
Deprettere Leiden University
Another table to exercise
Decimal (10)
7
8
9
10
11
12
13
14
15
Fall 2004
Binary (2)
0111
1000
1001
1010
1011
1100
1101
1110
1111
Octal (8)
07
10
11
12
13
14
15
16
17
Digital Design Fundamentals Ed F.
Deprettere Leiden University
Hex (16)
7
8
9
a
b
c
d
e
f
Conversions
• Group bits
• Binary to octal or hex: start at binary point
1101010.012 to octal (groups of 3): 001 101 010 . 0102 =
152.28
1101010.012 to hex (groups of 4): 0110 1010.01002 = 6a.416
• Octal to binary: a digit at a time
127.48 = 001 010 111.1002 = 1010111.12
• Hexadecimal to binary : a digit at a time
b65f16 = 1011 0110 0101 11112 = 10110110010111112
• Hexadecimal to octal or octal to hex:
– Hex —> binary —> octal
– Octal —> binary —> hex
Fall 2004
Digital Design Fundamentals Ed F.
Deprettere Leiden University
Remains 2-to-10 and 10-to-r
2-to-10 is easy: use expansion
10-to-r
Decimal integers to Octal.
(25)10
25/8 = 3 + 1/8 remainder = 1
3/8 = 0 + 3/8 remainder = 3
(31)8
Decimal fractions to Octal.
(0.26)10
0.26 x 8 = 2.08 integer = 2
0.08 x 8 = 0.64 integer = 0
(0.20)8 (approximate)
Fall 2004
Digital Design Fundamentals Ed F.
Deprettere Leiden University
Back to basic structure
The conversion from
base 10 to base r
can be programmed
for execution on a
digital computer like
this one.
storage
control
cpu unit
I’ll give a program in a
high-level language. We
will see later how that
language is translated to
the computer’s binary language.
Fall 2004
Digital Design Fundamentals Ed F.
Deprettere Leiden University
data
path
input/output
(0.N)10 = (0.A-1A-2…..A-n)r
we know the procedure, and here is a
storage
program
k = -1;
Clock
N
while (k >= -n) {
control
data
tem = path
N*r;
cpu unit
Control
Multiply
A[k] = Int(tem);
by r
N = Fract(tem);
Integer
input/output
part
k = k-1;
Storage
} end
Fractional
part
Fall 2004
Digital Design Fundamentals Ed F.
Deprettere Leiden University
Number ranges.
• Three bit binary number 1112 = 7
• Two digit octal number 778 = 6310
• General case?
111112 + 1 = 100000 = 25
111112 = 25 - 1 = 32 - 1 = 31
• Largest n-bit (binary) number = n ones = 2n - 1
• Largest n-digit radix r number = n (r-1)’s = rn - 1
• Example: largest 3 digit decimal number = 103 - 1 =
1000 - 1 = 999
What about smallest n-bit binary fractions?
Fall 2004
Digital Design Fundamentals Ed F.
Deprettere Leiden University
Can we also talk binary?
RF wave modulated by the bits
speech in
what happens in here?
This
speech is sampled at 8000
samples per second and each
sample is coded as a single byte.
The cost is 64 Kbit/sec which is way too much. Speech processing
techniques (digital signal processing) allow us to bring this amount
down to as low as 2.4 Kbit/s. What about image and video?
Fall 2004
Digital Design Fundamentals Ed F.
Deprettere Leiden University