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 describes a social contract as defined by Western philosophers in the 18th century?
Solnce55 [7]
<span>Social Contract is defined as the rights and obligations of citizens to the government.  This can be seen through the laws that people must obey when they are in a country.  In the 18th century, the concept of social contract is that man surrenders some of his freedom in exchange for the benefits and protection that the state provides.  Some state that it rises from natural law where people obey the government in exchange for the protection of their rights.  Still if the conditions imposed on them is unfair, then they have right to challenge those conditions.</span>
7 0
2 years ago
How did people who moved from the East to the West in the U.S. in the late 1800s adjust to conditions in their new homes?
Pachacha [2.7K]

Anwer:

ty for the pionts (sorry i didn't help i don't know the answer :( sorry)

Explanation:

3 0
3 years ago
Read 2 more answers
Why is the Netherlands vulnerable to changes in climate?
e-lub [12.9K]

Answer:

I believe it is D. Hope this helps!

Explanation:

4 0
3 years ago
McCarthyism Political Cartoons What is the car in this cartoon supposed to represent? How is the car running recklessly through
viktelen [127]

One of the most important events which happened during the McCarthyism is:

  • Accusations of communism based on mere suspicion and not through trial by law courts.

<h3>What is McCarthyism?</h3>

This referred to the period in American history when there was the fear of communism which brought about several accusations against people on the suspicion of being communists.

With this in full effect, this had adverse effects on many people as they were found guilty based on public opinion and this was led by Joseph McCarthy.

Please note that your question is incomplete so I gave you a general overview so that you can get a better understanding of the concept.

Read more about McCarthyism here:
brainly.com/question/613682

3 0
2 years ago
Please Help Thank You
kap26 [50]
Considering that iron has always been more common than gold, I don't think they would have first found it during what we now call "the golden age." It was probably more useful and impressive to them during the dark ages.
8 0
3 years ago
Read 2 more answers
Other questions:
  • Which beliefs are held by both Hindus and Buddhists choose three correct answers
    12·1 answer
  • The personal values of team members on high-performing teams can be enhanced through all of the following beneficial communicati
    13·1 answer
  • Explain how "walk-away power" can be used as a negotiating tool.
    5·1 answer
  • In a certain cave 2 bats could see out of the right eye, 3 could see out of the left eye, exactly 4 could not see out of the lef
    12·1 answer
  • How is genocide different from outright war
    6·1 answer
  • Which one was strictly ruled by the Motherland?
    11·1 answer
  • Why did the Dutch settle New York?
    12·2 answers
  • What does jonas learn about the child previously selected to become receiver of memory? your answer?
    6·1 answer
  • Black national consciousness has been generated in part by:
    13·1 answer
  • A nurse is having difficulty observing the rise and fall of a client's chest when assessing respirations. which action would be
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!