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_task_rand.vhd 5.5KB

1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.numeric_std.all;
  4. use ieee.float_pkg.all;
  5. library work;
  6. use work.test_hardware_task.all;
  7. use work.task.all;
  8. use work.rand_data.all;
  9. use work.test_utility.all;
  10. use work.test_data_channel_pkg.all;
  11. library std;
  12. use std.env.all;
  13. use std.textio.all;
  14. entity test_task_rand is
  15. generic( CHECK_RESULTS : boolean; GUI_MODE : boolean := false );
  16. end entity test_task_rand;
  17. architecture test of test_task_rand is
  18. procedure test_configure( signal clk : in std_logic;
  19. signal req : out work.avalon_slave.Request;
  20. signal rsp : in work.avalon_slave.Response ) is
  21. variable index : integer := 0;
  22. variable writedata : std_logic_vector( 31 downto 0 );
  23. begin
  24. std.textio.write( std.textio.OUTPUT, " test_configure ... " );
  25. writedata := to_std_logic_vector( to_float( 1.3 ) );
  26. write_and_assert_config_eq( clk => clk, req => req, rsp => rsp,
  27. index => index, config => writedata );
  28. std.textio.write( std.textio.OUTPUT, TEST_OK );
  29. end procedure test_configure;
  30. procedure test_execute( signal clk : in std_logic;
  31. signal req : out work.avalon_slave.Request;
  32. signal rsp : in work.avalon_slave.Response;
  33. signal write : in std_logic;
  34. signal writedata : in std_logic_vector( 31 downto 0 )) is
  35. variable expected_readdata : std_logic_vector( 31 downto 0 );
  36. variable state : std_logic_vector( 31 downto 0 );
  37. variable index : integer := 0;
  38. begin
  39. std.textio.write( std.textio.OUTPUT, " test_execute ... " );
  40. expected_readdata := to_std_logic_vector( TASK_IDLE, expected_readdata'length );
  41. assert_state_eq( clk => clk, req => req, rsp => rsp, state => expected_readdata );
  42. write_start( clk => clk, req => req );
  43. expected_readdata := to_std_logic_vector( TASK_RUNNING, expected_readdata'length );
  44. assert_state_eq( clk => clk, req => req, rsp => rsp, state => expected_readdata );
  45. while true loop
  46. work.test_hardware_task.read_state( clk => clk, req => req, rsp => rsp, state => state );
  47. if ( state = to_std_logic_vector( TASK_DONE, expected_readdata'length ) ) then
  48. exit;
  49. end if;
  50. end loop;
  51. std.textio.write( std.textio.OUTPUT, TEST_OK );
  52. end procedure test_execute;
  53. signal clk : std_logic := '0';
  54. signal reset : std_logic := '1';
  55. signal req : work.avalon_slave.Request;
  56. signal rsp : work.avalon_slave.Response;
  57. signal data_channel_req : work.avalon_slave.Request;
  58. signal data_channel_rsp : work.avalon_slave.Response;
  59. signal address : std_logic_vector( 3 downto 0 );
  60. signal read : std_logic := '0';
  61. signal readdata : std_logic_vector( 31 downto 0 );
  62. signal write : std_logic := '0';
  63. signal writedata : std_logic_vector( 31 downto 0 );
  64. signal signal_write : std_logic;
  65. signal signal_writedata : std_logic_vector( 31 downto 0 );
  66. signal results : work.reg32.RegArray( 0 to 1023 );
  67. signal data_channel_read : std_logic;
  68. signal data_channel_readdata : std_logic_vector( 31 downto 0 );
  69. begin
  70. dut : entity work.task_rand
  71. port map (
  72. clk => clk,
  73. reset => reset,
  74. address => req.address,
  75. read => req.read,
  76. readdata => rsp.readdata,
  77. write => req.write,
  78. writedata => req.writedata,
  79. signal_write => signal_write,
  80. signal_writedata => signal_writedata
  81. );
  82. u_data_channel : entity work.data_channel
  83. port map (
  84. clk => clk,
  85. reset => reset,
  86. ctrl_address => data_channel_req.address,
  87. ctrl_read => data_channel_req.read,
  88. ctrl_readdata => data_channel_rsp.readdata,
  89. ctrl_write => data_channel_req.write,
  90. ctrl_writedata => data_channel_req.writedata,
  91. hw_sink_write => signal_write,
  92. hw_sink_writedata => signal_writedata,
  93. hw_source_read => data_channel_read,
  94. hw_source_readdata => data_channel_readdata
  95. );
  96. clk <= not clk after 10 ns;
  97. reset_release : process is
  98. begin
  99. wait for 35 ns;
  100. reset <= '0';
  101. wait;
  102. end process reset_release;
  103. stimulus: process is
  104. constant expected : work.reg32.RegArray( 0 to 3 )
  105. := ( 0 => ( others => 'U' ), 2 => ( others => 'U' ),
  106. others => ( others => '0' ) );
  107. variable data_channel_config : std_logic_vector( 31 downto 0 ) := x"00000001";
  108. begin
  109. wait until falling_edge( reset );
  110. work.test_data_channel_pkg.write_and_assert_config( clk => clk,
  111. req => data_channel_req,
  112. rsp => data_channel_rsp,
  113. config => data_channel_config );
  114. test_configure( clk => clk, req => req, rsp => rsp );
  115. test_execute( clk => clk, req => req, rsp => rsp,
  116. write => signal_write, writedata => signal_writedata );
  117. if ( CHECK_RESULTS ) then
  118. check_and_write_content( clk => clk,
  119. req => data_channel_req, rsp => data_channel_rsp,
  120. expected => work.rand_data.expected );
  121. else
  122. write_content( clk => clk,
  123. req => data_channel_req, rsp => data_channel_rsp );
  124. end if;
  125. if ( GUI_MODE ) then
  126. std.env.stop;
  127. else
  128. std.env.finish;
  129. end if;
  130. end process stimulus;
  131. end architecture test;