Library of reusable VHDL components
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.

89 lines
2.6 KiB

  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. entity WishBoneSlaveE is
  4. generic (
  5. G_ADR_WIDTH : positive := 8; --* address bus width
  6. G_DATA_WIDTH : positive := 8 --* data bus width
  7. );
  8. port (
  9. --+ wishbone system if
  10. WbRst_i : in std_logic;
  11. WbClk_i : in std_logic;
  12. --+ wishbone inputs
  13. WbCyc_i : in std_logic;
  14. WbStb_i : in std_logic;
  15. WbWe_i : in std_logic;
  16. WbAdr_i : in std_logic_vector(G_ADR_WIDTH-1 downto 0);
  17. WbDat_i : in std_logic_vector(G_DATA_WIDTH-1 downto 0);
  18. --+ wishbone outputs
  19. WbDat_o : out std_logic_vector(G_DATA_WIDTH-1 downto 0);
  20. WbAck_o : out std_logic;
  21. WbErr_o : out std_logic;
  22. --+ local register if
  23. LocalWen_o : out std_logic;
  24. LocalRen_o : out std_logic;
  25. LocalAdress_o : out std_logic_vector(G_ADR_WIDTH-1 downto 0);
  26. LocalData_o : out std_logic_vector(G_DATA_WIDTH-1 downto 0);
  27. LocalData_i : in std_logic_vector(G_DATA_WIDTH-1 downto 0)
  28. );
  29. end entity WishBoneSlaveE;
  30. architecture rtl of WishBoneSlaveE is
  31. type t_wb_slave_fsm is (IDLE, ADDRESS, DATA);
  32. signal s_wb_slave_fsm : t_wb_slave_fsm;
  33. signal s_wb_active : boolean;
  34. begin
  35. WbSlaveControlP : process (WbClk_i) is
  36. begin
  37. if (rising_edge(WbClk_i)) then
  38. if (WbRst_i = '1') then
  39. s_wb_slave_fsm <= IDLE;
  40. else
  41. WbReadC : case s_wb_slave_fsm is
  42. when IDLE =>
  43. s_wb_slave_fsm <= ADDRESS;
  44. when ADDRESS =>
  45. if (s_wb_active and WbWe_i = '0') then
  46. s_wb_slave_fsm <= DATA;
  47. end if;
  48. when DATA =>
  49. s_wb_slave_fsm <= ADDRESS;
  50. when others =>
  51. s_wb_slave_fsm <= IDLE;
  52. end case;
  53. end if;
  54. end if;
  55. end process WbSlaveControlP;
  56. s_wb_active <= true when s_wb_slave_fsm /= IDLE and WbCyc_i = '1' and WbStb_i = '1' else false;
  57. --+ local register if outputs
  58. LocalWen_o <= WbWe_i when s_wb_slave_fsm = ADDRESS and s_wb_active else '0';
  59. LocalRen_o <= not(WbWe_i) when s_wb_slave_fsm = ADDRESS and s_wb_active else '0';
  60. LocalAdress_o <= WbAdr_i when s_wb_slave_fsm /= IDLE and s_wb_active else (others => '0');
  61. LocalData_o <= WbDat_i when s_wb_slave_fsm = ADDRESS and s_wb_active and WbWe_i = '1' else (others => '0');
  62. --+ wishbone if outputs
  63. WbDat_o <= LocalData_i when s_wb_slave_fsm = DATA and WbWe_i = '0' else (others => '0');
  64. WbAck_o <= '1' when s_wb_slave_fsm = DATA or (s_wb_slave_fsm = ADDRESS and s_wb_active and WbWe_i = '1') else '0';
  65. WbErr_o <= '0';
  66. end architecture rtl;