$29
Background
In the previous projects we've built a computer's basic processing and storage devices (ALU and RAM, respectively). In the labs, we also gained firsthand exposure to building the TOY computer in the labs and HACK Computer in the lectures with their underlying components. In this project we will put our knowledge and skills to work in constructing our very own BITBOT computer by putting everything together, yielding the complete BITBOT Hardware Platform. The result will be a general-purpose computer that can run many general-purpose programs that you fancy.
Below we will describe the overall design objective, the chips needing to be implemented, and recommended testing. Then we will dive into the BITBOT computer specifications. Please read the specs and examine the schematics very carefully before creating your implementation plan.
As demonstrated in lecture and lab using the HACK and TOY computers as a teaching vehicle, we recommend using a similar approach to build out the complete set of schematics on paper before diving into the respective HDL implementations.
Objective
Complete the construction of the BITBOT CPU and computer platform memory component. These components will integrate in the top-most BITBOT Computer chip. The CPU and Data Memory are already instantiated (connected) in the Computer chip but you will be required to instantiate Instruction ROM to complete the Computer chip design. Once you have designed your CPU and Data Memory, and instantiated the Instruction ROM inside the Computer, you will be able to exercise the Computer chip.
2
Chips
|
|
Chip (HDL) |
|
Description |
|
Testing |
|
|
|
|
|
|
|||
|
|
Memory.hdl |
|
Entire Data Memory |
|
Test this chip using Memory.tst and Memory.cmp |
|
|
|
|
address space |
|
|
||
|
|
|
|
|
|
|
|
|
|
CPU.hdl |
|
The BITBOT CPU |
|
Test this chip using CPU.tst and CPU.cmp. |
|
|
|
|
|
|
|||
|
|
Computer.hdl |
|
The BITBOT |
|
Test this chip using the BITBOT machine language |
|
|
|
|
Computer |
|
programs noted below. |
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
|
|
Contract
The computer platform that you build should be capable of executing programs written in the BITBOT machine (assembly) language, specified below.
Testing
Testing the Data Memory and CPU chips: It's important to unit-test these chips before proceeding to build the overall BITBOT Computer chip. Starter test collateral is provided. You are advised to extend them to perform robust testing.
Testing the Computer chip: A natural way to test the Computer chip implementation is to have it execute some sample programs written in the BITBOT machine (assembly) language. In order to perform such a test, one can write a test script that (i) loads the Computer.hdl chip description into the supplied Hardware Simulator, (ii) loads a machine-level program from an external file containing the program instructions into the ROM chip-part of the loaded Computer.hdl chip, and then (iii) runs the clock for enough number of cycles to execute the loaded instructions. Three such programs are provided:
|
|
Program |
|
Comments |
|
|
|
Add.hack |
|
Adds two numbers at RAM[0] and RAM[1] and writes the result in RAM[2]. |
|
|
|
Mult.hack |
|
Computes the multiplication of RAM[0] and RAM[1] and writes the result in |
|
|
|
|
RAM[2]. |
|
|
|
|
|
|
|
|
|
|
Rect.hack |
|
Draws a rectangle of width 16 pixels and length RAM[1] at the top left of the |
|
|
|
|
screen. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The test collateral for these exercises is also included that you may use as is to test your Computer implementation. Unlike the CPU and Memory chips where we have only provided the starter collateral to be extended by you for comprehensive testing, the testing of the Computer chip will be done with the test collateral as is (i.e. you do not need to extend the Computer-level test collateral).
Finally, a nifty test collateral is provided for you to test your KEYBOARD USE (Keyboard.hack, Keyboard.tst, and Keyboard.cmp). You also do not need to modify this and may use as is.
3
BITBOT Computer Design Specifications
[A] BITBOT Computer Instructions
The BITBOT computer supports FIVE types of instructions as follows:
Format:
ADD Rx, Ry, Rz //Rx = Ry+Rz, where Rx, Ry, Rz are registers SUB Rx, Ry, Rz // Rx = Ry-Rz, where Rx, Ry, Rz are registers
ADDI Rx, Ry, Constant //Rx = Ry+Constant, where Rx, Ry are registers and Constant is a 6-bit positive number between 0 and 63
SUBI Rx, Ry, Constant ////Rx = Ry-Constant, where Rx, Ry are registers and Constant is a 6-bit positive number between 0 and 63
4
Examples:
READ R0, R1 - Operation is R0 = MEM[R1]
WRITE R4, R5 - Operation is MEM[R4] = R5
Format:
BEQ Rx, Ry //Conditional: Fetch Next Instruction from ROM[Rx] if (Ry == 0)
JMP Rx //Unconditional: Fetch Next Instruction from ROM[Rx] Examples:
BEQ R0, R5 //Fetch Next Instruction from ROM[R0] if (R5 == 0) JMP R7 //Fetch Next Instruction from ROM[R7]
OUT Rx, Ry //MEM[Rx] = Ry
//Assume: Rx contents are within SCREEN Memory range INP Rx // Rx = MEM[hardwired address for Keyboard]
//Assume: Only one location for Keyboard Input will be tested
Examples:
OUT R0, R5 //MEM[R0] = R5, //R0 content is within SCREEN Memory range INP R0 // R0 = contents of Memory address dedicated to Keyboard m
[B] BITBOT Computer Instruction Encodings
Our BITBOT computer uses a Register Indirect Mode of Addressing. Unlike the HACK Computer where only the A-Register could be used to address data memory, we have a larger number of choices here. There is also no distinction made as to which register may be used to hold data versus address.
The 16-bit Instruction In[15:0] is designed to be interpreted as follows (examples are also provided along with bit encodings):
KEYBOARD)
5
CONDITIONAL BRANCH).
Examples (Note: Spaces in bit encoding are there for readability only, and X represents don’t care or unused bit)
Arithmetic
6
Logical
XXX
XXX
Memory
Branch
I/O
BITBOT INSTRUCTION ENCODING CHART
7
Arithmetic and Logical Instructions.
[D] INTERFACES
a. Input Pins:
8
9
[E] BITBOT CPU High Level Schematic
10
Implementation Tips
Complete the computer's construction in the following order:
(Data) Memory: This chip includes three chip-parts: RAM32K, Screen, and Keyboard. All of these chips are provided as built-in chips, so there is no need to implement them. All you need to do is to implement the top-level Data Memory by instantiating and connecting these three parts together.
CPU: This chip can be constructed according to the proposed CPU schematic and aligned with the definition of BITBOT Instructions. Note that the custom ALU chip is provided to you as a collateral.
Important Advisory: Please move the files RAM32K.class and RAM32K.hdl into tools/builtInChips inside nand2Tetris folder. After that you will be able to use RAM32K for your Memory.hdl. Also use the hardware simulator instead of VScode to test this. VScode has given error in the past. So you may decide to just stick to the hardware simulator if you encounter unexplained error.
If you choose to create any custom new chips, be sure to document and unit-test them carefully before you plug them into the architecture. And then please include them in your turn-in otherwise your design will fail during our testing.
Instruction memory: Use the built-in ROM32K chip.
Computer: The top-most Computer chip can be constructed according to the proposed implementation.
Tools
All the chips mentioned in this project, including the topmost Computer chip, can be implemented and tested using the supplied Hardware Simulator. For example, the Rect program draws a rectangle of width 16 pixels and length RAM[0] at the top-left of the screen. Now here is an interesting observation: normally, when you run a program on some computer, and you don't get the desired result, you conclude that the program is buggy. In our case though, the supplied Rect program is bug-free. Thus, if running this program yields unexpected results, it means that the computer platform on which it runs (Computer.hdl and/or some of its lower-level chip parts) is buggy. If that is the case, you have to debug your chips.
Reference Resources
The relevant readings for this project are Chapter 5, Appendix A, and Appendix B (as a reference, and use TAMU mail id to access). Be sure to participate in the labs to build the HACK computer. The principles you will learn in these labs will prepare you to succeed in building your own BITBOT computer! The resources that you need for this project are the supplied Hardware Simulator and the files provided in Project 5 collateral.
Rubrics
CPU: 60 points
Memory: 30 points
Computer: 10 points