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.

153 lines
4.4 KiB

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