Reading Assignment, Reference Material, and Resources
- Sections 1-6 of Appendix C of the textbook, continued.
- TREE_Lab
- Using Quartus
- DE1 I/O Pins
- Using Seven-Segment Displays
- hex2sevenseg.v
Assignment To Hand In
The assignment is to build and test a 3-bit Arithmetic Logic Unit based on the 32-bit MIPS ALU developed in Appendix C of the textbook. Unlike the paper-and-pencil design used in the textbook, or a software simulation, you are to build a real ALU and implement it in hardware using the logic kits available for use on the course laboratory computers.
Do this assignment as an ordered set of steps as described below. Do not proceed to a new step until the previous step is completed and tested.
-
Set up a Quartus project for the assignment.
See the TREE_Lab web page for information on making sure your laboratory account is set up and working correctly. Then read the Using Quartus web page to see how to set up a project. Put the assignment in a directory named Assignment_03 under your My Projects directory. Name the project “Three-bit_ALU,” and call the top level design “Three-bit_ALU_Testbed." Follow the directions on the Using Quartus web page for setting the FPGA device type.
Be sure you can log out of one computer, log back into another computer, and reopen your project on the second computer.
-
Implement the full adder module.
Implement the full adder module as shown in the Using Quartus web page. Temporarilty set up your “Three-bit_ALU_Testbed” module as testbed for just the full adder using, three any slide switches for inputs and any two LEDs for the outputs. Make sure the full adder works correctly.
If you have already completed this part of the assignment using a different name for the testbed module, that’s all right. You don’t have to rename it.
-
Build the real testbed for the assignment.
Delete all the pins, node lines, and the full-adder symbol from your testbed, and add the following items back into it:
-
Ten input pins for the ten slide switches named “Switch_0,” “Switch_1,” etc. Alternatively, you may use
one pin and name it “Switch[9..0].” Ten separate pins is more work to set up, but can make it easier to
make connections. Using the bus notation is very easy to set up, but you have to be careful making the
connections. I’ll use the bus notation here because it’s faster for me and because you will see what’s
involved in using it.
While writing up the assignment, I finally learned how to use bus notation for inputs and outputs. It’s a little weird because it relies on using the “disconnected wires” technique I mentioned in class on February 24. At least, it looks weird to me to have wires in a schematic that are not connected to anything. I updated the Bus Wiring section of the Using Quartus web page to explain it.
- Ten output pins for the red LEDs. Again, this can be either ten separate pins or one pin set up using bus notation. Connect the ten switches to the corresponding red LEDs.
- Eight output pins of the green LEDs.
- Four sets of seven output pins for the four seven-segment displays.
If you use bus notation, your testbed will now look like this:
-
Ten input pins for the ten slide switches named “Switch_0,” “Switch_1,” etc. Alternatively, you may use
one pin and name it “Switch[9..0].” Ten separate pins is more work to set up, but can make it easier to
make connections. Using the bus notation is very easy to set up, but you have to be careful making the
connections. I’ll use the bus notation here because it’s faster for me and because you will see what’s
involved in using it.
-
Create a symbol for the full ALU and connect it to the testbed.
The Using Quartus web page shows how to do this.
-
Set up seven segment displays to show the values of the the A and B inputs to, and the condition code and result outputs from, the ALU.
Also, use green LEDs 7..4 to display the four condition code bits, and green LEDs 3..0 to display the four result bits.
Again, the Using Quartus web page shows how to do this. There is a web page on Using Seven-Segment Displays that includes a link to a Verilog program that you will need to add to your project.
To add a file to your project, downlod the file into your project directory. In this case, you should end up with a file named hex2sevenseg.v in your Assignment_03 directory.
Then open the Quartus
menu and select the “Add/Remove Files in Project...” option. That will bring up a panel where you can browse to the file you want to add to the project.For this course, never add files that are not inside the project directory to a project. When I grade your assignment, I will be making a copy of just the project directory and will not have access to any files from outside that directory. The project could work fine for you, but I won’t be able to test it.
-
Set up the Three-Bit ALU Module, and add it to the testbed.
The ALU will have three input busses: A[2..0], B[2..0], and f[3..0]. There will be two output busses: Result[2..0] and the condition code bits, CVNZ[3..0]. All you have to do is to add the pins for these inputs and outputs to a new schematic diagram, and you will be able to save the module as a symbol, which you can then add to the testbed module.
At this point, you can complete the wiring of the testbed and run the Analysis and Synthesis tool (Ctrl-K), which will then allow you to do all the pin assignments for the project. (10 inputs plus 46 outputs!)
-
Create the module for one slice of the ALU.
Add another schematic to the project for an ALU slice. There will be seven input pins: A, B, Cin, Ainv, Bneg, f_1, and f_0. There will be just two output pins: Result and Cout.
Implement the ALU slice as described in the textbook and as outlined in class on February 24. Save the slice as a symbol.
-
Complete the ALU
Add three instances of the ALU slice to the ALU module, and connect them to implement the full 16-function 3-bit MIPS ALU.
-
Build and Test
Unfortunately, you have to complete all the modules for the whole assignment before you can start testing. Build the project using the Build tool (Ctrl-L) and make sure the only warnings are ones that make sense: just one output should be stuck at ground; no output capacitance values were specified; there is no clock for the project.
Use the Programmer tool to download the circuit to a DE-1, and start testing. This is actually the most difficult part. You have to set the input switches to various values that will test the various functions that the ALU can perform on various combinations of input values, checking that both the result and the condition code bits are correct. We will discuss the testing procedure in class some.
-
Submit the Assignment
Once you have the project working, simply send me email with “CS-343 Assignment 3” as the subject line and with your name in the message body. That will signal me that I can copy your project directory from the lab to my computer for testing.
I will make a copy of your project directory, but will re-build the project on my computer to make sure there are no extraneous warnings, and then I will download the copy of the circuit to that I build into a DE-1 for testing.