FPGA Project: Blink an LED on Basys 3, Arty A7 or DE10-Lite
To blink an LED once a second, count clock cycles and toggle the LED every half second. At 100 MHz (Basys 3 and Arty A7) that is every 50,000,000 clocks, so the counter runs from 0 to 49,999,999; at 50 MHz (DE10-Lite) every 25,000,000. The whole design is one counter and one flip-flop, and it is the quickest way to check your tools, your board and your constraints all work.
How this was checked
The design was simulated in Icarus Verilog 12 and linted with Verilator 5.036 (-Wall, no warnings) for every board's top level. The Basys 3 and Arty A7 versions were synthesized, placed and routed in Vivado 2025.2, met timing, and produced a bitstream. The DE10-Lite version was simulated and linted but not compiled, because Intel Quartus was not used here; its pin assignments come from Terasic's DE10-Lite System Builder file. None of the bitstreams has been loaded onto a board yet. If you build it and something doesn't behave as described, please tell us through the contact page.
The three boards
| Board | FPGA | Clock | Tools |
|---|---|---|---|
| Digilent Basys 3 | AMD Artix-7 XC7A35T | 100 MHz, pin W5 | Vivado |
| Digilent Arty A7-35 | AMD Artix-7 XC7A35T | 100 MHz, pin E3 | Vivado |
| Terasic DE10-Lite | Intel MAX 10 10M50 | 50 MHz, pin P11 | Quartus Prime Lite |
The Verilog
`timescale 1ns/1ps
// Blink an LED at 1 Hz: toggle every CLK_HZ / 2 clocks.
module blink #(parameter CLK_HZ = 100_000_000) (
input wire clk,
output reg led
);
localparam integer HALF = CLK_HZ / 2;
localparam integer W = $clog2(HALF);
localparam integer LAST_I = HALF - 1;
localparam [W-1:0] LAST = LAST_I[W-1:0];
reg [W-1:0] count = 0;
initial led = 1'b0;
always @(posedge clk) begin
if (count == LAST) begin
count <= {W{1'b0}};
led <= ~led;
end else begin
count <= count + 1'b1;
end
end
endmodule
CLK_HZ is a parameter, so one module serves all three boards. $clog2 sizes the counter: 26 bits for 50,000,000 and 25 bits for 25,000,000. Each board gets a tiny top-level module with its own port names:
`timescale 1ns/1ps
// One blink top per board, so each has its own port names.
module top_blink_basys3 (input wire clk, output wire [0:0] led); blink #(.CLK_HZ(100_000_000)) u (.clk(clk), .led(led[0])); endmodule
module top_blink_arty (input wire CLK100MHZ, output wire [0:0] led); blink #(.CLK_HZ(100_000_000)) u (.clk(CLK100MHZ), .led(led[0])); endmodule
module top_blink_de10lite (input wire MAX10_CLK1_50, output wire [0:0] LEDR); blink #(.CLK_HZ(50_000_000)) u (.clk(MAX10_CLK1_50), .led(LEDR[0])); endmodule
Constraints
On the Basys 3 the clock is pin W5 and LED 0 is U16; on the Arty A7 the clock is E3 and LED 0 is H5; on the DE10-Lite the 50 MHz clock is PIN_P11 and LEDR[0] is PIN_A8. The files are in the repository under scripts/fpga/constraints, taken from Digilent's master XDC files and Terasic's System Builder file.
Simulation and build results
With CLK_HZ set to 10 in simulation, the LED toggled 20 times in 100 clocks, once every 5. In Vivado the Basys 3 build used 7 LUTs and 27 flip-flops and met timing with 5.949 ns of slack at 100 MHz; the Arty A7 build was the same size with 6.056 ns.
Build and run
- Basys 3 or Arty A7: create a Vivado project for the right part (xc7a35tcpg236-1 or xc7a35ticsg324-1L), add blink.v, top_blink.v and the matching XDC file, set the top module, generate the bitstream and program the board with Hardware Manager.
- Or run scripts/fpga/build_all.sh, which builds every design in batch mode.
- DE10-Lite: create a Quartus project for the 10M50DAF484C7G, add the Verilog, paste the assignments from blink_de10lite.qsf into your project's .qsf, compile, and program with the USB-Blaster.
Common mistakes
- No clock constraint, or the wrong clock pin.
- Counting to CLK_HZ instead of CLK_HZ / 2, which blinks at 0.5 Hz.
- A counter too narrow to reach the end value, so it never wraps.
- Choosing the wrong part, so the bitstream doesn't match the board.
Check your understanding
- Q1. How many bits does the counter need at 50 MHz? Answer: 25, since it counts to 24,999,999 and 2^25 = 33,554,432.
- Q2. How would you blink at 4 Hz on a Basys 3? Answer: toggle every 12,500,000 clocks.
- Q3. Why use a parameter for the clock frequency? Answer: so the same module works on boards with different clocks.
Beginner FPGA projects
Sources
Last verified
Simulated, linted and built on 17 November 2026; the files are in the site's repository under scripts/fpga.