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.

132 lines
4.2 KiB

  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.numeric_std.all;
  4. entity WishBoneSlaveE is
  5. generic (
  6. G_ADR_WIDTH : positive := 8; --* address bus width
  7. G_DATA_WIDTH : positive := 8 --* data bus width
  8. );
  9. port (
  10. --+ wishbone system if
  11. WbRst_i : in std_logic;
  12. WbClk_i : in std_logic;
  13. --+ wishbone inputs
  14. WbCyc_i : in std_logic;
  15. WbStb_i : in std_logic;
  16. WbWe_i : in std_logic;
  17. WbAdr_i : in std_logic_vector(G_ADR_WIDTH-1 downto 0);
  18. WbDat_i : in std_logic_vector(G_DATA_WIDTH-1 downto 0);
  19. --+ wishbone outputs
  20. WbDat_o : out std_logic_vector(G_DATA_WIDTH-1 downto 0);
  21. WbAck_o : out std_logic;
  22. WbErr_o : out std_logic;
  23. --+ local register if
  24. LocalWen_o : out std_logic;
  25. LocalRen_o : out std_logic;
  26. LocalAdress_o : out std_logic_vector(G_ADR_WIDTH-1 downto 0);
  27. LocalData_o : out std_logic_vector(G_DATA_WIDTH-1 downto 0);
  28. LocalData_i : in std_logic_vector(G_DATA_WIDTH-1 downto 0)
  29. );
  30. end entity WishBoneSlaveE;
  31. architecture rtl of WishBoneSlaveE is
  32. type t_wb_slave_fsm is (IDLE, ADDRESS, DATA);
  33. signal s_wb_slave_fsm : t_wb_slave_fsm;
  34. signal s_wb_active : boolean;
  35. begin
  36. WbSlaveControlP : process (WbClk_i) is
  37. begin
  38. if (rising_edge(WbClk_i)) then
  39. if (WbRst_i = '1') then
  40. s_wb_slave_fsm <= IDLE;
  41. else
  42. WbReadC : case s_wb_slave_fsm is
  43. when IDLE =>
  44. s_wb_slave_fsm <= ADDRESS;
  45. when ADDRESS =>
  46. if (s_wb_active and WbWe_i = '0') then
  47. s_wb_slave_fsm <= DATA;
  48. end if;
  49. when DATA =>
  50. s_wb_slave_fsm <= ADDRESS;
  51. when others =>
  52. s_wb_slave_fsm <= IDLE;
  53. end case;
  54. end if;
  55. end if;
  56. end process WbSlaveControlP;
  57. s_wb_active <= true when s_wb_slave_fsm /= IDLE and WbCyc_i = '1' and WbStb_i = '1' else false;
  58. --+ local register if outputs
  59. LocalWen_o <= WbWe_i when s_wb_slave_fsm = ADDRESS and s_wb_active else '0';
  60. LocalRen_o <= not(WbWe_i) when s_wb_slave_fsm = ADDRESS and s_wb_active else '0';
  61. LocalAdress_o <= WbAdr_i when s_wb_slave_fsm /= IDLE and s_wb_active else (others => '0');
  62. LocalData_o <= WbDat_i when s_wb_slave_fsm = ADDRESS and s_wb_active and WbWe_i = '1' else (others => '0');
  63. --+ wishbone if outputs
  64. WbDat_o <= LocalData_i when s_wb_slave_fsm = DATA and WbWe_i = '0' else (others => '0');
  65. 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';
  66. WbErr_o <= '0';
  67. -- psl default clock is rising_edge(WbClk_i);
  68. --
  69. -- psl LOCAL_WRITE : assert always
  70. -- ((WbCyc_i and WbStb_i and WbWe_i) ->
  71. -- (LocalWen_o = '1' and WbAck_o = '1' and LocalAdress_o = WbAdr_i and LocalData_o = WbDat_i)) abort WbRst_i
  72. -- report "PSL ERROR: Local write error";
  73. --
  74. -- psl LOCAL_READ : assert always
  75. -- ({not(WbCyc_i) and not(WbStb_i); WbCyc_i and WbStb_i and not(WbWe_i)} |->
  76. -- {LocalRen_o = '1' and LocalAdress_o = WbAdr_i and WbAck_o = '0'; LocalRen_o = '0' and WbDat_o = LocalData_i and WbAck_o = '1'}) abort WbRst_i
  77. -- report "PSL ERROR: Local read error";
  78. --
  79. -- psl WB_ACK : assert always
  80. -- WbAck_o ->
  81. -- (WbCyc_i and WbStb_i)
  82. -- report "PSL ERROR: WbAck invalid";
  83. --
  84. -- psl WB_ERR : assert always
  85. -- WbErr_o ->
  86. -- (WbCyc_i and WbStb_i)
  87. -- report "PSL ERROR: WbErr invalid";
  88. --
  89. -- psl LOCAL_WE : assert always
  90. -- LocalWen_o ->
  91. -- (WbCyc_i and WbStb_i and WbWe_i and not(LocalRen_o)) and
  92. -- (next not(LocalWen_o))
  93. -- report "PSL ERROR: LocalWen invalid";
  94. --
  95. -- psl LOCAL_RE : assert always
  96. -- LocalRen_o ->
  97. -- (WbCyc_i and WbStb_i and not(WbWe_i) and not(LocalWen_o)) and
  98. -- (next not(LocalRen_o))
  99. -- report "PSL ERROR: LocalRen invalid";
  100. --
  101. -- psl RESET : assert always
  102. -- WbRst_i ->
  103. -- (to_integer(unsigned(WbDat_o)) = 0 and WbAck_o = '0' and WbErr_o = '0' and
  104. -- LocalWen_o = '0' and LocalRen_o = '0' and to_integer(unsigned(LocalAdress_o)) = 0 and to_integer(unsigned(LocalData_o)) = 0)
  105. -- report "PSL ERROR: Reset error";
  106. end architecture rtl;