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.

85 lines
2.1 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.DictP.all;
  15. entity DictT is
  16. end entity DictT;
  17. architecture sim of DictT is
  18. type t_scoreboard is array (natural range <>) of std_logic_vector(7 downto 0);
  19. shared variable sv_dict : t_dict;
  20. begin
  21. DictInitP : process is
  22. begin
  23. sv_dict.init(false);
  24. wait;
  25. end process DictInitP;
  26. DictTestP : process is
  27. variable v_key : string(1 to 4);
  28. variable v_random : RandomPType;
  29. variable v_input : std_logic_vector(7 downto 0);
  30. variable v_output : std_logic_vector(7 downto 0);
  31. variable v_scoreboard : t_scoreboard(0 to 256);
  32. begin
  33. v_random.InitSeed(v_random'instance_name);
  34. -- check initial emptiness
  35. assert sv_dict.size = 0
  36. report "ERROR: Dict should be empty"
  37. severity failure;
  38. -- fill dictionary and check count
  39. report "INFO: Test : Fill dictionary";
  40. for i in 0 to 255 loop
  41. v_input := v_random.RandSlv(8);
  42. sv_dict.set(integer'image(i), v_input);
  43. v_scoreboard(i) := v_input;
  44. assert sv_dict.size = i+1
  45. report "ERROR: Dict should have " & to_string(i+1) & " entries"
  46. severity failure;
  47. end loop;
  48. report "INFO: Test successful";
  49. -- read all entries and check for correct data
  50. report "INFO: Test : Read dictionary";
  51. for i in 0 to 255 loop
  52. sv_dict.get(integer'image(i), v_output);
  53. assert v_output = v_scoreboard(i)
  54. report "ERROR: Got 0x" & to_hstring(v_output) & ", expected 0x" & to_hstring(v_scoreboard(i))
  55. severity failure;
  56. end loop;
  57. report "INFO: Test successful";
  58. report "INFO: t_dict test finished successfully";
  59. wait;
  60. end process DictTestP;
  61. end architecture sim;