Silicon to Scripting 11
Now that we have many different 16 bit operations, we can make a generic way to apply an operation to two inputs.
Logic Unit
Given a way to select an operation (op0
, op1
), apply an operation to the two 16 bit inputs X
, Y
.
op1 | op0 | output |
---|---|---|
0 | 0 | X and Y |
0 | 1 | X or Y |
1 | 0 | X xor Y |
1 | 1 | inv X |
Since we know we need to do the and
, or
, xor
, and inv
operations, we can add those gates.
Now we have 4 outlets but only 1 output.
That means we need to use 3 select gates to select which operation to use.
Looking at the truth table, when op0
is 0, the output should either be and
or xor
, and when it is 1, the output should be or
or inv
.
The select component selects DO
when s
is 0, so we can connect and
and xor
to the two D0
inlets and connect op0
to s
.
The same logic applies to the D1
inlets.
Now that we have only two outlets to work with, we can use the final select to pick the correct one.
When op1
is 0, it should select and
or or
, which is the right select.
Same for the left select, when op1
is 1, it should select xor
or inv
.
Using multiple selects like this to chose more than just two inlets will show up again, so try to understand it to the best of your ability.