Elements of Computing Systems
Introduction
I got started with this project after watching a couple videos that
described the course. You can find them linked from the courses main
webpage here. You can
also find a study plan that describes all of the projects
here.
Interesting Technical Information
Hardware
The hardware design is very simple/elegant (in my opinion). The processor
has only two instructions. The first instruction is used to load an immediate
value into the chips address register. The second instruction is sort of an
"uber" instruction that does everything else. The instruction has optional
destination registers for the result, various source registers, a calculation
of some kind, and optional branch flags depending on the result of the
calculation.
The calculations supported by the processor are very basic. You can do
very simple math (add/subtract) and some bitwise operations (AND, OR, NOT).
In fact all these math operations are implemented by setting "flags" on the
ALU based directly on the instructions encoding. There is no need to do any
sort of instruction decoding.
With just these two instructions it is possible to implement a complete
computer system. More advanced operations (like multiplication) are
implemented in software instead of in hardware like any modern processor.
Software
The course itself is often called Nand-to-Tetris because many people
choose to implement Tetris to run on their "Hack" computer system. I chose
to implement "Hacman" instead.
I actually had to write a somewhat optimized sprite routine just to draw
Hacman and the 4 ghosts on the screen. To draw each frame I erase the sprites
and redraw them in their new locations. Even with such simple rendering the
framerate on the simulator is quite slow.
I am considering writing an efficient emulator of the Hack
instruction set to see how fast I can emulate the chip.
|