| 90 | } |
| 91 | |
| 92 | func (g *Add2) Update(inputA, inputB, carryIn bool) { |
| 93 | g.inputA.Update(inputA) |
| 94 | g.inputB.Update(inputB) |
| 95 | g.carryIn.Update(carryIn) |
| 96 | |
| 97 | g.xor1.Update(g.inputA.Get(), g.inputB.Get()) |
| 98 | g.xor2.Update(g.xor1.Output(), g.carryIn.Get()) |
| 99 | |
| 100 | g.sumOut.Update(g.xor2.Output()) |
| 101 | |
| 102 | g.and1.Update(g.carryIn.Get(), g.xor1.Output()) |
| 103 | g.and2.Update(g.inputA.Get(), g.inputB.Get()) |
| 104 | |
| 105 | g.or1.Update(g.and1.Output(), g.and2.Output()) |
| 106 | |
| 107 | g.carryOut.Update(g.or1.Output()) |
| 108 | } |
| 109 | |
| 110 | func (g *Add2) Sum() bool { |
| 111 | return g.sumOut.Get() |