Challenge 56 (“Complete Multiply”) multiplies a constant 2-bit value in register A by a variable 2-bit value in register B, adding the product to 3-bit register C (modulo 8). By “constant” I mean the clever use of ramps as a kind of read-only memory, where the value can only be changed by what is in effect a re-wiring of the board. “Variable” means that the value can be entered into the register by setting the toggle bits (what I call here “programming”).
A similar circuit can do a divide, with the dividend in register C, the constant divisor in register A, and the quotient appearing in register B. The remainder is encoded in the final state of various toggle bits, but the encoding depends on the divisor, which I’m not happy with.
I have created a fully programmable multiply/divide that fits on the board. For multiply, there are two variable 2-bit operands and a 4-bit accumulator with capture on overflow. In order to get it to fit, one of the operands has to be entered in ones-complement form (every bit flipped the other way). The same circuit can do a divide with remainder, using a different initial state and interpretation of the registers. The divisor, quotient, and remainder are 2-bit variables, and the dividend is a 4-bit variable. There is capture on overflow, including divide by zero.
The core concept is a programmable pattern generator, whose initial state determines whether it will eject 0, 1, 2, or 3 balls for each cycle. Alternatively, it can eject 1, 2, 3, or 4 balls per cycle. All with the same wiring, just a different programmable initial state.
If by chance this is novel and of interest, I’ll post a picture and theory of operation.