Design and Simulation of Full Adder Using Vhdl
VHDL code for Full Adder
In this VHDL project, VHDL code for full adder is presented. VHDL code for the adder is implemented by using behavioral and structural models.
The full adder has three inputs X1, X2, Carry-In Cin and two outputs S, Carry-Out Cout as shown in the following figure:
The VHDL code for the full adder using the structural model:
-- fpga4student.com -- FPGA projects, VHDL projects, Verilog projects -- VHDL code for full adder -- Structural code for full adder library ieee; use ieee.std_logic_1164.all ; entity Full_Adder_Structural_VHDL is port( X1, X2, Cin : in std_logic; S, Cout : out std_logic ); end Full_Adder_Structural_VHDL ; architecture structural of Full_Adder_Structural_VHDL is signal a1, a2, a3: std_logic; begin a1 <= X1 xor X2; a2 <= X1 and X2; a3 <= a1 and Cin; Cout <= a2 or a3; S <= a1 xor Cin; end structural ; Library IEEE; USE IEEE.Std_logic_1164.all ; -- fpga4student.com -- FPGA projects, VHDL projects, Verilog projects -- VHDL code for full adder -- Testbench code of the structural code for full adder entity Testbench_structural_adder is end Testbench_structural_adder ; architecture behavioral of Testbench_structural_adder is component Full_Adder_Structural_VHDL port( X1, X2, Cin : in std_logic; S, Cout : out std_logic ); end component ; signal A,B,Cin: std_logic:=' 0 '; signal S,Cout: std_logic; begin structural_adder: Full_Adder_Structural_VHDL port map ( X1 => A, X2 => B, Cin => Cin, S => S, Cout => Cout ); process begin A <= ' 0 '; B <= ' 0 '; Cin <= ' 0 '; wait for 100 ns; A <= ' 0 '; B <= ' 0 '; Cin <= ' 1 '; wait for 100 ns; A <= ' 0 '; B <= ' 1 '; Cin <= ' 0 '; wait for 100 ns; A <= ' 0 '; B <= ' 1 '; Cin <= ' 1 '; wait for 100 ns; A <= ' 1 '; B <= ' 0 '; Cin <= ' 0 '; wait for 100 ns; A <= ' 1 '; B <= ' 0 '; Cin <= ' 1 '; wait for 100 ns; A <= ' 1 '; B <= ' 1 '; Cin <= ' 0 '; wait for 100 ns; A <= ' 1 '; B <= ' 1 '; Cin <= ' 1 '; wait for 100 ns; end process ; end behavioral ;
Simulation waveform of the structural VHDL code for the full adder:
The VHDL code for the full adder using the behavioral model:
-- fpga4student.com -- FPGA projects, VHDL projects, Verilog projects -- VHDL code for full adder -- Behavioral code for full adder library ieee; use ieee.std_logic_1164.all; use IEEE.STD_LOGIC_unsigned.ALL; use IEEE.NUMERIC_STD.ALL; entity Full_Adder_Behavioral_VHDL is port( X1, X2, Cin : in std_logic; S, Cout : out std_logic ); end Full_Adder_Behavioral_VHDL; architecture Behavioral of Full_Adder_Behavioral_VHDL is signal tmp: std_logic_vector(1 downto 0); begin process(X1,X2,Cin) begin tmp <= ('0'& X1) + ('0'& X2) +('0'& Cin) ; end process; S <= tmp(0); Cout <= tmp(1); end Behavioral; Library IEEE; USE IEEE.Std_logic_1164.all; -- fpga4student.com -- FPGA projects, VHDL projects, Verilog projects -- VHDL code for full adder -- Testbench code of the behavioral code for full adder entity Testbench_behavioral_adder is end Testbench_behavioral_adder; architecture behavioral of Testbench_behavioral_adder is component Full_Adder_Behavioral_VHDL port( X1, X2, Cin : in std_logic; S, Cout : out std_logic ); end component; signal A,B,Cin: std_logic:='0'; signal S,Cout: std_logic; begin behavior_adder: Full_Adder_Behavioral_VHDL port map ( X1 => A, X2 => B, Cin => Cin, S => S, Cout => Cout ); process begin A <= '1'; B <= '1'; Cin <= '1'; wait for 50 ns; A <= '1'; B <= '1'; Cin <= '0'; wait for 50 ns; A <= '1'; B <= '0'; Cin <= '1'; wait for 50 ns; A <= '0'; B <= '0'; Cin <= '0'; wait for 50 ns; A <= '0'; B <= '0'; Cin <= '1'; wait for 50 ns; A <= '0'; B <= '1'; Cin <= '0'; wait for 50 ns; A <= '0'; B <= '1'; Cin <= '1'; wait for 50 ns; A <= '1'; B <= '0'; Cin <= '0'; wait for 50 ns; end process; end behavioral;
Simulation waveform of the behavioral VHDL code for the full adder:
Trending FPGA Projects
-
Last time , an Arithmetic Logic Unit ( ALU ) is designed and implemented in VHDL . Full VHDL code for the ALU was presented. Today, f...
-
D Flip-Flop is a fundamental component in digital logic circuits. Verilog code for D Flip Flop is presented in this project. There are t...
-
In this project, Verilog code for counters with testbench will be presented including up counter, down counter, up-down counter, and r...
-
This FPGA tutorial will guide you how to control the 4-digit seven-segment display on Basys 3 FPGA Board. A display controller will be ...
-
Last time , I wrote a full FPGA tutorial on how to control the 4-digit 7-segment display on Basys 3 FPGA. A full Verilog code for displayi...
-
VHDL code for D Flip Flop is presented in this project. Verilog code for D Flip Flop here . There are several types of D Flip Flops such ...
-
Arithmetic Logic Unit ( ALU ) is one of the most important digital logic components in CPUs. It normally executes logic and arithmetic op...
-
In this V erilog project , Verilog code for a 16-bit RISC processor is presented. The RISC processor is designed based on its instructi...
-
This Verilog project is to present a full Verilog code for Sequence Detector using Moore FSM . A Verilog Testbench for the Moore FSM sequ...
-
This FPGA project is aimed to show in details how to process an image using Verilog from reading an input bitmap image (.bmp) in Verilog...
Design and Simulation of Full Adder Using Vhdl
Source: https://www.fpga4student.com/2017/02/vhdl-code-for-full-adder.html
0 Response to "Design and Simulation of Full Adder Using Vhdl"
Postar um comentário