Project 3: 24-Hour Time Audit & Boolean Arithmetic

Due Date: Friday, January 19, 2024 at 11:59pm

Learning Objectives

  • Collect real data about where your time goes and analyze it for takeaways that you would like to change.
  • Understand the ALU's function and organization in a computer.
  • Practice writing HDL code further on larger-scale chips.

Introduction

In this project, you will continue to engage metacognitively in your time-management as a student. The metacognitive part of this assignment consists of choosing a day to track how you spend your time and reflecting on the way you have spent your time that day.

The technical part of this project consists of implementing chips that support Boolean arithmetic that cumultate to building the Arithmetic Logic Unit (ALU).

Instructions

Navigate to the Project 3 assignment on Canvas. Download the document template titled Project 3.docx. Open the document, read the instructions on the first page, and estimate the amount of time you think it will take you to complete this project. Then, complete parts I, II, and III of the project.

Part I: 24-Hour Time Audit (10 points)

First, complete the 24-hour time audit activity. Pick a typical day in which you have a number of activities going on (e.g., classes, studying, work, etc.). For 24 hours, track all activities that you are engaging in intervals of thirty minutes. Be honest and be specific. If you are studying for Math 308 and browsing Instagram, note this. If you are spending time cooking breakfast and washing dishes, note this.

Complete this activity in the document that you downloaded above for Project 3. Once you have completed your 24-hour time audit, complete the reflection questions on page three of the document.

Part II: Boolean Arithmetic (15 points)

Background

The centerpiece of the computer's architecture is the CPU, or Central Processing Unit, and the centerpiece of the CPU is the ALU, or Arithmetic Logic Unit. In this project, you will gradually build a set of chips, culminating in the construction of the ALU chip of the computer we are building (called the "Hack" computer). The design of the ALU differs between all computers, but the rest of the chips you will build are standard and used in real computers today.

Pulling Project 3 Starter Code

To complete this assignment, you will need to use git to access the starter materials that have been pushed to your repository by the course staff. First, run git status and see if it reports any changes. If you have any, you'll need to commit them before proceeding (git add . followed by git commit -m "Your message here"). Then, run:

After running this command, you have synchronized the local copy of your repository with the copy on the server.

Overview

In this project, you will be building another set of chips. The only building blocks you can use are any chips you've already implemented (whether in Project 2 or in this project) and the "Additional Chips" listed in Project 3 that were not assigned for credit. As before, we highly recommend you implement in the order listed here.

Chip Name Description Test Script Expected Output
HalfAdder Adder with 2 inputs, sum & carry outputs HalfAdder.tst HalfAdder.cmp
FullAdder Adder with 3 inputs, sum & carry outputs FullAdder.tst FullAdder.cmp
Add16 16-bit Adder Add16.tst Add16.cmp
ALU Arithmetic Logic Unit (initial version, only needs to support the And function and doesn't need to handle status outputs) ALU-nostat-noadd.tst ALU-nostat-noadd.cmp
ALU Arithmetic Logic Unit (revised version, supports both And and Add but still no handling of status outputs) ALU-nostat.tst ALU-nostat.cmp
ALU Arithmetic Logic Unit (complete version) ALU.tst ALU.cmp

Contract

When loaded into the supplied Hardware Simulator, your chip design (modified .hdl program), tested on the supplied .tst script, should produce the outputs listed in the supplied .cmp file. If that is not the case, the simulator will let you know.

Resources

The relevant reading for this project is Chapter 2 and (again) Appendix A. Since you will be depending heavily on chips from Project 2, you may find this Chip Set Overview helpful to look up the chip signature (i.e., names of connections) for the chips you need. Like the previous project, you may also find this HDL Survival Guide written by Mark Armbrust helpful.

For each chip, we supply a skeletal .hdl file with a place holder for a missing implementation part. In addition, for each chip we supply a .tst script that instructs the hardware simulator how to test it, and a .cmp ("compare file") containing the correct output that this test should generate. Your job is to complete and test the supplied skeleton .hdl files. For the ALU, two additional .tst scripts are provided to test your intermediate implementations. The Hardware Simulator will allow you to load the intermediate scripts and the ALU chip to test them, even though they don't have the same name.

You will find the supplied Hardware Simulator and all the necessary project files in the tools/ directory and in the projects/p3/ directory of your repository, respectively.

Part II Tips

Using built-in chips: The HDL programs you write will include chip parts that you've built in Project 2. However, as long as you don't copy those .hdl files into the projects/p3/ directory, the Hardware Simulator will use the built-in versions instead. We strongly recommend using the built-in versions so you don't have to depend on a complete implementation of the previous project to complete this one (it will also speed up chip execution slightly).

Implementation order: While we recommend building the chips in the order above, the Hardware Simulator has built-in chips that can be used if you are stuck on one and want to move on. To use the built-in version, simply rename or relocate the file, so the Hardware Simulator doesn't find the .hdl at hand in the directory and try using it.

The Hack ALU produces two kinds of outputs: a "main" 16-bit output resulting from operating on the two 16-bit inputs, and two one-bit "status outputs" named 'zr' and 'ng'. We recommend building this functionality in three stages:

By using this approach, you can better detect problems as you add code to your implementation, attributing errors seen in each new test to the incremental code that you've added in that stage. This three-stage implementation plan was initially proposed by Mark Armbrust and iterated upon by the course staff.

Remember to peruse Chapter 2 of the online textbook before you start implementing chips. It breaks down each one's interface in depth, and often describes strategies for implementation.

When you test your code by running the Hardware Simulator, loading the corresponding .tst script and pressing Run, it may indicate a "comparison error." When this happens, we recommend going to your file explorer and searching for: (1) a corresponding .cmp file that shows the inputs being tested and expected outputs of your chip, and (2) a correspondingĀ .out file that shows the actual outputs of your chip when tested. Given that information, a good next step is tracing through your design with those inputs to see why it produced the value it did.

Additional Chips

The following additional chip (described in Chapter 2) can be used in future projects, but you are not required to implement it. Again, the goal is to give you a tool you can use to make future projects easier, but there is little to be gained by implementing this yourself.

Submitting Part II

To submit Part II, make sure you commit and push your changes, then tag them as project-3 and push that tag as well:

Lastly, verify that the tag and all your code is uploaded correctly by checking on https://gitlab.cs.washington.edu/ .

Part III: Project 3 Reflection (5 points)

In the document Project 3.docx, record how long the project took you in reality and write a short written reflection about your experience completing this project.

Submitting Your Work

Make sure you have submitted your completed .hdl files on GitLab by following the instructions in the heading above titled "Submitting Part II." Then, save your changes from the Project 3.docx document as a PDF and submit the document to the assignment titled "Project 3: 24-Hour Time Audit & Boolean Arithmetic" on Gradescope. Project 3 will be considered completed once you have followed these steps.