CS223 Laboratory Assignment 2 Full Adder, 2-Bit Adder, Lab Calculator On FPGA
CS223 Laboratory Assignment 2 Full Adder, 2-Bit Adder, Lab Calculator On FPGA
Location: EA Z04 (in the EA building, straight ahead past the elevators)
Groups: Each student will do the lab individually. Group size = 1
2
(d) Simulation: Implement the lab calculator module using a half adder, a half subtractor, an
AND gate, and a Nor gate in structural style (preliminary part-h). Then, using the
SystemVerilog testbench code you wrote, verify in simulation that your circuit works
correctly.
(e) When you are convinced that your codes work correctly, show the simulation results to your
TA. Be prepared to answer questions that you may be asked.
(f) Program the FPGA: Now, follow the Xilinx Vivado design flow to synthesize, implement,
generate a bitstream file, and program 2-bit adder and lab calculator to Basys 3 FPGA
board.
(g) Test your design: Using the switches and LEDs (on Basys 3) that you have assigned in the
constraint file (.xdc), test your designs. When you are convinced that they work correctly,
show the physical implementation results to the TA. Be prepared to answer questions that
you may be asked.
Lab calculator
For this part the module given in Figure 3 will be implemented such that for a given C and D,
outputs Y and Z will be a certain functions of A and B. When C=0 and D=0, the lab calculator acts
as an AND gate, therefore, Y = AB, Z = d (don’t care). When, C=0 and D=1, the first lab calculator
acts as a NOR gate, so Y = (𝐴 + 𝐵), Z = d. When C=1 and D=0, the first lab calculator acts as a
half-adder, Y = sum, Z = Carry out. When C=1 and D=1 the first lab calculator acts as a
half-subtractor, Y = Difference, Z = Borrow out. The function codes are summarized in the table
below.
C D module Y Z
0 0 AND A.B d
0 1 NOR (𝐴 + 𝐵) d
1 0 Half Adder Sum Carry Out
1 1 Half Subtractor Difference Borrow out
Figure 3: Lab calculator
3
C D A B Y Z
0 0 0 0 0 d
0 0 0 1 0 d
0 0 1 0 0 d
0 0 1 1 1 d
0 1 0 0 1 d
0 1 0 1 0 d
0 1 1 0 0 d
0 1 1 1 0 d
1 0 0 0 0 0
1 0 0 1 1 0
1 0 1 0 1 0
1 0 1 1 0 1
1 1 0 0 0 0
1 1 0 1 1 1
1 1 1 0 1 0
1 1 1 1 0 0
Figure 4: Truth table of the lab calculator
Clean Up
(1) Clean up your lab station, and return all the parts, wires, the Beti trainer board, etc. Leave your
lab workstation for others the way you would like to find it.
(2) CONGRATULATIONS! You are finished with Lab#2 and are one step closer to becoming a
computer engineer.
NOTES
--Advance work on this lab, and all labs, is strongly suggested.
--Be sure to read and follow the Policies for CS223 labs, posted in Moodle.
LAB POLICIES
1. There are three computers in each row in the lab. Don’t use middle computers, unless you are
allowed by lab coordinator.
2. You borrow a lab-board containing the development board, connectors, etc. in the beginning.
The lab coordinator takes your signature. When you are done, return it to his/her, otherwise you
will be responsible and lose points.
3. Each lab-board has a number. You must always use the same board throughout the semester.
4. You must be in the lab, working on the lab, from the time lab starts until you finish and leave.
(bathroom and snack breaks are the exception to this rule). Absence from the lab, at any time, is
counted as absence from the whole lab that day.
5. No cell phone usage during lab. Tell friends not to call during the lab hours--you are busy
learning how digital circuits work !
6. Internet usage is permitted only to lab-related technical sites. No Facebook, Twitter, email,
news, video games, etc--you are busy learning how digital circuits work !
4
7. You need to be in lab on time and turn in your preliminary report at the start of the lab.