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.

104 lines
2.8 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. library osvvm;
  7. use osvvm.RandomPkg.all;
  8. entity QueueT is
  9. end entity QueueT;
  10. architecture sim of QueueT is
  11. constant C_QUEUE_DEPTH : natural := 64;
  12. package SlvQueue is new libvhdl.QueueP
  13. generic map (
  14. QUEUE_TYPE => std_logic_vector(63 downto 0),
  15. MAX_LEN => C_QUEUE_DEPTH,
  16. to_string => to_hstring
  17. );
  18. shared variable sv_simple_queue : SlvQueue.t_simple_queue;
  19. shared variable sv_list_queue : SlvQueue.t_list_queue;
  20. begin
  21. QueueInitP : process is
  22. begin
  23. sv_simple_queue.init(false);
  24. sv_list_queue.init(false);
  25. wait;
  26. end process QueueInitP;
  27. SimpleQueueTestP : process is
  28. variable v_data : std_logic_vector(63 downto 0);
  29. variable v_random : RandomPType;
  30. begin
  31. -- check initial emptiness
  32. assert_true(sv_simple_queue.is_empty, "Queue should be empty!");
  33. -- Fill queue
  34. v_random.InitSeed(v_random'instance_name);
  35. for i in 0 to C_QUEUE_DEPTH-1 loop
  36. v_data := v_random.RandSlv(64);
  37. sv_simple_queue.push(v_data);
  38. end loop;
  39. -- check that it's full
  40. assert_true(sv_simple_queue.is_full, "Queue should be full!");
  41. -- Check number of entries
  42. assert_equal(sv_simple_queue.fillstate, C_QUEUE_DEPTH, "Queue should have" & integer'image(C_QUEUE_DEPTH) & "entries");
  43. -- empty the queue
  44. v_random.InitSeed(v_random'instance_name);
  45. for i in 0 to C_QUEUE_DEPTH-1 loop
  46. sv_simple_queue.pop(v_data);
  47. assert_equal(v_data, v_random.RandSlv(64));
  48. end loop;
  49. -- check emptiness
  50. assert_true(sv_simple_queue.is_empty, "Queue should be empty!");
  51. report "INFO: t_simple_queue test finished successfully";
  52. wait;
  53. end process SimpleQueueTestP;
  54. ListQueueTestP : process is
  55. variable v_data : std_logic_vector(63 downto 0);
  56. variable v_random : RandomPType;
  57. begin
  58. -- check initial emptiness
  59. assert_true(sv_list_queue.is_empty, "Queue should be empty!");
  60. -- Fill queue
  61. v_random.InitSeed(v_random'instance_name);
  62. for i in 0 to C_QUEUE_DEPTH-1 loop
  63. v_data := v_random.RandSlv(64);
  64. sv_list_queue.push(v_data);
  65. end loop;
  66. -- check that it's full
  67. assert_true(sv_list_queue.is_full, "Queue should be full!");
  68. -- Check number of entries
  69. assert_equal(sv_list_queue.fillstate, C_QUEUE_DEPTH, "Queue should have" & integer'image(C_QUEUE_DEPTH) & "entries");
  70. -- empty the queue
  71. v_random.InitSeed(v_random'instance_name);
  72. for i in 0 to C_QUEUE_DEPTH-1 loop
  73. sv_list_queue.pop(v_data);
  74. assert_equal(v_data, v_random.RandSlv(64));
  75. end loop;
  76. -- check emptiness
  77. assert_true(sv_list_queue.is_empty, "Queue should be empty!");
  78. report "INFO: t_list_queue test finished successfully";
  79. wait;
  80. end process ListQueueTestP;
  81. end architecture sim;