Make a decimal digit advance once per second
Online version: https://fpga.labsland.com/altera/digital-logic/lab-04/part-03/
A board clock keeps ticking while your browser waits for the next camera frame. Use the DE1-SoC's 50 MHz clock to display 0 through 9 repeatedly on HEX0. SW8 resets the counter. SW9 pauses the count so you can read the display.
Lab setup
LabsLand Online Editor · DE1-SoC
Physical DE1-SoCCyclone V · 5CSEMA5F31C6 · camera, switches and buttons in the browser
Compile and measure the clock on a DE1-SoC
Extract the project for your HDL and open second_digit.qpf in Quartus Prime Lite with the Cyclone V device package. Complete the interval counter and decimal rollover in the starter. Leave CYCLES_PER_SECOND at 50,000,000. The supplied second_digit.sdc defines the 20 ns period of CLOCK_50. Run Processing → Start Compilation and check that the fitted device is 5CSEMA5F31C6.
Open the DE1-SoC binary-upload lab in the Standard interface. Upload output_files/second_digit.sof to the firmware library, select that file and enter the board. Use SW8 to reset, SW9 to pause and HEX0 to time a complete ten-digit cycle. Record the results in the observation table.
- Get the starterDownload
second_digit.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 and the Quartus project.
- Complete the design and compileStart with Design the interval in the worksheet below, then complete the design as its build steps describe. Open
second_digit.qpfand choose Processing → Start Compilation. Quartus writesoutput_files/second_digit.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
Design the interval
How many rising edges make one second? If the first count is zero, find the last count and the minimum width of the interval register. Draw the sequence across the last two clock edges before a tick and the first edge after it. Use a clock enable in one clock domain.
Build
Open the second_digit starter for your HDL in the Standard Online Editor. The two switches are already synchronized to CLOCK_50. The reset path and active-low display decoder are supplied. Implement the interval and decimal counters. Check that pause holds both counters and reset takes priority over pause. Keep the hardware parameter at 50,000,000 when you synthesize and upload the program.
Measure a complete cycle
Raise SW8 until HEX0 reads 0. Lower SW8 and start timing when the display changes from 0 to 1. Observe the sequence for a full turn. Time the interval from one transition to the same transition ten digits later. Camera updates can arrive unevenly, so measure the full cycle and divide by ten.
| Trial | First and last digits | Elapsed time | Observation |
|---|---|---|---|
| Ten transitions | |||
| SW9 held high for at least 3 seconds | |||
| Reset while paused, then release reset |
Resume and confirm that the next digit follows from the one you froze. Submit the table, one observation of 9 wrapping to 0 and your measured seconds per digit. Explain what happens if the terminal count is 24,999,999. Return both switches to zero before leaving.
Adapted from FPGAcademy Digital Logic 21.1 · Lab 4, III. verilog · vhdl · MIT
