Musings of a Fondue

Tag: Fpga

A VHDL Take on Ben Eater's CPU

IMG_20170903_132332

As part of the Homebrew Computer Project, I have been exploring other CPU architectures and their implementations in order to broaden my understanding of CPU design.

An awesome one that I came across was Ben Eater’s 8-bit computer. It is well documented through a series of videos on Youtube and also on his blog. The architecture is simple which allows you to get a firm understanding of all its components.

Since it is a known working design, I saw it as the perfect opportunity to practice implementing a CPU in VHDL.

Learning VHDL - VGA

Next in line in the awesome tutorial series from Nandland was VGA. I didn’t have a VGA connector for my FPGA, but wondered if I could jury-rig something with what I had on hand.

The wiring diagram below from Grant Seale’s Multicomp gave me a very good idea on how to go about it.

In the Nandland tutorial (image below), three signals are used per channel instead of two so my setup reflects that.

I had five 1Kohm resistors on hand, enough to control one channel. I used two of them in parallel to get the 500 ohms (close enough to 549), two in series to get the 2K ohms, and one on its own for the 1K ohms. Jumper wires were used to connect to the pins (red, green, blue, hsync, vsync). Luckily, all the ground pins were in-line (and the random pin in-between was an unused pin) so I just tied the whole line to ground using one wire (instead of several jumper wires). Here is the final masterpiece:

IMG_20170124_121927

And the overall setup:

IMG_20170124_124112

Learning VHDL

I chose to use VHDL to program the FPGA because it is closer to a schematic representation than Verilog. Verilog seems (to me) like learning a new programming language whereas VHDL is more like describing the circuit.

For example, take the construction of a full adder. Here is a video of the structure generated by my code below:

An FPGA for the Computer

I’ll be using the Altera Cyclone II - Mini Development Board as the main FPGA of the Hack Computer V1 (name pending).

Cyclone II Mini Dev Board

I got it for $20 on eBay and the kit came with a (knockoff) USB Blaster for programming. The idea to use the board came from Charles Cole’s hardware setup of his homebrew Z-Machine. The price is great and I love that it only has the bare minimum components on it.

I worked through this excellent getting started guide by Trey Dahlberg on Youtube and everything seems to be running well.

Specs:

  • Altera Cyclone II EP2C5T144C8
  • 50MHz clock
  • Schematic

Update (January 18, 2017):

I recently came across the Multicomp project by Grant Searle. In it he uses this development board and consequentially has a ton of really helpful information on the board and some of the things it’s capable of. The project is described by Hackaday as a ‘pick and mix retrocomputer’ which allows you to use the FPGA as a Z80, 6502, 6800 or whatever CPU mashup you feel inspired to. His project also describes in detail interfacing with various devices including SRAM, SD cards, VGA, composite video, PS/2, USB - basically I found the holy grail! Check out the project page to learn more about the board, and maybe even build a mix and match computer of your own.

Note: if you use this development board, make sure to desolder the four zero ohm resistors as explained in Grant’s project page.