Full Adder
There are only 10 types of people in the world. Those who understand binary, and those who don't.
← RISC-V
Prerelease
Ongoing Research: This module is deployed while active validation is underway. Schematics, HDL code, and verification notes are evolving.
Overview
Full-Adder
{cout, s} = a + b + cin
Fundamental arithmetic building block that sums two operand bits along with an incoming carry bit (cin) for multi-bit addition.
Logic Diagram
Truth Table
| a | b | cin | cout | s |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 1 |
| 0 | 1 | 0 | 0 | 1 |
| 0 | 1 | 1 | 1 | 0 |
| 1 | 0 | 0 | 0 | 1 |
| 1 | 0 | 1 | 1 | 0 |
| 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 1 |
--
-- A simple 1-bit full adder that can be utilized within
-- larger n-bit adders
--
-- Created: Winter 2022
-- Author: Kevin Cloutier <kevincloutier@mac.com>
--
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library riscv;
use riscv.riscv_pkg.all;
library riscv;
entity full_adder is
Port (
-- INPUTS
i_a : in std_logic;
i_b : in std_logic;
i_cin : in std_logic;
-- OUTPUTS
o_sum : out std_logic;
o_cout : out std_logic
);
end full_adder;
architecture full_adder_arch of full_adder is
signal w_and_1 : std_logic := '0';
signal w_and_2 : std_logic := '0';
signal w_xor_1 : std_logic := '0';
begin
--**********************************************************
-- COMPONENT INSTANTIATION
--**********************************************************
xor_1: entity riscv.xor_gate
port map(
-- IN
i_a => i_a,
i_b => i_b,
-- OUT
o_y => w_xor_1
);
and_1: entity riscv.and_gate
port map(
-- IN
i_a => i_a,
i_b => i_b,
-- OUT
o_y => w_and_1
);
xor_2: entity riscv.xor_gate
port map(
--IN
i_a => w_xor_1,
i_b => i_cin,
-- OUT
o_y => o_sum -- SUM
);
and_2: entity riscv.and_gate
port map(
--IN
i_a => w_xor_1,
i_b => i_cin,
-- OUT
o_y => w_and_2
);
or_1: entity riscv.or_gate
port map(
--IN
i_a => w_and_1,
i_b => w_and_2,
-- OUT
o_y => o_cout -- CARRY OUT
);
end full_adder_arch;
GHDL Simulation Waveform
FPGA Synthesis & Utilization
LUTs / ALUTs
1 (2-input LUT)
Registers (FF)
0 (Combinational)
Logic Depth
1 Level
I/O Pins
3 (2 in, 1 out)