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.

128 lines
3.9 KiB

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