It computes the Fibonacci sequence!
I finally got my prototype to do a real calculation: computing the Fibonacci sequence F(n) = F(n-1) + F(n-2). Started with 1 and 1, the sequence is 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377,...
Here's a still image after it just computed 233,
It's running at the full "Babbage speed" of 157 milliseconds per digit. I consider this my first real milestone!
There are three phases to the computation, assuming F(n) is on digit wheel A1, F(n-1) is on anticipating carriage wheel F, and digit wheel A2 is zero.
- add A1 to F, while simultaneously preserving A1 by copying it to A2.
- move F to A1
- move A2 to F
Repeating that generates the Fibonacci sequence on A1.
Below is the detailed microcode. Each quoted string lists the operations that are executed simultaneously during one time unit of 157 milliseconds.
The "delay" modifier causes a lock operation, which takes only half a time unit, to occur in the second half. With that we implement Babbage's "consecutive locking" of motive trains from the source to the destination.
//**cycle 1: add A1 to F while simultaneously copying it to A2
"finger A1; mesh FC; mesh MPC A1; mesh FPC A2; keepers up; unlock F delay; unlock A1 delay; unlock a2 delay; unlock FP delay;",
"giveoff A", "giveoff A", "giveoff A", "giveoff A", "giveoff A", "giveoff A", "giveoff A", "giveoff A", "giveoff A",
"lock A1; lock FP delay;",
"lock F; lock a2; nofinger a; unmesh fc; unmesh MPC; unmesh FPC; carrywarn up;",
"giveoff A; keepers bottom",
"carrywarn down; unlock f delay;",
"carry add;",
"keepers top; lock F; setcarry nowarn;",
"keepers down; setcarry 9;",
"carry sub;",
//**cycle 2: move F to A1
"finger F; mesh FC; mesh MPC A1; unlock F; unlock A1; unlock FP;",
"giveoff F", "giveoff F", "giveoff F", "giveoff F", "giveoff F", "giveoff F", "giveoff F", "giveoff F", "giveoff F",
"lock F; lock FP delay;",
"lock A1; nofinger F; unmesh FC; unmesh MPC;",
" giveoff F",
//**cycle 3: move A2 to F
"finger A2; mesh FC; mesh MPC A2; unlock F delay; unlock A2 delay; unlock FP delay;",
"giveoff A", "giveoff A", "giveoff A", "giveoff A", "giveoff A", "giveoff A", "giveoff A", "giveoff A", "giveoff A",
"lock A2; lock FP delay;", // consecutive locking
"lock F; nofinger A; unmesh FC; unmesh MPC;",
"giveoff A"The total time unit count is 18+13+13 = 44, so at 0.157 seconds/unit it takes 6.9 seconds to generate each successive number. And thanks to the anticipating carriage design, the time is of course independent of the number of carries needed during the addition.
Comments
Post a Comment