FPGA Lab 01: Basic I/O Correspondence between Switch and LED

Course Platform: Terasic DE10-Lite with Intel/Altera MAX 10 FPGA (10M50DAF484C7G)
Software: Intel Quartus Prime Lite v25.1, Questa Starter FPGA Edition 2025.2
Experiment Type: Foundational Verilog FPGA Laboratory
Difficulty: Beginner
Naming Convention: Top-level modules end with _top; testbench modules end with _tb

Important Note:

This experiment requires students to implement the same function twice using two different Verilog modeling methods:

  • Gate-level (structural) modeling
  • Dataflow modeling

Students must test both versions and compare the two approaches.

The instructor will guide students through the design process in class. A complete final solution is not provided here. After finishing the experiment, students must submit all correct answers, design files, simulation results, and written responses to the instructor

1. Experiment Objective

The objective of this experiment is to understand how physical inputs and outputs on the DE10-Lite board are connected to the FPGA and controlled by a Verilog design. Students will begin with direct switch-to-LED correspondence, then explore alternate logical mapping, and finally design a more advanced LED pattern controller that uses switches to select different visual patterns.

2. Learning Outcomes

  • Understand how board-level user I/O devices connect to the FPGA chip
  • Create a synthesizable top-level Verilog design using switch and LED ports
  • Use Quartus Prime Lite to compile and program the FPGA
  • Use Questa Starter FPGA Edition to perform functional simulation
  • Distinguish between combinational logic and sequential logic in FPGA design
  • Interpret signal mapping, indexing, and visible hardware behavior correctly
  • Develop disciplined engineering habits: naming consistency, simulation-first workflow, and hardware verification

3. Pre-Experiment Hardware Background

Why this section matters:
Before students write any Verilog code, they must understand that the switches and LEDs on the DE10-Lite board are not automatically connected to each other. Both devices are connected to the MAX 10 FPGA, and the FPGA must be programmed to determine how the input signals are interpreted and how the output signals are driven.

3.1 FPGA-Centered Board Architecture

The DE10-Lite board includes 10 LEDs, 10 slide switches, 2 debounced push buttons, and six 7-segment displays. The board block diagram shows that, for user flexibility, the board connections are made via the MAX 10 FPGA. This means the FPGA becomes the central digital system that reads user inputs and drives user outputs.

In practical terms, the signal path in this lab is:

Physical switch position → FPGA input pin → Verilog logic → FPGA output pin → Physical LED response

3.2 How the Slide Switches Connect to the FPGA

The DE10-Lite board provides ten slide switches. These switches are used as level-sensitive digital inputs. Each switch is connected directly and individually to a MAX 10 FPGA pin. When a switch is in the DOWN position, closest to the edge of the board, it provides a logic 0 to the FPGA. When the switch is in the UP position, it provides logic 1 to the FPGA.

A 4bit 2to1 MUX

Therefore, for this experiment:

  • A slide switch behaves like a stable logic input, not a short pulse
  • No clock is required to read the switch value
  • No debouncing logic is needed for the slide switches in this lab
  • Each switch must be interpreted through the FPGA design

3.3 How the Red LEDs Connect to the FPGA

The board also provides ten user-controllable red LEDs. Each LED is driven directly and individually by a MAX 10 FPGA pin. Driving the corresponding FPGA pin to logic high turns the LED on, and driving the pin to logic low turns the LED off. Therefore, the DE10-Lite red LEDs behave as active-high outputs.

ConnBtwLEDsAndMax10

Therefore, for this experiment:

  • An LED can be treated as a standard digital output
  • Logic 1 turns the LED on
  • Logic 0 turns the LED off
  • Each LED is independently driven by the FPGA design

3.4 Signal Names Used in This Lab

The user I/O signal names used in this lab are:

  • SW[9:0] for the ten slide switches
  • LEDR[9:0] for the ten red LEDs

Students must ensure that the Verilog port names match the project pin assignments exactly.

3.5 Notes About Other Board Resources

  • KEY[1:0]: Push buttons are active-low and already include board-level debouncing
  • All 7-segment displays are active-low
  • These resources are not required in Experiment 1A, but students should remember their logic conventions for future labs

3.6 Why This Matters Before Coding

This first experiment is not just about making LEDs light up. It is about learning the engineering chain that connects physical hardware, HDL, synthesis, simulation, and board-level verification. Students should understand that even a very simple design requires correct module naming, port declarations, pin mapping, bit ordering, and verification steps.

4. Pre-Lab Thinking Questions

  1. Why do the switches not control the LEDs automatically, even though both are on the same board?
  2. What does it mean that a switch is connected directly to an FPGA pin?
  3. Why is a slide switch considered level-sensitive?
  4. Why is an LED considered an output device from the FPGA point of view?
  5. What can go wrong if the Verilog port names do not match the Quartus pin assignments?
  6. If the LEDs were active-low instead of active-high, what would change in the design?

