Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.84 KB | None | 0 0
  1. ----------------------------------------------------------------------
  2. ---- ----
  3. ---- ATARI compatible IP Core ----
  4. ---- ----
  5. ---- This file is part of the FPGA-ATARI project. ----
  6. ---- http://www.experiment-s.de ----
  7. ---- ----
  8. ----------------------------------------------------------------------
  9. ---- Description: ----
  10. ---- This VHDL model is based on PERA Putnik's IDE interface ----
  11. ---- (version 1998-12-23) but has full decoding of the respective ----
  12. ---- address lines The address FC0000 is used twice in the STs. ----
  13. ---- Using it byte wide, it is the selection register to switch ----
  14. ---- to 16MHz (see Atari Hardware Register Listing). Using it ----
  15. ---- word wide, it is the IDE controller data register. The UDSn ----
  16. ---- bus control signal and the lower address lines 3 downto 1 ----
  17. ---- are not used for decoding of the FC0000 address. Thus, any ----
  18. ---- dummy information is written to the IDE controller's data ----
  19. ---- register when FC0000 is used byte wide. This does not affect ----
  20. ---- the proper operation of the IDE port. ----
  21. ---- ----
  22. ---- Use external bus drivers for the connection of the IDE data ----
  23. ---- lines as follows: ----
  24. ---- Use a 16 bit wide LVTTL tri state drivers to control the ----
  25. ---- data direction from or to an IDE device. ----
  26. ---- The IDE_D_EN_INn and IDE_D_EN_OUTn outputs are the respective----
  27. ---- tri state enables where IDE_D_EN_INn controls the tri state ----
  28. ---- for the read operation from an IDE device and IDE_D_EN_OUTn ----
  29. ---- controls the write operation to an IDE device. ----
  30. ---- Select for the output buffers a supply of +5V. ----
  31. ---- Select for the input buffers a supply of VCCIO of the ----
  32. ---- selected programmable logic device. ----
  33. ---- ----
  34. ---- Be aware, that only TOS 2.06 or above operating system ----
  35. ---- versions check for IDE drives during boot process. ----
  36. ---- ----
  37. ---- ----
  38. ---- To Do: ----
  39. ---- - ----
  40. ---- ----
  41. ---- Author(s): ----
  42. ---- - Wolfgang Foerster, wf@experiment-s.de; wf@inventronik.de ----
  43. ---- ----
  44. ----------------------------------------------------------------------
  45. ---- ----
  46. ---- Copyright (C) 2005 - 2011 Wolfgang Foerster ----
  47. ---- ----
  48. ---- This source file may be used and distributed without ----
  49. ---- restriction provided that this copyright statement is not ----
  50. ---- removed from the file and that any derivative work contains ----
  51. ---- the original copyright notice and the associated disclaimer. ----
  52. ---- ----
  53. ---- This source file is free software; you can redistribute it ----
  54. ---- and/or modify it under the terms of the GNU Lesser General ----
  55. ---- Public License as published by the Free Software Foundation; ----
  56. ---- either version 2.1 of the License, or (at your option) any ----
  57. ---- later version. ----
  58. ---- ----
  59. ---- This source is distributed in the hope that it will be ----
  60. ---- useful, but WITHOUT ANY WARRANTY; without even the implied ----
  61. ---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
  62. ---- PURPOSE. See the GNU Lesser General Public License for more ----
  63. ---- details. ----
  64. ---- ----
  65. ---- You should have received a copy of the GNU Lesser General ----
  66. ---- Public License along with this source; if not, download it ----
  67. ---- from http://www.gnu.org/licenses/lgpl.html ----
  68. ---- ----
  69. ----------------------------------------------------------------------
  70. ---- ----
  71. ---- IDE connector pinout: ----
  72. ---- Pin-Nr. Name Remarks ----
  73. ---- 40 GND ----
  74. ---- 38 CS1n ----
  75. ---- 36 IDE_A2 Hardwired to ATARI adress bit A4 ----
  76. ---- 34 PDIAG ----
  77. ---- 32 reseved ----
  78. ---- 30 GND ----
  79. ---- 28 CSEL Cable select, hardwired to GND ----
  80. ---- 26 GND ----
  81. ---- 24 GND ----
  82. ---- 22 GND ----
  83. ---- 20 keypin No connection ----
  84. ---- 18 IDE_D15 ----
  85. ---- 16 IDE_D14 ----
  86. ---- 14 IDE_D13 ----
  87. ---- 12 IDE_D12 ----
  88. ---- 10 IDE_D11 ----
  89. ---- 8 IDE_D10 ----
  90. ---- 6 IDE_D9 ----
  91. ---- 4 IDE_D8 ----
  92. ---- 2 GND ----
  93. ---- 39 DASP LED-Cathode, host's output ----
  94. ---- 37 CS0n ----
  95. ---- 35 IDE_A0 Hardwired to ATARI adress bit A2 ----
  96. ---- 33 IDE_A1 Hardwired to ATARI adress bit A3 ----
  97. ---- 31 INTRQ ----
  98. ---- 29 DMACKn Wire via 100 Ohm to VCC ----
  99. ---- 27 IDE_IORDYn ----
  100. ---- 25 IORDn ----
  101. ---- 23 IOWRn ----
  102. ---- 21 DMARQ ----
  103. ---- 19 GND ----
  104. ---- 17 IDE_D0 ----
  105. ---- 15 IDE_D1 ----
  106. ---- 13 IDE_D2 ----
  107. ---- 11 IDE_D3 ----
  108. ---- 9 IDE_D4 ----
  109. ---- 7 IDE_D5 ----
  110. ---- 5 IDE_D6 ----
  111. ---- 3 IDE_D7 ----
  112. ---- 1 IDE_RESn ----
  113. ---- ----
  114. ----------------------------------------------------------------------
  115. --
  116. -- Revision History
  117. --
  118. -- Revision 1.0 2005/09/10 WF
  119. -- Initial Release.
  120. -- Revision 1.1 2007/01/06 WF
  121. -- Minor enhancements.
  122. -- Revision 1.2 2008/06/16 WF
  123. -- Modifications to meet the STBook compatibility.
  124. -- Revision 2K8A 2008/07/14 WF
  125. -- Minor changes.
  126. -- Revision 2K8B 2008/12/24 WF
  127. -- Bug fixes to get the thing working.
  128. -- Revision 2K9B 2009/12/24 WF
  129. -- Removed DMAn.
  130. -- Revision 2K15B 20151224 WF
  131. -- Replaced the data type bit by std_logic.
  132. -- DTACKn is now in the correct address space.
  133. --
  134.  
  135. library ieee;
  136. use ieee.std_logic_1164.all;
  137. use ieee.std_logic_unsigned.all;
  138.  
  139. entity WF_IDE is
  140. port (
  141. RESETn : in std_logic;
  142. CLK : in std_logic;
  143.  
  144. ADR : in std_logic_vector(23 downto 1);
  145. DATA_IN : in std_logic_vector(7 downto 0);
  146.  
  147. ASn : in std_logic;
  148. LDSn : in std_logic;
  149. RWn : in std_logic;
  150. DTACKn : out std_logic;
  151.  
  152. -- Interrupt via ACSI:
  153. ACSI_HDINTn : out std_logic;
  154.  
  155. -- IDE section:
  156. IDE_INTRQ : in std_logic;
  157. IDE_IORDY : in std_logic;
  158. -- PDIAG : in std_logic; -- Not used so far.
  159. -- DASP : in std_logic; -- See pinout above.
  160. -- DMARQ : in std_logic; -- Not used so far.
  161. -- DMACKn : out std_logic; -- See pinout above.
  162. IDE_RESn : out std_logic;
  163. CS0n : out std_logic;
  164. CS1n : out std_logic;
  165. IORDn : out std_logic;
  166. IOWRn : out std_logic;
  167.  
  168. IDE_BYTESWAP : out std_logic;
  169. IDE_D_EN_INn : out std_logic;
  170. IDE_D_EN_OUTn : out std_logic
  171. );
  172. end WF_IDE;
  173.  
  174. architecture BEHAVIOR of WF_IDE is
  175. signal CMD_REG : std_logic_vector(7 downto 0);
  176. begin
  177. DTACKn <= '0' when ASn = '0' and LDSn = '0' and ADR & '0' >= x"F00000" and ADR & '0' <= x"F0003A" and IDE_IORDY = '1' else '1';
  178.  
  179. ACSI_HDINTn <= '0' when IDE_INTRQ = '1' else '1';
  180. IDE_RESn <= RESETn;
  181.  
  182. IDE_CMD: process(RESETn, CLK)
  183. -- This is the command register shadow. It is used to detect the IDE command
  184. -- 'IDENTIFY DRIVE' in which case the data may not be bytewise swapped.
  185. begin
  186. if RESETn = '0' then
  187. CMD_REG <= x"00";
  188. elsif CLK = '1' and CLK' event then
  189. if ASn = '0' and ADR = x"F0001" & "110" and RWn = '0' then -- Command register at x"F0001D".
  190. CMD_REG <= DATA_IN;
  191. end if;
  192. end if;
  193. end process IDE_CMD;
  194.  
  195. -- Data is bytewise swapped, if the command is not 'IDENTIFY DRIVE'.
  196. IDE_BYTESWAP <= '1' when ASn = '0' and ADR(23 downto 2) = x"F0000" & "00" and CMD_REG /= x"EC" else '0'; -- The data register is Long.
  197.  
  198. IOWRn <= '0' when ASn = '0' and LDSn = '0' and ADR(23 downto 4) = x"F0000" and RWn = '0' else
  199. '0' when ASn = '0' and LDSn = '0' and ADR(23 downto 4) = x"F0001" and RWn = '0' else
  200. '0' when ASn = '0' and LDSn = '0' and ADR(23 downto 4) = x"F0002" and RWn = '0' else
  201. '0' when ASn = '0' and LDSn = '0' and ADR(23 downto 4) = x"F0003" and RWn = '0' else '1';
  202.  
  203. IORDn <= '0' when ASn = '0' and LDSn = '0' and ADR(23 downto 4) = x"F0000" and RWn = '1' else
  204. '0' when ASn = '0' and LDSn = '0' and ADR(23 downto 4) = x"F0001" and RWn = '1' else
  205. '0' when ASn = '0' and LDSn = '0' and ADR(23 downto 4) = x"F0002" and RWn = '1' else
  206. '0' when ASn = '0' and LDSn = '0' and ADR(23 downto 4) = x"F0003" and RWn = '1' else '1';
  207.  
  208. CS0n <= '0' when ASn = '0' and ADR(23 downto 4) = x"F0000" else
  209. '0' when ASn = '0' and ADR(23 downto 4) = x"F0001" else '1';
  210.  
  211. CS1n <= '0' when ASn = '0' and ADR(23 downto 4) = x"F0002" else
  212. '0' when ASn = '0' and ADR(23 downto 4) = x"F0003" else '1';
  213.  
  214. IDE_D_EN_INn <= '0' when ASn = '0' and ADR(23 downto 4) = x"F0000" and RWn = '1' else
  215. '0' when ASn = '0' and ADR(23 downto 4) = x"F0001" and RWn = '1' else
  216. '0' when ASn = '0' and ADR(23 downto 4) = x"F0002" and RWn = '1' else
  217. '0' when ASn = '0' and ADR(23 downto 4) = x"F0003" and RWn = '1' else '1';
  218.  
  219. IDE_D_EN_OUTn <= '0' when ASn = '0' and ADR(23 downto 4) = x"F0000" and RWn = '0' else
  220. '0' when ASn = '0' and ADR(23 downto 4) = x"F0001" and RWn = '0' else
  221. '0' when ASn = '0' and ADR(23 downto 4) = x"F0002" and RWn = '0' else
  222. '0' when ASn = '0' and ADR(23 downto 4) = x"F0003" and RWn = '0' else '1';
  223. end BEHAVIOR;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement