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.

78 lines
2.0 KiB

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