summaryrefslogtreecommitdiff
path: root/3.md
blob: fb54e4cabebcca25f4fb34d10753f868aac9bd27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
[\<- Truth tables, minterms, and simple synthesis](2.md)

---

# Boolean Algebra and DeMorgan's Theorem

## Boolean algebra basics

### Boolean Algebra Properties

- Commutative (input order doesn't matter)
	- `X*Y` = `Y*X`
	- `X+Y` = `Y+X`
- Associative (can combine like functions)
	- `X*(Y*Z)` = `(X*Y)*Z` = `X*Y*Z`
	- `X+(Y+Z)` = `(X+Y)+Z` = `X+Y+Z`
- Distributive (going the other way: factoring)
	- `X * (Y+Z)` = `X*Y + X*Z`
- Combining
	- `X * Y + X * !Y` = `X * (Y + !Y)` = `X`

---

## DeMorgan's Theorem

- `!(X*Y)` = `!X + !Y` (and `!(X+Y)` = `!X * !Y`)
- Allows us to transform any AND gate to an OR gate, or vice versa
- NOTE: `!(X*Y)` != `!X * !Y`

|x|y| |x\*y|!(x\*y)| |!x|!y|!x + !y|
|-|-|-|----|-------|-|--|--|-------|
|0|0| |0   |1      | |1 |1 |1      |
|0|1| |0   |1      | |1 |0 |1      |
|1|0| |0   |1      | |0 |1 |1      |
|1|1| |1   |0      | |0 |0 |0      |

### NAND and NOR gates

- An AND gate with an inverter on the output is called a NAND gate
- An OR gate with an inverter on the output is called a NOR gate

![diagram](3.1.png)

### Visualizing DeMorgan

- "Flip" the gate type (AND \<-> OR), invert all the inputs, invert the output
	- Remember that bubbles mean inverters
	- Can be applied to any gate/inverter combo

![diagram](3.2.png)

### A note about inversions

- To be clear: inverting an inversion essentially cancels it out
	- If you invert a value and then invert it again, you're back to where you started
- When applying DeMorgan's, inverting an inversion makes it go away

![diagram](3.3.png)

### Applying DeMorgan

- Inversions can be added in pairs

![diagram](3.4.png)

- Inversions can "slide" to the other end of a wire

![diagram](3.5.png)

---

## Other Synthesis Approaches: solving for 0's, POS, reducing with Boolean Algebra

- Say we had f(x1,x2,x3) = ∑m(1,4,5,6)
	- What does the truth table look like?
	- What is the canonical SOP equation?
	- What does the matching circuit look like?
- What are some other ways we can synthesize this function?
	- Synthesize the inverse function, then invert
		- Simpler circuit if more 1's than 0's in truth table (which is actually not the case here)
	- Reduce the equation using Boolean algebra

### Truth table for inverse function

- If F(x1,x2,x3) = ∑m(1,4,5,6), then !F = ∑m(0,2,3,7)

|x1x2x3|F|!F|
|------|-|--|
|000   |0|1 |
|001   |1|0 |
|010   |0|1 |
|011   |0|1 |
|100   |1|0 |
|101   |1|0 |
|110   |1|0 |
|111   |0|1 |

### Synthesizing the inverse

- Create equation for !f by adding minterms that evaluate to 0
	- !f = m0 + m2 + m3 + m7
	- f = !(m0 + m2 + m3 + m7) (a valid answer)
- A step further would apply deMorgan's 
	- f = !m0 * !m2 * !m3 * !m7
- One step further would use maxterms
	- ex. !m0 = M0 = !(!x1 * !x2 * !x3) = x1 + x2 + x3
	- f = M0 * M2 * M3 * M7 (yet another valid answer)
	- Called product of sums (POS) form

### Another POS example

- Say F(A,B,C) = ∑m(0,2,3,4,6,7)
	- !F = ∑m(1,5)

![diagram](3.6.png)

### Reduction w/ Boolean Algebra

- f = `(!x1 * !x2 * x3) + (x1 * !x2 * !x3) + (x1 * !x2 * x3) +(x1 * x2 * !x3)` (canonical SOP)
- f = `((!x1 + x1) * !x2 * x3) + (x1 * (!x2 + x2) * !x3)`
- f = `(!x2 * x3) + (x1 * !x3)`
- The best answer yet, but it can be hard to see these reductions in equation form

![diagram](3.7.png)

---

[Karnaugh Maps, Prime Implicants ->](4.md)