| 72 | } |
| 73 | |
| 74 | func NewAdd2() *Add2 { |
| 75 | a := new(Add2) |
| 76 | |
| 77 | a.inputA = *circuit.NewWire("a", false) |
| 78 | a.inputB = *circuit.NewWire("b", false) |
| 79 | a.carryIn = *circuit.NewWire("c", false) |
| 80 | a.carryOut = *circuit.NewWire("co", false) |
| 81 | a.sumOut = *circuit.NewWire("so", false) |
| 82 | |
| 83 | a.xor1 = *circuit.NewXORGate() |
| 84 | a.xor2 = *circuit.NewXORGate() |
| 85 | a.and1 = *circuit.NewANDGate() |
| 86 | a.and2 = *circuit.NewANDGate() |
| 87 | a.or1 = *circuit.NewORGate() |
| 88 | |
| 89 | return a |
| 90 | } |
| 91 | |
| 92 | func (g *Add2) Update(inputA, inputB, carryIn bool) { |
| 93 | g.inputA.Update(inputA) |