Question

In: Electrical Engineering

Create a 4-bit full adder design using VHDL in vivado 2017.2. Project description: You need to...

Create a 4-bit full adder design using VHDL in vivado 2017.2.

Project description: You need to create a vhd file for the four-bit full adder.

Note: Instead of using bit, please use std_logic; instead of using bit_vector, please use std_logic_vector.

One simulation source is required, i.e. testbench

Please don't write out on paper. Code written out in text or screen shots would be very much apprecitated.

Solutions

Expert Solution

andGate.vhd:

ibrary ieee;

use ieee.std_logic_1164.all;

entity andGate is

port( A, B : in std_logic;

F : out std_logic);

end andGate;

architecture func of andGate is

begin

F <= A and B;

end func;

xorGate.vhd:

library ieee;

use ieee.std_logic_1164.all;

entity xorGate is

port( A, B : in std_logic;

F : out std_logic);

end xorGate;

architecture func of xorGate is

begin

F <= A xor B;

end func;

orGate.vhd :

library ieee;

use ieee.std_logic_1164.all;

entity orGate is

port( A, B : in std_logic;

F : out std_logic);

end orGate;

architecture func of orGate is

begin

F <= A or B;

end func;

halfAdder.vhd:

library ieee;

use ieee.std_logic_1164.all;

entity halfAdder is

port( A, B : in std_logic;

sum, Cout : out std_logic);

end halfAdder;

architecture halfAdder of halfAdder is

component andGate is

port( A, B : in std_logic;

F : out std_logic);

end component;

component xorGate is

port( A, B : in std_logic;

F : out std_logic);

end component;

begin

G1 : xorGate port map(A, B, sum);

G2 : andGate port map(A, B, Cout);

end halfAdder;

fullAdder.vhd:

library ieee;

use ieee.std_logic_1164.all;

entity fullAdder is

port( A, B, Cin : in std_logic;

sum, Cout : out std_logic);

end fullAdder;

architecture fullAdder of fullAdder is

component halfAdder is

port( A, B : in std_logic;

sum, Cout : out std_logic);

end component;

component orGate is

port( A, B : in std_logic;

F : out std_logic);

end component;

signal halfTohalf, halfToOr1, halfToOr2: std_logic;

begin

G1: halfAdder port map(A, B, halfTohalf, halfToOr1);

G2: halfAdder port map(halfTohalf, Cin, sum, halfToOr2);

G3: orGate port map(halfToOr1, halfToOr2, Cout);

end fullAdder;


fullAdder_tb.vhd:

library ieee;
use ieee.std_logic_1164.all;

entity fullAdder_tb is
end fullAdder_tb;

architecture tb of fullAdder_tb is

component fullAdder is
port( A, B, Cin : in std_logic;
sum, Cout : out std_logic);
end component;

signal A, B, Cin, sum, Cout : std_logic;

begin
mapping: fullAdder port map(A, B, Cin, sum, Cout);

--concurrent processes
process
begin
Cin <= '0'; wait for 5 ns;
Cin <= '1'; wait for 5 ns;
end process;

process
variable errCnt : integer := 0;
begin


A <= '0';
B <= '1';
wait for 10 ns;
assert(sum = '0') report "Error in Sum" severity error;
assert(Cout = '1') report "Error in Cout" severity error;
if(sum /= '1' or Cout /= '0') then
errCnt := errCnt + 1;
end if;


A <= '1';
B <= '1';
wait for 10 ns;
assert(sum = '1') report "Error in Sum" severity error;
assert(Cout = '1') report "Error in Cout" severity error;
if(sum /= '0' or Cout /= '1') then
errCnt := errCnt + 1;
end if;


A <= '1';
B <= '0';
wait for 10 ns;
assert(sum = '0') report "Error in Sum" severity error;
assert(Cout = '1') report "Error in Cout" severity error;
if(sum /= '1' or Cout /= '0') then
errCnt := errCnt + 1;
end if;


if(errCnt = 0) then
assert false report " Testing is successful as no error occurred " severity note;
else
assert false report "Testing is not successful as errors occurred" severity note;
end if;

end process;
end tb;

configuration cfg_tb of fullAdder_tb is
for tb
end for;
end cfg_tb;


Related Solutions

Design a 4-bit multiplier by using 4 bit full adder and write a verilog code.
Design a 4-bit multiplier by using 4 bit full adder and write a verilog code.
Design and Test an 8-bit Adder using 4-bit adder. Use 4-bit adder coded in class using...
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.
Design a 32 bit adder using a single 4 bit adder using verilog code
Design a 32 bit adder using a single 4 bit adder using verilog code
I want VHDL program and testbench program for 4 bit binary full adder with fast carry...
I want VHDL program and testbench program for 4 bit binary full adder with fast carry using behavioral and structural style modling (ls7483)
design full adder using 4:1 mux
design full adder using 4:1 mux
Design and implementation 4-bit binary full adder with fast carry using behavioral and structural style of...
Design and implementation 4-bit binary full adder with fast carry using behavioral and structural style of modelling. (LS 7483) I want logic diagram and its truth table also i want code for it in VDHL software
Design and implementation 4-bit binary full adder with fast carry using behavioral and structural style of...
Design and implementation 4-bit binary full adder with fast carry using behavioral and structural style of modelling. (LS 7483) i want logic diagram and truth table
Problem 3.73 (1-bit full adder using carry lookahead – gate level circuit) 3.73 Design a 4-bit...
Problem 3.73 (1-bit full adder using carry lookahead – gate level circuit) 3.73 Design a 4-bit full adder using carry look-ahead rather than ripple carry.
Using Behavorial VHDL, design a 4-bit up/down counter.
Using Behavorial VHDL, design a 4-bit up/down counter.
Using the following VHDL code for an 8 bit adder, make the sum be displayed on...
Using the following VHDL code for an 8 bit adder, make the sum be displayed on the seven segment display of an Elbert V2 Spartan 3A FPGA Board. VHDL: library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity state_bit_adder is Port ( clk : in STD_LOGIC; reset : in STD_LOGIC;            D : in STD_LOGIC;            Enable : out STD_LOGIC_vector (2 downto 0);            input: in std_logic_vector(7 downto 0);            SUM: out...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT