Table of Contents
- Obligatory Bullet Points — We Have Them
- Future Versions
- Programmer's Front Panel Crash Course
- Visual Aids
- Playing with the Emulator
- Address C000: Reboot
- Address C100: Counter
- Address C200: Adding Machine
- Address C300: Echo
- Address C400: Rolling Lights
- Address C500: Fibonacci Sequence
- Address C600: Eratosthenes' (Prime Number) Sieve
- Address C700: Hello World
- Questions I'll Never Have to Read
- Why are so many lights off?
- What do the Rightmost Two Toggles Do?
- In Fast Mode, the Lights Don't Make Sense. What Gives?
- I Need to Know More! Where Do I Start?
- Assembly Listing of the ROM
Try it right now: set the switches to
c700 (type it on your
keyboard if you can't convert hexadecimal to binary in your head), then press
the RUN switch. Read on for more details.
You've seen all those images of the CFT front-panel (Coming Real Soon Now). You've seen screenshots of unit tests running, Forth executing exotic code, even the microcode. You've seen screenshots of the CFT emulator. But so far, you've never had a chance to play with a CFT processor yourself. It's time to remedy this, so here's a CFT emulator and Front Panel trainer rolled into one, with a bonus ROM full (for very, very sparse values of ‘full’) of goodies. What's best, this emulator isn't the C-based one. Oh no. This one runs in your browser.
Very, very slowly. On my computer, using the latest version of Chrome, it runs at about 250 Hz. The CFT is intended to run at 4 MHz, so the emulator runs 15,000 times slower than the actual processor. But this is a good thing because now you can see all those blinkenlights1 at proper Hollywood-style speeds.
This emulator requires a large-ish screen to use. It probably won't work on mobile devices or old browsers. It was tested on Chrome 24 and 25 (and above), Firefox 19 (and above) and Opera 12, but will work with any reasonable version of these browsers with varying degrees of eye candy. It does not currently work on Internet Explorer and I'm not even working on it. Drop me a comment below if you need it to run on Explorer. I reserve the right to laugh at you, though.
Obligatory Bullet Points — We Have Them
Here's a list of the features available:
- Full CFT processor emulation at the microcode level.
- 48 kWords of RAM, 16 kWords of ROM.
- Seven panel-oriented test programs already in ROM, or toggle in your own!
- Full programmer's control panel, except the power and panel lock switches.
- Debugging board (partial emulation, to capture processor output and state).
- Various light decoding aids.
And here's what we don't have.
- No Memory Banking Unit.
- No Interrupt Controller Unit.
- No serial ports, printers, graphics, sound, bells or whistles.
In short, you're getting the glorious CFT processor as the Elder Gods intended: unadulterated, unexpanded, without bloat or feature creep. You'll find it's still pretty capable.
This version of the emulator is meant to demonstrate the microcode and front panel, and for that we need to be graphics-intensive and run at the microcode level, clock tick by clock tick. A better approach would be to implement instruction-level emulation, which will easily be a couple of orders of magnitude faster, approaching the speed of the real thing. It won't have a front panel, but it will have a serial console and may be able to run ROM Forth.
Programmer's Front Panel Crash Course
All computers used to have these once upon a time. These days, some explanation is required. You can use the Programmer's Front Panel (PFP) to operate, inspect, program and debug the machine. The CFT's PFP shows pretty much all of the computer's internal state from the microcode level up.
There are loads. If you're overwhelmed, set the ‘LTS’ switch to ‘OFF’ to extinguish the less used lights. A bunch of these are permanently off because the hardware that would drive them isn't emulated. Others are off and unlabelled because they haven't been assigned functions yet. Don't worry about them. Here are the really important ones.
- Program Counter
- Shows the address of the next instruction to be executed.
- Shows the value of the Accumulator (AC register), the main register of the machine. All the magic happens here.
- Output Register
- Shows the value of the Front Panel's Output Register, which is used to output results to the user. To display this register, set the white ‘OR/DR/µADDR’ switch to the ‘OR’ position (up — this is the default).
- Shows whether the computer is running or stopped. Many panel switches only work with the computer stopped. The computer only works when it's running, of course.
- Next to the Run/Stop lights are the Fetch/Exec lights. When Fetch is lit, the computer is reading a new instruction from memory. When Exec is lit, it's executing the last instruction it fetched.
There are three groups of these. Computer and panel control switches on the left, the Switch Register in the middle, and programming switches on the right. Here's a quick description of the important ones.
- Push up (or press Alt+Shift+R) to reset the computer, push down (or press Alt+Shift+S) to reset it and start it if it was stopped (this is the same behaviour as the ‘reset’ button on PCs).
- Push up (or press Alt+R) to start the computer, push down (or press Alt+S) to stop it. The computer can stop itself by operating the panel programmatically, and you can also stop it to examine its state. You can use the panel to program and debug the computer when it's stopped.
- Sets the computer's clock speed. This switch behaves differently to the real thing: in fast mode, the lights don't update as often, and the processor runs at around 250–900 Hz (the real CFT runs at 4 MHz). In slow and creep modes, the lights update all the time. Slow is good for watching code execute, creep is good for watching microcode execute.
- Light Switch
- The LTS ON/OFF switch disables most of the panel's lights, which is useful when not debugging. This emulator also runs slightly faster in LTS OFF mode.
- Controls what's displayed on the Multi-Function Display, the middle of the fourth row of lights.
- The Switch Register
- The 16 switches in the middle of the front panel are used to input
values to the computer. The panel uses them for programming, and the
computer reads them to find out the user's intentions. When a switch is up,
the corresponding bit value is
1, otherwise it's
0. You can enter values using the hexadecimal keys 0–9 and A–F. Each key press sets four switches at once (highlighted in red). You can use Backspace to go back, but the focus wraps around to the leftmost digit after the rightmost digit is entered.
- With the computer stopped, push down (or press Shift+:) to set the Program Counter to the value of the Switch Register.
- With the computer stopped, push up or down (or press =) to set the Accumulator from the Switch Register.
- MEM W/W NEXT
- With the computer stopped, push up to store the write the Switch Register to the memory location indicated by the Program Counter lights. Push down (or press Shift+Enter) to do the same and increment the PC, ready for the next value to be deposited. This is the switch most used when storing programs or data in memory. Note there are another three switches for reading memory and writing and reading from I/O space that work in exactly the same way.
Many lights and switches are decoded to help you enter values. The decoding
appears next to the register name in dark grey (hover over the register to make
it brighter). Values like
0000 are in hexadecimal, sometimes
followed by a CFT machine code disassembly of the same value. Decimal values
may be shown as something like
(42) after that.
Playing with the Emulator
When you first load the emulator in your browser, it will run briefly then halt with all Accumulator lights off and all Output Register lights on. I use this as a prompt. Set the switch register to an address by toggling it in manually or pressing, e.g. C700 and press ‘RUN’ (Alt+R). The address identifies one of the programs in the ROM. Each program behaves differently.
Address C000: Reboot
This is the code that shows the prompt and waits for an entry address. You can get there by simply pressing ‘START’ (Alt+Shift+S) at any time. The program halts, then (when the computer starts again), reads the value of the Switch Register and jumps to it.
Address C100: Counter
Counts up from zero to the value of the Switch Register, which can be changed while the program is running. The Output Register displays the current count. When the count is reached, the computer stops. Resuming by pressing the ‘RUN’ switch (Alt+R) starts counting all over again.
Address C200: Adding Machine
This is a simple adding machine with printout (on the Debug Terminal, shown below the front panel). Key in a number using the Switch Register and press the ‘RUN’ switch (Alt+R) to add it to the running total. The running total is displayed in the Output Register and printed out on the Debug Terminal. The total is displayed modulo 65,536 since the CFT is a 16-bit machine.
Address C300: Echo
The Accumulator and Output Register follow the value set on the Switch Register in real time. This program never stops.
Address C400: Rolling Lights
Upon entry, the program halts, waiting for a bit pattern to be set on the
Switch Register. Try
1111. Once this is done, press the ‘RUN’
switch (Alt+R) and the Accumulator and
Output Register will roll this pattern to the left. The gap in the pattern is
due to the ‘L’ register participating in the rolls as a 17th bit.
Address C500: Fibonacci Sequence
This program prints out (and displays on the Output Register) the first numbers of the Fibonacci Sequence: 0, 1, 1, 2, 3, 5, etc. Only numbers that fit in 16 bits are displayed, so the calculation will stop with 46,368.
Address C600: Eratosthenes' (Prime Number) Sieve
This program prints out prime numbers calculated using Eratosthenes' Sieve, an ancient algorithm, but very effective for generating shortish lists of primes. Upon entry, the program prints out (on a line of its own) the maximum integer to be tested, which is 30. Then, prime numbers are printed out one by one, as they are found, separated by spaces.
The maximum number of primes can be set manually by modifying the value at
0017 (hexadecimal), and then entering the algorithm at
C602. To do this:
- Press ‘STOP’ (Alt+S). The machine stops (if it wasn't already).
- Key in
0017on the Switch Register (manually, or by pressing 0017 — ensure the first digit focused is the right one).
- Press ‘→PC’ (Shift+:). The PC is set to
- On the Switch Register, toggle in the maximum number to test. Remember that the number is entered in hexadecimal.
- Press ‘MEM W’ or ‘MEM W NEXT’ (Shift+Enter). The memory location
0017is set to the value you toggled in.
- Press ‘START’ (Alt+Shift+S).
- Key in
C602on the Switch Register (manually, or by pressing C602 — ensure the first digit focused is the right one).
- Press ‘RUN’ (Alt+R). The calculation starts.
You can generate any number of primes up to a maximum of 45,056 (the beginning of the ROM). Unless you have a lot of free time, I recommend sticking to numbers less than a few hundred. Remember, this simulator runs at around 250 Hz.
Address C700: Hello World
The Standard Program. No input is expected. Output is sent to the Debug Terminal, but the ASCII/UCS character codepoints are also shown on the Output Register as they're printed. The program halts on termination, but can be restarted by pressing ‘Run’ (Alt+R).
Questions I'll Never Have to Read
In time honoured fashion, here's a NAQ (Never Asked Questions) list:
Why are so many lights off?
Some have never been designated a function. The version 4 front panel is smaller by 2U than the version 3, but it has space for a good 48 more lights, left there for future expansion and debugging of the actual beast. These lights are usually in the peripheral section, to the right of the register display and above the programming toggles.
Some other lights are supposed to be driven by hardware that isn't present. The Memory Bank Unit (MBU) isn't included here. It's part of the processor boards as constructed, but it's not necessary for the processor to function and we have more memory than we'll ever need for a panel-programmed computer. This includes the ‘MBEN’ light, which is on when the MBU is enabled and remapping addresses.
What do the Rightmost Two Toggles Do?
Nothing in this version.
The second switch from the right controls the memory map of the computer at boot time, before the MBU is enabled. In the ‘RAM BNK’ position, all 64 kWords of memory are RAM. In the ‘ROM BNK’ position, the upper 32 kWords are ROM. This is all done by the MBU, which isn't installed in this virtual computer. So the switch does nothing and the mapping is hardwired: 48 kWords of RAM, 16 kWords of ROM.
The rightmost switch issues Interrupt Requests at levels 1 and 6 when pressed. This is meant to input simple asynchronous signals to the processor via the front panel, but it requires the Interrupt Controller Unit which (shock!) isn't installed. So the switch does nothing.
In Fast Mode, the Lights Don't Make Sense. What Gives?
Well spotted. In Fast mode, there are 10 processor ticks for every update of the front panel lights, so some status changes aren't shown. If you have a really quick eye, you can see the PC jumping around where there are no jump instructions. Switch to a slower mode and the panel updates every tick.
I Need to Know More! Where Do I Start?
For proper documentation, you might try the CFT Book, which contains more information about the hardware and software than you'll ever need (or want) to know. Even if you're me. This is a draft, and full of typesetting mistakes, typos, information in need of review, and the like. But it should be informative nonetheless.
Assembly Listing of the ROM
Here's the Standard Assembly listing of the ROM used in the emulator right now:
- 1 Not all blinkenlights implemented yet — many are permanently off because the emulated cards driving them aren't installed.