Chapter 15
The circuit, in full
“The machine as a circuit” ends with a stepper as one box. This chapter chains six of them into the machine, then puts four machines side by side to decide a problem. Every drawing is still generated from the netlist of src/circuit.c, which records how each box is wired.
Six steppers make a core §
A core is the machine unrolled. Its input arrives as AX's two bits, both flags start at the constant 0, and the program's twelve bits split into six lines of two. Each stepper takes the four state wires the one before it left and its own line's two bits, and the sixth stepper's accepted' is the core's answer.
tests/test_circuit.c runs the core on all 16,384 runs, 4,096 programs by four inputs, holds every stepper's flags, step by step, to sat_step's, and holds the core's answer to the interpreter's.
Four cores decide a problem §
Whether a program decides a problem takes four cores, one per input. The want register holds four bits, one per input, saying which inputs the problem holds: {1, 2, 3} is 0111, input 0's bit first. The program's twelve bits go to all four cores, and each core has its input wired in as constants. A comparator, same, checks each core's answer against its want bit, and an AND of the four lights "decides".
A comparator is five gates: (accepted AND want) OR (NOT accepted AND NOT want). tests/test_circuit.c runs the decider on all 4,096 programs and all 16 want registers: it lights "decides" exactly where the program decides the problem the register holds, 4,096 times in all.
A program through it §
Load the want register with 0111 and the program register with program 2916 (decr, mod2, zero, decr, zero, nada), the five-line answer to is_not_tiny, whose bits are 10 11 01 10 01 00. The four cores settle like this:
| core | the run | accepted | want | same? |
|---|---|---|---|---|
| 0 | decr finds AX at 0: reject |
0 | 0 | yes |
| 1 | decr to 0, mod2 keeps 0, zero: accept |
1 | 1 | yes |
| 2 | decr to 1, mod2 keeps 1, zero passes, decr to 0, zero: accept |
1 | 1 | yes |
| 3 | decr to 2, mod2 folds 2 to 0, zero: accept |
1 | 1 | yes |
All four comparators say yes, so the AND lights "decides".