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.

152 lines
4.4 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 : in boolean);
  6. procedure assert_true (a : in boolean; str : in string);
  7. procedure assert_false (a : in boolean);
  8. procedure assert_false (a : in boolean; str : in string);
  9. procedure assert_equal (a : in integer; b : in integer);
  10. procedure assert_equal (a : in integer; b : in integer; str : in string);
  11. procedure assert_equal (a : in std_logic_vector; b : in std_logic_vector);
  12. procedure assert_equal (a : in std_logic_vector; b : in std_logic_vector; str : in string);
  13. procedure assert_equal (a : in string; b : in string);
  14. procedure assert_equal (a : in string; b : in string; str : in string);
  15. procedure assert_unequal (a : in integer; b : in integer);
  16. procedure assert_unequal (a : in integer; b : in integer; str : in string);
  17. procedure assert_unequal (a : in std_logic_vector; b : in std_logic_vector);
  18. procedure assert_unequal (a : in std_logic_vector; b : in std_logic_vector; str : in string);
  19. procedure assert_unequal (a : in string; b : in string);
  20. procedure assert_unequal (a : in string; b : in string; str : in string);
  21. end package AssertP;
  22. package body AssertP is
  23. procedure assert_true (a : in boolean) is
  24. begin
  25. assert a
  26. report "FAILURE: a should be evaluate to true"
  27. severity failure;
  28. end procedure assert_true;
  29. procedure assert_true (a : in boolean; str : in string) is
  30. begin
  31. assert a
  32. report "FAILURE: " & str
  33. severity failure;
  34. end procedure assert_true;
  35. procedure assert_false (a : in boolean) is
  36. begin
  37. assert not(a)
  38. report "FAILURE: a should be evaluate to false"
  39. severity failure;
  40. end procedure assert_false;
  41. procedure assert_false (a : in boolean; str : in string) is
  42. begin
  43. assert not(a)
  44. report "FAILURE: " & str
  45. severity failure;
  46. end procedure assert_false;
  47. procedure assert_equal (a : in integer; b : in integer) is
  48. begin
  49. assert a = b
  50. report "FAILURE: " & integer'image(a) & " should be equal to " & integer'image(b)
  51. severity failure;
  52. end procedure assert_equal;
  53. procedure assert_equal (a : in integer; b : in integer; str : in string) is
  54. begin
  55. assert a = b
  56. report "FAILURE: " & str
  57. severity failure;
  58. end procedure assert_equal;
  59. procedure assert_equal (a : in std_logic_vector; b : in std_logic_vector) is
  60. begin
  61. assert a = b
  62. report "FAILURE: " & to_string(a) & " should be equal to " & to_string(b)
  63. severity failure;
  64. end procedure assert_equal;
  65. procedure assert_equal (a : in std_logic_vector; b : in std_logic_vector; str : in string) is
  66. begin
  67. assert a = b
  68. report "FAILURE: " & str
  69. severity failure;
  70. end procedure assert_equal;
  71. procedure assert_equal (a : in string; b : in string) is
  72. begin
  73. assert a = b
  74. report "FAILURE: " & a & " should be equal to " & b
  75. severity failure;
  76. end procedure assert_equal;
  77. procedure assert_equal (a : in string; b : in string; str : in string) is
  78. begin
  79. assert a = b
  80. report "FAILURE: " & str
  81. severity failure;
  82. end procedure assert_equal;
  83. procedure assert_unequal (a : in integer; b : in integer) is
  84. begin
  85. assert a /= b
  86. report "FAILURE: " & integer'image(a) & " should be unequal to " & integer'image(b)
  87. severity failure;
  88. end procedure assert_unequal;
  89. procedure assert_unequal (a : in integer; b : in integer; str : in string) is
  90. begin
  91. assert a /= b
  92. report "FAILURE: " & str
  93. severity failure;
  94. end procedure assert_unequal;
  95. procedure assert_unequal (a : in std_logic_vector; b : in std_logic_vector) is
  96. begin
  97. assert a /= b
  98. report "FAILURE: " & to_string(a) & " should be unequal to " & to_string(b)
  99. severity failure;
  100. end procedure assert_unequal;
  101. procedure assert_unequal (a : in std_logic_vector; b : in std_logic_vector; str : in string) is
  102. begin
  103. assert a /= b
  104. report "FAILURE: " & str
  105. severity failure;
  106. end procedure assert_unequal;
  107. procedure assert_unequal (a : in string; b : in string) is
  108. begin
  109. assert a /= b
  110. report "FAILURE: " & a & " should be unequal to " & b
  111. severity failure;
  112. end procedure assert_unequal;
  113. procedure assert_unequal (a : in string; b : in string; str : in string) is
  114. begin
  115. assert a /= b
  116. report "FAILURE: " & str
  117. severity failure;
  118. end procedure assert_unequal;
  119. end package body AssertP;