Lösung des Praktikums Systementwurf
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_crc.vhd 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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.reg32.all;
  7. use work.avalon_slave.all;
  8. use work.test_utility.all;
  9. use work.test_avalon_slave.all;
  10. use work.task.all;
  11. use work.crc_data.all;
  12. use work.fft_data.all;
  13. use work.test_hardware_task.all;
  14. use work.test_data_channel_pkg.all;
  15. library std;
  16. use std.env.all;
  17. use std.textio.all;
  18. entity test_task_crc is
  19. generic( CHECK_RESULTS : boolean );
  20. end entity test_task_crc;
  21. architecture test of test_task_crc is
  22. signal clk : std_logic := '0';
  23. signal reset : std_logic := '1';
  24. signal req : work.avalon_slave.Request;
  25. signal rsp : work.avalon_slave.Response;
  26. signal data_channel_req : work.avalon_slave.Request;
  27. signal data_channel_rsp : work.avalon_slave.Response;
  28. signal signal_read : std_logic;
  29. signal signal_readdata : std_logic_vector( 31 downto 0 );
  30. signal signal_write : std_logic;
  31. signal signal_writedata : std_logic_vector( 31 downto 0 );
  32. signal data_channel_read : std_logic;
  33. signal data_channel_readdata : std_logic_vector( 31 downto 0 );
  34. signal index_output : integer range 0 to 1023;
  35. begin
  36. dut : entity work.task_crc
  37. port map (
  38. clk => clk,
  39. reset => reset,
  40. address => req.address,
  41. read => req.read,
  42. readdata => rsp.readdata,
  43. write => req.write,
  44. writedata => req.writedata,
  45. signal_read => signal_read,
  46. signal_readdata => signal_readdata,
  47. signal_write => signal_write,
  48. signal_writedata => signal_writedata
  49. );
  50. u_data_channel : entity work.data_channel
  51. port map (
  52. clk => clk,
  53. reset => reset,
  54. ctrl_address => data_channel_req.address,
  55. ctrl_read => data_channel_req.read,
  56. ctrl_readdata => data_channel_rsp.readdata,
  57. ctrl_write => data_channel_req.write,
  58. ctrl_writedata => data_channel_req.writedata,
  59. hw_sink_write => signal_write,
  60. hw_sink_writedata => signal_writedata,
  61. hw_source_read => data_channel_read,
  62. hw_source_readdata => data_channel_readdata
  63. );
  64. clk <= not clk after 10 ns;
  65. reset_release : process is
  66. begin
  67. wait for 35 ns;
  68. reset <= '0';
  69. wait;
  70. end process reset_release;
  71. p_number_input_sample: process ( clk, reset ) is
  72. begin
  73. if ( reset = '1' ) then
  74. index_output <= 1;
  75. signal_readdata <= to_std_logic_vector( to_float( work.fft_data.expected( 0 ) ) );
  76. elsif ( rising_edge( clk ) ) then
  77. if signal_read = '1' then
  78. if index_output /= 1023 then
  79. index_output <= index_output + 1;
  80. end if;
  81. signal_readdata <= to_std_logic_vector( to_float( work.fft_data.expected( index_output ) ) );
  82. end if;
  83. end if;
  84. end process p_number_input_sample;
  85. stimulus: process is
  86. variable data_channel_config : std_logic_vector( 31 downto 0 ) := x"00000001";
  87. variable expected_crc_value : std_logic_vector( 31 downto 0 ) := work.crc_data.expected;
  88. begin
  89. wait until falling_edge( reset );
  90. work.test_data_channel_pkg.write_and_assert_config( clk => clk,
  91. req => data_channel_req,
  92. rsp => data_channel_rsp,
  93. config => data_channel_config );
  94. test_execute( clk => clk, req => req, rsp => rsp,
  95. write => signal_write, writedata => signal_writedata );
  96. std.textio.write( std.textio.OUTPUT, " test_crc_value ... " );
  97. assert_read_sw_source_eq( clk => clk,
  98. req => data_channel_req, rsp => data_channel_rsp,
  99. expected => expected_crc_value );
  100. std.textio.write( std.textio.OUTPUT, TEST_OK );
  101. finish;
  102. end process stimulus;
  103. end architecture test;