Loesung des Praktikums Systementwurf - Bjarne Hoesch - Bernhard Schoeffel
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.

fft.vhd 2.8KB

1 year ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. ------------------------------------------------------------------------
  2. -- fft
  3. --
  4. -- calculation of FFT magnitude
  5. --
  6. -- Inputs:
  7. -- 32-Bit Floating Point number in range +-16 expected (loaded from FIFO)
  8. --
  9. -- Outputs
  10. -- 32-Bit Floating Point number in range +-16 calculated (stored in FIFO)
  11. --
  12. -----------------------------------------------------------------------
  13. library ieee;
  14. use ieee.std_logic_1164.all;
  15. use ieee.numeric_std.all;
  16. library work;
  17. use work.reg32.all;
  18. use work.task.all;
  19. use work.float.all;
  20. entity fft is
  21. generic (
  22. -- input data width of real/img part
  23. input_data_width : integer := 32;
  24. -- output data width of real/img part
  25. output_data_width : integer := 32
  26. );
  27. port (
  28. clk : in std_logic;
  29. reset : in std_logic;
  30. task_start : in std_logic;
  31. task_state : out work.task.State;
  32. signal_read : out std_logic;
  33. signal_readdata : in std_logic_vector( 31 downto 0 );
  34. signal_write : out std_logic;
  35. signal_writedata : out std_logic_vector( 31 downto 0 )
  36. );
  37. end entity fft;
  38. architecture rtl of fft is
  39. signal current_task_state : work.task.State;
  40. signal next_task_state : work.task.State;
  41. signal index : integer range 0 to work.task.STREAM_LEN;
  42. begin
  43. task_state_transitions : process ( current_task_state, task_start, index ) is
  44. begin
  45. next_task_state <= current_task_state;
  46. case current_task_state is
  47. when work.task.TASK_IDLE =>
  48. if ( task_start = '1' ) then
  49. next_task_state <= work.task.TASK_RUNNING;
  50. end if;
  51. when work.task.TASK_RUNNING =>
  52. if ( index = work.task.STREAM_LEN - 1 ) then
  53. next_task_state <= work.task.TASK_DONE;
  54. end if;
  55. when work.task.TASK_DONE =>
  56. if ( task_start = '1' ) then
  57. next_task_state <= work.task.TASK_RUNNING;
  58. end if;
  59. end case;
  60. end process task_state_transitions;
  61. sync : process ( clk, reset ) is
  62. begin
  63. if ( reset = '1' ) then
  64. current_task_state <= work.task.TASK_IDLE;
  65. index <= 0;
  66. elsif ( rising_edge( clk ) ) then
  67. current_task_state <= next_task_state;
  68. case next_task_state is
  69. when work.task.TASK_IDLE =>
  70. index <= 0;
  71. signal_write <= '0';
  72. when work.task.TASK_RUNNING =>
  73. index <= index + 1;
  74. signal_write <= '1';
  75. signal_writedata <= ( others => '0' );
  76. when work.task.TASK_DONE =>
  77. index <= 0;
  78. signal_write <= '0';
  79. end case;
  80. end if;
  81. end process sync;
  82. task_state <= current_task_state;
  83. end architecture rtl;