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.

68 lines
1.6 KiB

  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.numeric_std.all;
  4. --+ including vhdl 2008 libraries
  5. --+ These lines can be commented out when using
  6. --+ a simulator with built-in VHDL 2008 support
  7. --library ieee_proposed;
  8. -- use ieee_proposed.standard_additions.all;
  9. -- use ieee_proposed.std_logic_1164_additions.all;
  10. -- use ieee_proposed.numeric_std_additions.all;
  11. library osvvm;
  12. use osvvm.RandomPkg.all;
  13. library libvhdl;
  14. use libvhdl.AssertP.all;
  15. use libvhdl.StackP.all;
  16. entity StackT is
  17. end entity StackT;
  18. architecture sim of StackT is
  19. constant C_STACK_DEPTH : natural := 64;
  20. type t_scoreboard is array (natural range <>) of std_logic_vector(7 downto 0);
  21. shared variable sv_stack : t_stack;
  22. begin
  23. StackInitP : process is
  24. begin
  25. sv_stack.init(false);
  26. wait;
  27. end process StackInitP;
  28. StackTestP : process is
  29. variable v_data : std_logic_vector(7 downto 0);
  30. begin
  31. -- check initial emptiness
  32. assert_true(sv_stack.is_empty, "Stack should be empty!");
  33. for i in 0 to C_STACK_DEPTH-1 loop
  34. sv_stack.push(std_logic_vector(to_unsigned(i, 8)));
  35. end loop;
  36. -- check that it's full
  37. assert_equal(sv_stack.fillstate, C_STACK_DEPTH, "Stack should have" & integer'image(C_STACK_DEPTH) & "entries");
  38. -- empty the queue
  39. for i in C_STACK_DEPTH-1 downto 0 loop
  40. sv_stack.pop(v_data);
  41. assert_equal(v_data, std_logic_vector(to_unsigned(i, 8)));
  42. end loop;
  43. -- check emptiness
  44. assert_true(sv_stack.is_empty, "Stack should be empty!");
  45. report "INFO: t_stack test finished successfully";
  46. wait;
  47. end process StackTestP;
  48. end architecture sim;