Lab 1: Intro to the Digital Tool

This lab introduces Digital - an educational tool for designing and simulating digital logic circuits.

Exercise 0: Digital Tutorial

Complete the built-in Digital tutorial. It should pop up the first time you open Digital. If the tutorial does not show up, go to Help > Documentation and follow the steps on pages 6-14. Alternatively, you can click View -> Start tutorial.

Tip: Component Tree View

To make it easier to access the components, you can enable the component tree view. To do this, click View -> Component Tree View.

To make the component tree view always visible at startup, click Edit -> Settings -> Component tree view is visible at startup.

Note for macOS users

If control-click does not work for you, try two-finger tap.

To right click on macOS, tap your laptop’s trackpad with two fingers. If this doesn’t work, search up Trackpad in your computer settings and set Secondary click to “Click or Tap with Two Fingers”.

Deliverables

There is nothing to submit for exercise 0.

Exercise 1: Tunnels

Tunnels are a feature that will both save you a lot of time debugging and make your circuits look much cleaner.

A tunnel allows you draw an “invisible wire” to bind two points together. Tunnels are grouped by case-sensitive labels. They are used to connect wires like so:

tunnel example

which effectively is:

tunnel example with wires

If a wiring connection is invalid, the wires will turn red as seen below.

tunnel example with invalid tunnels

The above circuit is equivalent to the circuit below.

tunnel example with invalid wiring

This circuit is invalid because two different inputs are trying to drive the same signal.

We strongly recommend you use tunnels when working in Digital because they make your circuits much cleaner (less wiring spaghetti), which means easier debugging.

Let’s look at an example of how helpful tunnels are in cleaning up a circuit schematic. You can find the schematic below in ex1-example.dig.

ex1 example with wires

The above schematic is hard to read and would be difficult to debug if there was an error. Below is the same circuit but making use of tunnels. You can see that it is much easier to read this circuit diagram. You can find the schematic below in ex1-example-tunnels.dig.

ex1 example with tunnels

Deliverable: ex1.dig

Now it’s time for you to try! Clean up the circuit schematic below by using tunnels. You can find this schematic in ex1.dig. Place your solution here.

Tip: To rotate a tunnel, select the tunnel and click the r key.

ex-1-starter

Testing

A test fixture is included for you to verify the functionality of your circuit. To run the test fixture, click Simulation -> Run Tests.

A new window should appear showing you the results. This test is verifying that X, Y, and Z are the correct values for each combination of A, B, and C. If you pass all test cases, all outputs will be highlighted in green as shown below.

Exercise 2: Splitters

Splitters allow you to take a multi-bit value and split it up into smaller parts, or (despite the name) combine multiple values that are one or more bits into a single value. Here, we split our 2-bit input into two 1-bit values:

splitter-example-1

You can see when our input is 0b10, only our MSB output lights up:

Here is another example where we have a 16-bit input. The input is then split into 2 bytes:

splitter-example-16bits

We don’t have to split the values evenly - it is possible to split an input into various group sizes - and you don’t have to use all the bits. Here is an example where we take a 10-bit input and split it into bits 0-2, 5-7, and 8.

splitter-example-16bits-2

Deliverable: ex2-0.dig

Build the above circuit yourself in the file ex2-0.dig.

Do not modify the names of the input or outputs!!! Doing so will cause the autograder to fail.

Step 1: Configure the splitter. You can find the splitter by clicking Components -> Wires -> Splitter / Merger. Right click (or double tap) the splitter to change the input and output splitting as seen in the following screenshot. If you would like to change the spacing between the outputs, you can do this by going to Advanced -> spreading -> and selecting the desired spacing.

splitter-setup

Step 2: Configure the inputs and outputs. The bit width of the inputs and outputs must be compatible with the splitter. To change the bit width, right click (or double tap) the input/output, and use the Data Bits field to set the bit width. For example, the input should be 10 bits.

If the bit widths of your input and outputs do not match their corresponding connections with the splitter, you will get an error when you try to simulate the design in the next step.

Step 3: Simulate your design. Click the play button in the top bar to start the simulation. To change the value of the input, right-click it and set the input field to the desired value. When you click Apply, you should see the outputs change. Notice that by default, the values are displayed in decimal. If you would like to change the base of the number being displayed, stop the simulation, right click the output, go to the Advanced tab, and under Number Format select the desired base.

Testing

A test fixture is included for you to verify the functionality of your circuit. To run the test fixture, click Simulation -> Run Tests.

A new window should appear showing you the results. If you pass all test cases, all outputs will be highlighted in green as shown below.

Notice, there are two test cases. In the first test case, IN = 0x1D5. The expected outputs are OUT0 = 0x5, OUT1 = 0x6, and OUT2 = 0x1. In the next test case, IN = 0x22A. The expected outputs are OUT0 = 2, OUT1 = 1, and OUT2 = 0.

Deliverable: ex2-1.dig

Using what you just learned about splitters, build a circuit that outputs true if a 10-bit value is negative and odd. All values are encoded in 2’s complement. Build your implementation in ex2-1.dig.

Do not modify the name of the input or output pin provided in the file!!! Doing so will cause the autograder to fail.

Testing

A test fixture is included for you to verify the functionality of your circuit. To run the test fixture, click Simulation -> Run Tests.

A new window should appear showing you the results. If you pass all test cases, all outputs will be highlighted in green. Even if everything works the first time, make sure you understand what the test is checking.

Exercise 3: 2-bit Comparison Circuit

In this exercise, you will build a circuit that will output 1 if A > B, and 0 if A <= B. A and B are both two-bit unsigned numbers. Additionally, define A1 and B1 as the msb of A and B respectively, and A0 and B0 as the lsb of A and B. Build your design in ex3.dig.

Deliverable: ex3.dig

Build your circuit in Digital. Ensure you use tunnels to simplify your diagram.

Do not modify the name of the input or output pin provided in the file!!! Doing so will cause the autograder to fail.

Tip: Changing the number of inputs.

To change the number of inputs to a gate, right click (or double-tap) the gate. Then select the desired number of inputs in the drop down.

Testing

A test fixture is included for you to verify the functionality of your circuit. To run the test fixture, click Simulation -> Run Tests.

A new window should appear showing you the results. If you pass all test cases, all outputs will be highlighted in green. Even if everything works the first time, make sure you understand what the test is checking.

Submission Instructions

Assignments are submitted through Gradescope.

  1. Commit and push your changes to your course workspace GitHub repo.
  2. Go to the COMP 311 course in Gradescope and click on the assignment called Lab 1.
  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. Select your 311 workspace repository and the main branch.
  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.