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.

rand.vhd 2.2KB

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