A RISC-V computer and VT220 terminal on one FPGA board
We turned a Digilent Basys 3 FPGA board (AMD Artix-7 XC7A35T) into
a complete 32-bit computer. Plug in a VGA monitor and a USB keyboard and it
starts up into BASIC, or works as a colour serial terminal for a Linux
machine.
Every part is our own Verilog and C, written from scratch: the RISC-V
processor, the terminal, the video, the keyboard interface, the file system,
the BASIC interpreter and compiler, and the debugger and assembler. The source is open
and free to download.
What's inside
RISC-V at 100 MHzA 32-bit RISC-V processor
(RV32IMF: the base instructions, multiply and divide, and IEEE 754
single-precision floating point in hardware) written in Verilog, with
interrupts, counters and hardware breakpoints. Most instructions take 2
clocks, about 40 million instructions a second in BASIC. It passes the
official riscv-tests.
Dartmouth-style BASICFloating point,
strings, numeric and string arrays, user functions, colour graphics, sound,
data files and a clock, with the structured statements of later BASICs:
DO … LOOP, IF … ELSE … END IF blocks and SELECT CASE. A line editor with the cursor keys: Up brings back
the last line, and a line number then Right copies the stored line to edit.
RENUM renumbers a program and fixes its GOTOs to match.
Programs are typed in at the keyboard or sent from a PC.
BASIC compilerA tool on the PC compiles a
BASIC program into RISC-V machine code that loads and runs like the games.
Loops, arithmetic, arrays and graphics run 7 to 26 times faster, and
everything else goes through BASIC's own routines, so a compiled program
behaves exactly as it does interpreted.
Scientific mathsInverse and hyperbolic
trigonometry (ASIN, ACOS, ANGLE, SINH, ACOSH…), SEC, CSC and COT,
LOG10 and LOG2, ROUND, TRUNCATE, CEIL, MOD, MIN, MAX, FACT and PI, with
OPTION ANGLE DEGREES for working in degrees. Every function is
checked to within 3 units in the last place of single precision.
Colour graphics320 × 240 in 16
colours, or 640 × 480 in two, under the text, with PLOT, LINE, RECT,
FILL and CIRCLE straight from BASIC.
Hardware sprites32 sprites of 16 × 16
pixels from 64 shapes, drawn by the hardware over the graphics: move one by
giving it a new position, with no flicker. Flipping, a frame counter for
smooth motion, and collision flags for sprites touching each other or the
walls.
Monitor and debuggerPress Pause at any time
to stop the machine. On the 132-column screen everything is shown at once:
all the integer and floating-point registers, the status registers, the
disassembly, the stack and memory, with registers that changed highlighted.
Single steps and breakpoints are done in hardware, so they work on any code,
BASIC included.
RISC-V assemblerAssemble source files saved
from BASIC, or type instructions in one line at a time, in the same syntax
as the GNU assembler: .org, .word,
.string, %hi/%lo, labels and
expressions, and the full RV32IMF instruction set. The disassembler shows
code as objdump does; both are checked against the GNU
tools.
Files in flashPrograms, data and memory
blocks are kept in the board's flash with the date they were saved, and
survive power-off.
VT220 terminal1280 × 1024 VGA, 132
× 64 characters, or 80 × 32 in a double-size font, ANSI colour, smooth scrolling and
serial speeds up to 3 Mbaud. It makes a good console for a Linux
machine.
PC toolsPython scripts send BASIC programs
to the board and fetch them back, and load machine code compiled on the PC
(Intel HEX) through the monitor into flash. Ctrl-Alt-Del restarts the
computer.
Made for gamesA port that reads the keys
being held down - arrows, W A S D, fire - so games don't depend on key
repeat, alongside the sprites, the frame counter and the collision flags.
Hardware scrollingThe graphics scroll in any
direction and wrap round, so a whole scene moves without being redrawn; a
hidden border lets a program draw what comes into view out of sight.
SoundThree square-wave voices and a noise
source, each with 16 volumes and an attack and decay envelope, so a game can
fire off a laser or an explosion with a few OUTs. It plays through a Digilent
PmodAMP2 to headphones or a speaker.
Crystal Cavern
A maze chase in C, compiled for RISC-V. You are a miner gathering the
crystals in a cave, chased by four bats that each hunt in their own way - one
comes straight for you, one heads you off, one works with the first and one
keeps its distance. A lantern scares them for a while, so you can catch them
and send their eyes flying home to the roost. Side tunnels wrap round, and
gold nuggets turn up for bonus points. On the board, RUN "CAVERN".
The bats leave the roost as the miner gathers crystals.
The title screen over the whole cave.
The cave is an original maze, made by a program that
joins up a grid of junctions and takes links away at random while keeping it
connected, mirrored and free of dead ends.
Star Swarm
A swooping alien shooter in C, compiled for RISC-V. A swarm of 46 aliens
sways in formation overhead and peels off in looping dives at your ship,
firing as they come; those that miss fly back into their places. A flagship
dives with its escorts - shoot both escorts first for a big bonus. One shot in
the air at a time. On the board, RUN "SWARM".
An alien peels off the formation in a dive.
The title screen.
There are more aliens than sprites, so the formation is
drawn into the graphics and sways by the hardware scroll; a diving alien is
wiped from the graphics and flies as a sprite until it is home again.
Star Warden
A side-scrolling planet defence game in C, compiled for RISC-V. Landers
come down to snatch the humanoids walking on a planet that wraps round; one
that carries a humanoid to the top turns into a mutant that hunts you. Shoot
them, catch the humanoids they drop, dodge the bombers' mines, and use smart
bombs and hyperspace when it gets too hot. The long-range scanner across the
top shows the whole planet. On the board, RUN "WARDEN".
Flying over the mountains, with the scanner at the top.
The title screen.
The planet is four screens round and scrolls both ways;
only the columns scrolling into view are drawn.
Bastion Raid
An isometric scrolling shooter in C, compiled for RISC-V. Fly over a
fortress that scrolls diagonally towards you and destroy the reactor core at
its far end. Climb over the low walls and fly low through the doorways in the
tall ones; your shadow on the floor and the altimeter show your height. Shoot
the turrets before they shoot you, shoot fuel tanks to keep flying, and fight
off the fighters that come at you between the fortresses. On the board,
RUN "RAID".
Coming in over the edge of the fortress.
The title screen, over the start of the fortress.
The fortress is drawn pixel by pixel from a formula into
the scrolling graphics, two new columns and one new row every frame; all
that moves is sprites.
The Iron Keep
A game written for the machine, in C compiled for RISC-V. You are a
prisoner in a castle of twelve rooms: steal the king's crown from the throne
room and escape down the stairs. Guards patrol, and shoot when they can see
you along a row or column; some come after you. Keys open locked doors, chests
hold gold, crates hold ammunition, and you have three lives. On the board,
RUN "KEEP".
The title screen.
The guard room: two guards on patrol, and a key to take.
All the game screens on this page were drawn by the games'
own tests, which run them in a RISC-V emulator of the machine with a model of
the board's graphics, sprites and font.
What you need
- A Digilent Basys 3 board.
- A VGA monitor that can show 1280 × 1024, and a USB keyboard.
- For sound (optional): a Digilent PmodAMP2 in the top row of the JA
port, and headphones or a speaker.
- To load it: Vivado's Hardware Manager or openFPGALoader. To build it
from source: Vivado 2025.2, which also ships the RISC-V GCC compiler it
uses.
Downloads
Free to download and use. The source is under the
MIT license:
use it, change it and share it, including in your own products. The current
release is release 6.
Ready-to-load bitstream
- release 6 (1.4 MB zip). Includes the
.bit to load into
the FPGA and the
.mcs to write to its flash, with instructions.
BASIC and monitor manual
(PDF) - getting started, the whole BASIC language, graphics and sprites,
sound, files, the monitor and the assembler, with example programs.
Source code
- release 6 (617 KB). Verilog, BASIC, monitor, assembler and game sources,
simulation testbenches, build scripts and PC tools.
Releases
Each release gets the next number, and the number is part of
the file names.
| Release | Date | What's in it | Files |
| 6 (current) | December 2, 2026 |
Wide monitor screen: on the 132 × 64 screen the monitor
shows everything at once - all 32 integer registers, all 32 floating-point
registers in hex and decimal with the rounding mode and flags, the status
registers with the trap cause decoded, 24 rows of disassembly beside the
stack, and memory - with registers that changed since the last step
highlighted. The 80-column layout is unchanged. A new manual, typeset in
IBM Plex. |
Bitstream ·
Source ·
Manual |
| 5 | December 1, 2026 |
BASIC compiler: tools/basc.py on the PC compiles a
BASIC program into machine code, loaded and run like the games. Arithmetic,
variables, arrays, every kind of loop and branch, and the graphics
statements run 7 to 26 times faster; printing, input, strings, files and
sound use BASIC's own routines through a fixed table in its ROM. Tested by
running 31 programs both ways and comparing the screens. Fix:
variables X1 to Z9 no longer share storage with A to B9 (A7 and Y were the
same variable). The manual has a new section on compiling. |
Bitstream ·
Source ·
Manual |
| 4 | December 1, 2026 |
GNU assembler syntax: the monitor's assembler takes the same
source as the GNU assembler - .org, .byte,
.word, .string, .space,
.align, # comments, 0x numbers and
%hi/%lo - and the disassembler shows code as
objdump does. The older forms still work. UCASE$ and
LCASE$ in BASIC. The manual's machine-code sections are rewritten to
match. |
Bitstream ·
Source ·
Manual |
| 3 | December 1, 2026 |
Scientific functions in BASIC: ASIN,
ACOS, ANGLE, SEC, CSC,
COT, SINH, COSH, TANH
and their inverses, LOG10, LOG2, IP,
FP, CEIL, ROUND,
TRUNCATE, MOD, MIN, MAX,
FACT, PI, DEG and RAD,
and OPTION ANGLE DEGREES. A new bitstream (BASIC is in it); the
manual covers them all. |
Bitstream ·
Source ·
Manual |
| 2 | December 1, 2026 |
Floating point in hardware: the processor is now RV32IMF, with an
IEEE 754 single-precision unit, and runs at 100 MHz, so BASIC's arithmetic is
about twice as fast. 640 × 480 graphics in two colours
(SCREEN 1). Structured BASIC: DO … LOOP
with WHILE and UNTIL, EXIT DO and
EXIT FOR, ELSE, block IF … ELSEIF
… END IF and SELECT CASE. The screen starts at
132 × 64. The manual covers all of it. |
Bitstream ·
Source ·
Manual |
| 1 | November 30, 2026 |
First RISC-V release: our own RV32IM processor at 90 MHz in place of the
Z-80, with the whole machine carried over - the VT220 terminal, graphics,
sprites, scrolling, sound, BASIC (with RENUM, string arrays and the line
editor), the monitor with a RISC-V assembler and disassembler, and all five
games. |
Bitstream ·
Source ·
Manual |
Source repositories
The live source is on our git server, where you can browse it, follow the
changes and clone it:
| Repository | What it holds |
| Basys3RiscV |
The whole design: the RISC-V processor, terminal, video and sprites in
Verilog, BASIC, the monitor and assembler in C, five games, testbenches,
the manual and the PC tools. |
| Basys3Terminal |
The earlier Z-80 version of the same computer, now retired. Its last
release, release 9, stays available:
bitstream ·
source ·
manual. |
git clone https://git.barant.com/barant/Basys3RiscV.git