Getting Started with FPGA Development: Building a 4‑Bit Adder on Xilinx Artix‑7
Editor’s Note: As advanced algorithms continue to evolve, embedded designers often struggle to meet the processing demands of modern applications. Field‑Programmable Gate Arrays (FPGAs) provide the necessary performance, and recent hardware and tooling advances have made FPGA development accessible to a broader audience. This article, the fourth in a series derived from *Architecting High‑Performance Embedded Systems* by Jim Ledin, offers a hands‑on walk‑through of building a simple but complete FPGA project.
Developing Your First FPGA Project
We’ll construct a 4‑bit binary adder on a Xilinx Artix‑7 FPGA housed in a Digilent Arty A7 development board. Two board variants are available: the cost‑effective 35T model (US $129) and the more powerful 100T model (US $249). The only distinction is the FPGA variant, which influences available logic resources. The 100T is preferable for future projects that demand more resources, such as the digital oscilloscope example in later chapters.
Purchase options: Digilent Store, Amazon, and other retailers.
For this tutorial, we’ll focus on the FPGA core, four user switches, four pushbuttons, and five LEDs. The steps below cover installing the Vivado tool suite, creating a project, writing VHDL code, and loading a bitstream onto the board—both into volatile configuration memory and into onboard flash for persistent operation.
Project Overview
The design implements a 4‑bit adder. Four switches provide the first 4‑bit operand, four pushbuttons supply the second. The FPGA continuously adds these operands and displays the 4‑bit sum on four LEDs, with a fifth LED indicating the carry‑out. This straightforward design lets us concentrate on toolchain workflow rather than complex logic.
Installing Vivado
We’ll use Xilinx Vivado, available free of charge for Windows and Linux. The following instructions assume Windows; Linux installation steps are analogous.
- Create a Xilinx user account: https://www.xilinx.com/registration/create-account.html
- Log in at https://xilinx.com and navigate to the download page.
- Download the Xilinx Unified Installer (Windows Self‑Extracting Web Installer). For consistency with this book, select version 2020.1; otherwise, use the latest release.
- Run the installer (e.g., Xilinx_1_0602_1208_Win64.exe). If Windows blocks the download, choose “Install anyway.”
- Click Next on the welcome screen.
- Enter your Xilinx credentials and click Next.
- Acknowledge the license agreements and click Next.
- Choose Vitis as the product (Vitis bundles Vivado and additional tools). Click Next.
- Accept the default component selections and click Next.
- Select a destination directory (e.g., C:\Xilinx) and click Next.
- Review the summary and click Install. Installation may take several minutes.
Once installed, launch Vivado from the desktop shortcut or Start menu.
Creating the Project
- Open Vivado and click Create Project in the Quick Start pane.
- Enter ArtyAdder as the project name, choose a directory (e.g., C:\Projects), and tick Create a subdirectory for this project. Click Next.
- Select RTL Project and check Do not specify sources at this time. Click Next.
- Under the Boards tab, search for “Arty” and pick Arty A7-100 or Arty A7-35 based on your hardware. Click Next.
- Finish the wizard to create an empty project.
Adding VHDL Source Files
- In the Sources pane, right‑click Design Sources → Add Sources….
- Choose Add or create design sources and click Next.
- Select Create File, name it FullAdder.vhdl, and click OK.
- Repeat to create Adder4.vhdl, then click Finish.
- Ignore the Define Modules dialog; click OK and confirm with Yes.
- Open FullAdder.vhdl and paste the following code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity FULL_ADDER is
port (
A : in std_logic;
B : in std_logic;
C_IN : in std_logic;
S : out std_logic;
C_OUT : out std_logic
);
end entity FULL_ADDER;
architecture BEHAVIORAL of FULL_ADDER is
begin
S <= (A XOR B) XOR C_IN;
C_OUT <= (A AND B) OR ((A XOR B) AND C_IN);
end architecture BEHAVIORAL;
- Open Adder4.vhdl and replace its contents with:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity ADDER4 is
port (
A4 : in std_logic_vector(3 downto 0);
B4 : in std_logic_vector(3 downto 0);
SUM4 : out std_logic_vector(3 downto 0);
C_OUT4: out std_logic
);
end entity ADDER4;
architecture BEHAVIORAL of ADDER4 is
component FULL_ADDER is
port (
A : in std_logic;
B : in std_logic;
C_IN : in std_logic;
S : out std_logic;
C_OUT : out std_logic
);
end component;
signal c0, c1, c2 : std_logic;
begin
FULL_ADDER0 : FULL_ADDER
port map (
A => A4(0),
B => B4(0),
C_IN => '0',
S => SUM4(0),
C_OUT => c0
);
FULL_ADDER1 : FULL_ADDER
port map (
A => A4(1),
B => B4(1),
C_IN => c0,
S => SUM4(1),
C_OUT => c1
);
FULL_ADDER2 : FULL_ADDER
port map (
A => A4(2),
B => B4(2),
C_IN => c1,
S => SUM4(2),
C_OUT => c2
);
FULL_ADDER3 : FULL_ADDER
port map (
A => A4(3),
B => B4(3),
C_IN => c2,
S => SUM4(3),
C_OUT => C_OUT4
);
end architecture BEHAVIORAL;
Next Steps
The following article will guide you through simulating this design, synthesizing it for the Arty board, and programming the resulting bitstream onto the FPGA.
Reprinted with permission from Packt Publishing. Copyright © 2021 Packt Publishing
Jim Ledin is the CEO of Ledin Engineering, Inc. He specializes in embedded software and hardware design, development, and testing, and holds expertise in embedded system cybersecurity, penetration testing, and ethical hacking. Jim earned a B.S. in aerospace engineering from Iowa State University and an M.S. in electrical and computer engineering from Georgia Institute of Technology. He is a licensed professional electrical engineer in California, a CISSP, CEH, and CPT holder.
Related Content
- Embedded design with FPGAs: Hardware resources
- Embedded design with FPGAs: Implementation languages
- Embedded design with FPGAs: Development process
- Open‑source tools simplify FPGA programming
- Implementing floating‑point algorithms in FPGAs or ASICs
- Leveraging FPGAs for deep learning
- Software tools migrate GPU code to FPGAs for AI applications
- FPGAs displace ASICs in Subaru Eyesight vision‑based ADAS
Subscribe to Embedded’s weekly newsletter for more insights.
Embedded
- Embedded System Design: Steps, Principles, and Real‑World Applications
- Designing High‑Performance Interconnects Across PCIe Generations
- FPGA Implementation Languages: From VHDL and Verilog to High‑Level C/C++
- FPGA Hardware Resources for High‑Performance Embedded Systems
- Embedded FPGA Design: A Complete Development Process
- Mastering FPGA Embedded Design: A Practical Implementation Guide
- Embedded FPGA (eFPGA) Technology: Revolutionizing ASIC and SoC Design
- Streamline Electrical Harness Design with E3.series
- Build a Simple AM Radio Receiver: A Step‑by‑Step Guide
- Maximizing Production with Advanced Additive Manufacturing Software