Project 15 (ecs05)

Feb 14, 2011

Objective

Build the Hack computer platform, culminating in the top-most Computer chip.

Resources

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.

Requirements

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.tst

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.  

Tools

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.

Recommended Steps

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.

cd src/project05
git add *
git commit -m "Adding project05 files. Hlehhcch!"
git push

Build the computer in the following order:

  1. Memory: Composed from three chips: 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.
  2. CPU: Can be composed according to the proposed implementation given in Figure 5.9, using the 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.
    In the course of implementing the CPU, it is allowed (but not necessarily recommended) to specify and build some internal chips of your own. This is up to you. If you choose to create new chips not mentioned in the book, be sure to document and test them carefully before you plug them into the architecture.
  3. Instruction Memory: Use the built-in ROM32K chip.
  4. Computer: The top-most Computer chip can be composed from the chips mentioned above, using Figure 5.10 as a blueprint.

Grading Criteria (400 pts)

I must be able to pull your repo at 5PM on Monday, February 21 and I should see your project05 files.

Your directory structure must match the description above.

Your chips must pass all tests to receive full credit.

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 "project done" is not acceptable.

Due by 5PM on Monday, February 21.

Recommended personal deadlines: