Description
Building a Multiplier Circuit and a Simple Calculator
The purpose of this lab is to build a binary multiplier circuit, verify its functionality using a testbench, then combine it with an adder/subtractor circuit to create a basic calculator.
Part 1 (Building a multiplier circuit)
Two binary numbers can be multiplied in the same method used to multiply two decimal numbers. The figure below shows an example of multiplying 14×11=154. In this part, we focus on building an unsigned number multiplier, because signed number multiplication is more complex.
A binary multiplier can be implemented using several stages of full-adder (FA) blocks connected in a ripple-carry configuration. However, the delay caused by the carry signal rippling through the different FA blocks and the different stages can cause a significant impact on the time needed to generate a correct product result. The carry-save array configuration, is a binary multiplier that reduces the delay effect and produces correct results faster. The diagram below shows a 4-bit multiplier circuit arranged in a carry-save array configuration.
In this part, you will build the carry-save array multiplier circuit shown in the figure above, then you will write a test bench to verify the functionality of your implmentation. In all your steps in this part, assume the numbers used are 4-bit unsigned integers.
The following steps should guide you through the implementation:
- Verify the functionality of the circuit by tracing the multiplications 14×11 and 9×5 direclty on the digram. In other words, (with a pencil and paper) trace the patterns of 1’s and 0’s propagating through the different circuit elements, and verify they produce the correct results
- To reduce clutter and make your code easier to read, debug, and modify, you will use hierarchical design.
- miqj can be simply implemented using a 2-input and Write a verilog module (call it mq_4bit) that takes a 4-bit signal m, 1-bit signal q, and generates a 4-bit signal mq. Specifically, the module’s output should be anding the different bits of m with the signle bit of q. You might find the concatenation operator useful in this step
- Import all files included with this guide. Open v and make sure you understand how to use it.
- Write a verilog module (call it csa_multiplier) to describe the circuit shown in the figure above. You should utilize the full_adder and mq_4bit modules and instantiate as many of them as necessary
- Verify the functionality of csa_multiplier by writing a testbench
(csa_multiplier_tb). You should use the following test vectors (0x10, 5×5, 9×5, 12×13, 15×10) to verify the multiplier is working correctly. You can add more test vectors if you want.
- Include a screenshot of the simulation output with your submission, you might want to figure out how to embed it in your README.md file
Part 2 (Building a simple calculator)
In this part, you will combine the csa_multiplier and adder_subtractor (provided with this guide) to build a simple calculator. The calculator should perform 4-bit addition, subtraction, and multiplication. You will also verify the functionality of your calculator by implementing it on the FPGA board.
- Write Verilog code to describe an 8-bit 2×1 multiplexer. This MUX will be used to control what is displayed at the output of the calculator
- Write a Verilog module (simple_calc)
- The module should accept two 4-bit inputs X, Y
- The module should accept a 2-bit operator select input (op_sel).
- op_sel = 00 (add)
- op_sel = 01 (subtract)
- op_sel = 1x (multiply)
- The module should output an 8-bit signal (result)
- Draw a block diagram of the calculator. Show the different circuit elements and how they are connect. Specifically, your diagram should show a multiplier, adder/subtractor, and 8-bit 2×1 MUX circuit:
- Instantiate an instance of a 4-bit adder/subtractor and connect X, Y and the appropriate add_n signal to it
- Instantiate an instance of the 4-bit multiplier circuit you built in part 1. Connect X, Y to it iii. Instantiate an 8-bit 2×1 MUX you wrote in the step above. Connect the output of the multiplier to one input and the output of the adder/subtractor to the other input. You might also want to connect 4’b0 to the most significant bits of the input connected to the adder/subtractor.
- Verify the functionality of your simple calculator by implementing in on the FPGA board using the following IO specifications:
- SW3 ß SW0 for the input X
- SW7 ß SW4 for the input Y
- SW15 ß SW14 for the op_sel LED7 ß LED0 for the output result
- LED14 to display the carry_out of the adder/subtractor
- LED15 to display the overflow of the adder/subtractor



