Skip to content
Tutorials Center
My learning

Topics

Lesson 31 of 37 ยท Synthesis and FPGA

The FPGA Flow, Pins and Your First Board

Follow the FPGA flow from VHDL to bitstream: synthesis, place and route, pin constraints, top-level wrapper, switch debouncing, and a first LED blink design.

An FPGA (field-programmable gate array) is a chip full of configurable logic that your design wires up after manufacturing. Getting from a VHDL file to a blinking LED on a board involves a short chain of tools and one new idea: your design must connect to the pins of the chip. This lesson walks the whole chain and teaches the habits that make a first board bring-up painless.

Boards and vendor tools are not available on this site. VHDL and constraint files are shown read-only; C stand-ins model the counter arithmetic and the debounce logic.

The flow

flowchart LR
  A["VHDL + constraints"] --> B["Synthesis"]
  B --> C["Implementation:<br/>place and route"]
  C --> D["Timing check"]
  D --> E["Bitstream"]
  E --> F["Program the FPGA"]

The standard FPGA flow. If timing fails, go back and change the design or the constraints.

  1. Synthesis produces the netlist of LUTs and flip-flops (what synthesis does).
  2. Place and route assigns each LUT and flip-flop to a physical cell and connects them through the routing fabric. Placement decides where; routing decides how.
  3. Timing analysis checks every path against the clock constraint.
  4. Bitstream generation creates the file that configures the chip: the contents of every LUT, every routing switch, every I/O setting.
  5. Programming loads the bitstream into the device. Most FPGAs lose their configuration at power-off, so boards also hold the bitstream in a flash chip that loads it at start-up.

Typical vendor suites: Vivado (AMD/Xilinx), Quartus (Intel/Altera), Radiant and Diamond (Lattice), Libero (Microchip). The open-source toolchain Yosys + nextpnr covers several families.

The top-level design

The top entity is the one whose ports are the chip's pins. Keep it thin: inputs and outputs, a reset synchronizer, and instances of your real modules. A blinking LED needs a clock and an LED:

VHDL
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity top is
  port (
    clk100 : in  std_logic;       -- 100 MHz board oscillator
    led    : out std_logic        -- one LED
  );
end entity;

architecture rtl of top is
  constant HALF : natural := 50_000_000;   -- 0.5 s at 100 MHz
  signal cnt : unsigned(25 downto 0) := (others => '0');
  signal led_r : std_logic := '0';
begin
  process (clk100)
  begin
    if rising_edge(clk100) then
      if cnt = HALF - 1 then
        cnt <= (others => '0');
        led_r <= not led_r;
      else
        cnt <= cnt + 1;
      end if;
    end if;
  end process;
  led <= led_r;
end architecture;

Initial values (:= '0') on signals are honored by FPGA tools (the registers start at that value after configuration). This is a difference from ASICs, where an explicit reset is the only reliable start.

Sizing the counter

How many bits does a counter need to divide a clock down? The program below computes it for a few target blink periods.

C C stand-in: clock divider counter width and values

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with scanf or fgets), it gets the next line from this box.

A 26-bit counter reaches 67 million, enough for a 0.5 s half period at 100 MHz. A wider counter than needed wastes flip-flops; a narrower one overflows early.

Pin constraints

VHDL port names must be tied to physical pins and I/O standards. That belongs in the constraints file, not in the VHDL. For a board in the AMD/Xilinx style (pin names are examples and differ per board):

TEXT
set_property PACKAGE_PIN W5  [get_ports clk100]
set_property IOSTANDARD LVCMOS33 [get_ports clk100]
create_clock -period 10.000 [get_ports clk100]

set_property PACKAGE_PIN U16 [get_ports led]
set_property IOSTANDARD LVCMOS33 [get_ports led]

Always use the board's schematic or manual to find pin names, voltages (I/O standard) and whether buttons and LEDs are active-high or active-low. A wrong I/O voltage can damage hardware; a wrong polarity just makes everything look inverted.

Real-world inputs: buttons and switches

A mechanical button does not give one clean edge: it bounces, producing many transitions for a few milliseconds. It is also asynchronous to your clock. Two steps fix that:

  1. Synchronize the input with two flip-flops, so the rest of the design sees a clean synchronous signal.
  2. Debounce: accept a change only after the input has stayed the same for, say, 10 ms.
VHDL
-- two-stage synchronizer
process (clk)
begin
  if rising_edge(clk) then
    sync1 <= btn;
    sync2 <= sync1;
  end if;
end process;
C C stand-in: debounce with a stability counter

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with scanf or fgets), it gets the next line from this box.

The output rises only after five consecutive 1 samples and falls only after five consecutive 0 samples, so the bounces vanish (at the cost of a short delay).

Bring-up checklist

  1. Make the first design the simplest possible: a clock divider and an LED.
  2. Check that the clock pin and its frequency match the board manual.
  3. Run the constraints check: no unconstrained ports ("unspecified I/O standard" warnings become real problems).
  4. Look at the utilization and timing summaries after each build.
  5. Use the on-chip logic analyzer (ILA, SignalTap) or simply route signals to LEDs and pins for debugging.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does place and route do?

    Placement chooses locations for each cell; routing creates the connections.
  2. 2. Where do you map a port to a physical pin?

    Pin and I/O-standard assignments live in the constraints (XDC, QSF, SDC, PCF...).
  3. 3. Why synchronize a button input with two flip-flops?

    An asynchronous input may change near a clock edge; the first flip-flop may go metastable and the second filters it.
  4. 4. A 100 MHz clock needs how many cycles for a 0.5 s delay?

    0.5 s x 100,000,000 cycles per second = 50,000,000 cycles.

Summary

  • The flow is synthesis, place and route, timing check, bitstream, programming.
  • The top entity's ports are the chip pins; pin numbers and I/O standards go in the constraints file.
  • Initial values are honored in FPGA registers; size counters from clock frequency and period.
  • Synchronize and debounce all asynchronous inputs such as buttons.
  • Start with a minimal blink design and check reports after every build.

Next: Pipelining