Question

In: Electrical Engineering

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.
in behavioral not endmodule

plz help me

Solutions

Expert Solution

--VHDL top level CODE for 8 bit adder using two 4 bit adders

library IEEE;

use IEEE.STD_LOGIC_1164.ALL;

--entity declaration for 8 bit adder

entity Adder_8bit is

Port ( A : in STD_LOGIC_VECTOR (7 downto 0);

B : in STD_LOGIC_VECTOR (7 downto 0);

Cin : in STD_LOGIC;

S : out STD_LOGIC_VECTOR (7 downto 0);

Cout : out STD_LOGIC);

end Adder_8bit;

--archiecture declaration for 8 bit adder

architecture Behavioral of Adder_8bit is

-- 4 bit Adder VHDL Code Component Decalaration

component Adder_4bit

Port ( A : in STD_LOGIC_VECTOR (3 downto 0);

B : in STD_LOGIC_VECTOR (3 downto 0);

Cin : in STD_LOGIC;

S : out STD_LOGIC_VECTOR (3 downto 0);

Cout : out STD_LOGIC);

end component;

-- Intermediate Carry siganl declaration

signal C1: STD_LOGIC;

begin

-- Port Mapping 4bit Adder with insatntiations

FA1_4: Adder_4bit port map( A(3 downto 0), B(3 downto 0), Cin, S(3 downto 0), C1);

FA2_4: Adder_4bit port map( A(7 downto 4), B(7 downto 4), C1, S(7 downto 4),Cout);

end Behavioral;

--VHDL code for 4 bit full adder using 1 bit full adders

library IEEE;

use IEEE.STD_LOGIC_1164.ALL;

--entity declaration for 4 bit adder

entity Adder_4bit is

Port ( A : in STD_LOGIC_VECTOR (3 downto 0);

B : in STD_LOGIC_VECTOR (3 downto 0);

Cin : in STD_LOGIC;

S : out STD_LOGIC_VECTOR (3 downto 0);

Cout : out STD_LOGIC);

end Adder_4bit;

--architecture declaration for 4 bit adder

architecture Behavioral of Adder_4bit is

-- Full Adder VHDL Code Component Decalaration

component full_adder_vhdl_code

Port ( A : in STD_LOGIC;

B : in STD_LOGIC;

Cin : in STD_LOGIC;

S : out STD_LOGIC;

Cout : out STD_LOGIC);

end component;

-- Intermediate Carry declaration

signal c1,c2,c3: STD_LOGIC;

begin

-- Instantiating (Port Mapping) Full Adder 4 times

FA1: full_adder_vhdl_code port map( A(0), B(0), Cin, S(0), c1);

FA2: full_adder_vhdl_code port map( A(1), B(1), c1, S(1), c2);

FA3: full_adder_vhdl_code port map( A(2), B(2), c2, S(2), c3);

FA4: full_adder_vhdl_code port map( A(3), B(3), c3, S(3), Cout);

end Behavioral;

-- VHDL CODE for full adder

Library IEEE;

use IEEE.std_logic_1164.all;

--entity declrartion for full adder

entity full_adder_vhdl_code is

port(

A,B ,Cin: in std_logic;

S, Cout: out std_logic);

end full_adder_vhdl_code;

--architecture behavorial declaration for full adder

architecture behavioral of full_adder_vhdl_code is

begin

--sum logic

S<=A xor B xor Cin;

-- carry logic

Cout<=((A xor B) and Cin) or (A and B);

end behavioral;

-- VHDL testbench code for 8 bit adder

library IEEE;

use IEEE.STD_LOGIC_1164.ALL;

--entity declaartion for testbench

entity Adder_test is

end Adder_test;

--architecture declaration for testbench

architecture behavioral of Adder_test is

--component declaration for 8 bit adder

component Adder_8bit is

Port ( A : in STD_LOGIC_VECTOR (7 downto 0);

B : in STD_LOGIC_VECTOR (7 downto 0);

Cin : in STD_LOGIC;

S : out STD_LOGIC_VECTOR (7 downto 0);

Cout : out STD_LOGIC);

end component;

--inputs and output signals

signal A,B,S : std_logic_vector (7 downto 0);

signal Cin,Cout : std_logic;

begin

--instantiate UUT of 8 bit adder

DUT : Adder_8bit port map (A=>A,B=>B,Cin=>Cin,S=>S,Cout=>Cout);

  

--input stimulus geneartion

stim_proc:process

begin

A <= "10101010";

B <= "01010101";

Cin <= '0';

wait for 10 ns;

  

A <= "10100000";

B <= "00000101";

Cin <= '0';

wait for 10 ns;

A <= "00100100";

B <= "00010101";

Cin <= '0';

wait for 10 ns;

A <= "00000000";

B <= "11000101";

Cin <= '0';

wait for 10 ns;

  

A <= "00000111";

B <= "11000101";

Cin <= '1';

wait for 10 ns;

  

A <= "11111111";

B <= "01010000";

Cin <= '1';

wait ;

  

end process;

end behavioral;

-- simulation waveforms


Related Solutions

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
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 an 8-bit adder. Show Verilog code and testbench.
Design an 8-bit adder. Show Verilog code and testbench.
Design of 4 Bit Adder/Subtractor using Loops (Behavior Modeling Style) (verilog Code) -
Design of 4 Bit Adder/Subtractor using Loops (Behavior Modeling Style) (verilog Code) -
write a verilog code for a 4-bit multiplier by using 4 bit full adder
write a verilog code for a 4-bit multiplier by using 4 bit full adder
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.
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
Implement 4-bit binary adder/subtractor using gate level. ( verilog code and test bench)
Implement 4-bit binary adder/subtractor using gate level. ( verilog code and test bench)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT