EGN3373-Week5a – Digital

Download Report

Transcript EGN3373-Week5a – Digital

Ch. 10 – Fundamentals of Logic Circuits
So far, the circuits we’ve discussed were analog
circuits, meaning that circuit parameters such as
voltage and current were continuous quantities.
1
What would happen if we sample the instantaneous
value at specific times? Then we would get a series
of discrete values that approximate the continuous
quantity.
2
Discrete values that approximate [represent]
continuous functions lead to the concept of a
digital circuit.
The simplest digital circuits consist of two
possible signal values.
These circuits are binary in nature, and are
represented with binary numbers.
3
Number Systems
We commonly use a decimal, or Base 10,
number system. Why?
It turns out that the number 10 does not have
very nice mathematical properties.
It is rather difficult and awkward to implement a
digital circuit based on the number 10.
4
Number Systems
A power of the number 2 (the number of binary states)
works much better.
2, 4, 8, 16, 32, 64, …
We will look at two of these number systems in some detail:
Base 2 (binary)
and
Base 16 (hexadecimal)
We’ll compare/contrast them with the good old (but
mathematically awkward) Base 10 (decimal) system.
5
Number Systems
The decimal, binary, and hexadecimal number systems are
place-valued number systems, where each digit takes on a
weighting based on the place within the number that it
appears.
Not all number systems are place valued. Some are based on
combinations of numerals.
© MCMLXIV
I=1
C = 100
V = 5 D = 500
X = 10 M = 1000
L = 50
6
Number Systems
In Base 10, we have the digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.
In Base 10, we have the following place values:
1000s 100s
4
10s
3
4  102
3  101
5  100
6  10-1
1  10-2
1s
.
5 . 6
1
= 400
= 30
= 5
= 0.6
= 0.01
435.61
7
Number Systems
In Base 2, we have the digits: 0 and 1.
In Base 2, we have the following place values:
8s
4s
2s
1
1
1  22
1  21
0  20
0  2-1
1  2-2
1s
.
0 . 0
=
=
=
=
=
1
4
2
0
0
0.25
6.25
8
Number Systems
In Base 16, we have the digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F.
In Base 16, we have the following place values:
4096s 256s
6
16s
C
6  162
12  161
3  160
13  16-1
10  16-2
1s
.
3 . D
A
= 1536
= 192
=
3
=
0.8125
=
0.0390265
1731.8515265
9
Number Conversion
• Binary to decimal conversion:
– Convert 100112 to decimal
• Decimal to binary conversion:
– Convert 4710 to binary
Number Conversion
• Binary to decimal conversion:
– Convert 100112 to decimal
– 16×1 + 8×0 + 4×0 + 2×1 + 1×1 = 1910
• Decimal to binary conversion:
– Convert 4710 to binary
– 32×1 + 16×0 + 8×1 + 4×1 + 2×1 + 1×1 = 1011112
Converting Between Base 2 and Base 16
Since 16 = 24, we can group binary digits into groups of
4 binary digits (bits) and convert each group of 4 bits
to hexadecimal (hex) separately.
1011 0010 1100 0111
C
4+2+1=7
8+4=12
2
8+2+1=11
B
2
7
(1011 0010 1100 0111)2 = B2C716
12
Powers of Two
•
•
•
•
•
•
•
•
20 =
21 =
22 =
23 =
24 =
25 =
26 =
27 =
•
•
•
•
•
•
•
•
28 =
29 =
210 =
211 =
212 =
213 =
214 =
215 =
Powers of Two
•
•
•
•
•
•
•
•
•
20 = 1
• 28 = 256
21 = 2
• 29 = 512
22 = 4
• 210 = 1024
23 = 8
• 211 = 2048
24 = 16
• 212 = 4096
25 = 32
• 213 = 8192
26 = 64
• 214 = 16384
27 = 128
• 215 = 32768
Handy to memorize up to 29
Converting Between Decimal,
Hexa, and Binary
15
Binary Arithmetic
Addition: 0 + 0 = 0
0+1=1
1 + 1 = 10
carry sum
Subtraction: A – B =
A + (– B) =
A + (2’s Complement of B)
OR
1–0=1
110 – 101 = 001 (Borrow)
One’s Complement:
Two’s Complement:
Toggle each bit (make each “0” a “1”
and each “1” a “0”)
One’s Complement + 1
Number: 0110 1101
1’s Complement: 1001 0010
Number: 0110 1101
1’s Complement: 1001 0010
2’s Complement: 1001 0011
MSB of a 2’s Complement number is
the sign bit (0=positive, 1=negative)
16
Binary Subtraction Example (Complement)
1001 0110
– 0010 0111
1’s Complement
1001 0110
– 1101 1000
2’s Complement
1001 0110
+ 1101 1001
1 0110 1111
ignore
Check using Decimal Subtraction:
1001 01102 = 15010
0010 01112 = 3910
111
150
– 39
check
111
17
Binary Subtraction Example (Borrow)
110
– 101
Borrow from 1
110010
– 101
Subtract
110010
+ 101
001
Check using Decimal Subtraction:
1102 = 610
1012 = 510
1
6
– 5
check
1
18