Lab 4

Count with a 16-bit register and an adder

Use Quartus Prime Lite with Cyclone V support to compare an arithmetic counter with the toggle stages in Part I. Display the result in hexadecimal on four digits of a real DE1-SoC.

Lab setup

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

This activity requires Quartus RTL Viewer. Use desktop Quartus to compare the schematics, then test your bitstream on the remote board.

  1. Install Quartus Prime Lite with Cyclone V supportSkip this if it is already installed.
  2. Download the activityDownload worksheet and both Quartus projects Includes the worksheet, the Quartus project, a second project for comparison and the simulation files.
  3. Complete the design and compileStart with Predict in the worksheet below, then complete the design as its build steps describe. Open adder_counter.qpf and choose Processing → Start Compilation. Quartus writes output_files/adder_counter.sof.
  4. 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 · Quartus 24.1 · VHDL · Quartus 24.1 · SystemVerilog · Quartus 24.1

Predict

Sketch the data input of a 16-bit register that can clear, hold or increment. Which control should have priority? Predict the next state for 000F, 00FF and FFFF with counting enabled. Choose a test that would expose a faulty enable even when the arithmetic works.

Build

Download the worksheet ZIP and open project/adder_counter.qpf. Repair the enable condition in the starter. Simulate, then select Processing → Start Compilation. In the Fitter report record ALM usage and the total registers. Open Tools → Netlist Viewers → RTL Viewer. Find the addition, the count register and the feedback path. Zoom in on the counter; the four display decoders can occupy most of the view.

Compare your schematic with the four-bit toggle implementation from Part I. The worksheet includes that project in comparison-project/toggle_four.qpf. Repair its toggle chain before compiling the comparison. Mark one structural difference and explain how both designs implement the same count sequence.

Simulate

Extract the complete worksheet ZIP. In the folder containing activity.md, run the commands below with Icarus Verilog for Verilog or SystemVerilog, or NVC for VHDL. The bench checks every count through rollover, then holds and clears the counter.

test_adder_counter.v

test_adder_counter.vhd

Verilog

iverilog -g2005 -s test_adder_counter -o bench project/adder_counter.v simulation/test_adder_counter.v
vvp bench

SystemVerilog

iverilog -g2012 -s test_adder_counter -o bench project/adder_counter.sv simulation/test_adder_counter.v
vvp bench

VHDL

nvc --std=2008 -a project/adder_counter.vhd simulation/test_adder_counter.vhd
nvc --std=2008 -e test_adder_counter
nvc --std=2008 -r test_adder_counter

Run the four-bit comparison from the same folder.

test_toggle_four.v

test_toggle_four.vhd

Verilog

iverilog -g2005 -s test_toggle_four -o bench comparison-project/toggle_four.v simulation/test_toggle_four.v
vvp bench

SystemVerilog

iverilog -g2012 -s test_toggle_four -o bench comparison-project/toggle_four.sv simulation/test_toggle_four.v
vvp bench

VHDL

nvc --std=2008 -a comparison-project/toggle_four.vhd simulation/test_toggle_four.vhd
nvc --std=2008 -e test_toggle_four
nvc --std=2008 -r test_toggle_four

Test the bitstream

Upload output_files/adder_counter.sof from the 16-bit project. Set SW0 low and pulse KEY0. Raise SW0 and SW1, then advance one release at a time until HEX3–0 crosses 000F. Lower SW1 and pulse KEY0 twice. Lower SW0, observe the display before the next release, then pulse KEY0.

Observation Expected Measured
Carry out of the low digit
Two pulses with enable low
Clear asserted before a clock edge
First rising edge with clear asserted

Submit one adjacent pair across a carry, the state held while disabled, and the fitter comparison. Use simulation to supply evidence for the full-width rollover.

FPGAcademy · Digital Logic · Lab 4 · II. VERILOG · VHDL · MIT