5 Lecture 3

advertisement
29/01/2013
DIGITAL ELECTRONICS I
Lecture 3 – Binary Arithmetic


Addition
Subtraction
◦ Signed magnitude numbers
◦ 2’s complement numbers


Multiplication
Division
©2013 Dr. F. Muddeen
2
1
29/01/2013
00  0
0 1  1
1 0  1
1  1  10


Which is really ‘0’ carry ‘1’
Like 8 + 2 = 10, which is ‘0’ carry ‘1’
©2013 Dr. F. Muddeen

3
Try this out using the previous rules:
Decimal
Binary
50
127
177
©2013 Dr. F. Muddeen
4
2
29/01/2013
Fill in the blanks
Decimal
Binary
50
00110010
127
01111111
177
©2013 Dr. F. Muddeen
5
Fill in the blanks
Decimal
Binary
50
00110010
127
01111111
177
10110001
©2013 Dr. F. Muddeen
6
3
29/01/2013
00  0
1 0  1
11  0

0 – 1 = 1 borrow ‘1’ which is 10 – 1 = 1
©2013 Dr. F. Muddeen
7
©2013 Dr. F. Muddeen
8
4
29/01/2013
©2013 Dr. F. Muddeen

9
Addition used to facilitate multiplication of
numbers
◦ We will see later in this lecture

Relatively easy to create adder circuits in digital
electronics
©2013 Dr. F. Muddeen
10
5
29/01/2013

Subtraction used to compare numbers.
◦ Example if we have a set point in some
engineering system
 Say 30 Volts
◦ How do we know if we have achieved this?
 Need to compare actual value with set value by
subtraction.
©2013 Dr. F. Muddeen

11
More difficult process than addition
◦ Circuitry more complex

Leads to the representation of negative
numbers
◦ Can then use addition to perform subtraction

Two ways of representing negative numbers
◦ Signed magnitude
◦ Complement
©2013 Dr. F. Muddeen
12
6
29/01/2013

Use the MSB of the binary bit string to indicate
the sign of the number
◦ ‘0’ is positive;
◦ ‘1’ is negative

Easier to understand by human user
85
-85
01010101
11010101
©2013 Dr. F. Muddeen

Has 2 representations for zero
+0
-0

13
00000000
10000000
For a given number of bits, n, lets you cover:
 2n1  1 to  2n1  1
©2013 Dr. F. Muddeen
14
7
29/01/2013
©2013 Dr. F. Muddeen

15
We will examine the ‘Radix-complement’
system
©2013 Dr. F. Muddeen
16
8
29/01/2013
©2013 Dr. F. Muddeen
17
• Very easy to do in digital electronics
©2013 Dr. F. Muddeen
18
9
29/01/2013


Try the following example
229
11100101
-46
11010010
183
110110111
Discard the MSB leaving 10110111 which is 18310
©2013 Dr. F. Muddeen
229
x
46
19
1 1 1 0 0 1 0 1
 0 0 1 0 1 1 1 0
10534
©2013 Dr. F. Muddeen
20
10
29/01/2013
1 1 1 0 0 1 0

0 0 0 0 0 0 0
0 0 0 0 0 0
1 1 1 0 0
0 0 0 0
1 1 1
1 1
1
1
0
0
0
1
0
0
1
1
0
1 1 0 0 1 0

0 1 0 1 1 1 0

0
0
0
0
0
1
0
0
1
0
1
0
0
0
1

0
0
1
0
0
0
1
0
1
0
0
1
0 1
0 0 0
1 1 0
Exactly like
decimal math
Notice how it
is simply a
set of shifting
and adding
operations
©2013 Dr. F. Muddeen
21
©2013 Dr. F. Muddeen
22
Subtraction
done using 2’s
complement
and addition
11
Download