More on the Spartan 3 Starter Kit Computer

I promised a bit more about the computer I’ve built around the Spartan 3 Starter Kit. Let me tell you a bit about the front panel. The CPU is a 16-bit machine with a 12-bit address bus (4K words or 8K bytes of memory). But the board doesn’t have enough I/O to actually support this via the front panel. So a little ingenuity was required.

The board has 4 numeric digital displays. These can display hex (if you provide a hex decoder in the FPGA) so that’s enough to show a single 16-bit quantity. Each digit also has a decimal point which will become important later.

The board also has 8 toggle switches, 8 discrete LEDs, and only 4 push buttons that you can use. Let’s start with the 4 buttons. The leftmost button is predefined to the FPGA’s reset line, so it is the reset button. The next button selects the mode of the front panel (there are 6 modes that you select sequentially — each button press picks the next mode). The second to last button is an “execute” button that means different things depending on the current mode. The final button works as an “enter button” in all modes. Of the 8 LEDs, 6 are dedicated to showing the current mode.

Mode 0 – Register select

In this mode, each press of the enter key changes what register the display shows. The display can show 4 different registers and which one it shows is indicated by which decimal point is turned on. When the rightmost decimal point is on, the display shows the program counter (PC). The next LED signifies the accumulator is displayed. The 3rd LED indicates the “switch” register (more on that in a second). The final LED indicates the instruction register (IR) is displayed.

Note that in all modes, when you press the enter key and hold it down, the front panel does three things:

  1. It shifts the switch register left 8 bits
  2. It puts the current 8 switches into the right 8 bits of the switch register
  3. It displays the switch register (and the corresponding decimal point) until you release the button

So to enter A105 into the switch register, you have to enter A1 into the switches, press enter, and then enter 05 into the switches and press enter again.

Mode 1 – Set PC
Pressing execute in this mode transfers the switch register to the program counter.

Mode 2 – Dump
In this mode, every press of the execute button puts the contents of the memory at the PC into the accumulator and increments the program counter. You can use this to examine memory.

Mode 3 – Load

This is similar to mode 2 except that pressing the execute button puts the contents of the switch register into the memory at PC and increments PC. In addition, in this mode (and assuming the processor is halted) any bytes that show up on the serial port will be entered as though they were entered at the switches. This is a handy way to load an initial program over the serial port (sort of like a paper tape reader).

Mode 4 – Single Step
This mode causes the program to step each time you press execute.

Mode 5 – Run
When in mode 5, pressing execute will start the processor running (or stop it if it is running already).

The two leftmost LEDs are used to indicate status. The very leftmost LED is the Q LED which the program can turn on and off (useful for debugging). The next LED turns on when the processor is running.

This is surprisingly flexible and is pretty quick to operate once you get the hang of it. Of course, you don’t want to enter long programs which is why there is the serial port option.

The switch register can be read and written under program control. The program can also read the raw value of the switch inputs. These are mapped, along with the UART registers, to the top part of the memory (FF0-FFF are reserved for I/O).

So that gives you a little flavor of what I do in my spare time. Next time I’ll talk about the instruction set (which includes a stack, indexing, and a few other interesting instructions).

Leave a Reply