Full adder implementation on a Basys 3 FPGA
This walkthrough implements a 4-bit full adder in Verilog on a Digilent Basys 3 FPGA board using the free edition of Vivado 2022.1. Two 4-bit binary numbers (plus an optional carry-in bit) are entered via the board's slide switches, and the result is displayed directly on the on-board LEDs.
Basys 3 Artix-7 FPGA board
The Basys 3 is an entry-level FPGA development board that ships ready to use out of the box, with a wide range of on-board I/O, built-in support circuitry, and free Xilinx Vivado tooling.
Board specifications
- Xilinx Artix-7 FPGA (
XC7A35T-1CPG236C) - 33,280 logic cells across 5,200 slices (each with four 6-input LUTs and 8 flip-flops)
- 1,800 Kbits of fast block RAM
- Five clock management tiles, each with a phase-locked loop (PLL)
- 90 DSP slices and internal clock speeds exceeding 450 MHz
- On-chip analogue-to-digital converter (XADC)
- 16 user slide switches, 16 user LEDs, 5 pushbuttons, and a 4-digit 7-segment display
- 4 Pmod ports (3 standard 12-pin ports plus 1 dual-purpose XADC/standard port)
- 12-bit VGA output, USB-UART bridge, USB HID host, and SPI Serial Flash
- Digilent USB-JTAG port for programming and debugging
Because it includes so many switches, LEDs, and displays directly on the board, it is great for learning FPGA design without needing external breadboards straight away.
Logic diagram
Here is the gate-level diagram of a 1-bit full adder. If you want a slower walkthrough of the truth tables and gate logic, check out my earlier post on building a full adder circuit in Python.

Vivado project sources
Here is the Vivado project structure showing the design files, constraints, and simulation testbench:

Design sources
fullAdder.v — single-bit full adder built from two half adders and an OR gate:
// Full adder routine
`timescale 1ns / 1ps
module fullAdder(
sum,
carry_out,
input1,
input2,
carry_in
);
output sum, carry_out;
input input1, input2, carry_in;
wire sum1, connection1, connection2;
xor (sum1, input1, input2);
and (connection1, input1, input2);
xor (sum, sum1, carry_in);
and (connection2, sum1, carry_in);
or (carry_out, connection2, connection1);
endmodule
fullAdder4BitsRoutine.v — top-level 4-bit ripple-carry adder that instantiates fullAdder four times, chaining each carry output into the next stage:

// Full adder circuit on 4-bits using full adder routine constructed from two halfs
`timescale 1ns / 1ps
module fullAdder4BitsRoutine(
sum,
carry_out,
input1,
input2,
carry_in
);
output [3:0] sum;
output carry_out;
input [3:0] input1, input2;
input carry_in;
wire connection1, connection2, connection3;
fullAdder run0(sum[0], connection1, input1[0], input2[0], carry_in);
fullAdder run1(sum[1], connection2, input1[1], input2[1], connection1);
fullAdder run2(sum[2], connection3, input1[2], input2[2], connection2);
fullAdder run3(sum[3], carry_out, input1[3], input2[3], connection3);
endmodule
Pin constraints
To map the Verilog ports to physical switches and LEDs on the Basys 3, I started from Digilent's default Basys 3 .xdc template and enabled the pins shown below:

