Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
Episodes Upgraded. Nov 10, 2019
OpcodesImplemented.txt
README.md Added short description of Ethernet part of the computer. Oct 26, 2018
statistics.txt

README.md

Design Your Own Computer

Welcome to this series where you will learn how to Design Your Own Computer on an FPGA!

Overview of series

In the first few episodes we'll be focussing on the VGA output, essentially building a (small) GPU. The reason is that this will give us excellent possibilities later on to view the internal state of the CPU.

Later we'll design and implement the 6502 processor. This is the same processor that was used in e.g. the Commodore 64 computer from the 1980's. There is an abundance of information on this processor on the Internet. In later episodes I'll provide more links.

In the end I would like to build a web server that can run on this computer.

Of course, the ultimate goal is to have fun building stuff!

Overall design

The computer we're building will be running on an FPGA board, and inside the FPGA there will be:

  • VGA interface (GPU)
  • Memory (RAM and ROM)
  • 6502 CPU
  • Keyboard interface
  • Ethernet interface

We will be designing and building these blocks roughly in the above order.

List of episodes:

VGA

  1. "Hello World". Here you will generate a checkerboard pattern on the VGA output.
  2. "Binary Digits". Here you will learn how to display a string of binary digits on VGA.

Memory

  1. "Adding memory to the system". Here we will add memory to the system, and display accesses on VGA.
  2. "Adding hexadecimal output to VGA". Here we will implement a complete font and show data in hexadecimal format.

CPU

  1. "Datapath". Here the skeleton of the CPU datapath will be developed. Instructions implemented: 1/151.
  2. "Load and Store". We will add instructions that load and store in memory. Instructions implemented: 4/151.
  3. "Control logic". The control logic will be greatly expanded. Instructions implemented: 4/151.
  4. "ALU". Here the Arithmetic and Logic Unit will be added to the CPU. Instructions implemented: 16/151.
  5. "Branching". We add conditional jumps to allow brancing. Instructions implemented: 31/151.
  6. "Assembler". Now we use an assembler to compile programs with. Instructions implemented: 31/151.
  7. "Zero Page". We build on the datapath to support the zero-page addressing mode. Instructions implemented: 39/151.
  8. "Stack Pointer". We add the stack pointer and can now support subroutine calls. Instructions implemented: 45/151.
  9. "More ALU". We expand the ALU and add several more instructions. Instructions implemented: 64/151.
  10. "Registers X and Y". We add the two remaining registers 'X' and 'Y'. Instructions implemented: 90/151.
  11. "Indexed addressing". We implement the indexed addressing modes. Instructions implemented: 132/151.
  12. "Indirect addressing". We finish (almost) the CPU by adding support for indirect addressing modes. Instructions implemented: 148/151.
  13. "Software Interrupts". We add the remaining three instructions. Instructions implemented: 151/151.
  14. "Hardware Interrupts". We finish the CPU by adding support for hardware interrupts.
  15. "C Runtime". We modify the toolchain to allow CPU to run C programs.

VGA part 2

  1. "Text display". We expand on the VGA module by adding a screen memory to contain the text to be displayed.
  2. "Reading from Display memory". We make it possible for the CPU to read from the character and colour memories.
  3. "Memory Mapped I/O". Now we allow the CPU to control e.g. background colour.

Keyboard

  1. "Interrupt Controller". Here we build an interrupt controller.
  2. "Keyboard". We are now ready to add the keyboard interface.
  3. "Sample Programs". We now demonstrate some sample programs for our new computer.

Ethernet

  1. "Ethernet PHY". Here we start communicating with the Ethernet PHY.
  2. "Rx DMA". Now we can receive Ethernet frames.
  3. "Tx DMA". Now we can send Ethernet frames.
  4. "Protocol Stack". Now we can reply to ping!

More to come soon...

Prerequisites

FPGA board

To get started you need an FPGA board. There are many possibilities, e.g.

  • Nexys 4 DDR (from Digilent). This is the one I am using (but somewhat of an overkill for this project).
  • Basys 3 (from Digilent). Less expensive.
  • Go board (from Nandland). Even less expensive.

Make sure that the FPGA board you buy has (at least) the following features:

  • VGA connector
  • USB input connector (for keyboard)
  • Crystal oscillator
  • Ethernet PHY (optional)

FPGA toolchain (software)

You need a tool chain for programming the FPGA. There are three major FPGA vendors:

  • Xilinx
  • Intel (formerly Altera)
  • Lattice

The Nexys 4 DDR board uses a Xilinx FPGA, and the toolchain is called Vivado. Use the Webpack edition, because it is free to use.

Recommended additional information

I recommend watching the video series Building an 8-bit breadboard computer! by Ben Eater. He goes into great depth explaining the concepts and elements in a computer. The design we're building will be somewhat more elaborate and have more features. This is largely due to the many possibilities of using FPGAs.

I also recommend watching (at least the first half of) the video series Computation Structures from MIT. These are university lectures explaining very clearly the concepts involved in digital design.

I will in this series assume you are at least a little familiar with logic gates and digital electronics.

I will also assume you are comfortable in at least one other programming language, e.g. C, C++, Java, or similar.

About me

I'm currently working as a professional FPGA developer, but have previously been teaching the subjects mathematics, physics, and programming in High School. Before that I've worked for twelve years as a software developer.

As a child I used to program in assembler on the Commodore 64. This "heritage" is reflected in some of the design choices for the present project, e.g. choosing the 6502 processor.

You can’t perform that action at this time.