Assignment 5

Due Date: 2015-2-24, 11:59pm

Objective

This assignment has two parts. First you must complete HDL implementations for the following 3 gates so that the tests are successful. This will wrap up the HDL portion of the class, and give you the full computer which we'll be using in the rest of the class.
  1. Memory
  2. CPU
  3. Computer - Note for Computer there are three separate tests.
    • ComputerAdd - Adds 2 and 3, writes result to RAM[0]
    • ComputerMax - Computes maximum of RAM[0] and RAM1[], writes result to RAM[2]
    • ComputerRect - Draws a rectangle 16 pixels by x pixels, where x is in RAM[0].

Second, write a program that will convert .asm assembly code to .hack machine code in the same way the built-in assembler does. There are two sets of programs to test your assembler with.

  • Symbol-less Programs (in increasing complexity)
    1. Add.asm
    2. MaxL.asm
    3. RectL.asm
    4. PongL.asm
  • Programs with Symbols
    1. Max.asm
    2. Rect.asm
    3. Pong.asm

You should write a version of the assembler that handles programs with no symbols first, and once that is working correctly, then proceed to resolving symbols.

This is the first assignment that requires you to write your own code. Please see the Writing Code page for more information. Stubs for Java and Python are provided in your repos. Your code will be run with one of the following commands:

  • Java - java Assembler Something.asm
  • Python - python assembler.py Something.asm
  • C/C++ - ./assembler Something.asm

Tips and Resources

  • For Memory, use the chips RAM16K, Screen and Keyboard. For CPU use any of the previously made chips, but instead of Register, use ARegister and DRegister. For the Computer, use the ROM32K for your instruction memory.
  • For the invalid parts of memory, it is up to you what value you return if that memory address is requested. If you happen to return the value of the keyboard for all invalid addresses, that is valid.
  • Chapter 5 and Chapter 6. Note that these are the last chapters which are available for free. If you have been finding the book useful, you should consider buying it!
  • Your assembler output must match the built-in assembler's output. You can test this by loading your .hack file into the built-in assembler (using the equals icon in the toolbar, or going to File-->Load Comparison File) and then running the built-in assembler. This allows you to see exactly what lines are different.
  • To make parsing easier, the test examples use minimal white space, i.e. D+A instead of D + A. You may assume that the input to your parser will be the same (as it is in the test files).
  • In case it's useful to you, here's a table of comp mnemonics in text form.
    00101010
    10111111
    -10111010
    D0001100
    A0110000
    !D0001101
    !A0110001
    -D0001111
    -A0110011
    D+10011111
    A+10110111
    D-10001110
    A-10110010
    D+A0000010
    A+D0000010
    D-A0010011
    A-D0000111
    D&A0000000
    A&D0000000
    D|A0010101
    A|D0010101
    M1110000
    !M1110001
    -M1110011
    M+11110111
    M-11110010
    D+M1000010
    M+D1000010
    D-M1010011
    M-D1000111
    D&M1000000
    M&D1000000
    D|M1010101
    M|D1010101