Expand description
§Crossed Wires
Part one is a straightforward simulation of the gates. Part two asks us to fix a broken ripple carry adder.
The structure of the adder is:
- Half adder for bits
x00
andy00
. Outputs sum toz00
and carry toz01
. - Full adder for bits
x01..x44
andy01..y44
. Outputs carry to next bit in the chain “rippling” up to final bit. z45
is the carry output fromx44
andy44
.
Implemented in logic gates this looks like:
Half Adder Full Adder
┌───┐ ┌───┐ ┌───┐ ┌───┐
|x00| |y00| |x01| |y01|
└───┘ └───┘ └───┘ └───┘
| | ┌─┘ | | | ┌─┘ |
| └───┐ | | └───┐ |
| ┌-┘ | | | ┌-┘ | |
┌───┐ ┌───┐ ┌───┐ ┌───┐
|XOR| |AND| |XOR| |AND|
└───┘ └───┘ └───┘ └───┘
| | ┌───┴┐ |
| └──┬────┐ | |
| Carry| | ┌───┐ |
| out | | |AND| |
| | | └───┘ |
| | | └────┐ |
| | └────┐ | |
| └────┐ | | |
| ┌───┐ ┌───┐
| |XOR| |OR | Carry
| └───┘ └───┘ out
| | | |
┌───┐ ┌───┐ | ┌───┐
|z00| |z01| Carry ...repeat for z01 to z44... |z45|
└───┘ └───┘ out └───┘
Then we can deduce some rules for the output of each gate type:
- XOR If inputs are
x
andy
then output must be another XOR gate (except for inputsx00
andy00
) otherwise output must bez
. - AND Output must be an OR gate (except for inputs
x00
andy00
). - OR Output must be both AND and XOR gate, except for final carry
which must output to
z45
.
We only need to find swapped outputs (not fix them) so the result is the labels of gates that breaks the rules in alphabetical order.
Functions§
Type Aliases§
- Input 🔒