CPU Design
Context
This project was conducted by me and three friends in the context of our Digital System course. The goal was to design a simple CPU with logic gates in a somewhat high-level language, compile it in a netlist then program a netlist simulator and run the CPU with some programs.
Designing the CPU
When designing the CPU, a lot of decisions had to be made. Mainly, we had to settle on an instruction set and the size and quantity of registers.
From the design of the CPU results the definition of a machine/assembly language.
Simulation
To simulate a netlist, we wrote an OCaml program that parses the netlist and outputs some C code that does the simulation.
Running programs
The CPU runs which ever assembly program is written on its ROM. Now, writing programs in binary is tedious so we wrote a text assembly compiler and also a higher level language ‘Tong’. We wrote most programs in Tong and compiled them in binary with a compiler written in Java.
Pong example
For example we were able to make a pong program. The interface is a Java program that provides a screen and user inputs to the simulator.