1 |
2 |
dimamali |
------------------------------------------------------------------------------
|
2 |
|
|
-- This file is a part of the GRLIB VHDL IP LIBRARY
|
3 |
|
|
-- Copyright (C) 2003, Gaisler Research
|
4 |
|
|
--
|
5 |
|
|
-- This program is free software; you can redistribute it and/or modify
|
6 |
|
|
-- it under the terms of the GNU General Public License as published by
|
7 |
|
|
-- the Free Software Foundation; either version 2 of the License, or
|
8 |
|
|
-- (at your option) any later version.
|
9 |
|
|
--
|
10 |
|
|
-- This program is distributed in the hope that it will be useful,
|
11 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
|
|
-- GNU General Public License for more details.
|
14 |
|
|
--
|
15 |
|
|
-- You should have received a copy of the GNU General Public License
|
16 |
|
|
-- along with this program; if not, write to the Free Software
|
17 |
|
|
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
18 |
|
|
-----------------------------------------------------------------------------
|
19 |
|
|
-- Entity: atactrl_nodma
|
20 |
|
|
-- File: atactrl_nodma.vhd
|
21 |
|
|
-- Author: Nils-Johan Wessman, Gaisler Research
|
22 |
|
|
-- Description: ATA controller
|
23 |
|
|
------------------------------------------------------------------------------
|
24 |
|
|
|
25 |
|
|
library ieee;
|
26 |
|
|
use ieee.std_logic_1164.all;
|
27 |
|
|
use ieee.numeric_std.all;
|
28 |
|
|
library grlib;
|
29 |
|
|
use grlib.amba.all;
|
30 |
|
|
use grlib.stdlib.all;
|
31 |
|
|
library gaisler;
|
32 |
|
|
use gaisler.ata.all;
|
33 |
|
|
library opencores;
|
34 |
|
|
use opencores.occomp.all;
|
35 |
|
|
|
36 |
|
|
entity atactrl_nodma is
|
37 |
|
|
generic (
|
38 |
|
|
hindex : integer := 0;
|
39 |
|
|
haddr : integer := 0;
|
40 |
|
|
hmask : integer := 16#ff0#;
|
41 |
|
|
pirq : integer := 0;
|
42 |
|
|
|
43 |
|
|
TWIDTH : natural := 8; -- counter width
|
44 |
|
|
|
45 |
|
|
-- PIO mode 0 settings (@100MHz clock)
|
46 |
|
|
PIO_mode0_T1 : natural := 6; -- 70ns
|
47 |
|
|
PIO_mode0_T2 : natural := 28; -- 290ns
|
48 |
|
|
PIO_mode0_T4 : natural := 2; -- 30ns
|
49 |
|
|
PIO_mode0_Teoc : natural := 23 -- 240ns ==> T0 - T1 - T2 = 600 - 70 - 290 = 240
|
50 |
|
|
|
51 |
|
|
);
|
52 |
|
|
port (
|
53 |
|
|
rst : in std_ulogic;
|
54 |
|
|
arst : in std_ulogic;
|
55 |
|
|
clk : in std_ulogic;
|
56 |
|
|
ahbsi : in ahb_slv_in_type;
|
57 |
|
|
ahbso : out ahb_slv_out_type;
|
58 |
|
|
cfo : out cf_out_type;
|
59 |
|
|
|
60 |
|
|
-- ATA signals
|
61 |
|
|
ddin : in std_logic_vector(15 downto 0);
|
62 |
|
|
iordy : in std_logic;
|
63 |
|
|
intrq : in std_logic;
|
64 |
|
|
ata_resetn : out std_logic;
|
65 |
|
|
ddout : out std_logic_vector(15 downto 0);
|
66 |
|
|
ddoe : out std_logic;
|
67 |
|
|
da : out std_logic_vector(2 downto 0);
|
68 |
|
|
cs0n : out std_logic;
|
69 |
|
|
cs1n : out std_logic;
|
70 |
|
|
diorn : out std_logic;
|
71 |
|
|
diown : out std_logic;
|
72 |
|
|
dmack : out std_logic
|
73 |
|
|
);
|
74 |
|
|
end;
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
architecture rtl of atactrl_nodma is
|
78 |
|
|
-- Device ID
|
79 |
|
|
constant DeviceId : integer := 2;
|
80 |
|
|
constant RevisionNo : integer := 0;
|
81 |
|
|
constant VERSION : integer := 0;
|
82 |
|
|
|
83 |
|
|
component ocidec2_amba_slave is
|
84 |
|
|
generic (
|
85 |
|
|
hindex : integer := 0;
|
86 |
|
|
haddr : integer := 0;
|
87 |
|
|
hmask : integer := 16#ff0#;
|
88 |
|
|
pirq : integer := 0;
|
89 |
|
|
DeviceID : integer := 0;
|
90 |
|
|
RevisionNo : integer := 0;
|
91 |
|
|
|
92 |
|
|
-- PIO mode 0 settings (@100MHz clock)
|
93 |
|
|
PIO_mode0_T1 : natural := 6; -- 70ns
|
94 |
|
|
PIO_mode0_T2 : natural := 28; -- 290ns
|
95 |
|
|
PIO_mode0_T4 : natural := 2; -- 30ns
|
96 |
|
|
PIO_mode0_Teoc : natural := 23; -- 240ns ==> T0 - T1 - T2 = 600 - 70 - 290 = 240
|
97 |
|
|
|
98 |
|
|
-- Multiword DMA mode 0 settings (@100MHz clock)
|
99 |
|
|
DMA_mode0_Tm : natural := 4; -- 50ns
|
100 |
|
|
DMA_mode0_Td : natural := 21; -- 215ns
|
101 |
|
|
DMA_mode0_Teoc : natural := 21 -- 215ns ==> T0 - Td - Tm = 480 - 50 - 215 = 215
|
102 |
|
|
);
|
103 |
|
|
port (
|
104 |
|
|
rst : in std_ulogic;
|
105 |
|
|
arst : in std_ulogic;
|
106 |
|
|
clk : in std_ulogic;
|
107 |
|
|
ahbsi : in ahb_slv_in_type;
|
108 |
|
|
ahbso : out ahb_slv_out_type;
|
109 |
|
|
cf_power: out std_logic;
|
110 |
|
|
|
111 |
|
|
-- ata controller signals
|
112 |
|
|
|
113 |
|
|
-- PIO control input
|
114 |
|
|
PIOsel : out std_logic;
|
115 |
|
|
PIOtip, -- PIO transfer in progress
|
116 |
|
|
PIOack : in std_logic; -- PIO acknowledge signal
|
117 |
|
|
PIOq : in std_logic_vector(15 downto 0); -- PIO data input
|
118 |
|
|
PIOpp_full : in std_logic; -- PIO write-ping-pong buffers full
|
119 |
|
|
irq : in std_logic; -- interrupt signal input
|
120 |
|
|
PIOa : out std_logic_vector(3 downto 0);
|
121 |
|
|
PIOd : out std_logic_vector(15 downto 0);
|
122 |
|
|
PIOwe : out std_logic;
|
123 |
|
|
|
124 |
|
|
-- DMA control inputs
|
125 |
|
|
DMAsel : out std_logic;
|
126 |
|
|
DMAtip, -- DMA transfer in progress
|
127 |
|
|
DMAack, -- DMA transfer acknowledge
|
128 |
|
|
DMARxEmpty, -- DMA receive buffer empty
|
129 |
|
|
DMATxFull, -- DMA transmit buffer full
|
130 |
|
|
DMA_dmarq : in std_logic; -- wishbone DMA request
|
131 |
|
|
DMAq : in std_logic_vector(31 downto 0);
|
132 |
|
|
|
133 |
|
|
-- outputs
|
134 |
|
|
-- control register outputs
|
135 |
|
|
IDEctrl_rst,
|
136 |
|
|
IDEctrl_IDEen,
|
137 |
|
|
IDEctrl_FATR1,
|
138 |
|
|
IDEctrl_FATR0,
|
139 |
|
|
IDEctrl_ppen,
|
140 |
|
|
DMActrl_DMAen,
|
141 |
|
|
DMActrl_dir,
|
142 |
|
|
DMActrl_BeLeC0,
|
143 |
|
|
DMActrl_BeLeC1 : out std_logic;
|
144 |
|
|
|
145 |
|
|
-- CMD port timing registers
|
146 |
|
|
PIO_cmdport_T1,
|
147 |
|
|
PIO_cmdport_T2,
|
148 |
|
|
PIO_cmdport_T4,
|
149 |
|
|
PIO_cmdport_Teoc : out std_logic_vector(7 downto 0);
|
150 |
|
|
PIO_cmdport_IORDYen : out std_logic;
|
151 |
|
|
|
152 |
|
|
-- data-port0 timing registers
|
153 |
|
|
PIO_dport0_T1,
|
154 |
|
|
PIO_dport0_T2,
|
155 |
|
|
PIO_dport0_T4,
|
156 |
|
|
PIO_dport0_Teoc : out std_logic_vector(7 downto 0);
|
157 |
|
|
PIO_dport0_IORDYen : out std_logic;
|
158 |
|
|
|
159 |
|
|
-- data-port1 timing registers
|
160 |
|
|
PIO_dport1_T1,
|
161 |
|
|
PIO_dport1_T2,
|
162 |
|
|
PIO_dport1_T4,
|
163 |
|
|
PIO_dport1_Teoc : out std_logic_vector(7 downto 0);
|
164 |
|
|
PIO_dport1_IORDYen : out std_logic;
|
165 |
|
|
|
166 |
|
|
-- DMA device0 timing registers
|
167 |
|
|
DMA_dev0_Tm,
|
168 |
|
|
DMA_dev0_Td,
|
169 |
|
|
DMA_dev0_Teoc : out std_logic_vector(7 downto 0);
|
170 |
|
|
|
171 |
|
|
-- DMA device1 timing registers
|
172 |
|
|
DMA_dev1_Tm,
|
173 |
|
|
DMA_dev1_Td,
|
174 |
|
|
DMA_dev1_Teoc : out std_logic_vector(7 downto 0)
|
175 |
|
|
);
|
176 |
|
|
end component;
|
177 |
|
|
|
178 |
|
|
-- asynchronous reset signal
|
179 |
|
|
signal arst_signal : std_logic;
|
180 |
|
|
|
181 |
|
|
-- primary address decoder
|
182 |
|
|
signal PIOsel : std_logic; -- controller select, IDE devices select
|
183 |
|
|
|
184 |
|
|
-- control signal
|
185 |
|
|
signal IDEctrl_rst, IDEctrl_IDEen, IDEctrl_FATR0, IDEctrl_FATR1 : std_logic;
|
186 |
|
|
-- compatible mode timing
|
187 |
|
|
signal PIO_cmdport_T1, PIO_cmdport_T2, PIO_cmdport_T4, PIO_cmdport_Teoc : std_logic_vector(7 downto 0);
|
188 |
|
|
signal PIO_cmdport_IORDYen : std_logic;
|
189 |
|
|
-- data port0 timing
|
190 |
|
|
signal PIO_dport0_T1, PIO_dport0_T2, PIO_dport0_T4, PIO_dport0_Teoc : std_logic_vector(7 downto 0);
|
191 |
|
|
signal PIO_dport0_IORDYen : std_logic;
|
192 |
|
|
-- data port1 timing
|
193 |
|
|
signal PIO_dport1_T1, PIO_dport1_T2, PIO_dport1_T4, PIO_dport1_Teoc : std_logic_vector(7 downto 0);
|
194 |
|
|
signal PIO_dport1_IORDYen : std_logic;
|
195 |
|
|
|
196 |
|
|
signal PIOack : std_logic;
|
197 |
|
|
signal PIOq : std_logic_vector(15 downto 0);
|
198 |
|
|
signal PIOa : std_logic_vector(3 downto 0);
|
199 |
|
|
signal PIOd : std_logic_vector(15 downto 0);
|
200 |
|
|
signal PIOwe : std_logic;
|
201 |
|
|
|
202 |
|
|
signal irq : std_logic; -- ATA bus IRQ signal
|
203 |
|
|
|
204 |
|
|
signal reset : std_logic;
|
205 |
|
|
signal gnd,vcc : std_logic;
|
206 |
|
|
signal gnd32 : std_logic_vector(31 downto 0);
|
207 |
|
|
|
208 |
|
|
begin
|
209 |
|
|
gnd <= '0';vcc <= '1'; gnd32 <= zero32;
|
210 |
|
|
-- generate asynchronous reset level
|
211 |
|
|
arst_signal <= arst;-- xor ARST_LVL;
|
212 |
|
|
reset <= not rst;
|
213 |
|
|
|
214 |
|
|
dmack <= vcc; -- Disable DMA
|
215 |
|
|
|
216 |
|
|
-- Generate CompactFlash signals
|
217 |
|
|
--cfo.power connected to bit 31 of the control register
|
218 |
|
|
cfo.atasel <= gnd;
|
219 |
|
|
cfo.we <= vcc;
|
220 |
|
|
cfo.csel <= gnd;
|
221 |
|
|
cfo.da <= (others => gnd);
|
222 |
|
|
|
223 |
|
|
u0: ocidec2_amba_slave
|
224 |
|
|
generic map(
|
225 |
|
|
hindex => hindex,
|
226 |
|
|
haddr => haddr,
|
227 |
|
|
hmask => hmask,
|
228 |
|
|
pirq => pirq,
|
229 |
|
|
DeviceID => DeviceID,
|
230 |
|
|
RevisionNo => RevisionNo,
|
231 |
|
|
|
232 |
|
|
-- PIO mode 0 settings
|
233 |
|
|
PIO_mode0_T1 => PIO_mode0_T1,
|
234 |
|
|
PIO_mode0_T2 => PIO_mode0_T2,
|
235 |
|
|
PIO_mode0_T4 => PIO_mode0_T4,
|
236 |
|
|
PIO_mode0_Teoc => PIO_mode0_Teoc,
|
237 |
|
|
|
238 |
|
|
-- Multiword DMA mode 0 settings
|
239 |
|
|
-- OCIDEC-1 does not support DMA, set registers to zero
|
240 |
|
|
DMA_mode0_Tm => 0,
|
241 |
|
|
DMA_mode0_Td => 0,
|
242 |
|
|
DMA_mode0_Teoc => 0
|
243 |
|
|
)
|
244 |
|
|
port map(
|
245 |
|
|
arst => arst_signal,
|
246 |
|
|
rst => rst,
|
247 |
|
|
clk => clk,
|
248 |
|
|
ahbsi => ahbsi,
|
249 |
|
|
ahbso => ahbso,
|
250 |
|
|
|
251 |
|
|
cf_power => cfo.power, -- power switch for compactflash
|
252 |
|
|
|
253 |
|
|
-- PIO control input
|
254 |
|
|
-- PIOtip is only asserted during a PIO transfer (No shit! ;)
|
255 |
|
|
-- Since it is impossible to read the status register and access the PIO registers at the same time
|
256 |
|
|
-- this bit is useless (besides using-up resources)
|
257 |
|
|
PIOtip => gnd,
|
258 |
|
|
PIOack => PIOack,
|
259 |
|
|
PIOq => PIOq,
|
260 |
|
|
PIOsel => PIOsel,
|
261 |
|
|
PIOpp_full => gnd, -- OCIDEC-1 does not support PIO-write PingPong, negate signal
|
262 |
|
|
irq => irq,
|
263 |
|
|
PIOa => PIOa,
|
264 |
|
|
PIOd => PIOd,
|
265 |
|
|
PIOwe => PIOwe,
|
266 |
|
|
|
267 |
|
|
-- DMA control inputs (negate all of them)
|
268 |
|
|
DMAtip => gnd,
|
269 |
|
|
DMAack => gnd,
|
270 |
|
|
DMARxEmpty => gnd,
|
271 |
|
|
DMATxFull => gnd,
|
272 |
|
|
DMA_dmarq => gnd,
|
273 |
|
|
DMAq => gnd32,
|
274 |
|
|
|
275 |
|
|
-- outputs
|
276 |
|
|
-- control register outputs
|
277 |
|
|
IDEctrl_rst => IDEctrl_rst,
|
278 |
|
|
IDEctrl_IDEen => IDEctrl_IDEen,
|
279 |
|
|
IDEctrl_FATR0 => IDEctrl_FATR0,
|
280 |
|
|
IDEctrl_FATR1 => IDEctrl_FATR1,
|
281 |
|
|
|
282 |
|
|
-- CMD port timing registers
|
283 |
|
|
PIO_cmdport_T1 => PIO_cmdport_T1,
|
284 |
|
|
PIO_cmdport_T2 => PIO_cmdport_T2,
|
285 |
|
|
PIO_cmdport_T4 => PIO_cmdport_T4,
|
286 |
|
|
PIO_cmdport_Teoc => PIO_cmdport_Teoc,
|
287 |
|
|
PIO_cmdport_IORDYen => PIO_cmdport_IORDYen,
|
288 |
|
|
|
289 |
|
|
-- data-port0 timing registers
|
290 |
|
|
PIO_dport0_T1 => PIO_dport0_T1,
|
291 |
|
|
PIO_dport0_T2 => PIO_dport0_T2,
|
292 |
|
|
PIO_dport0_T4 => PIO_dport0_T4,
|
293 |
|
|
PIO_dport0_Teoc => PIO_dport0_Teoc,
|
294 |
|
|
PIO_dport0_IORDYen => PIO_dport0_IORDYen,
|
295 |
|
|
|
296 |
|
|
-- data-port1 timing registers
|
297 |
|
|
PIO_dport1_T1 => PIO_dport1_T1,
|
298 |
|
|
PIO_dport1_T2 => PIO_dport1_T2,
|
299 |
|
|
PIO_dport1_T4 => PIO_dport1_T4,
|
300 |
|
|
PIO_dport1_Teoc => PIO_dport1_Teoc,
|
301 |
|
|
PIO_dport1_IORDYen => PIO_dport1_IORDYen
|
302 |
|
|
);
|
303 |
|
|
|
304 |
|
|
u1: ocidec2_controller
|
305 |
|
|
generic map(
|
306 |
|
|
TWIDTH => TWIDTH,
|
307 |
|
|
PIO_mode0_T1 => PIO_mode0_T1,
|
308 |
|
|
PIO_mode0_T2 => PIO_mode0_T2,
|
309 |
|
|
PIO_mode0_T4 => PIO_mode0_T4,
|
310 |
|
|
PIO_mode0_Teoc => PIO_mode0_Teoc
|
311 |
|
|
)
|
312 |
|
|
port map(
|
313 |
|
|
clk => clk,
|
314 |
|
|
nReset => arst_signal,
|
315 |
|
|
rst => reset,
|
316 |
|
|
irq => irq,
|
317 |
|
|
IDEctrl_rst => IDEctrl_rst,
|
318 |
|
|
IDEctrl_IDEen => IDEctrl_IDEen,
|
319 |
|
|
IDEctrl_FATR0 => IDEctrl_FATR0,
|
320 |
|
|
IDEctrl_FATR1 => IDEctrl_FATR1,
|
321 |
|
|
cmdport_T1 => PIO_cmdport_T1,
|
322 |
|
|
cmdport_T2 => PIO_cmdport_T2,
|
323 |
|
|
cmdport_T4 => PIO_cmdport_T4,
|
324 |
|
|
cmdport_Teoc => PIO_cmdport_Teoc,
|
325 |
|
|
cmdport_IORDYen => PIO_cmdport_IORDYen,
|
326 |
|
|
dport0_T1 => PIO_dport0_T1,
|
327 |
|
|
dport0_T2 => PIO_dport0_T2,
|
328 |
|
|
dport0_T4 => PIO_dport0_T4,
|
329 |
|
|
dport0_Teoc => PIO_dport0_Teoc,
|
330 |
|
|
dport0_IORDYen => PIO_dport0_IORDYen,
|
331 |
|
|
dport1_T1 => PIO_dport1_T1,
|
332 |
|
|
dport1_T2 => PIO_dport1_T2,
|
333 |
|
|
dport1_T4 => PIO_dport1_T4,
|
334 |
|
|
dport1_Teoc => PIO_dport1_Teoc,
|
335 |
|
|
dport1_IORDYen => PIO_dport1_IORDYen,
|
336 |
|
|
PIOreq => PIOsel,
|
337 |
|
|
PIOack => PIOack,
|
338 |
|
|
PIOa => PIOa,
|
339 |
|
|
PIOd => PIOd,
|
340 |
|
|
PIOq => PIOq,
|
341 |
|
|
PIOwe => PIOwe,
|
342 |
|
|
|
343 |
|
|
RESETn => ata_resetn,
|
344 |
|
|
DDi => ddin,
|
345 |
|
|
DDo => ddout,
|
346 |
|
|
DDoe => ddoe,
|
347 |
|
|
DA => da,
|
348 |
|
|
CS0n => cs0n,
|
349 |
|
|
CS1n => cs1n,
|
350 |
|
|
DIORn => diorn,
|
351 |
|
|
DIOWn => diown,
|
352 |
|
|
IORDY => iordy,
|
353 |
|
|
INTRQ => intrq
|
354 |
|
|
);
|
355 |
|
|
|
356 |
|
|
-- pragma translate_off
|
357 |
|
|
bootmsg : report_version
|
358 |
|
|
generic map ("atactrl" & tost(hindex) &
|
359 |
|
|
": ATA controller rev " & tost(VERSION) & ", no DMA, irq " & tost(pirq));
|
360 |
|
|
-- pragma translate_on
|
361 |
|
|
end;
|
362 |
|
|
|