ECE 550D
Fundamentals of Computer Systems and Engineering
Fall 2016
Combinational Logic
Tyler Bletsch Duke University Slides are derived from work by Andrew Hilton (Duke)
ECE 550D Fundamentals of Computer Systems and Engineering Fall 2016 - - PowerPoint PPT Presentation
ECE 550D Fundamentals of Computer Systems and Engineering Fall 2016 Combinational Logic Tyler Bletsch Duke University Slides are derived from work by Andrew Hilton (Duke) Last time. Who can remind us what we talked about last time?
ECE 550D
Fundamentals of Computer Systems and Engineering
Fall 2016
Combinational Logic
Tyler Bletsch Duke University Slides are derived from work by Andrew Hilton (Duke)
2
Last time….
3
a b AND(a,b) a b OR(a,b) XOR(a,b) a b NAND(a,b) a b a b NOR(a,b) XNOR(a,b) a b
a
NOT(a)
Boolean Gates
4
(!A & !C)|(A & C)
Boolean Functions, Gates and Circuits
A C Out
5
A few more words about gates
(Think of the transistors each gate represents)
(also not good, but not set-your-chip-on-fire bad)
a b c d
BAD!
6
Introducing the Multiplexer (“mux”)
Input A Input B Output
Selector
(S) “B” “A”
7
Introducing the Multiplexer (“mux”)
mux
Input A Selector (S) Input B Output “A”
8
Introducing the Multiplexer (“mux”)
mux
Selector (S) Input B Output “B”
Input A
9
Introducing the Multiplexer (“mux”)
mux
Selector (S) Input B Output “B”
Input A
10
Let’s Make a Useful Circuit
Sum-of-products
A B S Output 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
11
Sum of Products
!A & B & S A & !B & !S A & B & !S A & B & S
A B S Output 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
12
Let’s Make a Useful Circuit
(!A & B & S) | (A & !B & !S) | (A & B & !S ) | (A & B & S)
Need to simplify.
A B S Output 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
13
Simplifying The Formula
(!A & B & S) |
(A & !B & !S) | (A & B & !S ) | (A & B & S)
B doesn’t matter
14
Simplifying The Formula
(!A & B & S) |
(A & !S) | (A & B & S)
A doesn’t matter
15
Simplifying The Formula
(A & !S) | (B & S)
16
Let’s Make a Useful Circuit
(A & !S) | (B & S)
A B S Output 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
17
Circuit Example: 2x1 MUX
MUX(A, B, S) = (A & !S) | (B & S) Draw it in gates:
A B S AND AND OR
s a b
So common, we give it its own symbol:
18
Example 4x1 MUX
3 2 1
a b c d y
S 2
a b c d
s0 s1
The / 2 on the wire means “2 bits”
19
Boolean Function Simplification
rules (bitwise logical):
20
DeMorgan’s Laws
!(A & B) = (!A) | (!B) !(A | B) = (!A) & (!B) Alluded to these last time Very good rules to know in general
21
Next: logic to work with numbers
22
Numbers for computers
23
Basic Binary
24
Binary continued:
25
Binary continued:
1 in 32’s place = 32 0 in 16’s place 1 in 8’s place = 8 1 in 4’s place = 4 0 in 2’s place 1 in 1’s place = 1 — 45
26
Converting Numbers
Suppose I want to convert 457 to binary Think for a second about how to do this
27
Decimal to binary using remainders ? Quotient Remainder
457 2 = 228 1 228 2 = 114 114 2 = 57 57 2 = 28 1 28 2 = 14 14 2 = 7 7 2 = 3 1 3 2 = 1 1 1 2 = 1
111001001
28
Decimal to binary using comparison
Num Compare 2n ≥ ? 457 256 1 201 128 1 73 64 1 9 32 9 16 9 8 1 1 4 1 2 1 1 1
111001001
29
Hexadecimal: Convenient shorthand for Binary
30
Hexadecimal
Hex digit Binary Decimal 0000 1 0001 1 2 0010 2 3 0011 3 4 0100 4 5 0101 5 6 0110 6 7 0111 7 8 1000 8 9 1001 9 A 1010 10 B 1011 11 C 1100 12 D 1101 13 E 1110 14 F 1111 15
0000 0010 0100 0110 1000 1010 1100 1110
0001 0011 0101 0111 1001 1011 1101 1111
1101 1110 1010 1101 1011 1110 1110 1111
Indicates a hex number
Binary Hex conversion is straightforward. Every 4 binary bits = 1 hex digit. If # of bits not a multiple of 4, add implicit 0s on left as needed
31
Binary to/from hexadecimal
1 F 4 B16 --> 0001 1111 0100 10112 --> 00011111010010112
Hex digit Binary Decimal 0000 1 0001 1 2 0010 2 3 0011 3 4 0100 4 5 0101 5 6 0110 6 7 0111 7 8 1000 8 9 1001 9 A 1010 10 B 1011 11 C 1100 12 D 1101 13 E 1110 14 F 1111 15
32
Binary Math : Addition
00011101 + 00101011
33
Binary Math : Addition
00011101 695 + 00101011 + 232
34
Binary Math : Addition
00011101 695 + 00101011 + 232 7
35
Binary Math : Addition
1 00011101 695 + 00101011 + 232 27
36
Binary Math : Addition
1 00011101 695 + 00101011 + 232 927
37
Binary Math : Addition
00011101 + 00101011
38
Binary Math : Addition
1 00011101 + 00101011
39
Binary Math : Addition
11 00011101 + 00101011 00
40
Binary Math : Addition
111111 00011101 = 29 + 00101011 = 43 01001000 = 72
41
Negative Numbers
42
2’s Complement Integers
0000 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 1000
1001
1010
1011
1100
1101
1110
1111
43
Binary Math : Addition
01011101 + 01101011
44
Binary Math : Addition
1111111 01011101 = 93 + 01101011 = 107 11001000 = -56
45
Integer Overflow
46
Subtraction
that means flip bits (“not”)
1 0110101 -> 0110101
47
Signed and Unsigned Ints
48
One hot representation
1 2 3
49
Converting to/from one hot
(which may be quite useful on hwk1)
50
Lets build a 4-to-2 encoder
In0 In1 In2 In3 Out1 Out0 1 1 1 1 1 1 1 1
51
4-to-2 encoder
In0 In1 In2 In3 Out0 Out1
52
4-to-2 encoder
In0 In1 In2 In3 Out0 Out1 In0 didn’t actually figure into the logic. That’s ok Synthesis will eliminate it if its not used elsewhere… And whatever logic creates it, etc..
53
Lets build a 2-to-4 decoder
Now sum-of-powers more useful, do for each of the 4 outputs:
Out0 = (Not In1) and (Not In0) Out1 = (Not In1) and In0 Out2 = In1 and (Not In0) Out3 = In1 and In0
In1 In0 Out0 Out1 Out2 Out3 1 1 1 1 1 1 1 1
54
2-to-4 decoder
In0 In1 Out0 Out1 Out2 Out3
55
2-to-4 decoder
In0 In1 Out0 Out1 Out2 Out3
56
2-to-4 decoder
In0 In1 Out0 Out1 Out2 Out3
57
Delays
58
Wrap Up