Übungen der VHDL-Einführung
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_fsm.vhd 3.1KB

2 weeks ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. ------------------------------------------------------------------------
  2. -- fft_magnitude_calc
  3. --
  4. -- calculation of FFT magnitude sqrt(real_part²+im_part²)
  5. -- Inputs:
  6. -- input_re in: +-1 signed Fixpoint (0.5=0x40000000, -0.5=0xC0000000 (negative numbers in 2K)
  7. -- input_im in: +-1 signed Fixpoint (0.5=0x40000000, -0.5=0xC0000000 (negative numbers in 2K)
  8. -- input_valid: high = inputs are valid for data processing
  9. -- Outputs
  10. -- output_magnitude: Fixpoint 0.5=0x40000000 (always positive)
  11. -- output_valid: high = magnitude data is valid
  12. -----------------------------------------------------------------------
  13. library ieee;
  14. use ieee.std_logic_1164.all;
  15. use ieee.numeric_std.all;
  16. entity tb_fft_magnitude_calc is
  17. generic( GUI_MODE : boolean; CHECK_RESULTS : boolean );
  18. end entity tb_fft_magnitude_calc;
  19. architecture rtl of tb_fft_magnitude_calc is
  20. signal clk : std_logic := '0'; -- Takt
  21. signal reset : std_logic := '1'; -- Reset
  22. signal input_valid: std_logic := '0'; -- Eingangsdaten gültig
  23. signal input_re : std_logic_vector( 31 downto 0 ) := X"40000000"; -- Realteil in Fixpoint
  24. signal input_im : std_logic_vector( 31 downto 0 ):= X"40000000"; -- Imaginärteil in Fixpoint
  25. signal output_valid : std_logic; -- Ausgangsdaten gültig
  26. signal output_magnitude : std_logic_vector( 31 downto 0 );
  27. begin
  28. clk <= not clk after 10 ns;
  29. reset_release : process is
  30. begin
  31. wait for 435 ns;
  32. reset <= '0';
  33. wait;
  34. end process reset_release;
  35. -- Instanziierung des SQRT Moduls für die Berechnung der Quardratwurzel
  36. -- Weisen Sie die Signale output_sqrt, reset, input_sqrt und clk richtig zu
  37. fft_magnitude_calc_module : entity work.fft_magnitude_calc
  38. port map (
  39. clk => clk,
  40. reset => reset,
  41. input_valid => input_valid, -- Eingangsdaten gültig
  42. input_re => input_re, -- Realteil in Fixpoint
  43. input_im => input_im, -- Imaginärteil in Fixpoint
  44. output_valid => output_valid, -- Ausgangsdaten gültig
  45. output_magnitude => output_magnitude -- Berechnete magnitude
  46. );
  47. stimulus: process is
  48. begin
  49. wait until falling_edge( reset );
  50. wait until falling_edge( clk );
  51. input_valid <= '1';
  52. wait until falling_edge( clk );
  53. input_valid <= '0';
  54. wait until falling_edge( output_valid );
  55. wait for 200 ns;
  56. wait until falling_edge( clk );
  57. input_valid <= '1';
  58. input_re <= X"20000000";
  59. input_im <= X"20000000";
  60. wait until falling_edge( clk );
  61. input_valid <= '0';
  62. wait until falling_edge( output_valid );
  63. wait until falling_edge( clk );
  64. if ( GUI_MODE ) then
  65. std.env.stop;
  66. else
  67. std.env.finish;
  68. end if;
  69. end process stimulus;
  70. end architecture rtl;