Lab 2

Follow a carry through four bit positions

Digital Logic · Lab 2, Part III · DE1-SoC

Build a four-bit adder from four copies of the same one-bit circuit. A change to a single switch can flip five LEDs. Find an input that makes that happen, then explain it one column at a time.

Lab setup

Physical DE1-SoCCyclone V · 5CSEMA5F31C6 · camera, switches and buttons in the browser

  1. Get the starterDownload ripple_sum.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

Predict the carry

Draw the eight rows of the truth table for three inputs a, b and carry-in. Write two output bits for each row. Which rows generate a carry even when carry-in is zero? Which rows pass a carry from the previous column to the next? Derive one Boolean expression for the sum bit and one for the carry bit.

Read SW7…4 as unsigned A and SW3…0 as unsigned B. SW8 supplies the carry-in. LEDR3…0 show the sum and LEDR4 is the final carry. SW9 is unused.

Build

Open the starter for your HDL in the DE1-SoC Online Editor with Standard selected. Create ripple_sum, paste the starter and select it as the top level. Find the one-bit component. Its sum output is supplied. Replace its fixed carry output with your expression. Follow the four instances from the least significant bit to the most significant bit. Synthesize and upload to the board.

Read the board

A B Carry-in Predicted LEDR4…0 Camera LEDR4…0
0000 0000 0
0001 0001 0
0111 0000 1
1111 0000 0
1111 0000 1
1111 1111 1

In the two rows with A = 1111 and B = 0000 change only SW8. Label each carry into and out of the four columns. The camera shows the stable result after the switch change. The carry sequence itself comes from your logic analysis. Toggle SW9 once and check your prediction.

Hand in

Submit the one-bit truth table, your two equations, the six board readings and the four-column explanation. Which test first exposes the original starter's fault?

Adapted from FPGAcademy Digital Logic 21.1, Verilog Lab 2, Part III and its VHDL edition. LabsLand wrote the programs and remote procedure. MIT notice