DAVIAC-3: DAVIAC on an FPGA

DAVIAC-3 is DAVIAC-2, revision 2.04, described in VHDL and run on a Digilent Basys 3 FPGA board. It keeps the machine state by state: the same registers, the same 16-state sequencer, the same 6551 ACIA. It runs DAVIAC-1 and DAVIAC-2 programs unchanged, at any speed from two states a second to 12.5 million. The current version, DAVIAC 3.5, adds subroutine instructions.

The Digilent Basys 3 FPGA board running DAVIAC-3: the 7-segment display and the row of green LEDs above the 16 switches are lit
DAVIAC-3 on the Basys 3. The switches along the front edge choose the speed and what the display and LEDs show; the buttons are RESET, RUN/STOP, STEP and FREE.

Hardware

The board

BoardDigilent Basys 3: AMD Artix-7 FPGA (XC7A35T), 100 MHz clock, USB for JTAG and serial, 16 switches, 16 LEDs, 5 buttons, a 4-digit 7-segment display, Pmod connectors
DesignVHDL, built with AMD Vivado. The bitstream is kept in the board's flash and loads at power-up.
SpeedChosen with switches: 2 or 20 states a second to watch on the LEDs, 2 million (DAVIAC-2's speed), or 12.5 million states a second
Serial portA 6551-compatible ACIA in the FPGA, through the board's USB port, 9600 baud 8N1
Parallel portDAVIAC-2.04's PIA: writes drive Pmod JA, reads take Pmod JB (3.3 V only)

Memory map (DAVIAC-2 revision 2.04)

RangeDevice
0000–7FFFROM, 32 KiB (DavSys)
8000–FBFFRAM, 31 KiB; the stack grows down from FBFF
FC00–FDFFPIA
FE00–FFFFACIA

New in DAVIAC 3.5: subroutines

Three instructions use opcodes that were spare on DAVIAC-1 and DAVIAC-2, so every older program still runs:

OpcodeInstructionBytesStatesAction
64JSR addr315push the return address, branch to addr
68RTS111pop the return address into PC
6CLDSP addr315load the stack pointer

The stack is in RAM and grows down; the stack pointer resets to FC00. Before 3.5 a call took 7 bytes and 59 states and could not nest; a JSR takes 3 bytes and 15 states, and subroutines can nest to any depth and call themselves.

Software: DavSys 350

DavSys 350 is DavSys 325.6 (see DAVIAC-2) converted to JSR and RTS. It has the same DAVBUG, MATHS16 and DAVBAS, and the same commands, with these differences:

  • Faster: BASIC runs about 27% faster. A test that finds ten n-th roots to many digits takes 1,338 million states, against 1,833 million on 325.6: 105 seconds on the board.
  • Smaller: 12,168 bytes, 2,908 fewer than 325.6; the 88 return vectors in RAM are gone.
  • Bigger programs: with DAVIAC-3's 31 KiB of RAM, DAVBAS takes 255 lines and 16 KB of program, and LOAD has an 8 KiB buffer.
  • Machine code: a routine called with GOSUB $addr, or started with DAVBUG's G, returns with RTS.
DAVBAS350 ready
Abort to BIOS <\>, Exit to DAVBAS <ESC>

DAVIAC-3 also runs DavSys 325.6 unchanged.

Downloads

Documentation

User's guide: getting started

  1. Plug the Basys 3 into a PC with its USB cable, with SW0 down, and switch it on.
  2. Open a terminal (PuTTY, for example) on the board's COM port at 9600 baud, 8 data bits, no parity, 1 stop bit.
  3. Set SW2 and SW1 up for full speed.
  4. Press BTNC (RESET), then BTNR (RUN). DAVBAS prints DAVBAS350 ready. The machine starts stopped at 0000 after power-up, so this is needed every time.

Controls

ControlFunction
BTNCRESET (also resets the ACIA, as on DAVIAC-2)
BTNRRUN / STOP
BTNUSTEP: half a state on press, the other half on release
BTNLFREE: ends a WAIT
SW0The USB serial port: down = the ACIA (DavSys), up = the loader
SW2, SW1Speed: 00 = 2 states/s, 01 = 20 states/s, 10 = 2 million (DAVIAC-2), 11 = 12.5 million
SW5–SW37-segment display: 000 address bus, 001 PC, 010 A:B, 011 C:IR, 100 M, 101 AD+, 110 state and flags, 111 data bus : ACIA status
SW6LEDs: down = sequencer states S0–S15; up = DAVIAC-2's status lamps (SYS ALU MOV MEM WAIT HALT RUN STEP BRA Z P N OVF TxD RxD, loader)

At 2 states a second, with SW6 down, the LEDs show the sequencer stepping through each instruction.

The loader (SW0 up)

With SW0 up the USB serial port talks to a loader at 115200 baud 8N1 instead of the ACIA. It can write the ROM as well as the RAM. One command per line; it answers OK, or ? if it can't parse the line:

CommandAction
AAAA: HH HH ..Write bytes from address AAAA. These are the assembler's .hex lines, so a .hex file can be sent line by line.
R AAAARead 16 bytes
XRESET
GRUN
SSTOP