Lab 6

Multiply two four-bit numbers with an array of adders

Set A on switches SW7 through SW4 and B on SW3 through SW0. Each group represents one hexadecimal digit. Your circuit will show their product on the two leftmost displays. A single hexadecimal digit represents values up to 15. What is the largest product, and how many binary digits does it need?

Lab setup

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.

  1. Get the starterDownload array_product.v
  2. Open the LabsLand Online EditorOpen the lab LabsLand asks you to sign in. Use the access your course or institution provides.
  3. Follow the worksheetPredict first, then build, read the board and hand in. The build steps are below.

Starter files · Verilog · VHDL · SystemVerilog

Build

  1. In the LabsLand Online Editor, choose DE1-SoC for your HDL and the Standard interface.
  2. Create array_product, paste the design and set it as the top level.
  3. Choose Synthesize → Upload to FPGA. After editing the design, synthesize and upload it again to test the change on the board.

Locate the row selected by bit 2 of B. When A is 3, that row should contribute either 0 or 12. Draw its eight columns and fix the alignment of the partial product before it enters the row of full adders. Keep the sum and carry wiring. Use the same rule for all four rows.

Check all inputs

Extract the worksheet ZIP and run these commands from the folder containing activity.md.

The testbench checks all six display outputs against arithmetic multiplication for all 1,024 switch settings. Try the starter, record the first pair that fails, and repeat after aligning the rows.

test_array.v

test_array.vhd

Verilog

iverilog -g2005 -s test_array -o bench starter/array_product.v simulation/test_array.v
vvp bench

SystemVerilog

iverilog -g2012 -s test_array -o bench starter/array_product.sv simulation/test_array.v
vvp bench

VHDL

nvc --std=2008 -a starter/array_product.vhd simulation/test_array.vhd
nvc --std=2008 -e test_array
nvc --std=2008 -r test_array

Read your multiplier

Upload your repaired design and set the input pairs from the table. Look at HEX5 and HEX4 for the product, HEX2 for A and HEX0 for B. HEX3 and HEX1 separate the readings. Hexadecimal b and d appear in lowercase on the physical displays.

A B Predicted product (hex) Product on HEX5…4
3 1
3 2
3 6
b C
C b
F F

For 3 × 6, identify the two rows that contribute. Swap the inputs of b × C and compare both the displayed product and your sketch of the active rows. Try changing SW8 and SW9 while the other switches stay still. Submit the table, one observed carry into the upper digit, and your sketch.

Original LabsLand activity following FPGAcademy Digital Logic Lab 6, Part III. Verilog handout · VHDL handout · MIT