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.

80 lines
2.0 KiB

  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.numeric_std.all;
  4. library libvhdl;
  5. use libvhdl.AssertP.all;
  6. use libvhdl.QueueP.all;
  7. entity QueueT is
  8. end entity QueueT;
  9. architecture sim of QueueT is
  10. constant C_QUEUE_DEPTH : natural := 64;
  11. shared variable sv_simple_queue : t_simple_queue;
  12. shared variable sv_list_queue : t_list_queue;
  13. begin
  14. QueueInitP : process is
  15. begin
  16. sv_list_queue.init(C_QUEUE_DEPTH);
  17. wait;
  18. end process QueueInitP;
  19. SimpleQueueTestP : process is
  20. variable v_data : std_logic_vector(63 downto 0);
  21. begin
  22. -- check initial emptiness
  23. assert_true(sv_simple_queue.is_empty, "Queue should be empty!");
  24. for i in 0 to 63 loop
  25. sv_simple_queue.push(std_logic_vector(to_unsigned(i, 64)));
  26. end loop;
  27. -- check that it's full
  28. assert_true(sv_simple_queue.is_full, "Queue should be full!");
  29. -- empty the queue
  30. for i in 0 to 63 loop
  31. sv_simple_queue.pop(v_data);
  32. assert_equal(v_data, std_logic_vector(to_unsigned(i, 64)));
  33. end loop;
  34. -- check emptiness
  35. assert_true(sv_simple_queue.is_empty, "Queue should be empty!");
  36. report "INFO: t_simple_queue test finished successfully";
  37. wait;
  38. end process SimpleQueueTestP;
  39. ListQueueTestP : process is
  40. variable v_data : std_logic_vector(7 downto 0);
  41. begin
  42. -- check initial emptiness
  43. assert_true(sv_list_queue.is_empty, "Queue should be empty!");
  44. for i in 0 to C_QUEUE_DEPTH-1 loop
  45. sv_list_queue.push(std_logic_vector(to_unsigned(i, 8)));
  46. end loop;
  47. -- check that it's full
  48. assert_true(sv_list_queue.is_full, "Queue should be full!");
  49. -- empty the queue
  50. for i in 0 to C_QUEUE_DEPTH-1 loop
  51. sv_list_queue.pop(v_data);
  52. assert_equal(v_data, std_logic_vector(to_unsigned(i, 8)));
  53. end loop;
  54. -- check emptiness
  55. assert_true(sv_list_queue.is_empty, "Queue should be empty!");
  56. report "INFO: t_list_queue test finished successfully";
  57. wait;
  58. end process ListQueueTestP;
  59. end architecture sim;