1 |
27 |
rherveille |
---------------------------------------------------------------------
|
2 |
|
|
---- ----
|
3 |
|
|
---- OpenCores IDE Controller ----
|
4 |
|
|
---- Wishbone Slave (common for all OCIDEC cores) ----
|
5 |
|
|
---- ----
|
6 |
|
|
---- Author: Richard Herveille ----
|
7 |
|
|
---- richard@asics.ws ----
|
8 |
|
|
---- www.asics.ws ----
|
9 |
|
|
---- ----
|
10 |
|
|
---------------------------------------------------------------------
|
11 |
|
|
---- ----
|
12 |
|
|
---- Copyright (C) 2002 Richard Herveille ----
|
13 |
|
|
---- richard@asics.ws ----
|
14 |
|
|
---- ----
|
15 |
|
|
---- This source file may be used and distributed without ----
|
16 |
|
|
---- restriction provided that this copyright statement is not ----
|
17 |
|
|
---- removed from the file and that any derivative work contains ----
|
18 |
|
|
---- the original copyright notice and the associated disclaimer.----
|
19 |
|
|
---- ----
|
20 |
|
|
---- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY ----
|
21 |
|
|
---- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED ----
|
22 |
|
|
---- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ----
|
23 |
|
|
---- FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR ----
|
24 |
|
|
---- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ----
|
25 |
|
|
---- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ----
|
26 |
|
|
---- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ----
|
27 |
|
|
---- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ----
|
28 |
|
|
---- BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ----
|
29 |
|
|
---- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ----
|
30 |
|
|
---- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ----
|
31 |
|
|
---- OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ----
|
32 |
|
|
---- POSSIBILITY OF SUCH DAMAGE. ----
|
33 |
|
|
---- ----
|
34 |
|
|
---------------------------------------------------------------------
|
35 |
|
|
|
36 |
|
|
--
|
37 |
|
|
-- CVS Log
|
38 |
|
|
--
|
39 |
|
|
-- $Id: atahost_wb_slave.vhd,v 1.1 2002-02-18 14:32:12 rherveille Exp $
|
40 |
|
|
--
|
41 |
|
|
-- $Date: 2002-02-18 14:32:12 $
|
42 |
|
|
-- $Revision: 1.1 $
|
43 |
|
|
-- $Author: rherveille $
|
44 |
|
|
-- $Locker: $
|
45 |
|
|
-- $State: Exp $
|
46 |
|
|
--
|
47 |
|
|
-- Change History:
|
48 |
|
|
-- $Log: not supported by cvs2svn $
|
49 |
|
|
--
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
library ieee;
|
53 |
|
|
use ieee.std_logic_1164.all;
|
54 |
|
|
use ieee.std_logic_arith.all;
|
55 |
|
|
|
56 |
|
|
entity atahost_wb_slave is
|
57 |
|
|
generic(
|
58 |
|
|
DeviceID : unsigned(3 downto 0) := x"0";
|
59 |
|
|
RevisionNo : unsigned(3 downto 0) := x"0";
|
60 |
|
|
|
61 |
|
|
-- PIO mode 0 settings (@100MHz clock)
|
62 |
|
|
PIO_mode0_T1 : natural := 6; -- 70ns
|
63 |
|
|
PIO_mode0_T2 : natural := 28; -- 290ns
|
64 |
|
|
PIO_mode0_T4 : natural := 2; -- 30ns
|
65 |
|
|
PIO_mode0_Teoc : natural := 23; -- 240ns ==> T0 - T1 - T2 = 600 - 70 - 290 = 240
|
66 |
|
|
|
67 |
|
|
-- Multiword DMA mode 0 settings (@100MHz clock)
|
68 |
|
|
DMA_mode0_Tm : natural := 4; -- 50ns
|
69 |
|
|
DMA_mode0_Td : natural := 21; -- 215ns
|
70 |
|
|
DMA_mode0_Teoc : natural := 21 -- 215ns ==> T0 - Td - Tm = 480 - 50 - 215 = 215
|
71 |
|
|
);
|
72 |
|
|
port(
|
73 |
|
|
-- WISHBONE SYSCON signals
|
74 |
|
|
clk_i : in std_logic; -- master clock in
|
75 |
|
|
arst_i : in std_logic := '1'; -- asynchronous active low reset
|
76 |
|
|
rst_i : in std_logic := '0'; -- synchronous active high reset
|
77 |
|
|
|
78 |
|
|
-- WISHBONE SLAVE signals
|
79 |
|
|
cyc_i : in std_logic; -- valid bus cycle input
|
80 |
|
|
stb_i : in std_logic; -- strobe/core select input
|
81 |
|
|
ack_o : out std_logic; -- strobe acknowledge output
|
82 |
|
|
rty_o : out std_logic; -- retry output
|
83 |
|
|
err_o : out std_logic; -- error output
|
84 |
|
|
adr_i : in unsigned(6 downto 2); -- A6 = '1' ATA devices selected
|
85 |
|
|
-- A5 = '1' CS1- asserted, '0' CS0- asserted
|
86 |
|
|
-- A4..A2 ATA address lines
|
87 |
|
|
-- A6 = '0' ATA controller selected
|
88 |
|
|
dat_i : in std_logic_vector(31 downto 0); -- Databus in
|
89 |
|
|
dat_o : out std_logic_vector(31 downto 0); -- Databus out
|
90 |
|
|
sel_i : in std_logic_vector(3 downto 0); -- Byte select signals
|
91 |
|
|
we_i : in std_logic; -- Write enable input
|
92 |
|
|
inta_o : out std_logic; -- interrupt request signal IDE0
|
93 |
|
|
|
94 |
|
|
-- PIO control input
|
95 |
|
|
PIOsel : buffer std_logic;
|
96 |
|
|
PIOtip, -- PIO transfer in progress
|
97 |
|
|
PIOack : in std_logic; -- PIO acknowledge signal
|
98 |
|
|
PIOq : in std_logic_vector(15 downto 0); -- PIO data input
|
99 |
|
|
PIOpp_full : in std_logic; -- PIO write-ping-pong buffers full
|
100 |
|
|
irq : in std_logic; -- interrupt signal input
|
101 |
|
|
|
102 |
|
|
-- DMA control inputs
|
103 |
|
|
DMAsel : out std_logic;
|
104 |
|
|
DMAtip, -- DMA transfer in progress
|
105 |
|
|
DMAack, -- DMA transfer acknowledge
|
106 |
|
|
DMARxEmpty, -- DMA receive buffer empty
|
107 |
|
|
DMATxFull, -- DMA transmit buffer full
|
108 |
|
|
DMA_dmarq : in std_logic; -- wishbone DMA request
|
109 |
|
|
DMAq : in std_logic_vector(31 downto 0);
|
110 |
|
|
|
111 |
|
|
-- outputs
|
112 |
|
|
-- control register outputs
|
113 |
|
|
IDEctrl_rst,
|
114 |
|
|
IDEctrl_IDEen,
|
115 |
|
|
IDEctrl_FATR1,
|
116 |
|
|
IDEctrl_FATR0,
|
117 |
|
|
IDEctrl_ppen,
|
118 |
|
|
DMActrl_DMAen,
|
119 |
|
|
DMActrl_dir,
|
120 |
|
|
DMActrl_BeLeC0,
|
121 |
|
|
DMActrl_BeLeC1 : out std_logic;
|
122 |
|
|
|
123 |
|
|
-- CMD port timing registers
|
124 |
|
|
PIO_cmdport_T1,
|
125 |
|
|
PIO_cmdport_T2,
|
126 |
|
|
PIO_cmdport_T4,
|
127 |
|
|
PIO_cmdport_Teoc : buffer unsigned(7 downto 0);
|
128 |
|
|
PIO_cmdport_IORDYen : out std_logic;
|
129 |
|
|
|
130 |
|
|
-- data-port0 timing registers
|
131 |
|
|
PIO_dport0_T1,
|
132 |
|
|
PIO_dport0_T2,
|
133 |
|
|
PIO_dport0_T4,
|
134 |
|
|
PIO_dport0_Teoc : buffer unsigned(7 downto 0);
|
135 |
|
|
PIO_dport0_IORDYen : out std_logic;
|
136 |
|
|
|
137 |
|
|
-- data-port1 timing registers
|
138 |
|
|
PIO_dport1_T1,
|
139 |
|
|
PIO_dport1_T2,
|
140 |
|
|
PIO_dport1_T4,
|
141 |
|
|
PIO_dport1_Teoc : buffer unsigned(7 downto 0);
|
142 |
|
|
PIO_dport1_IORDYen : out std_logic;
|
143 |
|
|
|
144 |
|
|
-- DMA device0 timing registers
|
145 |
|
|
DMA_dev0_Tm,
|
146 |
|
|
DMA_dev0_Td,
|
147 |
|
|
DMA_dev0_Teoc : buffer unsigned(7 downto 0);
|
148 |
|
|
|
149 |
|
|
-- DMA device1 timing registers
|
150 |
|
|
DMA_dev1_Tm,
|
151 |
|
|
DMA_dev1_Td,
|
152 |
|
|
DMA_dev1_Teoc : buffer unsigned(7 downto 0)
|
153 |
|
|
);
|
154 |
|
|
end entity atahost_wb_slave;
|
155 |
|
|
|
156 |
|
|
architecture structural of atahost_wb_slave is
|
157 |
|
|
--
|
158 |
|
|
-- constants
|
159 |
|
|
--
|
160 |
|
|
|
161 |
|
|
-- addresses
|
162 |
|
|
alias ATA_DEV_ADR : std_logic is adr_i(6);
|
163 |
|
|
alias ATA_ADR : unsigned(3 downto 0) is adr_i(5 downto 2);
|
164 |
|
|
|
165 |
|
|
constant ATA_CTRL_REG : unsigned(3 downto 0) := "0000";
|
166 |
|
|
constant ATA_STAT_REG : unsigned(3 downto 0) := "0001";
|
167 |
|
|
constant ATA_PIO_CMD : unsigned(3 downto 0) := "0010";
|
168 |
|
|
constant ATA_PIO_DP0 : unsigned(3 downto 0) := "0011";
|
169 |
|
|
constant ATA_PIO_DP1 : unsigned(3 downto 0) := "0100";
|
170 |
|
|
constant ATA_DMA_DEV0 : unsigned(3 downto 0) := "0101";
|
171 |
|
|
constant ATA_DMA_DEV1 : unsigned(3 downto 0) := "0110";
|
172 |
|
|
-- reserved --
|
173 |
|
|
constant ATA_DMA_PORT : unsigned(3 downto 0) := "1111";
|
174 |
|
|
|
175 |
|
|
--
|
176 |
|
|
-- function declarations
|
177 |
|
|
--
|
178 |
|
|
-- overload '=' to compare two unsigned numbers
|
179 |
|
|
function "=" (a, b : unsigned) return std_logic is
|
180 |
|
|
alias la: unsigned(1 to a'length) is a;
|
181 |
|
|
alias lb: unsigned(1 to b'length) is b;
|
182 |
|
|
variable result : std_logic;
|
183 |
|
|
begin
|
184 |
|
|
-- check vector length
|
185 |
|
|
assert a'length = b'length
|
186 |
|
|
report "std_logic_vector comparison: operands of unequal lengths"
|
187 |
|
|
severity FAILURE;
|
188 |
|
|
|
189 |
|
|
result := '1';
|
190 |
|
|
for n in 1 to a'length loop
|
191 |
|
|
result := result and not (la(n) xor lb(n));
|
192 |
|
|
end loop;
|
193 |
|
|
|
194 |
|
|
return result;
|
195 |
|
|
end;
|
196 |
|
|
|
197 |
|
|
-- primary address decoder
|
198 |
|
|
signal CONsel : std_logic; -- controller select, IDE devices select
|
199 |
|
|
signal berr, brty : std_logic; -- bus error, bus retry
|
200 |
|
|
|
201 |
|
|
-- registers
|
202 |
|
|
signal CtrlReg, StatReg : std_logic_vector(31 downto 0); -- control and status registers
|
203 |
|
|
|
204 |
|
|
begin
|
205 |
|
|
--
|
206 |
|
|
-- generate bus cycle / address decoder
|
207 |
|
|
--
|
208 |
|
|
gen_bc_dec: block
|
209 |
|
|
signal w_acc, dw_acc : std_logic; -- word access, double word access
|
210 |
|
|
signal store_pp_full : std_logic;
|
211 |
|
|
begin
|
212 |
|
|
-- word / double word
|
213 |
|
|
w_acc <= sel_i(1) and sel_i(0);
|
214 |
|
|
dw_acc <= sel_i(3) and sel_i(2) and sel_i(1) and sel_i(0);
|
215 |
|
|
|
216 |
|
|
-- bus error
|
217 |
|
|
berr <= not w_acc when (ATA_DEV_ADR = '1') else not dw_acc;
|
218 |
|
|
|
219 |
|
|
-- PIO accesses at least 16bit wide, no PIO access during DMAtip or pingpong full
|
220 |
|
|
PIOsel <= cyc_i and stb_i and ATA_DEV_ADR and w_acc and not (DMAtip or store_pp_full);
|
221 |
|
|
|
222 |
|
|
-- CON accesses only 32bit wide
|
223 |
|
|
CONsel <= cyc_i and stb_i and not ATA_DEV_ADR and dw_acc;
|
224 |
|
|
DMAsel <= CONsel and (ATA_ADR = ATA_DMA_PORT);
|
225 |
|
|
|
226 |
|
|
-- bus retry (OCIDEC-3 and above)
|
227 |
|
|
-- store PIOpp_full, we don't want a PPfull based retry initiated by the current bus-cycle
|
228 |
|
|
process(clk_i)
|
229 |
|
|
begin
|
230 |
|
|
if (clk_i'event and clk_i = '1') then
|
231 |
|
|
if (PIOsel = '0') then
|
232 |
|
|
store_pp_full <= PIOpp_full;
|
233 |
|
|
end if;
|
234 |
|
|
end if;
|
235 |
|
|
end process;
|
236 |
|
|
brty <= (ATA_DEV_ADR and w_acc) and (DMAtip or store_pp_full);
|
237 |
|
|
end block gen_bc_dec;
|
238 |
|
|
|
239 |
|
|
--
|
240 |
|
|
-- generate registers
|
241 |
|
|
--
|
242 |
|
|
register_block : block
|
243 |
|
|
signal sel_PIO_cmdport, sel_PIO_dport0, sel_PIO_dport1 : std_logic; -- PIO timing registers
|
244 |
|
|
signal sel_DMA_dev0, sel_DMA_dev1 : std_logic; -- DMA timing registers
|
245 |
|
|
signal sel_ctrl, sel_stat : std_logic; -- control / status register
|
246 |
|
|
begin
|
247 |
|
|
-- generate register select signals
|
248 |
|
|
sel_ctrl <= CONsel and we_i and (ATA_ADR = ATA_CTRL_REG);
|
249 |
|
|
sel_stat <= CONsel and we_i and (ATA_ADR = ATA_STAT_REG);
|
250 |
|
|
sel_PIO_cmdport <= CONsel and we_i and (ATA_ADR = ATA_PIO_CMD);
|
251 |
|
|
sel_PIO_dport0 <= CONsel and we_i and (ATA_ADR = ATA_PIO_DP0);
|
252 |
|
|
sel_PIO_dport1 <= CONsel and we_i and (ATA_ADR = ATA_PIO_DP1);
|
253 |
|
|
sel_DMA_dev0 <= CONsel and we_i and (ATA_ADR = ATA_DMA_DEV0);
|
254 |
|
|
sel_DMA_dev1 <= CONsel and we_i and (ATA_ADR = ATA_DMA_DEV1);
|
255 |
|
|
-- reserved 0x1C-0x38 --
|
256 |
|
|
-- reserved 0x3C : DMA port --
|
257 |
|
|
|
258 |
|
|
-- generate control register
|
259 |
|
|
gen_ctrl_reg: process(clk_i, arst_i)
|
260 |
|
|
begin
|
261 |
|
|
if (arst_i = '0') then
|
262 |
|
|
CtrlReg(31 downto 1) <= (others => '0');
|
263 |
|
|
CtrlReg(0) <= '1'; -- set reset bit
|
264 |
|
|
elsif (clk_i'event and clk_i = '1') then
|
265 |
|
|
if (rst_i = '1') then
|
266 |
|
|
CtrlReg(31 downto 1) <= (others => '0');
|
267 |
|
|
CtrlReg(0) <= '1'; -- set reset bit
|
268 |
|
|
elsif (sel_ctrl = '1') then
|
269 |
|
|
CtrlReg <= dat_i;
|
270 |
|
|
end if;
|
271 |
|
|
end if;
|
272 |
|
|
end process gen_ctrl_reg;
|
273 |
|
|
-- assign bits
|
274 |
|
|
DMActrl_DMAen <= CtrlReg(15);
|
275 |
|
|
DMActrl_dir <= CtrlReg(13);
|
276 |
|
|
DMActrl_BeLeC1 <= CtrlReg(9);
|
277 |
|
|
DMActrl_BeLeC0 <= CtrlReg(8);
|
278 |
|
|
IDEctrl_IDEen <= CtrlReg(7);
|
279 |
|
|
IDEctrl_FATR1 <= CtrlReg(6);
|
280 |
|
|
IDEctrl_FATR0 <= CtrlReg(5);
|
281 |
|
|
IDEctrl_ppen <= CtrlReg(4);
|
282 |
|
|
PIO_dport1_IORDYen <= CtrlReg(3);
|
283 |
|
|
PIO_dport0_IORDYen <= CtrlReg(2);
|
284 |
|
|
PIO_cmdport_IORDYen <= CtrlReg(1);
|
285 |
|
|
IDEctrl_rst <= CtrlReg(0);
|
286 |
|
|
|
287 |
|
|
-- generate status register clearable bits
|
288 |
|
|
gen_stat_reg: block
|
289 |
|
|
signal dirq, int : std_logic;
|
290 |
|
|
begin
|
291 |
|
|
gen_irq: process(clk_i, arst_i)
|
292 |
|
|
begin
|
293 |
|
|
if (arst_i = '0') then
|
294 |
|
|
int <= '0';
|
295 |
|
|
dirq <= '0';
|
296 |
|
|
elsif (clk_i'event and clk_i = '1') then
|
297 |
|
|
if (rst_i = '1') then
|
298 |
|
|
int <= '0';
|
299 |
|
|
dirq <= '0';
|
300 |
|
|
else
|
301 |
|
|
int <= (int or (irq and not dirq)) and not (sel_stat and not dat_i(0));
|
302 |
|
|
dirq <= irq;
|
303 |
|
|
end if;
|
304 |
|
|
end if;
|
305 |
|
|
end process gen_irq;
|
306 |
|
|
|
307 |
|
|
gen_stat: process(DMAtip, DMARxEmpty, DMATxFull, DMA_dmarq, PIOtip, int, PIOpp_full)
|
308 |
|
|
begin
|
309 |
|
|
StatReg(31 downto 0) <= (others => '0'); -- clear all bits (read unused bits as '0')
|
310 |
|
|
|
311 |
|
|
StatReg(31 downto 28) <= std_logic_vector(DeviceId); -- set Device ID
|
312 |
|
|
StatReg(27 downto 24) <= std_logic_vector(RevisionNo); -- set revision number
|
313 |
|
|
StatReg(15) <= DMAtip;
|
314 |
|
|
StatReg(10) <= DMARxEmpty;
|
315 |
|
|
StatReg(9) <= DMATxFull;
|
316 |
|
|
StatReg(8) <= DMA_dmarq;
|
317 |
|
|
StatReg(7) <= PIOtip;
|
318 |
|
|
StatReg(6) <= PIOpp_full;
|
319 |
|
|
StatReg(0) <= int;
|
320 |
|
|
end process;
|
321 |
|
|
end block gen_stat_reg;
|
322 |
|
|
|
323 |
|
|
-- generate PIO compatible / command-port timing register
|
324 |
|
|
gen_PIO_cmdport_reg: process(clk_i, arst_i)
|
325 |
|
|
begin
|
326 |
|
|
if (arst_i = '0') then
|
327 |
|
|
PIO_cmdport_T1 <= conv_unsigned(PIO_mode0_T1, 8);
|
328 |
|
|
PIO_cmdport_T2 <= conv_unsigned(PIO_mode0_T2, 8);
|
329 |
|
|
PIO_cmdport_T4 <= conv_unsigned(PIO_mode0_T4, 8);
|
330 |
|
|
PIO_cmdport_Teoc <= conv_unsigned(PIO_mode0_Teoc, 8);
|
331 |
|
|
elsif (clk_i'event and clk_i = '1') then
|
332 |
|
|
if (rst_i = '1') then
|
333 |
|
|
PIO_cmdport_T1 <= conv_unsigned(PIO_mode0_T1, 8);
|
334 |
|
|
PIO_cmdport_T2 <= conv_unsigned(PIO_mode0_T2, 8);
|
335 |
|
|
PIO_cmdport_T4 <= conv_unsigned(PIO_mode0_T4, 8);
|
336 |
|
|
PIO_cmdport_Teoc <= conv_unsigned(PIO_mode0_Teoc, 8);
|
337 |
|
|
elsif (sel_PIO_cmdport = '1') then
|
338 |
|
|
PIO_cmdport_T1 <= unsigned(dat_i( 7 downto 0));
|
339 |
|
|
PIO_cmdport_T2 <= unsigned(dat_i(15 downto 8));
|
340 |
|
|
PIO_cmdport_T4 <= unsigned(dat_i(23 downto 16));
|
341 |
|
|
PIO_cmdport_Teoc <= unsigned(dat_i(31 downto 24));
|
342 |
|
|
end if;
|
343 |
|
|
end if;
|
344 |
|
|
end process gen_PIO_cmdport_reg;
|
345 |
|
|
|
346 |
|
|
-- generate PIO device0 timing register
|
347 |
|
|
gen_PIO_dport0_reg: process(clk_i, arst_i)
|
348 |
|
|
begin
|
349 |
|
|
if (arst_i = '0') then
|
350 |
|
|
PIO_dport0_T1 <= conv_unsigned(PIO_mode0_T1, 8);
|
351 |
|
|
PIO_dport0_T2 <= conv_unsigned(PIO_mode0_T2, 8);
|
352 |
|
|
PIO_dport0_T4 <= conv_unsigned(PIO_mode0_T4, 8);
|
353 |
|
|
PIO_dport0_Teoc <= conv_unsigned(PIO_mode0_Teoc, 8);
|
354 |
|
|
elsif (clk_i'event and clk_i = '1') then
|
355 |
|
|
if (rst_i = '1') then
|
356 |
|
|
PIO_dport0_T1 <= conv_unsigned(PIO_mode0_T1, 8);
|
357 |
|
|
PIO_dport0_T2 <= conv_unsigned(PIO_mode0_T2, 8);
|
358 |
|
|
PIO_dport0_T4 <= conv_unsigned(PIO_mode0_T4, 8);
|
359 |
|
|
PIO_dport0_Teoc <= conv_unsigned(PIO_mode0_Teoc, 8);
|
360 |
|
|
elsif (sel_PIO_dport0 = '1') then
|
361 |
|
|
PIO_dport0_T1 <= unsigned(dat_i( 7 downto 0));
|
362 |
|
|
PIO_dport0_T2 <= unsigned(dat_i(15 downto 8));
|
363 |
|
|
PIO_dport0_T4 <= unsigned(dat_i(23 downto 16));
|
364 |
|
|
PIO_dport0_Teoc <= unsigned(dat_i(31 downto 24));
|
365 |
|
|
end if;
|
366 |
|
|
end if;
|
367 |
|
|
end process gen_PIO_dport0_reg;
|
368 |
|
|
|
369 |
|
|
-- generate PIO device1 timing register
|
370 |
|
|
gen_PIO_dport1_reg: process(clk_i, arst_i)
|
371 |
|
|
begin
|
372 |
|
|
if (arst_i = '0') then
|
373 |
|
|
PIO_dport1_T1 <= conv_unsigned(PIO_mode0_T1, 8);
|
374 |
|
|
PIO_dport1_T2 <= conv_unsigned(PIO_mode0_T2, 8);
|
375 |
|
|
PIO_dport1_T4 <= conv_unsigned(PIO_mode0_T4, 8);
|
376 |
|
|
PIO_dport1_Teoc <= conv_unsigned(PIO_mode0_Teoc, 8);
|
377 |
|
|
elsif (clk_i'event and clk_i = '1') then
|
378 |
|
|
if (rst_i = '1') then
|
379 |
|
|
PIO_dport1_T1 <= conv_unsigned(PIO_mode0_T1, 8);
|
380 |
|
|
PIO_dport1_T2 <= conv_unsigned(PIO_mode0_T2, 8);
|
381 |
|
|
PIO_dport1_T4 <= conv_unsigned(PIO_mode0_T4, 8);
|
382 |
|
|
PIO_dport1_Teoc <= conv_unsigned(PIO_mode0_Teoc, 8);
|
383 |
|
|
elsif (sel_PIO_dport1 = '1') then
|
384 |
|
|
PIO_dport1_T1 <= unsigned(dat_i( 7 downto 0));
|
385 |
|
|
PIO_dport1_T2 <= unsigned(dat_i(15 downto 8));
|
386 |
|
|
PIO_dport1_T4 <= unsigned(dat_i(23 downto 16));
|
387 |
|
|
PIO_dport1_Teoc <= unsigned(dat_i(31 downto 24));
|
388 |
|
|
end if;
|
389 |
|
|
end if;
|
390 |
|
|
end process gen_PIO_dport1_reg;
|
391 |
|
|
|
392 |
|
|
-- generate DMA device0 timing register
|
393 |
|
|
gen_DMA_dev0_reg: process(clk_i, arst_i)
|
394 |
|
|
begin
|
395 |
|
|
if (arst_i = '0') then
|
396 |
|
|
DMA_dev0_Tm <= conv_unsigned(DMA_mode0_Tm, 8);
|
397 |
|
|
DMA_dev0_Td <= conv_unsigned(DMA_mode0_Td, 8);
|
398 |
|
|
DMA_dev0_Teoc <= conv_unsigned(DMA_mode0_Teoc, 8);
|
399 |
|
|
elsif (clk_i'event and clk_i = '1') then
|
400 |
|
|
if (rst_i = '1') then
|
401 |
|
|
DMA_dev0_Tm <= conv_unsigned(DMA_mode0_Tm, 8);
|
402 |
|
|
DMA_dev0_Td <= conv_unsigned(DMA_mode0_Td, 8);
|
403 |
|
|
DMA_dev0_Teoc <= conv_unsigned(DMA_mode0_Teoc, 8);
|
404 |
|
|
elsif (sel_DMA_dev0 = '1') then
|
405 |
|
|
DMA_dev0_Tm <= unsigned(dat_i( 7 downto 0));
|
406 |
|
|
DMA_dev0_Td <= unsigned(dat_i(15 downto 8));
|
407 |
|
|
DMA_dev0_Teoc <= unsigned(dat_i(31 downto 24));
|
408 |
|
|
end if;
|
409 |
|
|
end if;
|
410 |
|
|
end process gen_DMA_dev0_reg;
|
411 |
|
|
|
412 |
|
|
-- generate DMA device1 timing register
|
413 |
|
|
gen_DMA_dev1_reg: process(clk_i, arst_i)
|
414 |
|
|
begin
|
415 |
|
|
if (arst_i = '0') then
|
416 |
|
|
DMA_dev1_Tm <= conv_unsigned(DMA_mode0_Tm, 8);
|
417 |
|
|
DMA_dev1_Td <= conv_unsigned(DMA_mode0_Td, 8);
|
418 |
|
|
DMA_dev1_Teoc <= conv_unsigned(DMA_mode0_Teoc, 8);
|
419 |
|
|
elsif (clk_i'event and clk_i = '1') then
|
420 |
|
|
if (rst_i = '1') then
|
421 |
|
|
DMA_dev1_Tm <= conv_unsigned(DMA_mode0_Tm, 8);
|
422 |
|
|
DMA_dev1_Td <= conv_unsigned(DMA_mode0_Td, 8);
|
423 |
|
|
DMA_dev1_Teoc <= conv_unsigned(DMA_mode0_Teoc, 8);
|
424 |
|
|
elsif (sel_DMA_dev1 = '1') then
|
425 |
|
|
DMA_dev1_Tm <= unsigned(dat_i( 7 downto 0));
|
426 |
|
|
DMA_dev1_Td <= unsigned(dat_i(15 downto 8));
|
427 |
|
|
DMA_dev1_Teoc <= unsigned(dat_i(31 downto 24));
|
428 |
|
|
end if;
|
429 |
|
|
end if;
|
430 |
|
|
end process gen_DMA_dev1_reg;
|
431 |
|
|
|
432 |
|
|
end block register_block;
|
433 |
|
|
|
434 |
|
|
--
|
435 |
|
|
-- generate WISHBONE interconnect signals
|
436 |
|
|
--
|
437 |
|
|
gen_WB_sigs: block
|
438 |
|
|
signal Q : std_logic_vector(31 downto 0);
|
439 |
|
|
begin
|
440 |
|
|
-- generate acknowledge signal
|
441 |
|
|
ack_o <= PIOack or CONsel; -- or DMAack; -- since DMAack is derived from CONsel this is OK
|
442 |
|
|
|
443 |
|
|
-- generate error signal
|
444 |
|
|
err_o <= cyc_i and stb_i and berr;
|
445 |
|
|
|
446 |
|
|
-- generate retry signal
|
447 |
|
|
rty_o <= cyc_i and stb_i and brty;
|
448 |
|
|
|
449 |
|
|
-- assign interrupt signal
|
450 |
|
|
inta_o <= StatReg(0);
|
451 |
|
|
|
452 |
|
|
-- generate output multiplexor
|
453 |
|
|
with ATA_ADR select
|
454 |
|
|
Q <= CtrlReg when ATA_CTRL_REG, -- control register
|
455 |
|
|
StatReg when ATA_STAT_REG, -- status register
|
456 |
|
|
std_logic_vector(PIO_cmdport_Teoc & PIO_cmdport_T4 & PIO_cmdport_T2 & PIO_cmdport_T1) when ATA_PIO_CMD, -- PIO compatible / cmd-port timing register
|
457 |
|
|
std_logic_vector(PIO_dport0_Teoc & PIO_dport0_T4 & PIO_dport0_T2 & PIO_dport0_T1) when ATA_PIO_DP0, -- PIO fast timing register device0
|
458 |
|
|
std_logic_vector(PIO_dport1_Teoc & PIO_dport1_T4 & PIO_dport1_T2 & PIO_dport1_T1) when ATA_PIO_DP1, -- PIO fast timing register device1
|
459 |
|
|
std_logic_vector(DMA_dev0_Teoc & x"00" & DMA_dev0_Td & DMA_dev0_Tm) when ATA_DMA_DEV0, -- DMA timing register device0
|
460 |
|
|
std_logic_vector(DMA_dev1_Teoc & x"00" & DMA_dev1_Td & DMA_dev1_Tm) when ATA_DMA_DEV1, -- DMA timing register device1
|
461 |
|
|
DMAq when ATA_DMA_PORT, -- DMA port, DMA receive register
|
462 |
|
|
(others => '0') when others;
|
463 |
|
|
|
464 |
|
|
dat_o <= (x"0000" & PIOq) when (ATA_DEV_ADR = '1') else Q;
|
465 |
|
|
end block gen_WB_sigs;
|
466 |
|
|
|
467 |
|
|
end architecture structural;
|