Build the Hack computer platform, culminating in the top-most Computer chip.
The only tools needed for this project are the supplied hardware simulator and the test scripts described below. The computer platform should be implemented in the HDL language specified in appendix A.
The computer platform that you build should be capable of executing programs written in the Hack machine language, specified in Chapter 4. Demonstrate this capability by having your Computer
chip run the three test programs given below.
In addition, test scripts and compare files for unit-testing the Memory
and CPU
chips in isolation are supplied. It's important to complete the testing of these chips before building the overall Computer
chip.
Chip (HDL) |
Function |
Test script |
Compare file |
Memory.hdl | Entire RAM address space | Memory.cmp | |
CPU.hdl | The Hack CPU | CPU.tst (recommended - requires the usage of the built-in DRegister) | CPU.cmp |
CPU-external.tst (less thorough but does not require the usage of the built-in DRegister) | CPU-external.cmp | ||
Computer.hdl | The platform's top-most chip | See below | See below |
A natural way to test the overall Computer chip implementation is to have it execute some sample programs written in the Hack language. In order to run such a test, one can write a test script that loads the Computer chip into the hardware simulator, loads a program from an external text file into its ROM chip, and then runs the clock enough cycles to execute the program. Three such tests, included in the project05.zip, are as follows:
Add.hack:
Adds
the two constants 2 and 3 and writes the result in RAM[0].
Recommended test script (requires the usage of the built-in ARegister, DRegister, PC and RAM16K): ComputerAdd.tst
and ComputerAdd.cmp.
Alternative test script (less thorough but only requires the usage of the built-in RAM16K): ComputerAdd-external.tst
and ComputerAdd-external.cmp.
Max.hack:
Computes
the maximum of RAM[0]
and RAM[1]
and writes the result in RAM[2].
Recommended test script: (requires the usage of the built-in ARegister, DRegister, PC and RAM16K): ComputerMax.tst
and ComputerMax.cmp.
Alternative test script: (less thorough but only requires the usage of the built-in RAM16K): ComputerMax-external.tst
and ComputerMax-external.cmp.
Rect.hack:
Draws
a rectangle of width 16 pixels and length RAM[0]
at the top left of the screen.
Recommended test script (requires the usage of the built-in ARegister, DRegister, PC and RAM16K): ComputerRect.tst
and ComputerRect.cmp.
Alternative test scripts (less thorough but does not require the usage of any built-in chips): ComputerRect-external.tst
and ComputerRect-external.cmp.
The Hardware Simulator: As in Projects 1-3, all the chips in this project (including the topmost Computer chip) can be implemented and tested using the hardware simulator supplied with the book. Here is a screen shot of testing the Rect.hack
program on a Computer
chip implementation.
The Rect program draws a rectangle of width 16 pixels and length RAM[0] at the top left of the screen. Note that the supplied Rect program is correct. Thus, if it does not work properly, it means that the computer platform on which it runs (your Computer.hdl
and/or some of its lower-level parts) has a bug.
First, read ECS chapter 5. You may find these additional slides and this CPU Emulator Tutorial helpful.
Fresh from professor evil: CPU Reference Sheet
Within your src
directory, create a subdir named project05
. Extract the contents of project05.zip into it.
Add, commit and push the new files.
Build the computer in the following order:
RAM16K
, Screen
, and Keyboard
. The Screen
and the Keyboard
are available as built-in chips and there is no need to build them. Although the RAM16K
chip was built in Project 3, use its built-in version, as it provides a debugging-friendly GUI.ALU
and register chips built in Chapters 2 and 3, respectively. Use the built-in versions of these chips, in particular ARegister
and DRegister
. These chips have exactly the same functionality of the Register
chip specified in Chapter 3, plus GUI side effects.ROM32K
chip.Computer
chip can be composed from the chips mentioned above, using Figure 5.10 as a blueprint.I must be able to pull your repo at 5PM on Monday, February 22 and I should see your project04
files.
Your repository must show a history of work. You should be committing every time you complete a chip. A repository log showing one commit with a message like "project04 done" is not acceptable.
Recommended personal deadlines: