Library of reusable VHDL components
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.6 KiB

  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use work.StringP.all;
  4. package AssertP is
  5. procedure assert_equal (a : in integer; b : in integer);
  6. procedure assert_equal (a : in std_logic_vector; b : in std_logic_vector);
  7. procedure assert_equal (a : in string; b : in string);
  8. procedure assert_unequal (a : in integer; b : in integer);
  9. procedure assert_unequal (a : in std_logic_vector; b : in std_logic_vector);
  10. end package AssertP;
  11. package body AssertP is
  12. procedure assert_equal (a : in integer; b : in integer) is
  13. begin
  14. assert a = b
  15. report "FAILURE: " & integer'image(a) & " should be equal to " & integer'image(b)
  16. severity failure;
  17. end procedure assert_equal;
  18. procedure assert_equal (a : in std_logic_vector; b : in std_logic_vector) is
  19. begin
  20. assert a = b
  21. report "FAILURE: " & to_string(a) & " should be equal to " & to_string(b)
  22. severity failure;
  23. end procedure assert_equal;
  24. procedure assert_equal (a : in string; b : in string) is
  25. begin
  26. assert a = b
  27. report "FAILURE: " & a & " should be equal to " & b
  28. severity failure;
  29. end procedure assert_equal;
  30. procedure assert_unequal (a : in integer; b : in integer) is
  31. begin
  32. assert a /= b
  33. report "FAILURE: " & integer'image(a) & " should be unequal to " & integer'image(b)
  34. severity failure;
  35. end procedure assert_unequal;
  36. procedure assert_unequal (a : in std_logic_vector; b : in std_logic_vector) is
  37. begin
  38. assert a /= b
  39. report "FAILURE: " & to_string(a) & " should be unequal to " & to_string(b)
  40. severity failure;
  41. end procedure assert_unequal;
  42. end package body AssertP;