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.

avalon_slave_transitions.vhd 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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.avalon_slave.all;
  7. entity avalon_slave_transitions is
  8. generic (
  9. REG_COUNT : natural;
  10. REG_ACCESS_TYPES : work.reg32.AccessArray
  11. );
  12. port (
  13. address : in std_logic_vector( 3 downto 0 );
  14. read : in std_logic;
  15. write : in std_logic;
  16. current_state : in work.avalon_slave.State;
  17. next_state : out work.avalon_slave.State;
  18. reg_index : out integer range 0 to REG_COUNT - 1
  19. );
  20. end entity avalon_slave_transitions;
  21. architecture rtl of avalon_slave_transitions is
  22. signal is_access : boolean;
  23. signal is_read : boolean;
  24. signal is_write : boolean;
  25. signal address_index : integer range 0 to 2 ** address'high - 1;
  26. signal is_valid_reg_index : boolean;
  27. signal access_type : work.reg32.AccessType;
  28. signal is_valid_access : boolean;
  29. signal is_valid_access_type : boolean;
  30. signal index : integer range 0 to REG_COUNT - 1;
  31. begin
  32. c_is_access: is_access <= ( read or write ) = '1';
  33. c_is_read: is_read <= read = '1';
  34. c_is_write: is_write <= write = '1' and not is_read;
  35. c_address_index: address_index <= to_integer( unsigned( address ) );
  36. c_is_valid_reg_index: is_valid_reg_index <= address_index <= ( REG_COUNT - 1 );
  37. c_index: index <= address_index when is_valid_reg_index else 0;
  38. c_reg_index: reg_index <= index;
  39. c_access_type: access_type <= REG_ACCESS_TYPES( index );
  40. c_is_valid_access_type: is_valid_access_type <= true when
  41. ( is_read and work.reg32.allows_read( access_type ) ) or
  42. ( is_write and work.reg32.allows_write( access_type ) )
  43. else false;
  44. c_is_valid_access: is_valid_access <= is_access and is_valid_reg_index and
  45. is_valid_access_type;
  46. transition : process( all ) is
  47. begin
  48. case current_state is
  49. when SLAVE_IDLE =>
  50. if ( is_valid_access and is_read ) then
  51. next_state <= SLAVE_READ;
  52. elsif ( is_valid_access and is_write ) then
  53. next_state <= SLAVE_WRITE;
  54. else
  55. next_state <= SLAVE_IDLE;
  56. end if;
  57. when SLAVE_READ =>
  58. next_state <= SLAVE_READ_DATA;
  59. when SLAVE_READ_DATA =>
  60. if ( is_valid_access and is_read ) then
  61. next_state <= SLAVE_READ;
  62. elsif ( is_valid_access and is_write ) then
  63. next_state <= SLAVE_WRITE;
  64. else
  65. next_state <= SLAVE_IDLE;
  66. end if;
  67. when SLAVE_WRITE =>
  68. next_state <= SLAVE_IDLE;
  69. end case;
  70. end process transition;
  71. end architecture rtl;