5. General Lab Rules

  • Use the DE10-Lite board only; no external hardware is required
  • Use the provided Quartus Setting File as the pin-assignment reference
  • Simulate the design before programming the FPGA board
  • Use consistent naming and project organization
  • Do not submit copied work; all answers and source files must reflect your own understanding

9. Recommended Design Workflow

  1. Create the Quartus project and select the correct MAX 10 device
  2. Set the correct top-level entity name
  3. Add the Verilog source file(s)
  4. Use the provided QSF reference for pin assignment consistency
  5. Compile the design and fix all syntax or naming errors
  6. Create the correct testbench module
  7. Run functional simulation in Questa Starter FPGA Edition 2025.2
  8. Verify the waveform behavior carefully
  9. Program the DE10-Lite board
  10. Compare hardware behavior with the expected design behavior

10. Common Mistakes to Avoid

  • Wrong top-level module name
  • Wrong testbench module name
  • Signal names that do not match the intended board resource names
  • Incorrect bit width or vector indexing
  • Skipping simulation
  • Programming the board before the compile is clean
  • Using a clock in Experiment 1A when none is needed
  • Trying to implement visible LED animation in Experiment 1C without timing logic

11. Deliverables

Students must submit all correct files and all written answers to the instructor.

  • All correct Verilog source files for the completed sub-experiments
  • All correct testbench files
  • Simulation waveform screenshots
  • Hardware verification photo(s) or screenshot(s)
  • Complete written answers to all pre-lab and post-lab questions
  • A short reflection on what was learned, what errors occurred, and how they were resolved

12. Final Reflection Questions

  1. What is the most important thing you learned from this lab about FPGA hardware interaction?
  2. What was the difference between a logical design error and a project setup error?
  3. Why is this first experiment important even though the initial design is simple?
  4. How does this lab prepare you for later labs involving counters, FSMs, displays, and more advanced timing behavior?

13. Submission Reminder

Before submission, make sure that:
  • Your project and module names follow the required naming convention
  • Your design compiles without errors
  • Your simulation results match your design intent
  • Your hardware results match your simulation results
  • All answers are complete and ready to submit to the instructor


FPGA Lab 01: Switches, LEDs, and Multiplexers

Objective

The purpose of this exercise is to learn how to connect simple input and output devices to an FPGA chip and implement a circuit that uses these devices. We will use the switches on the DE10-Lite board as inputs to the circuit. We will use light-emitting diodes (LEDs) as output devices.

Required Reading Materials

Overview

DE10-Lite FPGA Board Switches and LEDs

The Intel DE10-Lite FPGA board has ten switches and LEDs. The connections between the switches and LEDs are shown in the following Figures:

Figure 1: The Connections of Switches and LEDs on the DE10-Lite FPGA Board

Multiplexers (MUX)

In digital circuits, a multiplexer (or MUX) is a device that selects one of several digital input signals and forwards the selected input into a single line. A multiplexer of 2n inputs has n select lines, which are used to select which input line to send to the output.

  • A 2n-to-1 multiplexer sends one of the 2n input lines to a single output line.
  • A multiplexer has two sets of inputs:
    • 2n data input lines
    • n select lines to pick one of the 2n data inputs
  • The mux output is a single bit, which is one of the 2n data inputs.

2-to-1 1-bit MUX

Figure 2 (b) shows a sum-of-products circuit that implements a 2-to-1 multiplexer with a select input s. If s = 0, the output of the multiplexer (out) is equal to the input in0; if s = 1, the output is equal to in1. Part (a) of the figure gives a function table for this multiplexer, and part (c) shows its circuit symbol.


Figure 2: A 2-to-1 Multiplexer

2-to-1 4-bit MUX

Write a Verilog module with four assignment statements like the one shown above to describe the circuit given in Figure 3 (a). This circuit has two four-bit inputs, In0 and In1, and produces the four-bit output Out. If S = 0 then Out = In0, while if S = 1 then Out = In1. We refer to this circuit as a four-bit wide 2-to-1 multiplexer, and its circuit symbol shows in Figure 3(b), in which In0, In1, and Out depict as four-bit wires.


Figure 3: A four-bit wide 2-to-1 Multiplexer

4-to1 1-bit MUX

A 4-to-1 MUX takes four inputs and directs a single selected input to output. A 2-bits selection input controls the selection of input. The characteristic table of 4-to-1 MUX is shown below:

Select LinesOutput
S1 S0 Out
0 0 In0
0 1 In1
1 0 In2
1 1 In3

Figure 4: A 4-to-1 Multiplexer

The logic Circuit Diagram of 4-to-1 MUX is shown in the following Figure:

mux4 to 1 1bit Circuit
Figure 5: 4-to-1 1-bit MUX Logic Circuit

Lab Experiments

© 2026 Air Supply Information Center (Air Supply BBS)