Studentenversion des ESY6/A Praktikums "signal_processing".
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.

test_avalon_slave.vhd 2.7KB

1 year ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.numeric_std.all;
  4. library work;
  5. use work.reg32.all;
  6. use work.avalon_slave.all;
  7. package test_avalon_slave is
  8. procedure read( signal clk : in std_logic;
  9. variable address : in std_logic_vector;
  10. signal req : out work.avalon_slave.Request;
  11. signal rsp : in work.avalon_slave.Response;
  12. variable data : out std_logic_vector );
  13. procedure assert_readdata_eq( signal clk : in std_logic;
  14. variable address : in std_logic_vector;
  15. signal req : out work.avalon_slave.Request;
  16. signal rsp : in work.avalon_slave.Response;
  17. variable expected : in std_logic_vector;
  18. constant message : in string );
  19. procedure write( signal clk : in std_logic;
  20. variable address : in std_logic_vector;
  21. signal req : out work.avalon_slave.Request;
  22. variable data : in std_logic_vector );
  23. end package test_avalon_slave;
  24. package body test_avalon_slave is
  25. procedure read( signal clk : in std_logic;
  26. variable address : in std_logic_vector;
  27. signal req : out work.avalon_slave.Request;
  28. signal rsp : in work.avalon_slave.Response;
  29. variable data : out std_logic_vector ) is
  30. begin
  31. req.read <= '1';
  32. req.write <= '0';
  33. req.address <= address;
  34. wait until falling_edge( clk );
  35. wait until falling_edge( clk );
  36. req.read <= '0';
  37. data := rsp.readdata;
  38. wait until falling_edge( clk );
  39. end procedure read;
  40. procedure assert_readdata_eq( signal clk : in std_logic;
  41. variable address : in std_logic_vector;
  42. signal req : out work.avalon_slave.Request;
  43. signal rsp : in work.avalon_slave.Response;
  44. variable expected :in std_logic_vector;
  45. constant message : in string ) is
  46. variable readdata : std_logic_vector( expected'range );
  47. begin
  48. read( clk => clk,
  49. address => address,
  50. req => req,
  51. rsp => rsp,
  52. data => readdata );
  53. assert( readdata = expected )
  54. report message & LF &
  55. " expected: " & to_string( expected ) & LF &
  56. " actual: " & to_string( readdata ) & LF
  57. severity error;
  58. end procedure assert_readdata_eq;
  59. procedure write( signal clk : in std_logic;
  60. variable address : in std_logic_vector;
  61. signal req : out work.avalon_slave.Request;
  62. variable data : in std_logic_vector ) is
  63. begin
  64. req.read <= '0';
  65. req.write <= '1';
  66. req.address <= address;
  67. req.writedata <= data;
  68. wait until falling_edge( clk );
  69. req.write <= '0';
  70. end procedure write;
  71. end package body test_avalon_slave;