Multiply two registered bytes using shifted additions
Online version: https://fpga.labsland.com/altera/digital-logic/lab-06/part-04/
Use eight shifted rows to multiply unsigned bytes. Separate enables let you enter two operands through one switch bank. The four displays show a registered 16-bit product. They reveal which input values were in the registers immediately before the last clock edge.
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/registered_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
registered_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/registered_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 row generated by B bit 7 when A is FF. Compare it with the row for bit 0. Inspect the eight additions and find the final connection that drops the highest partial product. 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
registered_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
registered_product.qpfand choose Processing → Start Compilation. Quartus writesoutput_files/registered_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
registered_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 row generated by B bit 7 when A is FF. Compare it with the row for bit 0. Inspect the eight additions and find the final connection that drops the highest partial product. 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/registered_product.v simulation/test_product.v
vvp bench
SystemVerilog
iverilog -g2012 -s test_product -o bench starter/registered_product.sv simulation/test_product.v
vvp bench
VHDL
nvc --std=2008 -a starter/registered_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 |
Explain why FF × 80 exposes an omitted row even if a small product is correct. Identify one clock edge where the LEDs already show the new B while the displays still show the product from the old B. Submit your readings, your circuit change and a sketch of the adder structure.
Original LabsLand activity following FPGAcademy Digital Logic Lab 6, Part IV. verilog PDF · vhdl PDF · MIT
