Lab 5

Carry a count across three decimal digits

Build a decimal counter for the three rightmost displays. One second after 099, the displays should read 100. At 999, all three return to zero. A single board clock drives three copies of the same decimal stage.

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 cascade_bcd.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 enables

Make a table for 008, 009, 098, 099 and 999. For each value, decide which digits should change on the next one-second tick. Name the conditions that advance the tens and the hundreds. Distinguish a digit holding 9 between ticks from a carry that a higher digit should act on.

Build

  1. In the LabsLand Online Editor, choose DE1-SoC for your HDL and the Standard interface.
  2. Create cascade_bcd, 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.

The starter includes a clock divider, one decimal stage and a display decoder. Complete the tens and hundreds enable connections. Use CLOCK_50 for every stage. Keep the hardware clock parameter at 50,000,000. Synthesize, upload, and read HEX2 through HEX0 from left to right.

Simulate the carries

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

The bench runs all 1,000 values and checks the wrap, both presets and reset priority. It gives the divider two clock cycles per tick in simulation. Keep the original divider setting for the physical board. Compare the expected and observed three-digit readings at the first mismatch. Which digit missed its carry? Repair only that stage and rerun. Where does the next mismatch occur? Fix the remaining enable, then check that the bench reaches PASS.

test_cascade_bcd.v

test_cascade_bcd.vhd

Verilog

iverilog -g2005 -s test_cascade_bcd -o bench starter/cascade_bcd.v simulation/test_cascade_bcd.v
vvp bench

SystemVerilog

iverilog -g2012 -s test_cascade_bcd -o bench starter/cascade_bcd.sv simulation/test_cascade_bcd.v
vvp bench

VHDL

nvc --std=2008 -a starter/cascade_bcd.vhd simulation/test_cascade_bcd.vhd
nvc --std=2008 -e test_cascade_bcd
nvc --std=2008 -r test_cascade_bcd

Test the boundaries

Press KEY0 with both switches down to clear the count. Release it and watch the units advance. Raise SW8 to load 098, then lower SW8 and record four successive readings. Repeat with SW9, which loads 998. The preset switches let you visit carry boundaries during one reservation. Keep the other preset switch down.

Test Prediction First four readings Time for three transitions
Release the 098 preset
Release the 998 preset

While SW8 is up, hold KEY0 and read the displays. Release KEY0 while keeping SW8 up. Give the camera a few seconds to show the settled digits, then record the second reading. Which control takes priority? Explain why connecting the units carry output to a clock input would change the design. Finish with both preset switches down and press KEY0 once.

Source

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