This small project demonstrates how to build an N-bit adder using the generate construct in VHDL and how to drive/observe it with VIO (Virtual I/O) IP in Vivado.
Since the CMOD A7 board has no physical switches or LEDs, VIO is used to provide inputs and observe outputs in real time.
A full adder sums three inputs (A, B, Cin) and produces a Sum (S) and Carry-out (Cout).
Formulas:
S = A ⊕ B ⊕ CinCout = (A·B) + (B·Cin) + (A·Cin)
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity full_adder is
port(
a,b,cin: in std_logic;
s,cout: out std_logic
);
end full_adder;
architecture Behavioral of full_adder is
begin
s <= a xor b xor cin;
cout <= (a and b) or (b and cin) or (a and cin);
end Behavioral;library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity n_bit_adder is
generic(
N : integer := 8
);
port(
A_in : in std_logic_vector(N-1 downto 0);
B_in : in std_logic_vector(N-1 downto 0);
C_in : in std_logic;
S_out : out std_logic_vector(N-1 downto 0);
C_out : out std_logic
);
end n_bit_adder;
architecture Behavioral of n_bit_adder is
signal carry : std_logic_vector(N downto 0) := (others => '0');
begin
N_ADDER_GEN: for i in 0 to N-1 generate
adder_i : entity work.full_adder
port map(
a => A_in(i),
b => B_in(i),
cin => carry(i),
s => S_out(i),
cout => carry(i+1)
);
end generate;
carry(0) <= C_in;
C_out <= carry(N);
end Behavioral;The N-bit adder is created by chaining full adders in a generate loop. carry(0) is tied to the external C_in, and the final carry(N) becomes the C_out.
In Sources tab, you’ll see N instances (adder_i) generated:
Because CMOD A7 has no external switches/LEDs, VIO is used to drive and observe the adder.
-
Create a Block Design.
-
Add Clocking Wizard (use board clock → any clean internal clock, e.g., 50–100 MHz).
-
A_in,B_in,C_in→ VIO outputsS_out,C_out→ VIO inputs
-
Right-click BD → Create HDL Wrapper (let Vivado manage) → Set as Top.
-
Generate bitstream & program the FPGA.
-
In Hardware Manager, open VIO → + Add Probes → select signals.
You can now drive inputs (A_in, B_in, C_in) and observe outputs (S_out, C_out) live:
The ripple adder is tiny; the debug hub + VIO eats lots of the fabric in this demo. That’s normal: debug cores trade area for visibility. As you widen buses or add ILA, usage rises.





