Half Adder :
-----------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity half_adder is
port (
input1 : in std_logic;
input2 : in std_logic;
--
sum_out : out std_logic;
carry_out : out std_logic
);
end half_adder;
architecture arc_HA of half_adder is
begin
sum_out <= input1 xor input2;
carry_out <= input1 and input2;
end arc_HA;
----------------------------------------------------------------------------------------------------------------------
Full adder using Half adder code :
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity full_adder is
port (
input1 : in std_logic;
input2 : in std_logic;
carry_in : in std_logic;
--
sum_out : out std_logic;
carry_out : out std_logic
);
end full_adder;
architecture arc_FA of full_adder is
component half_adder is
port (
input1 : in std_logic;
input2 : in std_logic;
--
sum_out : out std_logic;
carry_out : out std_logic
);
signal cout_sig_1, cout_sig_1, sum_sig : std_logic ;
end component;
begin
U_fa1 : half_adder port map ( input1, carry_in, sum_sig,
cout_sig_1);
U_fa2 : half_adder port map ( input2, sum_sig, sum_out,
cout_sig_2);
assign carry_out = cout_sig_1 or cout_sig_2 ;
end arc_FA;
--------------------------------------------------------------------------------------------------------------------------------------------------
4 bit Full adder using Full adder code:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity fA_4bit is
port (
input1 : in std_logic_vector(3 downto 0);
input2 : in std_logic_vector(3 downto 0);
carry_in : in std_logic;
--
sum_out : out std_logic_vector(3 downto 0);
carry_out : out std_logic
);
end fA_4bit;
architecture arc_4bit_FA of fA_4bit is
component full_adder is
port (
input1 : in std_logic;
input2 : in std_logic;
carry_in : in std_logic;
--
sum_out : out std_logic;
carry_out : out std_logic
);
end component;
signal sum_out : std_logic_vector( 2 downto 0 ) ;
signal cout_sig : std_logic_vector ( 1 downto 0 );
end component;
begin
U_fa1 : full_adder port map ( input1(0), input2(0), '0',
sum_out(0), cout_sig(0) );
U_fa2 : full_adder port map ( input1(1), input2(1), cout_sig(0),
sum_out(1), cout_sig(1) );
U_fa3 : full_adder port map ( input1(2), input2(2), cout_sig(1),
sum_out(2), cout_sig(2) );
U_fa4 : full_adder port map ( input1(3), input2(3), cout_sig(2),
sum_out(3), carry_out );
end arc_4bit_FA;
----------------------------------------------------------------------------------------------------------------------------------------------
16bit Full adder using 4 bit full adder code :
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity fa_16bit is
port (
input1 : in std_logic_vector(15 downto 0);
input2 : in std_logic_vector(15 downto 0);
carry_in : in std_logic;
--
sum_out : out std_logic_vector(15 downto 0);
carry_out : out std_logic
);
end fa_16bit;
architecture arc_16bit_FA of fa_16bit is
component fA_4bit is
port (
input1 : in std_logic_vector(3 downto 0);
input2 : in std_logic_vector(3 downto 0);
carry_in : in std_logic;
--
sum_out : out std_logic_vector(3 downto 0);
carry_out : out std_logic
);
end component;
signal sum_out : std_logic_vector( 2 downto 0 ) ;
signal cout_sig : std_logic_vector ( 1 downto 0 );
end component;
begin
U_16fa1 : fA_4bit port map ( input1(3 downto 0), input2(3 downto
0), '0', sum_out(3 downto 0), cout_sig(0) );
U_16fa2 : fA_4bit port map ( input1(7 downto 4), input2(7 downto
4), cout_sig(0), sum_out(7 downto 4), cout_sig(1) );
U_16fa3 : fA_4bit port map ( input1(11 downto 8), input2(11 downto
8), cout_sig(1), sum_out(11 downto 8), cout_sig(2) );
U_16fa4 : fA_4bit port map ( input1(15 downto 12), input2(15 downto
12), cout_sig(2), sum_out(15 downto 12), carry_out );
end arc_16bit_FA;
----------------------------------------------------------------------------------------------------------------
Test bench code for 16 bit adder :
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity test_bench is
end test_bench;
architecture behave of test_bench is
signal tb_in1, tb_in2, tb_sum_out : std_logic_vector(15 downto
0);
signal tb_carry_in, tb_carry_out : std_logic ;
component fa_16bit is
port (
input1 : in std_logic_vector(15 downto 0);
input2 : in std_logic_vector(15 downto 0);
carry_in : in std_logic;
--
sum_out : out std_logic_vector(15 downto 0);
carry_out : out std_logic
);
end component;
begin
UU : fa_16bit port map ( tb_in1, tb_in2, tb_carry_in, tb_sum_out,
tb_carry_out );
process is
begin
tb_in1 <= "0000";
tb_in2 <= "0000";
tb_carry_in <= '0';
wait for 10 ns;
tb_in1 <= "0010";
tb_in2 <= "1111";
tb_carry_in <= '0';
wait for 10 ns;
tb_in1 <= "0010";
tb_in2 <= "1101";
tb_carry_in <= '0';
wait for 10 ns;
tb_in1 <= "0001";
tb_in2 <= "1111";
tb_carry_in <= '0';
wait for 10 ns;
end process;
end behave;
-----------------------------------------------------------------------------------------------
by using VIVADO , design 16 bit adder ( code + Testbench) - half adder - full adder using half adder - 4 bit adder using full adder -16 bit adder using 4 bit adder
Design an 8-bit full adder using Verilog (Use only 1-bit full adders). Write the design code, test-bench code of it, and test your design with six inputs. Note: Only use Verilog to design 8-bit full adder.
Design and Test an 8-bit Adder using 4-bit adder. Use 4-bit adder coded in class using full adder that is coded using data flow model. Use test bench to test 8-bit adder and consider at least five different test vectors to test it.
WRITE IN SYSTEM VERILOG: Using your preferred HDL program, design a complete 4-bit Carry Look Ahead (CLA) adder module. Then write a testbench to check its functionality C2. Using your preferred HDL program, design a complete 4-bit Carry Look Ahead (CLA) adder module. Then write a testbench to check its functionality C2.
design a 2-bit binary multiplier using only nands and a 4 bit binary full adder. draw out the diagram and truth table.
Use a "For generate" statement to design a 8 bit structural adder using full adders. Using hierarchical design, assume you have a functional full adder and declare a component "FA" for the full adder.
Design a 4-bit grey code adder. b) The adder has three components: two 4-bit grey-to-binary converters, a 4-bit binary adder, and a 5-bit binary-to-grey code convertor. c) Model this design with SV as a combinational block. d) Write one test bench to verify the SV model. it will receive a grey input that then will be converter into binary to be added then out putting from binary back to gray
4. Design a 4-bit Adder / Subtractor. Follow the steps given below. (a) Write the VHDL code for a 1-bit Full Adder. The VHDL code must include an entity and an architecture. (b) Draw the circuit diagram for a 4-bit Adder / Subtractor. The circuit diagram may include the following logic elements: 1-bit Full Adders (shown as a block with inputs and outputs) Any 2-input logic gates Multiplexers Do not draw the logic circuit for the 1-bit Full Adder.
WRITE IN SYSTEM VERILOG: Using your preferred HDL program (specifv, do not mix), write code for the following modules: i) a 1-bit half adder (HA). ii) a 1-bit full adder (FA) using the above HA a an OR gate. iii) a testbench to check complete functionality of the above FA. C2. Using your preferred HDL program (specifv, do not mix), write code for the following modules: i) a 1-bit half adder (HA). ii) a 1-bit full adder (FA) using the...
Implement Full adder using 8 times 1 multiplexer. Implement Full adder using 4 times 1 multiplexer. Show the Implementation adding two (4-bit numbers) using full adders. What is the main difference between pulse-trigger, positive-edge trigger and negative-edge trigger D Flip-flop? Design and implement a sequential circuit that can detect the code "111"with repetition. Show the state diagram, stale table and the circuit.
Write the Verilog HDL textfixture stimulus code for an 4 bit binary full adder