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.
Hardware
The board
| Board | Digilent 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 |
|---|---|
| Design | VHDL, built with AMD Vivado. The bitstream is kept in the board's flash and loads at power-up. |
| Speed | Chosen 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 port | A 6551-compatible ACIA in the FPGA, through the board's USB port, 9600 baud 8N1 |
| Parallel port | DAVIAC-2.04's PIA: writes drive Pmod JA, reads take Pmod JB (3.3 V only) |
Memory map (DAVIAC-2 revision 2.04)
| Range | Device |
|---|---|
0000–7FFF | ROM, 32 KiB (DavSys) |
8000–FBFF | RAM, 31 KiB; the stack grows down from FBFF |
FC00–FDFF | PIA |
FE00–FFFF | ACIA |
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:
| Opcode | Instruction | Bytes | States | Action |
|---|---|---|---|---|
64 | JSR addr | 3 | 15 | push the return address, branch to addr |
68 | RTS | 1 | 11 | pop the return address into PC |
6C | LDSP addr | 3 | 15 | load 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
- DavSys350.asm: source
- DavSys350.lst: assembler listing
- DavSys350.hex: ROM image
Documentation
- DAVBAS User's Manual, for DavSys 325.6; on DavSys 350 everything works as described, with the differences above (PDF, A5, 52 pages, 11 MB)
- DAVIAC-2 schematics: DAVIAC-3 follows revision 2.04
User's guide: getting started
- Plug the Basys 3 into a PC with its USB cable, with SW0 down, and switch it on.
- Open a terminal (PuTTY, for example) on the board's COM port at 9600 baud, 8 data bits, no parity, 1 stop bit.
- Set SW2 and SW1 up for full speed.
- Press BTNC (RESET), then BTNR (RUN). DAVBAS prints
DAVBAS350 ready. The machine starts stopped at0000after power-up, so this is needed every time.
Controls
| Control | Function |
|---|---|
| BTNC | RESET (also resets the ACIA, as on DAVIAC-2) |
| BTNR | RUN / STOP |
| BTNU | STEP: half a state on press, the other half on release |
| BTNL | FREE: ends a WAIT |
| SW0 | The USB serial port: down = the ACIA (DavSys), up = the loader |
| SW2, SW1 | Speed: 00 = 2 states/s, 01 = 20 states/s, 10 = 2 million (DAVIAC-2), 11 = 12.5 million |
| SW5–SW3 | 7-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 |
| SW6 | LEDs: 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:
| Command | Action |
|---|---|
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 AAAA | Read 16 bytes |
X | RESET |
G | RUN |
S | STOP |