A homebrew FPGA CPU with a native Pascal compiler and a simple development environment
Find a file
2024-12-27 03:02:11 +01:00
doc add 3dplot example, small doc fixes 2024-11-22 23:52:08 +01:00
examples add image data for Xmas demo 2024-12-24 03:07:16 +01:00
lib use precompiled standard library (not really a linker) 2024-11-09 22:22:48 +01:00
pcomp add serload python script, wrong filename in make.bat 2024-11-25 00:09:35 +01:00
progs reclaim: Bugfix marking last slot on empty volume on reclaim 2024-11-25 00:08:44 +01:00
tests Bugfix return type for some set operators 2024-10-16 02:01:12 +02:00
tridoracpu update Vivado project file 2024-12-27 03:02:11 +01:00
tridoraemu README: add emulator section 2024-10-06 23:56:50 +02:00
utils add sprites library and Xmas demo 2024-12-24 03:05:46 +01:00
.gitignore add sprites library and Xmas demo 2024-12-24 03:05:46 +01:00
LICENSE.md initial commit 2024-09-19 14:12:22 +02:00
README.md README: update download links 2024-11-10 01:39:18 +01:00

Tridora System

Tridora is a homebrew CPU written in Verilog and a matching software environment, including a Pascal compiler and assembler. Everything was created from the ground up (except soldering stuff). Everything is as simple as possible while still being reasonably useful. Everything is open source, so you can read, understand and modify the whole system, hardware and software.

Overview

  • homebrew CPU written in Verilog implemented on an FPGA
  • 32-bit word-oriented stack machine architecture
  • running at 83 MHz on an Arty-A7 board with four clocks per instruction
  • has its own instruction set architecture, compatible with nothing
  • additional IO controllers on FPGA: UART (serial console), SD-Card, VGA
  • Pascal compiler written from zero
  • CPU and compiler were designed together
  • minimal operating system
  • editor, compiler, assembler run natively
  • so you can develop programs directly on the machine
  • small: CPU has ~500 lines of Verilog, compiler ~9000 LoC
  • compiler written in Pascal and can compile itself
  • cross-compiler/-assembler can be compiled with FPC
  • compiler does its own Pascal dialect with some restrictions and some extensions
  • emulator available here

The name comes from a certain fictional monster with three heads. The prefix tri- is greek for three, and the Tridora-CPU has three stacks instead of just one like almost all other CPUs. It also has a strange mixture of features from three different eras of computing:

  • a simple instruction set without integer multiply/divide like an 8-bit CPU
  • speed is like a fast 16-bit CPU, also 16-bit instruction words
  • 32-bit word size from the 32-bit era

Contact the author here: tridoracpu [at] insignificance.de

You can also open a ticket on Gitlab or send a message on Hackaday.

Demos

Videos

Compiling and Running "Hello World" Moving Lines Demo
image image

Pictures

Mandelbrot Image Viewer Game of Life
image image image

Supported FPGA Boards

Arty-A7-35T

At the moment, the only supported board is the Digilent Arty-A7-35T.

Two Pmods are used for a complete system:

  • the Digilent MicroSD Pmod at the JA connector
  • the Digilent VGA Pmod at the JB and JC connectors

As the Arty-A7-35T is no longer in production, it should be easy to use the Arty-A7-100T instead, but this has not been tested yet.

Other boards under consideration are the Digilent Nexys-A7 and the Olimex GateMateA1-EVB.

Pascal Language

  • Wirth Pascal
  • no function types/parameters
  • arbitrary length strings (2GB)
  • safe strings (runtime information about max/current size)
  • tiny sets (machine word sized), that means no SET OF CHAR
  • array literals with IN-operator, which can replace most uses of SET OF CHAR
  • nested procedures with some limitations
  • 32 bit software floating point with low precision (5-6 digits)
  • break and exit statements, no continue yet
  • static variable initialization for global variables
  • non-standard file i/o (because the standard sucks, obl. XKCD reference)

Standard Library

  • everything from Wirth Pascal
  • some things from TP3.0
  • some graphics functionality (to be expanded in the future)

Operating System

  • not a real operating system, more of a program loader
  • some assembly routines for I/O resident in memory
  • one program image loaded at a time at a fixed address
  • most parts of the operating system are contained in the program image
  • file system is very primitive: only contiguous blocks, no subdirectories
  • simple shell reminiscent of TP3.0, edit, compile, run programs

Building the Compiler

  • you need to have FPC and Python3 installed
  • on Linux, you need make installed
  • in the pcomp directory, run make (or make.bat on Windows)
  • on Linux, you can also run make nativeprogs and make examples

Getting the ROM image

  • there are two formats for the ROM image, one for the emulator (rommon.prog) and one for building the FPGA bitstream (rom.mem)
  • to get the rommon.prog file, either copy it from the tridoraemu package file or build it
  • for rom.mem and rommon.prog, find both files in the lib directory after running make nativeprogs (or make.bat) in the pcomp directory (see above)

Building the FPGA bitstream

  • install Vivado (known to work with 2020.1, known NOT to work with 2024.1)
  • install the package for your board in Vivado (Tools -> Vivado Store -> Boards)
  • copy the ROM image (rom.mem) into the tridoracpu directory (see above)
  • start Vivado and open the project file tridoracpu.xpr in the tridoracpu directory
  • run synthesis, implementation and bitstream generation (Flow -> Generate Bitstream)
  • program your device (Flow -> Open Hardware Manager), the bitstream file should be in tridoracpu/tridoracpu.runs/impl_1
  • the bitstream file for (temporarily) programming your device is named top.bit, the file for flashing your device is named top.bin

Running the Emulator

See the emulator README.

Documentation

More documentation is coming, as time permits.