1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
masha68 [24]
3 years ago
6

Develop a testbench for the Half Adder that verifies the structural model. The testbench will have no ports. Your testbench shou

ld exhaustively stimulate the circuit and print output demonstrating that the model is correct. Text output can be generated using the $monitor and $display tasks.
Social Studies
1 answer:
Fynjy0 [20]3 years ago
8 0

Answer and Explanation:

--        Here we define the AND gate that we need for

-- the Half Adder

library 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;

--        Here we define the XOR gate that we need for

-- the Half Adder

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;

-- At this point we construct the half adder using

-- the AND and XOR gates

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 -- import AND Gate

     port( A, B : in std_logic;

              F : out std_logic);

  end component;

component xorGate is -- import XOR Gate

    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;

---------------------------------------------------------END

---------------------------------------------------------END

Test Bench:

--import std_logic from the IEEE library

library ieee;

use ieee.std_logic_1164.all;

entity halfAdder_tb is

end halfAdder_tb;

architecture tb of halfAdder_tb is

component halfAdder is

    port( A, B : in std_logic;

      sum, Cout : out std_logic);

  end component;

signal A, B, sum, Cout: std_logic;

begin

  mapping: halfAdder port map(A, B, sum, Cout);

  process

  variable errCnt : integer := 0;

  begin

--TEST 1

  A <= '0';

    B <= '1';

    wait for 10 ns;

    assert(sum = '1') report "sum error 1" severity error;

    assert(Cout = '0') report "Cout error 1" severity error;

    if(sum /= '1' or Cout /= '0') then

       errCnt := errCnt + 1;

    end if;

--TEST 2

  A <= '1';

    B <= '1';

    wait for 10 ns;

    assert(sum = '0') report "sum error 2" severity error;

    assert(Cout = '1') report "Cout error 2" severity error;

    if(sum /= '0' or Cout /= '1') then

       errCnt := errCnt + 1;

    end if;

--TEST 3

  A <= '1';

    B <= '0';

    wait for 10 ns;

    assert(sum = '1') report "sum error 3" severity error;

    assert(Cout = '0') report "Cout error 3" severity error;

    if(sum /= '1' or Cout /= '0') then

        errCnt := errCnt + 1;

    end if;

---- SUMMARY ----

    if(errCnt = 0) then

      assert false report "Success!" severity note;

    else

       assert false report "Faillure!" severity note;

    end if;

end process;

end tb;

-------------------------------------------------------------

configuration cfg_tb of halfAdder_tb is

  for tb

  end for;

end cfg_tb;

----------------------------------------------------------END

----------------------------------------------------------END

You might be interested in
What was the effect of the pilgrimage to Mecca
s344n2d4d5 [400]
The pilgrimage to Mecca is also known as Hajj. This is a religious even that every muslim man and women have to do at least once in their life.

The effect of going there could be finding a spiritiual attachment to god. Also by going for Hajj, all of your bad sins are erased.

Hope that helps :)
4 0
3 years ago
Read 2 more answers
Does costco executive membership provide roadside assistance
mr_godi [17]
Costco insurance coverages

Roadside Assistance and Towing: Covers costs of roadside assistance, like when you have a dead battery, lock your keys in your car or get a flat tire. It covers up to $75 per incident, and it's included if you have a Costco Executive Membership.
7 0
2 years ago
Which part of this region receives the most rain in asia
padilas [110]
Mawsynram, situated on the southern slopes of the Eastern Himalayas in Shillong, India, is one of the wettest places on Earth.
4 0
2 years ago
What determines the number of presidential electors for a state ?
aniked [119]

Each State is allocated a number of Electors equal to the number of its U.S. Senators (always 2) plus the number of its U.S. Representatives (which may change each decade according to the size of each State's population as determined in the Census).

4 0
3 years ago
2 of the secrets revolutionary groups in Russia
sdas [7]
Two secret revolutionary groups in Russia was the Nihilists and the Populists. 
8 0
3 years ago
Other questions:
  • Ichard had lived on the street for almost a year. his days were busy with doing things necessary to survive at a basic level-fin
    5·2 answers
  • Which term describes the construction on stage that suggests the time and place of the action?
    5·2 answers
  • Which option identifies why Luke was told he could not help in the following scenario? Luke, a psychologist, wanted to help anal
    13·1 answer
  • Read the summary.The earliest humans originated in northern Europe (1) and traveled south via land bridges to Asia and Africa (2
    10·1 answer
  • When two or more elements bond together In specific proportions is formed
    13·1 answer
  • Atlanta, Augusta, Columbus, and Macon can all be classified as being a part of which Georgia?
    15·2 answers
  • PLEASE HELP!!!!! (30 POINTS)
    15·2 answers
  • According to shermer, why do people believe in “weird things”?
    6·1 answer
  • The curriculum director for a school district is making arrangements to bring the works of Shakespeare into the school district.
    5·1 answer
  • Based on what you know
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!