COMP 311: Lab 4

Pull the new starter code!

The starter code for each subsequent lab will be added directly into the same course repository. To update your individual repo, navigate to your workspace on the GitHub website and you should see a “Sync Fork” button. Click this and then “Update Branch.” Now if you run ``git pull’’ in your terminal, you will have all the materials you need.

OR

If you went through the additional git set-up steps for lab 1, you should be able to run

git pull starter main --rebase

Then all the new code for lab4 should be there!

Register File

In this lab, you will be designing the register file that we have been studying in class!

Alt text

The register file will contain 32 registers, each holding a 32-bit value.

The register file has five inputs: 1. Read Register 1 2. Read Register 2 3. Write Register 4. Write Data 5. RegWrite

And two outputs: 1. Read Data 1 2. Read Data 2

See the full specification of the register file in the lecture slides. Remember, register 0 always holds the value 0!

register-file.dig already contains the inputs and outputs. You may move these inputs and outputs, but do not rename them!

Component: Register

You can find the register component under Components -> Memory -> Register. Remember to set the Data Bits field to 32.

This video gives an overview of simulating a register.

Tips

Component: Decoder

You will need to use a circuit called a decoder in your implementation! You can find the decoder in Components -> Plexers -> Decoder

A decoder is a circuit that takes in an unsigned value and outputs the ‘one-hot’ representation of that value. Below you will find the truth table for a 2:4 decoder. A 2:4 (pronounced two to four) decoder has two input bits and four output bits.

Alt text

Below is a 2:4 decoder in Digital. Notice that the input is 0b00 which corresponds to the one-hot value 0b0001 We can see this one-hot value represented in the outputs (Y0 is high while the other outputs are low).

Alt text

In the next example, notice that the input is 0b10 which corresponds to the one-hot value 0b0100. We can see this one-hot value represented in the output (Y2 is high while the other outputs are low).

Alt text

I encourage you to play around with the decoder component in Digital before starting the lab.

In your register file implementation, you will need to use a larger decoder.

Register File Design

Before beginning your design in Digital, ask yourself these questions: 1. What component will you use to choose the register you are writing to? 2. What component will you use to choose the register you are reading from?

Testing your circuit.

Local register file tests are provided for you. They work just like the tests in the previous labs.

This video provides an overview of the tests.

Remember that register 0 should always hold the value 0.


Submission Instructions

Assignments are submitted through Gradescope.

  1. Commit and push your changes to your Lab 4 GitHub repo.
  2. Go to the COMP 311 course in Gradescope and click on the assignment called Lab 4.
  3. Click on the option to Submit Assignment and choose GitHub as the submission method. You may be prompted to sign in to your GitHub account to grant access to Gradescope. When this occurs, grant access to the Comp311 organization.
  4. You should see a list of your repositories. Select your 311 workspace.
  5. Your assignment should be autograded within a few seconds and you will receive feedback.
  6. If you receive all the points, then you have completed this lab assignment! Otherwise, you are free to keep pushing commits to your GitHub repository and submit for regrading up until the deadline of the lab.