King of the 16-Bit Jungle: Lion FPGA CPU/Computer

Recreating the home computers of the '80s on an FPGA, the Lion FPGA CPU/computer project is an impressive 16-bit CPU written in VHDL.

If you're feeling nostalgic for the early 1980s home computers and you have an FPGA development board laying around, you can install Theodoulos Liontakis' 16-bit homebrew CPU architecture named Lion.

Lion's Tiny Basic screen.


Liontakis started the project back in 2015 while exploring FPGAs and FPGA design. He made a simple 16-bit CPU then he decided he wanted to build something similar to his childhood home computer. From the ground up, he coded his own assembler then built a serial UART controller and video controller for it. He ported over the Palo Alto version of Tiny BASIC (originally written for the 8080 Intel processor, also referred to as PATB) with fixed floating point arithmetic added. This is brilliant because this means Lion has the capability of handling decimals in calculations (although it is limited to a precision of 3 decimal places since it only uses 32 bits).

Liontakis also added to Lion's PATB version math functions such as INT(), COS(), SIN(), SQRT(), ROUND(), and PI(). Then even upgraded it to be able to recognize both uppercase and lowercase letters so commands are no longer case sensitive.

The Lion Computer hardware in action.

The current hardware specifications for the Lion CPU include 16-bit data bus with 19-bit address bus running at 50MHz with 8K rom, 56K ram, 32K video ram, 12K sprites ram, 64K paged ram, and 4K vector ram. There are two video output modes: one for text optimization and one for graphics optimization. Lion has forty-five 16x16 pixel hardware sprites (two-dimensional bitmaps) with 15 color transparencies that are double buffered for smoother animation, and three sound channels that have an an 8-bit digital volume control. The vector graphics support hardware line drawing at a 10-bit resolution using a 12-bit DAC with 4K vector RAM.

Sprite test on Lion.

Lion supports basic FAT storage on an SD indexable up to 30 Mbytes. There are ports for two joysticks, a serial port, VGA port, and a PS/2 keyboard port.

The first application on Lion being tested - a basic calculator written in assembly.

The project is currently built on the Altera's Cyclone V Core Board manufactured by QMTech which I was only able to find available on Alibaba.com for $82. But after looking through the VHDL source files, it seems like it would be a fairly straightforward process to port Lion onto another FPGA that has at least the same resources as the 5CEFA2F23I7 Cyclone chip.

The Lion assembler.

Lion has a simple Java compiler for the CPU course code. Java is a smart choice for a compiler language due to how Java creates an intermediate code that can be run on a virtual machine in almost any computer architecture then compiled from there to produce native assembly. Based on the open source project Java Grinder (a tool for writing programs in Java to run natively on microcontrollers), the Lion assembler outputs three different types of files:

  • Memory Initialization Files (.MIF) for the ROM and RAM that are instantiated in the VHDL.
  • Source code to copy and paste into the ROM and RAM during their initialization routines in VHDL.
  • The boot binary (.bin) loaded into memory from the SD card.

This means Lion has three different booting options. It seems that currently the most tested method is use of the .MIF files to initialize the ROM and RAM at boot to then load Lion's version of Tiny Basic.

Here's a link to a video showing Lion being put through its full paces in a demo on Liontakis' site where he's logged some of the earlier posts about the project.

Overall, Lion is full of hidden gems (its Windows Emulator is worth note) that make it a really fun project and extremely educational in the way it's been built from complete scratch. All of the source files are available in the project GitHub here.

whitney-knitter

All thoughts/opinions are my own and do not reflect those of any company/entity I currently/previously associate with.

Latest Articles