Forth on Nandland Go Board Jun 15, 2016
After a recent excursion into FPGAs, and in particular Z80 + CP/M emulation, I’ve been tracking developments and keeping tabs on what’s being going on in both FPGA- and Retrocomputing-land.
FPGAs are amazing chips. The interest in these universal chips is increasing, not in the least due to IceStorm - an open-source toolchain to perform the complex task of turning a high-level logical description of the chip into an actual “bitstream” which can be loaded into an FPGA.
One of the most interesting new low-end boards to bring FPGAs into the tinkerer’s reach is the Go Board by Russell Merrick:
It includes an ICE40HX1K FPGA chip by Lattice (that fat square chip in the picture above), as well as some buttons, LEDs, 7-segment displays, and VGA out connector (VGA is quite easy to generate in an FPGA).
The HX1K series FPGA chips are relatively small, with only 1280 logic elements (the EP2C5 chip in the Z80 emulator has 4608 LEs). It’s more than enough to learn the basics and drive all sorts of interfaces at high speed, but it’s on the small side for creating a complete CPU “soft core”.
Except for the J1a by James Bowman, which implements a really nice and clean small Forth processor. It’s all open source on GitHub, making it a perfect candidate for IceStorm. The J1a processor is defined in 100 lines of amazing Verilog code. Best of all: it fits into the ICE40HX1K.
Matthias Koch then extended this code to make the Forth implementation more Mecrisp-like and came up with “Mecrisp-ICE”. The upcoming 0.8 release also supports the Go Board, which means you can now explore a complete system, from chip design to programming language!
Here is some sample code for Mecrisp-ICE 0.8 on the Go Board, which displays key-presses coming in over USB serial as hexadecimal on the two 7-segment LEDs:
create font binary 0111111 , \ 0 0000110 , \ 1 1011011 , \ 2 1001111 , \ 3 1100110 , \ 4 1101101 , \ 5 1111101 , \ 6 0000111 , \ 7 1111111 , \ 8 1101111 , \ 9 1110111 , \ A 1111100 , \ B 0111001 , \ C 1011110 , \ D 1111001 , \ E 1110001 , \ F decimal : >seg ( u -- x ) 2* font + @ ; : seg.x ( c -- ) dup $F and >seg 7 lshift swap 4 rshift $F and >seg or $80 io! ; : ascii ( -- ) \ display keys on 7-seg until ESC is pressed begin key dup seg.x 27 = until ;
If you look very closely at the image above, you can see it running and
displaying “0d” for the
Return key I just pressed.
The Go Board draws 135 mA, but most of it is by the FT2232HL chip, which handles high-speed USB <-> serial conversion and FPGA programming. By themselves, the ICE40 chips are in fact very low-power.
For more info about FPGA’s and the Go Board, see Russell’s tutorials on YouTube.
Lastly, if the HX1K is too limited for your tastes, you can check out the iCEHX8K evaluation board, which has a larger FPGA and is also supported by Mecrisp-ICE.
It’s now only a matter of time: more open source projects based on FPGAs!