exam for Electronic Engineering
3/19/2018
1
EE 1301: MODERN ELECTRONIC TECHNOLOGY
SESSION #22: BINARY MATH AND YOUR COMPUTER 3/19/2018
Instructor: Joseph Cleveland, Ph.D. Email: [email protected]
Thought for the Day
03/19/2018 EE1301 Modern Electronic Technology 2
A large portion of the world’s working population are poorly
educated but work as entrepreneurs.
With all of this education could we do that?
3/19/2018
2
Topics & Comments
• Binary math (cont) – Addition
– Subtraction
• Logic gates (collection of transistors)
• Binary adder (collection of gates)
• Lab: use this week for make ups
• Exam #2: Friday, April 6
03/19/2018 EE1301 Modern Electronic Technology 3
Binary Addition
• Let’s work the following binary addition:
1 1 0 0 1 2510 + 1 1 0 1 1310
3810
03/19/2018 EE1301 Modern Electronic Technology 4
0
1 carry
1
0
1
0
0
1
0
1
1
3/19/2018
3
Subtraction
03/19/2018 EE1301 Modern Electronic Technology 5
4 7 - 0 6
4 1 1
- 0 0 0 1 1 0
0011
1 0 1 1 1 1
0
4 6 - 9 3 7
4 6 - 9
163
How to we perform borrowing in binary math?
Borrow 10
3 7
Subtraction …
03/19/2018 EE1301 Modern Electronic Technology 6
1 0 1 1 1 0
0 0 1 0 0 1
4 6
-9
3 7
= 1 + 1
1
1 0 1 1 0 0
1 0 0 1 0 0 1
Borrowing
01001 = 3710
3/19/2018
4
Subtraction …
03/19/2018 EE1301 Modern Electronic Technology 7
1 0 1 1 1 0
0 0 1 0 1 1
4 6
-1 1
3 5
= 1 + 1
1
1 0 1 1 0 0
= 1 + 1
0 0 1 0 1 1 1
Borrowing
1
0
Notice that you have a lot to keep track of!
2’s Complement Subtraction
• There is an easier way: 2s complement
• Example: Using the 2’s Complement method in the following example:
1 0 1 1 1 0 4 6 – 1 0 0 1 -1 1
03/19/2018 EE1301 Modern Electronic Technology 8
3/19/2018
5
2’s Complement Subtraction
• Step 1: Make both numbers have the same number of digits
1 0 1 1 1 0 46 – 0 0 1 0 1 1 -11
• Step 2: Take 2’s complement of the number to be subtracted:
001011 110100 + 1 = 110101.
03/19/2018 EE1301 Modern Electronic Technology 9
Complement of 001011
Add 1
2’s Complement Subtraction …
• Step 3: Add the result
1 0 1 1 1 0 46 + 1 1 0 1 0 1 -11
03/19/2018 EE1301 Modern Electronic Technology 10
01111 0
1100011
· · · · · ·
Note: Final carry
If the final carry is “1”, the answer is +. If it is “0” the answer is “-”.
3/19/2018
6
Binary Subtraction …
• We need to have – Registers
– Compliment operation
1 NOT 1 or 0 0 NOT 0 or 1
– Adder with carry
03/19/2018 EE1301 Modern Electronic Technology 11
Binary Multiplication
• Recall decimal number multiplication
4 5 6
7 8 9
4 1 0 4
3 6 4 8
3 1 9 2
3 5 9 7 8 4
03/19/2018 EE1301 Modern Electronic Technology 12
55 Carry4 444 Carry 553 Carry
3/19/2018
7
Binary Multiplication
• Binary multiplication follows the same format
1 0 1 1 1110 x 1 0 1 510
1 0 1 1
0 0 0 0
1 0 1 1
1 1 0 1 1 1 5510
03/19/2018 EE1301 Modern Electronic Technology 13
Shift left Shift left
03/19/2018 EE1301 Modern Electronic Technology 14
Logic Gates
3/19/2018
8
• Digital computers contain a large number of circuit blocks called logic gates – NOT
– AND
– NAND
– OR
– NOR
– XOR
03/19/2018 EE1301 Modern Electronic Technology 15
Compliment or NOT Function
• The complement of X is denoted as which is defined by a truth-table:
• A switch circuit that performs a complement
03/19/2018 EE1301 Modern Electronic Technology 16
X
0 1
1 0
R
D
G
S
5 V
ID
Vin
3/19/2018
9
Complement or “NOT” …
03/19/2018 EE1301 Modern Electronic Technology 17
X
R
D
G
S
5 V
5V A NOT gate
Notice that the electronic circuit is hidden.
Only the input/output is shown – standardized.
This is synthesis.
We use the NOT gate in 2’s complement.
NAND Gate
03/19/2018 EE1301 Modern Electronic Technology 18
Both transistors must be ON for current to flow in R3: to drop VOUT to LOW (~0.5V)
+5V
VOUT X
Y
X Y VOUT 0 0 1
0 1 1
1 0 1
1 1 0
X
Y
NAND Logic Gate Symbol
VOUT
3/19/2018
10
AND Logic Gate
03/19/2018 EE1301 Modern Electronic Technology 19
X
Y
VOUT
5V
NAND Gate NOT Gate
AND Logic Gate …
The AND of X and Y is denoted as XY and has the following truth-table:
Can be viewed as “multiplication”.
03/19/2018 EE1301 Modern Electronic Technology 20
X Y XY
0 0 0
0 1 0
1 0 0
1 1 1
X
Y XY
AND Logic Gate Symbol
3/19/2018
11
OR Logic
The OR of X and Y is denoted as X+Y and has the following truth-table:
Can be viewed as “addition”.
03/19/2018 EE1301 Modern Electronic Technology 21
X Y X+Y
0 0 0
0 1 1
1 0 1
1 1 1
X
Y X+Y
OR Logic Gate Symbol
NOR Logic
The NOR of X and Y is denoted as and has the following truth-table:
03/19/2018 EE1301 Modern Electronic Technology 22
X Y X+Y
0 0 1
0 1 0
1 0 0
1 1 0
X Y
NOR Logic Gate Symbol
3/19/2018
12
The XOR or Adder
The is denoted by XY and has the following truth-table:
03/19/2018 EE1301 Modern Electronic Technology 23
X Y XY
0 0 0
0 1 1
1 0 1
1 1 0
This looks like binary addition with no carry – a partial sum
X
Y XY
XOR Logic Gate Symbol
FET circuit combination is “hidden”. Only the input-output is shown. This is Synthesis
The Carry
• Truth table for the Carry
• This is the same as an AND gate
03/19/2018 EE1301 Modern Electronic Technology 24
X Y C
0 0 0
0 1 0
1 0 0
1 1 1
X
Y C=XY
3/19/2018
13
The Adder
• Let’s combine AND, OR, XOR gates to make an adder with carry
03/19/2018 EE1301 Modern Electronic Technology 25
XY (XY)C
(XY)C
Cin XY
S
XY
Cout
Y X
S
Cin Cout FA
Transistor Count XOR: 6 AND: 6 OR: 6
~30 MOSFETs
The Adder
• Adding two, 4-bit numbers
03/19/2018 EE1301 Modern Electronic Technology 26
Y0 X0
S0
C0
Y1 X1
S1
C1
Y2 X2
S2
C2
Y3 X3
S3
C3
C4
FA FA FA FA
3/19/2018
14
How The Adder works
• Check it out
• Adder truth table: 8 X,Y,C input possibilities
03/19/2018 EE1301 Modern Electronic Technology 27
1 1 0 0 1
0 1 1 0 1
X Y C S C
0 0 0 0 0
0 0 1 1 0
1 0 0 1 0
1 0 1 0 1
X Y C S C
0 1 0 1 0
0 1 1 0 1
1 1 0 0 1
1 1 1 1 1
0
11=0 00
S=0
0 1
011=1
0 C=1
0
End of Session
03/19/2018 EE1301 Modern Electronic Technology 28