Skip to content
Snippets Groups Projects
dampfmascine_tb.vhd 4.26 KiB
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
use IEEE.NUMERIC_STD.ALL;
--  A testbench has no ports.
entity dampfmascine_tb is
end dampfmascine_tb;

architecture behav of dampfmascine_tb is
  --  Declaration of the component that will be instantiated.
  component dampfmascine
    port (takt : in STD_LOGIC;
           pwm : in  STD_LOGIC_VECTOR (3 downto 0);
           led : out  STD_LOGIC);
  end component;
  --  Specifies which entity is bound with the component.
  for dampfmascine_0: dampfmascine use entity work.dampfmascine;
  signal takt,led : STD_LOGIC;
  signal pwm : STD_LOGIC_VECTOR (3 downto 0);
begin
  --  Component instantiation.
  dampfmascine_0: dampfmascine port map (takt => takt, pwm => pwm,
                                         led => led);
  
  --  This process does the real job.
  process
    type pattern_type is record
      --  The inputs of the adder.
      takt : STD_LOGIC;
      pwm  : STD_LOGIC_VECTOR (3 downto 0);
      --  The expected outputs of the adder.
      led  : STD_LOGIC;

    end record;
    --  The patterns to apply.
    type pattern_array is array (natural range <>) of pattern_type;
    constant patterns : pattern_array :=
      (('0', "0000", '0'),
       ('1', "0000", '0'),
       ('0', "0000", '0'),
       ('1', "0000", '0'),
       ('0', "0000", '0'),
       ('1', "0000", '0'),
       ('0', "0000", '0'),
       ('1', "0000", '0'),
       ('0', "0000", '0'),
       ('1', "0000", '0'),
       ('0', "0000", '0'),
       ('1', "0000", '0'),
       ('0', "0000", '0'),
       ('1', "0000", '0'),
       ('0', "0000", '0'),
       ('1', "0000", '0'),
       ('0', "0000", '0'),
       ('1', "0000", '0'),
       ('0', "0000", '0'),
       ('1', "0000", '0'),
       ('0', "0000", '0'),
       ('1', "0000", '0'),
       ('0', "0000", '0'),
       ('1', "0000", '0'),
       ('0', "0000", '0'),
       ('1', "0000", '0'),
       ('0', "0000", '0'),
       ('1', "0000", '0'),
       ('0', "0000", '0'),
       ('1', "0000", '0'),
       ('0', "0000", '0'),
       ('1', "0000", '0'),
       ('0', "0111", '0'),
       ('1', "0111", '1'),
       ('0', "0111", '1'),
       ('1', "0111", '1'),
       ('0', "0111", '1'),
       ('1', "0111", '1'),
       ('0', "0111", '1'),
       ('1', "0111", '1'),
       ('0', "0111", '1'),
       ('1', "0111", '1'),
       ('0', "0111", '1'),
       ('1', "0111", '1'),
       ('0', "0111", '1'),
       ('1', "0111", '1'),
       ('0', "0111", '1'),
       ('1', "0111", '0'),
       ('0', "0111", '0'),
       ('1', "0111", '0'),
       ('0', "0111", '0'),
       ('1', "0111", '0'),
       ('0', "0111", '0'),
       ('1', "0111", '0'),
       ('0', "0111", '0'),
       ('1', "0111", '0'),
       ('0', "0111", '0'),
       ('1', "0111", '0'),
       ('0', "0111", '0'),
       ('1', "0111", '0'),
       ('0', "0111", '0'),
       ('1', "0111", '0'),
       ('0', "0111", '0'),
       ('1', "0111", '0'),
       ('0', "1111", '0'),
       ('1', "1111", '1'),
       ('0', "1111", '1'),
       ('1', "1111", '1'),
       ('0', "1111", '1'),
       ('1', "1111", '1'),
       ('0', "1111", '1'),
       ('1', "1111", '1'),
       ('0', "1111", '1'),
       ('1', "1111", '1'),
       ('0', "1111", '1'),
       ('1', "1111", '1'),
       ('0', "1111", '1'),
       ('1', "1111", '1'),
       ('0', "1111", '1'),
       ('1', "1111", '1'),
       ('0', "1111", '1'),
       ('1', "1111", '1'),
       ('0', "1111", '1'),
       ('1', "1111", '1'),
       ('0', "1111", '1'),
       ('1', "1111", '1'),
       ('0', "1111", '1'),
       ('1', "1111", '1'),
       ('0', "1111", '1'),
       ('1', "1111", '1'),
       ('0', "1111", '1'),
       ('1', "1111", '1'),
       ('0', "1111", '1'),
       ('1', "1111", '1'),
       ('0', "1111", '1'),
       ('1', "1111", '0'));
  begin
    --  Check each pattern.
    for i in patterns'range loop
      --  Set the inputs.
    takt <= patterns(i).takt;
    pwm <= patterns(i).pwm;
    --  Wait for the results.
    wait for 1 ns;
    --  Check the outputs.
    assert led = patterns(i).led
      report "bad led out value" severity error;
    end loop;
    assert false report "end of test" severity note;
    --  Wait forever; this will finish the simulation.
    wait;
  end process;
end behav;