Balance eight partial products in an adder tree
Online version: https://fpga.labsland.com/altera/digital-logic/lab-06/part-05/
A balanced tree adds eight partial products in three levels. Its input and output registers have the same behavior as the serial adder chain. You will test whether every row reaches the output and distinguish the number of adder levels from the number of clock edges.
Lab setup
LabsLand Online Editor · DE1-SoC
Physical DE1-SoCCyclone V · 5CSEMA5F31C6 · camera, switches and buttons in the browser
Run the simulation on your computer with Icarus Verilog (Verilog or SystemVerilog) or NVC (VHDL). Then build your design and test it on the remote DE1-SoC.
Build
- From the extracted worksheet folder, open
starter/tree_product.qpfin the selected release of Quartus Prime Lite with Cyclone V support. The project-only download has the QPF at its root. - Edit the HDL file for
tree_product. If the exercise generates a new HDL file, copy its contents into that same project file. - Choose Processing → Start Compilation. Check the Fitter report for device 5CSEMA5F31C6.
- In the LabsLand bitstream upload lab, choose Standard and upload
output_files/tree_product.sof. Wait for programming confirmation before using the controls. - If your course uses a LabsLand classroom, the upload opens a firmware library instead: check that your SOF is selected and choose Enter board with selected firmware.
Draw the four first-level pairs, two second-level sums and final addition. Label which multiplier bits contribute to each half of the final result. Locate the starter expression that uses one of those halves twice. Write your correction without using a multiplication operator in the circuit. SW9 enables register A, SW8 enables register B, and SW7–0 supply the byte. LED7–0 read back A when SW9 is high, otherwise B when SW8 is high. With neither enabled they are dark.
- Get the starterDownload
tree_product.v - Open the LabsLand Online EditorOpen the lab Choose DE1-SoC · Verilog when you open the lab. LabsLand asks you to sign in. Use the access your course or institution provides.
- Follow the worksheetPredict first, then build, read the board and hand in. The build steps are below.
- Install Quartus Prime Lite with Cyclone V supportSkip this if it is already installed.
- Download the activityDownload worksheet and Quartus project Includes the worksheet, the Quartus project and the simulation files.
- Complete the design and compileComplete the design as Build in the worksheet below describes. Open
tree_product.qpfand choose Processing → Start Compilation. Quartus writesoutput_files/tree_product.sof. - Upload the bitstream to LabsLandUpload bitstream LabsLand asks you to sign in. Use the access your course or institution provides.
Already compiled? Upload your .sof directly
Starter files · Verilog · VHDL · SystemVerilog
Worksheet and starter (.zip) for offline work or printing
Build
- In the LabsLand Online Editor, choose DE1-SoC for your HDL and the Standard interface.
- Create
tree_product, paste the design and set it as the top level. - Choose Synthesize → Upload to FPGA. After editing the design, synthesize and upload it again to test the change on the board.
Draw the four first-level pairs, two second-level sums and final addition. Label which multiplier bits contribute to each half of the final result. Locate the starter expression that uses one of those halves twice. Write your correction without using a multiplication operator in the circuit. SW9 enables register A, SW8 enables register B, and SW7–0 supply the byte. LED7–0 read back A when SW9 is high, otherwise B when SW8 is high. With neither enabled they are dark.
Simulate
Extract the worksheet ZIP and run these commands from the folder containing activity.md.
The bench checks 65,536 operand pairs, separate and simultaneous operand loads, registered output latency and the clocked reset. It calculates expected products independently using integer multiplication. Record the first pair for which the starter fails.
Verilog
iverilog -g2005 -s test_product -o bench starter/tree_product.v simulation/test_product.v
vvp bench
SystemVerilog
iverilog -g2012 -s test_product -o bench starter/tree_product.sv simulation/test_product.v
vvp bench
VHDL
nvc --std=2008 -a starter/tree_product.vhd simulation/test_product.vhd
nvc --std=2008 -e test_product
nvc --std=2008 -r test_product
Take one clock edge at a time
Synthesize and upload. With both enables on and the data switches at 00, press and release KEY1 twice. This initializes both operands and then clocks their zero product into the output. In simulation also try holding the active-low KEY0 reset while a KEY1 rising edge occurs.
Work down the table in order. The first two bits are SW9 and SW8. The byte after the dot is the hexadecimal value on SW7–0. Press and release KEY1 once in each row except “No pulse”. After each action, record LED7–0 and HEX3–0 in hexadecimal. Before each pulse, predict which two stored operands the output register will multiply.
| SW9–8 · SW7–0 | KEY1 | LED7–0 | HEX3–0 |
|---|---|---|---|
| 10 · 12 | Load A | ||
| 01 · 34 | Load B | ||
| 00 · 34 | Hold A and B | ||
| 10 · FF | No pulse | ||
| 10 · FF | Load A | ||
| 01 · 80 | Load B | ||
| 01 · 80 | Repeat | ||
| 11 · FF | Load A and B | ||
| 00 · 00 | Hold A and B | ||
| 11 · 00 | Load A and B | ||
| 00 · 00 | Hold A and B |
Compare the balanced and chain versions for 12 × 34 and FF × 80. The observations should agree once both programs are repaired. Count the longest path through adders for both architectures. Explain what you would need to measure before claiming a higher clock frequency. Submit your readings, your circuit change and a sketch of the adder structure.
If you use desktop Quartus, open the Compilation Report for each repaired design. In Timing Analyzer, find the Slow 1100mV 85C Model Fmax Summary and record the Fmax for KEY[1]. Repeat for the 0C model. In Fitter Summary, record the ALMs and registers. Compare both circuits at the same temperature. Which one uses fewer resources, and which one has the higher estimated clock frequency?
Original LabsLand activity following FPGAcademy Digital Logic Lab 6, Part V. verilog PDF · vhdl PDF · MIT
