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
Which of the following BEST completes the blank line in diagram above?
lozanna [386]

Answer:

What is the diagram so I can help?

Explanation:

3 0
3 years ago
Read 2 more answers
John b. Watson believed that psychology should be the science of
inysia [295]
Watson believed that psychology should primarily be scientific observable behavior.
4 0
4 years ago
What type of vegetation is found in Central Africa?
777dan777 [17]
Many kinds of fruits. If u would like the names of these fruits, just look it up.
7 0
3 years ago
PLEASE HELP URGENT DO NOT WASTE ANSWERS WILL MARK BRAINLIEST
Oksi-84 [34.3K]
Inner-city schools hope this helps
6 0
3 years ago
Read 2 more answers
How do you think the Gilded Age and Progressive Era will change the country after Reconstruction?
ycow [4]

Answer: I think the Gilded Age and the Progressive Era change our country after Reconstruction by having the increase of production of iron and steel rising dramatically in the western as well like lumber, gold. The Progressive brought a lot urbanization to America demanding jobs and expansion to the west. Industrialization as well was a big factor for those who migrated providing jobs. Those who left west were granted land if they were able to maintain the land. Political machines as well to stop corruption that was lead from the Gilded Age with the monopolies and steel factories.

4 0
4 years ago
Other questions:
  • What does the term "Renaissance" mean?
    8·2 answers
  • When revenues are higher than expenditures in a budget, that budget
    8·2 answers
  • What conclusion do most americans draw because of their "grudging fairness"?
    15·1 answer
  • Logistic population growth patterns are indicative of what
    12·1 answer
  • The three-year-old class at Ms. Cherry's Preschool is getting ready to take a field trip to the local supermarket. While the two
    12·1 answer
  • HELP WANTED HELP WANTED!!!
    13·2 answers
  • In Christ, believers have both a sacrifice and a priest.<br> True<br> False
    10·1 answer
  • Yesssss mk please help-
    8·2 answers
  • Ano kasingkahulugan ng pagtitika?​
    10·1 answer
  • Susceptibility to peer pressure to become involved in antisocial behavior is at its highest level during?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!