A brief review of Lecture 03.
$A \equiv B$ is an assertion that two propositions $A$ and $B$ have the same truth values in all possible cases.
$A \equiv B$ and $\underbrace{(A \leftrightarrow B) \equiv \mathsf{T}}_\mathsf{tautology}$ have the same meaning.
A notation for combinational circuits.
Digital circuits implement propositional logic:
Digital circuits are functions that
We call these types of digital circuits combinational logic circuits. There are other kinds of digital circuits (called sequential circuits) but we’ll focus on combinational circuits in this course.
Think of it as a notation for propositional logic used in circuit design.
Boolean algebra consists of the following elements and operations:
These correspond to the truth values $\{\mathsf{F},\mathsf{T}\}$, and the logical connectives $\vee,\wedge,\neg$.
Boolean operations satisfy the following axioms for any $a,b,c\in B$:
Suppose that we want to compute the number of lectures or sections remaining at the start of a given day of the week.
The function for this computation has the following signature:
Here are some examples of the function’s input/output behavior:
Wednesday
, Lecture
), Output: 2Monday
, Section
), Output: 1How would you implement this function in Java?
public class Sessions {
public static int classesLeft(int day, boolean lecture) {
switch (day) {
case 0: // SUNDAY
case 1: // MONDAY
return lecture ? 3 : 1;
case 2: // TUESDAY
case 3: // WEDNESDAY
return lecture ? 2 : 1;
case 4: // THURSDAY
return lecture ? 1 : 1;
case 5: // FRIDAY
return lecture ? 1 : 0;
default: //case 6: // SATURDAY
return lecture ? 0 : 0;
}
}
public static void main(String []args){
System.out.println("(W, L) -> " + classesLeft(3,true));
System.out.println("(M, S) -> " + classesLeft(1,false));
}
}
Suppose that we need this function run really fast … To do that, we’ll implement a custom circuit (hardware accelerator!).
Recall the signature of our function:
How many bits for each input/output?
switch (day) {
case 0: // SUNDAY
case 1: // MONDAY
return lecture ? 3 : 1;
case 2: // TUESDAY
case 3: // WEDNESDAY
return lecture ? 2 : 1;
case 4: // THURSDAY
return lecture ? 1 : 1;
case 5: // FRIDAY
return lecture ? 1 : 0;
default: // SATURDAY etc.
return lecture ? 0 : 0;
}
Day | $d_2 d_1 d_0$ | $L$ | $c_1 c_0$ |
---|---|---|---|
SUN | 000 | 0 | 01 |
SUN | 000 | 1 | 11 |
MON | 001 | 0 | 01 |
MON | 001 | 1 | 11 |
TUE | 010 | 0 | 01 |
TUE | 010 | 1 | 10 |
WED | 011 | 0 | 01 |
WED | 011 | 1 | 10 |
THU | 100 | 0 | 01 |
THU | 100 | 1 | 01 |
FRI | 101 | 0 | 00 |
FRI | 101 | 1 | 01 |
SAT | 110 | 0 | 00 |
SAT | 110 | 1 | 00 |
- | 111 | 0 | 00 |
- | 111 | 1 | 00 |
Day | $d_2 d_1 d_0$ | $L$ | $c_1 c_0$ |
---|---|---|---|
SUN | 000 | 0 | 01 |
SUN | 000 | 1 | 11 |
MON | 001 | 0 | 01 |
MON | 001 | 1 | 11 |
TUE | 010 | 0 | 01 |
TUE | 010 | 1 | 10 |
WED | 011 | 0 | 01 |
WED | 011 | 1 | 10 |
THU | 100 | 0 | 01 |
THU | 100 | 1 | 01 |
FRI | 101 | 0 | 00 |
FRI | 101 | 1 | 01 |
SAT | 110 | 0 | 00 |
SAT | 110 | 1 | 00 |
- | 111 | 0 | 00 |
- | 111 | 1 | 00 |
To find an expression for $c_1$, look at the rows where $c_1 = 1$.
$d_2d_1d_0$==000 && L==1
$d_2d_1d_0$==001 && L==1
$d_2d_1d_0$==010 && L==1
$d_2d_1d_0$==011 && L==1
Split up the bits of the day to get a formula for each row.
$d_2$==0 && $d_1$==0 && $d_0$==0 && L==1
$d_2$==0 && $d_1$==0 && $d_0$==1 && L==1
$d_2$==0 && $d_1$==1 && $d_0$==0 && L==1
$d_2$==0 && $d_1$==1 && $d_0$==1 && L==1
Translate to Boolean algebra to get an expression for $c_1$.
$c_1 =\, $ | $d_2’\cdot d_1’\cdot d_0’\cdot L \,+$ |
$d_2’\cdot d_1’\cdot d_0\cdot L \,+$ | |
$d_2’\cdot d_1\cdot d_0’\cdot L \,+$ | |
$d_2’\cdot d_1\cdot d_0\cdot L \,$ |
Day | $d_2 d_1 d_0$ | $L$ | $c_1 c_0$ |
---|---|---|---|
SUN | 000 | 0 | 01 |
SUN | 000 | 1 | 11 |
MON | 001 | 0 | 01 |
MON | 001 | 1 | 11 |
TUE | 010 | 0 | 01 |
TUE | 010 | 1 | 10 |
WED | 011 | 0 | 01 |
WED | 011 | 1 | 10 |
THU | 100 | 0 | 01 |
THU | 100 | 1 | 01 |
FRI | 101 | 0 | 00 |
FRI | 101 | 1 | 01 |
SAT | 110 | 0 | 00 |
SAT | 110 | 1 | 00 |
- | 111 | 0 | 00 |
- | 111 | 1 | 00 |
$c_1 =\, $ | $d_2’\cdot d_1’\cdot d_0’\cdot L \,+$ |
$d_2’\cdot d_1’\cdot d_0\cdot L \,+$ | |
$d_2’\cdot d_1\cdot d_0’\cdot L \,+$ | |
$d_2’\cdot d_1\cdot d_0\cdot L \,$ |
Now we repeat this process to get $c_0$.
$c_0 =\, $ | $d_2’\cdot d_1’\cdot d_0’\cdot L’ \,+$ |
$d_2’\cdot d_1’\cdot d_0’\cdot L \,+$ | |
$d_2’\cdot d_1’\cdot d_0\cdot L’ \,+$ | |
$d_2’\cdot d_1’\cdot d_0\cdot L \,+$ | |
$d_2’\cdot d_1\cdot d_0’\cdot L’ \,+$ | |
$d_2’\cdot d_1\cdot d_0\cdot L’ \,+$ | |
$d_2\cdot d_1’\cdot d_0’\cdot L’ \,+$ | |
$d_2\cdot d_1’\cdot d_0’\cdot L \,+$ | |
$d_2\cdot d_1’\cdot d_0\cdot L \,$ |
$c_0 =\, $ | $d_2’\cdot d_1’\cdot d_0’\cdot L’ \,+$ |
$d_2’\cdot d_1’\cdot d_0’\cdot L \,+$ | |
$d_2’\cdot d_1’\cdot d_0\cdot L’ \,+$ | |
$d_2’\cdot d_1’\cdot d_0\cdot L \,+$ | |
$d_2’\cdot d_1\cdot d_0’\cdot L’ \,+$ | |
$d_2’\cdot d_1\cdot d_0\cdot L’ \,+$ | |
$d_2\cdot d_1’\cdot d_0’\cdot L’ \,+$ | |
$d_2\cdot d_1’\cdot d_0’\cdot L \,+$ | |
$d_2\cdot d_1’\cdot d_0\cdot L \,$ |
$c_1 =\, $ | $d_2’\cdot d_1’\cdot d_0’\cdot L \,+$ |
$d_2’\cdot d_1’\cdot d_0\cdot L \,+$ | |
$d_2’\cdot d_1\cdot d_0’\cdot L \,+$ | |
$d_2’\cdot d_1\cdot d_0\cdot L \,$ |
Here is $c_1$ as a circuit …
Create hardware implementations!
And perform program verification …
classesLeft
returns 3 only if lecture
is true.$c_0 =\, $ | $d_2’\cdot d_1’\cdot d_0’\cdot L’ \,+$ |
$d_2’\cdot d_1’\cdot d_0’\cdot L \,+$ | |
$d_2’\cdot d_1’\cdot d_0\cdot L’ \,+$ | |
$d_2’\cdot d_1’\cdot d_0\cdot L \,+$ | |
$d_2’\cdot d_1\cdot d_0’\cdot L’ \,+$ | |
$d_2’\cdot d_1\cdot d_0\cdot L’ \,+$ | |
$d_2\cdot d_1’\cdot d_0’\cdot L’ \,+$ | |
$d_2\cdot d_1’\cdot d_0’\cdot L \,+$ | |
$d_2\cdot d_1’\cdot d_0\cdot L \,$ |
$c_1 =\, $ | $d_2’\cdot d_1’\cdot d_0’\cdot L \,+$ |
$d_2’\cdot d_1’\cdot d_0\cdot L \,+$ | |
$d_2’\cdot d_1\cdot d_0’\cdot L \,+$ | |
$d_2’\cdot d_1\cdot d_0\cdot L \,$ |
Day | $d_2 d_1 d_0$ | $L$ | $c_1 c_0$ |
---|---|---|---|
SUN | 000 | 0 | 01 |
SUN | 000 | 1 | 11 |
MON | 001 | 0 | 01 |
MON | 001 | 1 | 11 |
TUE | 010 | 0 | 01 |
TUE | 010 | 1 | 10 |
WED | 011 | 0 | 01 |
WED | 011 | 1 | 10 |
THU | 100 | 0 | 01 |
THU | 100 | 1 | 01 |
FRI | 101 | 0 | 00 |
FRI | 101 | 1 | 01 |
SAT | 110 | 0 | 00 |
SAT | 110 | 1 | 00 |
- | 111 | 0 | 00 |
- | 111 | 1 | 00 |
Optimizing circuits and proving theorems.
Boolean algebra consists of the following elements and operations:
These correspond to the truth values $\{\mathsf{F},\mathsf{T}\}$, and the logical connectives $\vee,\wedge,\neg$.
Boolean operations satisfy the following axioms for any $a,b,c\in B$:
Uniting
$X \cdot Y + X \cdot Y'$ | $=$ | $X \cdot (Y + Y') $ | Distributivity |
$=$ | $X \cdot 1 $ | Complementarity | |
$=$ | $X $ | Identity |
Absorption
$X + X \cdot Y$ | $=$ | $X \cdot 1 + X \cdot Y $ | Identity |
$=$ | $X \cdot (1 + Y) $ | Distributivity | |
$=$ | $X \cdot (Y + 1) $ | Commutativity | |
$=$ | $X \cdot 1 $ | Null | |
$=$ | $X $ | Identity |
$X$ | $Y$ | $X’$ | $Y’$ | $(X+Y)’$ | $X’ \cdot Y’$ |
---|---|---|---|---|---|
0 | 0 | 1 | 1 | 1 | 1 |
0 | 1 | 1 | 0 | 0 | 0 |
1 | 0 | 0 | 1 | 0 | 0 |
1 | 1 | 0 | 0 | 0 | 0 |
$X$ | $Y$ | $X’$ | $Y’$ | $(X\cdot Y)’$ | $X’ + Y’$ |
---|---|---|---|---|---|
0 | 0 | 1 | 1 | 1 | 1 |
0 | 1 | 1 | 0 | 1 | 1 |
1 | 0 | 0 | 1 | 1 | 1 |
1 | 1 | 0 | 0 | 0 | 0 |
$c_1$ | $=$ | $d_2’\cdot d_1’\cdot d_0’\cdot L + d_2’\cdot d_1’\cdot d_0\cdot L + d_2’\cdot d_1\cdot d_0’\cdot L + d_2’\cdot d_1\cdot d_0\cdot L $ | (from classesLeft) |
$=$ | $\ldots $ | (HW2) | |
$=$ | $d_2’\cdot L $ | (HW2) |
$c_1$ | $=$ | $d_2’\cdot d_1’\cdot d_0’\cdot L + d_2’\cdot d_1’\cdot d_0\cdot L + d_2’\cdot d_1\cdot d_0’\cdot L + d_2’\cdot d_1\cdot d_0\cdot L $ | (from classesLeft) |
$=$ | $\ldots $ | (HW2) | |
$=$ | $d_2’\cdot L $ | (HW2) |
Here is the simplified $c_1$ circuit …