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.

sine.vhd 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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.float.all;
  7. use work.task.all;
  8. entity sine is
  9. port (
  10. clk : in std_logic;
  11. reset : in std_logic;
  12. task_start : in std_logic;
  13. task_state : out work.task.State;
  14. step_size : in work.reg32.word;
  15. phase : in work.reg32.word;
  16. amplitude : in work.reg32.word;
  17. signal_write : out std_logic;
  18. signal_writedata : out std_logic_vector( 31 downto 0 )
  19. );
  20. end entity sine;
  21. architecture rtl of sine is
  22. signal current_task_state : work.task.State;
  23. signal next_task_state : work.task.State;
  24. signal index : integer range 0 to work.task.STREAM_LEN;
  25. begin
  26. task_state_transitions : process ( current_task_state, task_start, index ) is
  27. begin
  28. next_task_state <= current_task_state;
  29. case current_task_state is
  30. when work.task.TASK_IDLE =>
  31. if ( task_start = '1' ) then
  32. next_task_state <= work.task.TASK_RUNNING;
  33. end if;
  34. when work.task.TASK_RUNNING =>
  35. if ( index = work.task.STREAM_LEN - 1 ) then
  36. next_task_state <= work.task.TASK_DONE;
  37. end if;
  38. when work.task.TASK_DONE =>
  39. if ( task_start = '1' ) then
  40. next_task_state <= work.task.TASK_RUNNING;
  41. end if;
  42. end case;
  43. end process task_state_transitions;
  44. sync : process ( clk, reset ) is
  45. begin
  46. if ( reset = '1' ) then
  47. current_task_state <= work.task.TASK_IDLE;
  48. index <= 0;
  49. elsif ( rising_edge( clk ) ) then
  50. current_task_state <= next_task_state;
  51. case next_task_state is
  52. when work.task.TASK_IDLE =>
  53. index <= 0;
  54. signal_write <= '0';
  55. when work.task.TASK_RUNNING =>
  56. index <= index + 1;
  57. signal_write <= '1';
  58. signal_writedata <= ( others => '0' );
  59. when work.task.TASK_DONE =>
  60. index <= 0;
  61. signal_write <= '0';
  62. end case;
  63. end if;
  64. end process sync;
  65. task_state <= current_task_state;
  66. end architecture rtl;