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.

crc.vhd 2.2KB

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