FPGA Lab 03: 7-Segment LED and 2-Digit Counters
- To become familiar with the seven-segment displays on the DE10-Lite board.
- Learn how to use a lookup table to implement a 4-digit hex-to-7-segment decoder.
Required Reading Material
Counters, as the name suggests, are for counting a sequence of values. However, there are many different types of counters, depending on the total number of count values, the sequence of values that it outputs, whether it counts up or down, and so on. The simplest is a modulo-n counter that counts the decimal sequence 0, 1, 2, ... up to $n-1$ and back to 0.
In this lab, you will design a counter that provides the following functions:
- Can change the counter to count up or down
- Can change the counting speed
- Can stop the counter
- Can preload the counter value
The top-module diagram is shown in Figure 1.
Exp #1: Hexadecimal Counter
- Launch the Quartus Prime software and create a new project. The following lists are the settings for the project.
- Working directory: <the folder you created for this lab>/Lab03_counter
- The name of the project: counter
- The name of the top-level design: counter_top
- Add three Verilog HDL files into the project.
- Import assignment file (DE10_Lite.qsf). Before clicking the OK button, make sure the item Global assignments in the Advance Import Settings must be checked.
- Save all files, then compile the code. If there are no errors. Using RTL Viewer to check the synthesized circuit is correct or not. It should be the same as our top-level diagram. Capture and save all RTL diagrams to disk.
Program the code to the FPGA board, then test your code:
- Set SW[6:0] to (011 1010), SW[9:7] to (000), and SW to (1).
- Press and hold the KEY (clear) to clear the display, and you should see  on the 7-segment displays.
- Release the KEY. The counter starts counting up.
- Change SW (dir) to (0), the counter starts counting down.
- Change SW to (1), then press and hold the KEY (load) to load value from SW[6:0] (din). You should see [3A] on the 7-segment displays.
- Release the KEY; counter continues counting.
- Change the SW (sel) to (1) to change the counting speed.