fullAdder_constraints.xdc:
## Switches - first 4bit input
set_property PACKAGE_PIN V17 [get_ports {input1[0]}]
set_property IOSTANDARD LVCMOS33 [get_ports {input1[0]}]
set_property PACKAGE_PIN V16 [get_ports {input1[1]}]
set_property IOSTANDARD LVCMOS33 [get_ports {input1[1]}]
set_property PACKAGE_PIN W16 [get_ports {input1[2]}]
set_property IOSTANDARD LVCMOS33 [get_ports {input1[2]}]
set_property PACKAGE_PIN W17 [get_ports {input1[3]}]
set_property IOSTANDARD LVCMOS33 [get_ports {input1[3]}]
## Switches - second 4bit input
set_property PACKAGE_PIN W15 [get_ports {input2[0]}]
set_property IOSTANDARD LVCMOS33 [get_ports {input2[0]}]
set_property PACKAGE_PIN V15 [get_ports {input2[1]}]
set_property IOSTANDARD LVCMOS33 [get_ports {input2[1]}]
set_property PACKAGE_PIN W14 [get_ports {input2[2]}]
set_property IOSTANDARD LVCMOS33 [get_ports {input2[2]}]
set_property PACKAGE_PIN W13 [get_ports {input2[3]}]
set_property IOSTANDARD LVCMOS33 [get_ports {input2[3]}]
## Switches - carry_in bit
set_property PACKAGE_PIN R2 [get_ports {carry_in}]
set_property IOSTANDARD LVCMOS33 [get_ports {carry_in}]
## LEDs
set_property PACKAGE_PIN U16 [get_ports {sum[0]}]
set_property IOSTANDARD LVCMOS33 [get_ports {sum[0]}]
set_property PACKAGE_PIN E19 [get_ports {sum[1]}]
set_property IOSTANDARD LVCMOS33 [get_ports {sum[1]}]
set_property PACKAGE_PIN U19 [get_ports {sum[2]}]
set_property IOSTANDARD LVCMOS33 [get_ports {sum[2]}]
set_property PACKAGE_PIN V19 [get_ports {sum[3]}]
set_property IOSTANDARD LVCMOS33 [get_ports {sum[3]}]
set_property PACKAGE_PIN U15 [get_ports {carry_out}]
set_property IOSTANDARD LVCMOS33 [get_ports {carry_out}]
Simulation testbench
Before flashing the FPGA, it helps to add an optional testbench (testRoutine4bit.v) to run a behavioural simulation in Vivado and verify the logic waveforms:
// Testing the implementation with 4bit inputs
`timescale 1ns / 1ps
module testRoutine4bit;
reg [3:0] input1, input2;
reg carry_in;
wire [3:0] sum;
wire carry_out;
fullAdder4BitsRoutine testRun (sum, carry_out, input1, input2, carry_in);
initial
begin
$monitor ($time, "INPUT1 = %b, INPUT2 = %b, CARRY_IN = %b, CARRY_OUT = %b, SUM = %b\n", input1, input2, carry_in, carry_out, sum);
end
initial
begin
// inputs as 4-bit, carry_in as binary 0 or 1
input1 = 4'b0010; input2 = 4'b0010; carry_in = 1'b0;
#10
input1 = 4'b0010; input2 = 4'b0010; carry_in = 1'b1;
#10
input1 = 4'b0000; input2 = 4'b0001; carry_in = 1'b0;
#10
input1 = 4'b1001; input2 = 4'b1001; carry_in = 1'b0;
end
endmodule
Running the simulation lets us confirm every transition matches expected binary addition:

RTL analysis
Opening RTL Analysis > Schematic in Vivado shows how the four fullAdder instances connect together to generate sum[3:0] and carry_out:

Generate the bitstream
After synthesis and implementation succeed, generate the bitstream. Enable the -bin_file option in bitstream settings if you also want a .bin image for flashing the on-board SPI memory so the design survives a power cycle.
Connect the Basys 3 over USB and detect it in Hardware Manager:

Program the SPI flash memory
By default, programming over USB loads the bitstream into the FPGA's volatile SRAM, which clears as soon as the board loses power or resets. To make the design persistent, write the .bin file to the on-board non-volatile SPI flash so the FPGA reloads it automatically at boot.
Identify the flash memory type
Check the exact SPI flash chip fitted to your Basys 3 board, as Digilent has used different flash parts depending on the manufacturing batch.
Here is the configuration memory device selected for my board under Add Configuration Memory Device:

Once the memory device is added, program it using the .bin file generated earlier.
Hardware demonstration
Here are three live tests on the Basys 3 board showing different 4-bit switch inputs and the resulting LED outputs:
0001 + 0001 = 0010

0011 + 0011 = 0110

1000 + 1000 = (1)0000 = (carry_out bit) + 0000
