Saturday, June 13, 2020

First trial of the Busicom calculator software

I've been slowly assembling a Verilog top module that will instantiate an emulation of the Busicom 141-PF calculator in the Spartan-6 LX9 FPGA in my rebuild Canon P170-DH calculator. With the emulation of all four required MCS-4 chips appearing to work properly, it seemed time to test it out.

The MCS-4 chips required for this are:
  • Five i4001 256 x 8-bit ROM with a 4-bit I/O port
  • Two i4002 20 x 4-bit RAM with a 4-bit Output port
  • Three i4003 10-bit serial-in, parallel-out Shift Register
  • One i4004 Central Processing Unit
To this I've added a clock driver that generates the two-phase clocks required by the MCS-4 chips.

The first thing I wanted to do was to observe the keyboard scanning performed by the Busicom software. The 141-PF's keyboard is physically and electrically laid out as four rows of eight columns. The rows are connected to the I/O port of one of the i4001 ROMs, while the columns are driven by the outputs of one of the i4003 shift registers. The data and clock inputs of the i4003 shift register are driven by the I/O port of another i4001 ROM. This arrangement nicely verifies both the input and output configuration of the i4001 ROM emulation, and of the i4003 shift register.

Here's a screen capture of the iSim Verilog simulator as the Busicom software running in the i4004 scans the keyboard. The top row of pulses is the data to be shifted into the shift register, while the row below that is the shift clock. Below that is the 10-bit parallel output of the shift register.


To scan the keyboard the software first clocks nine "1" bits into the shift register, followed by one "0" bit. About 76us later the software reads the row inputs to see if any keys in the selected column are pressed. Then another "1" bit is shifted in and the process repeated until all 8 columns have been scanned.

In the screen capture above, my testbench drives the row inputs when the eighth column is being scanned to simulate the "C" (clear) key being pressed.

Bill Kotaska, who recreated the Busicom 141-PF calculator using original chips in 2008, stated that a full schematic of the original calculator didn't exist. If one has been published in the 12 years since I haven't been able to find it. So there were a number of details I had to discover by trial and error. For example, I can see from the software that it walks a "0" bit down the i4003 shift register. A closed key switch must then pull the intersecting row signal to "0" as well, yet the software wants to see this as a "1" bit. Thus there were either inverters between the key switches or that i4001 was configured to invert its inputs.

I had to do some more fiddling to properly connect the print drum position signals. Here's a screen capture showing the Busicom software printing in response to the Clear key being pressed. The red signal is the output from the i4003 shift register that would fire the print hammers in the active columns.


The EP102 printer Bill Kotaska used has a sensor that pulls low when a sector of the print drum is properly aligned to print a character, and a second that pulls low when the the first sector of the drum is aligned. By both simulation and code examination I determined that the software expects the i4004's TEST input pin to go low when the print sector signal is low, but the expects the i4001 input that identifies the first sector to go high. This again suggests the i4001s were configured to invert their inputs. [Edit: further code examination indicates that the TEST input goes to a "one" when the print drum sector is aligned for printing. Likewise, the internal sector number counter is cleared if ROM 2 input bit 0 is a "one" and incremented otherwise.]



What shouldn't be lost in the details is that the emulated i4004 CPU is executing the Busicom software, fetched from emulated i4001 ROMs, with data stored in emulated i4002 RAMs, interacting with other modules through I/O ports on the ROMs and RAMs and emulated i4003 shift registers. This constitutes almost 4,500 lines of Verilog source code working together to recreate the world's first microcomputer-driven consumer product.

I can hardly wait to see it running on real hardware again!

No comments:

Post a Comment