DEV Community

Hedy
Hedy

Posted on

How to use Xilinx FPGA VHDL?

This guide covers the basics of programming Xilinx FPGAs using VHDL, including setup, coding, simulation, and synthesis.

Image description

πŸ”§ 1. Required Tools
Before starting, install these tools:

1.1 Xilinx Vivado (Free WebPACK Edition)

  • Download from: Xilinx Downloads
  • Supports Artix, Kintex, and Zynq FPGAs
  • Includes VHDL simulator & synthesis tools

1.2 FPGA Development Board (Optional but Recommended)
Example boards:

πŸ“ 2. Creating a Simple VHDL Project
2.1 Open Vivado & Create a New Project

  1. Launch Vivado β†’ Click "Create Project"
  2. Select RTL Project β†’ Choose VHDL as the language.
  3. Select your FPGA board model (or manually pick the chip).

2.2 Write a Basic VHDL Example (Blinking LED)
πŸ“„ File: led_blink.vhd

vhdl
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity led_blink is
    Port ( 
        clk : in  STD_LOGIC;   -- 100MHz clock input
        led : out STD_LOGIC    -- LED output
    );
end led_blink;

architecture Behavioral of led_blink is
    signal counter : STD_LOGIC_VECTOR(26 downto 0) := (others => '0');
begin
    process(clk)
    begin
        if rising_edge(clk) then
            counter <= counter + 1;
        end if;
    end process;

    led <= counter(26);  -- Blink LED at ~1Hz (100MHz / 2^27)
end Behavioral;
Enter fullscreen mode Exit fullscreen mode

2.3 Assign FPGA Pins (Constraints File)
πŸ“„ File: constraints.xdc

tcl
# Basys 3 Example
set_property PACKAGE_PIN W5 [get_ports clk]    # 100MHz Clock
set_property PACKAGE_PIN U16 [get_ports led]   # LED0
set_property IOSTANDARD LVCMOS33 [get_ports {led clk}]
Enter fullscreen mode Exit fullscreen mode

βš™οΈ 3. Compile & Program the FPGA
3.1 Run Synthesis & Implementation

  1. Click "Run Synthesis" β†’ Wait for completion.
  2. Click "Run Implementation" β†’ Generates a bitstream.

3.2 Generate & Flash the Bitstream

  1. Click "Generate Bitstream".
  2. Connect your FPGA via USB-JTAG (Digilent/USB-Blaster).
  3. Click "Open Hardware Manager" β†’ "Program Device".

βœ… The LED should now blink at ~1Hz!

πŸ” 4. Simulating VHDL (Optional but Recommended)
Vivado includes a built-in simulator (XSim).

4.1 Create a Testbench
πŸ“„ File: tb_led_blink.vhd

vhdl
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity tb_led_blink is
end tb_led_blink;

architecture Behavioral of tb_led_blink is
    signal clk : STD_LOGIC := '0';
    signal led : STD_LOGIC;
begin
    -- Instantiate the design
    DUT: entity work.led_blink
    port map (
        clk => clk,
        led => led
    );

    -- Generate a 100MHz clock
    clk <= not clk after 5 ns;  -- 10ns period = 100MHz

    -- Stop simulation after 1ms
    process
    begin
        wait for 1 ms;
        std.env.stop;
    end process;
end Behavioral;
Enter fullscreen mode Exit fullscreen mode

4.2 Run Simulation

  1. Right-click "Simulation Sources" β†’ "Add Sources" β†’ Select testbench.
  2. Click "Run Simulation" β†’ "Run Behavioral Simulation".
  3. View waveforms in XSim.

πŸ“Œ 5. Key VHDL Concepts for FPGAs

Image description

πŸš€ 6. Next Steps

  • Try UART communication (send/receive serial data).
  • Learn Finite State Machines (FSMs) for complex logic.
  • Explore Xilinx IP Integrator for pre-built modules (PLLs, RAM, etc.).

Top comments (0)

AI Agent image

How to Build an AI Agent with Semantic Kernel (and More!)

Join Developer Advocate Luce Carter for a hands-on tutorial on building an AI-powered dinner recommendation agent. Discover how to integrate Microsoft Semantic Kernel, MongoDB Atlas, C#, and OpenAI for ingredient checks and smart restaurant suggestions.

Watch the video πŸ“Ί

πŸ‘‹ Kindness is contagious

Engage with a wealth of insights in this thoughtful article, cherished by the supportive DEV Community. Coders of every background are encouraged to bring their perspectives and bolster our collective wisdom.

A sincere β€œthank you” often brightens someone’s dayβ€”share yours in the comments below!

On DEV, the act of sharing knowledge eases our journey and forges stronger community ties. Found value in this? A quick thank-you to the author can make a world of difference.

Okay