OpenCores
URL https://opencores.org/ocsvn/mips_enhanced/mips_enhanced/trunk

Subversion Repositories mips_enhanced

[/] [mips_enhanced/] [trunk/] [grlib-gpl-1.0.19-b3188/] [lib/] [opencores/] [ata/] [atahost_controller.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
---------------------------------------------------------------------
2
----                                                             ----
3
----  OpenCores IDE Controller                                   ----
4
----  ATA/ATAPI-5 Host controller (OCIDEC-3)                     ----
5
----                                                             ----
6
----  Author: Richard Herveille                                  ----
7
----          richard@asics.ws                                   ----
8
----          www.asics.ws                                       ----
9
----                                                             ----
10
---------------------------------------------------------------------
11
----                                                             ----
12
---- Copyright (C) 2001, 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
-- rev.: 1.0 march 8th, 2001. Initial release
37
--
38
--  CVS Log
39
--
40
--  $Id: atahost_controller.vhd,v 1.1 2002/02/18 14:32:12 rherveille Exp $
41
--
42
--  $Date: 2002/02/18 14:32:12 $
43
--  $Revision: 1.1 $
44
--  $Author: rherveille $
45
--  $Locker:  $
46
--  $State: Exp $
47
--
48
-- Change History:
49
--               $Log: atahost_controller.vhd,v $
50
--               Revision 1.1  2002/02/18 14:32:12  rherveille
51
--               renamed all files to 'atahost_***.vhd'
52
--               broke-up 'counter.vhd' into 'ud_cnt.vhd' and 'ro_cnt.vhd'
53
--               changed resD input to generic RESD in ud_cnt.vhd
54
--               changed ID input to generic ID in ro_cnt.vhd
55
--               changed core to reflect changes in ro_cnt.vhd
56
--               removed references to 'count' library
57
--               changed IO names
58
--               added disclaimer
59
--               added CVS log
60
--               moved registers and wishbone signals into 'atahost_wb_slave.vhd'
61
--
62
--
63
 
64
library ieee;
65
use ieee.std_logic_1164.all;
66
library grlib;
67
use grlib.amba.all;
68
use grlib.stdlib.all;
69
 
70
entity atahost_controller is
71
        generic(
72
                tech   : integer := 0;                   -- fifo mem technology
73
                fdepth : integer := 8;                   -- DMA fifo depth
74
                TWIDTH : natural := 8;                   -- counter width
75
 
76
                -- PIO mode 0 settings (@100MHz clock)
77
                PIO_mode0_T1 : natural := 6;             -- 70ns
78
                PIO_mode0_T2 : natural := 28;            -- 290ns
79
                PIO_mode0_T4 : natural := 2;             -- 30ns
80
                PIO_mode0_Teoc : natural := 23;          -- 240ns ==> T0 - T1 - T2 = 600 - 70 - 290 = 240
81
 
82
                -- Multiword DMA mode 0 settings (@100MHz clock)
83
                DMA_mode0_Tm : natural := 4;             -- 50ns
84
                DMA_mode0_Td : natural := 21;            -- 215ns
85
                DMA_mode0_Teoc : natural := 21           -- 215ns ==> T0 - Td - Tm = 480 - 50 - 215 = 215
86
        );
87
        port(
88
                clk : in std_logic;                                       -- master clock in
89
                nReset  : in std_logic := '1';                 -- asynchronous active low reset
90
                rst : in std_logic := '0';                    -- synchronous active high reset
91
 
92
                irq : out std_logic;                          -- interrupt request signal
93
 
94
                -- control / registers
95
                IDEctrl_IDEen,
96
                IDEctrl_rst,
97
                IDEctrl_ppen,
98
                IDEctrl_FATR0,
99
                IDEctrl_FATR1 : in std_logic;                 -- control register settings
100
 
101
                a : in std_logic_vector(3 downto 0);                  -- address input
102
                d : in std_logic_vector(31 downto 0);         -- data input
103
                we : in std_logic;                            -- write enable input '1'=write, '0'=read
104
 
105
                -- PIO registers
106
                PIO_cmdport_T1,
107
                PIO_cmdport_T2,
108
                PIO_cmdport_T4,
109
                PIO_cmdport_Teoc : in std_logic_vector(7 downto 0);
110
                PIO_cmdport_IORDYen : in std_logic;           -- PIO compatible timing settings
111
 
112
                PIO_dport0_T1,
113
                PIO_dport0_T2,
114
                PIO_dport0_T4,
115
                PIO_dport0_Teoc : in std_logic_vector(7 downto 0);
116
                PIO_dport0_IORDYen : in std_logic;            -- PIO data-port device0 timing settings
117
 
118
                PIO_dport1_T1,
119
                PIO_dport1_T2,
120
                PIO_dport1_T4,
121
                PIO_dport1_Teoc : in std_logic_vector(7 downto 0);
122
                PIO_dport1_IORDYen : in std_logic;            -- PIO data-port device1 timing settings
123
 
124
                PIOsel : in std_logic;                        -- PIO controller select
125
                PIOack : out std_logic;                       -- PIO controller acknowledge
126
                PIOq : out std_logic_vector(15 downto 0);     -- PIO data out
127
                PIOtip : out std_logic;              -- PIO transfer in progress
128
                PIOpp_full : out std_logic;                   -- PIO Write PingPong full
129
 
130
                -- DMA registers
131
                DMA_dev0_Td,
132
                DMA_dev0_Tm,
133
                DMA_dev0_Teoc : in std_logic_vector(7 downto 0);      -- DMA timing settings for device0
134
 
135
                DMA_dev1_Td,
136
                DMA_dev1_Tm,
137
                DMA_dev1_Teoc : in std_logic_vector(7 downto 0);      -- DMA timing settings for device1
138
 
139
                DMActrl_DMAen,
140
                DMActrl_dir,
141
                DMActrl_Bytesw,     --Jagre 2006-12-04 byte swap ATA data
142
                DMActrl_BeLeC0,
143
                DMActrl_BeLeC1 : in std_logic;                -- DMA settings
144
 
145
                DMAsel : in std_logic;                        -- DMA controller select
146
                DMAack : out std_logic;                       -- DMA controller acknowledge
147
                DMAq : out std_logic_vector(31 downto 0);     -- DMA data out
148
                DMAtip_out : out std_logic;                    -- DMA transfer in progress --Erik Jagre 2006-11-15
149
                DMA_dmarq : out std_logic;                    -- Synchronized ATA DMARQ line
150
 
151
                force_rdy : in std_logic;                     -- DMA transmit fifo filled up partly --Erik Jagre 2006-10-31
152
                fifo_rdy : out std_logic;                     -- DMA transmit fifo filled up --Erik Jagre 2006-10-30
153
                DMARxEmpty : out std_logic;                   -- DMA receive buffer empty
154
                DMARxFull : out std_logic;                    -- DMA receive fifo full Erik Jagre 2006-10-31
155
 
156
                DMA_req : out std_logic;                      -- DMA request to external DMA engine
157
                DMA_ack : in std_logic;                       -- DMA acknowledge from external DMA engine
158
                BM_en   : in std_logic;                       -- Bus mater enabled, for DMA reset Erik Jagre 2006-10-24
159
 
160
                -- ATA signals
161
                RESETn  : out std_logic;
162
                DDi     : in std_logic_vector(15 downto 0);
163
                DDo : out std_logic_vector(15 downto 0);
164
                DDoe : out std_logic;
165
                DA      : out std_logic_vector(2 downto 0) := "000";
166
                CS0n    : out std_logic;
167
                CS1n    : out std_logic;
168
 
169
                DMARQ   : in std_logic;
170
                DMACKn  : out std_logic;
171
                DIORn   : out std_logic;
172
                DIOWn   : out std_logic;
173
                IORDY   : in std_logic;
174
                INTRQ   : in std_logic
175
        );
176
end entity atahost_controller;
177
 
178
architecture structural of atahost_controller is
179
        --
180
        -- component declarations
181
        --
182
        component atahost_pio_controller is
183
        generic(
184
                TWIDTH : natural := 8;                   -- counter width
185
 
186
                -- PIO mode 0 settings (@100MHz clock)
187
                PIO_mode0_T1 : natural := 6;             -- 70ns
188
                PIO_mode0_T2 : natural := 28;            -- 290ns
189
                PIO_mode0_T4 : natural := 2;             -- 30ns
190
                PIO_mode0_Teoc : natural := 23           -- 240ns ==> T0 - T1 - T2 = 600 - 70 - 290 = 240
191
        );
192
        port(
193
                clk : in std_logic;                                       -- master clock in
194
                nReset  : in std_logic := '1';                 -- asynchronous active low reset
195
                rst : in std_logic := '0';                    -- synchronous active high reset
196
 
197
                -- control / registers
198
                IDEctrl_IDEen,
199
                IDEctrl_ppen,
200
                IDEctrl_FATR0,
201
                IDEctrl_FATR1 : in std_logic;
202
 
203
                -- PIO registers
204
                cmdport_T1,
205
                cmdport_T2,
206
                cmdport_T4,
207
                cmdport_Teoc : in std_logic_vector(7 downto 0);
208
                cmdport_IORDYen : in std_logic;            -- PIO command port / non-fast timing
209
 
210
                dport0_T1,
211
                dport0_T2,
212
                dport0_T4,
213
                dport0_Teoc : in std_logic_vector(7 downto 0);
214
                dport0_IORDYen : in std_logic;             -- PIO mode data-port / fast timing device 0
215
 
216
                dport1_T1,
217
                dport1_T2,
218
                dport1_T4,
219
                dport1_Teoc : in std_logic_vector(7 downto 0);
220
                dport1_IORDYen : in std_logic;             -- PIO mode data-port / fast timing device 1
221
 
222
                sel : in std_logic;                           -- PIO controller selected
223
                ack : out std_logic;                          -- PIO controller acknowledge
224
                a : in std_logic_vector(3 downto 0);                  -- lower address bits
225
                we : in std_logic;                            -- write enable input
226
                d : in std_logic_vector(15 downto 0);
227
                q : out std_logic_vector(15 downto 0);
228
 
229
                PIOreq : out std_logic;                       -- PIO transfer request
230
                PPFull : out std_logic;                       -- PIO Write PingPong Full
231
                go : in std_logic;                            -- start PIO transfer
232
                done : out std_logic;                      -- done with PIO transfer
233
 
234
                PIOa : out std_logic_vector(3 downto 0);              -- PIO address, address lines towards ATA devices
235
                PIOd : out std_logic_vector(15 downto 0);     -- PIO data, data towards ATA devices
236
 
237
                SelDev : out std_logic;                    -- Selected Device, Dev-bit in ATA Device/Head register
238
 
239
                DDi     : in std_logic_vector(15 downto 0);
240
                DDoe : out std_logic;
241
 
242
                DIOR    : out std_logic;
243
                DIOW    : out std_logic;
244
                IORDY   : in std_logic
245
        );
246
        end component atahost_pio_controller;
247
 
248
        component atahost_dma_actrl is
249
        generic(
250
                tech   : integer := 0;                     -- fifo mem technology
251
                fdepth : integer := 8;                     -- DMA fifo depth
252
                TWIDTH : natural := 8;                     -- counter width
253
 
254
                -- DMA mode 0 settings (@100MHz clock)
255
                DMA_mode0_Tm : natural := 4;               -- 50ns
256
                DMA_mode0_Td : natural := 21;              -- 215ns
257
                DMA_mode0_Teoc : natural := 21             -- 215ns ==> T0 - Td - Tm = 480 - 50 - 215 = 215
258
        );
259
        port(
260
                clk : in std_logic;                           -- master clock
261
                nReset : in std_logic;                        -- asynchronous active low reset
262
                rst : in std_logic;                           -- synchronous active high reset
263
 
264
                IDEctrl_rst : in std_logic;                   -- IDE control register bit0, 'rst'
265
 
266
                sel : in std_logic;                           -- DMA buffers selected
267
                we : in std_logic;                            -- write enable input
268
                ack : out std_logic;                                    -- acknowledge output
269
 
270
                dev0_Tm,
271
                dev0_Td,
272
                dev0_Teoc : in std_logic_vector(7 downto 0);          -- DMA mode timing device 0
273
                dev1_Tm,
274
                dev1_Td,
275
                dev1_Teoc : in std_logic_vector(7 downto 0);          -- DMA mode timing device 1
276
 
277
                DMActrl_DMAen,
278
                DMActrl_dir,
279
                DMActrl_Bytesw,
280
                DMActrl_BeLeC0,
281
                DMActrl_BeLeC1 : in std_logic;                -- control register settings
282
 
283
                TxD : in std_logic_vector(31 downto 0);       -- DMA transmit data
284
                TxFull : out std_logic;                    -- DMA transmit buffer full
285
                TxEmpty : out std_logic;
286
                RxQ : out std_logic_vector(31 downto 0);      -- DMA receive data
287
                RxEmpty : out std_logic;                   -- DMA receive buffer empty
288
                RxFull : out std_logic;                       -- DMA receive buffer full
289
                DMA_req : out std_logic;                      -- DMA request to external DMA engine
290
                DMA_ack : in std_logic;                       -- DMA acknowledge from external DMA engine
291
 
292
                DMARQ : in std_logic;                         -- ATA devices request DMA transfer
293
 
294
                SelDev : in std_logic;                        -- Selected device        
295
 
296
                Go : in std_logic;                            -- Start transfer sequence
297
                Done : out std_logic;                         -- Transfer sequence done
298
 
299
                DDi : in std_logic_vector(15 downto 0);       -- Data from ATA DD bus
300
                DDo : out std_logic_vector(15 downto 0);      -- Data towards ATA DD bus
301
 
302
                DIOR,
303
                DIOW : out std_logic
304
        );
305
        end component atahost_dma_actrl;
306
 
307
        type reg_type is record
308
          force_rdy : std_logic;
309
          fifo_rdy : std_logic;
310
          s_DMATxEmpty : std_logic;
311
          s_DMATxFull : std_logic;
312
          s_DMARxEmpty : std_logic;
313
          s_DMARxFull : std_logic;
314
        end record;
315
 
316
        constant RESET_VECTOR : reg_type := ('0','0','0','0','0','0');
317
 
318
        signal r,ri : reg_type;
319
 
320
        --
321
        -- signals
322
        --
323
        signal SelDev : std_logic;                       -- selected device
324
        signal s_DMARxFull : std_logic;                    -- DMA receive buffer full
325
 
326
        -- PIO / DMA signals
327
        signal PIOgo, DMAgo : std_logic :='0';                 -- start PIO / DMA timing controller
328
        signal PIOdone, DMAdone : std_logic :='0';             -- PIO / DMA timing controller done
329
 
330
        -- PIO signals
331
        signal PIOdior, PIOdiow : std_logic;
332
        signal PIOoe : std_logic;
333
 
334
        -- PIO pingpong signals
335
        signal PIOd : std_logic_vector(15 downto 0);
336
        signal PIOa : std_logic_vector(3 downto 0):="0000";
337
        signal PIOreq : std_logic;
338
 
339
        -- DMA signals
340
        signal DMAd : std_logic_vector(15 downto 0);
341
        signal DMAtip, s_fifo_rdy, s_DMARxEmpty, s_DMATxFull,s_DMATxEmpty, DMAdior, DMAdiow, s_DMArst: std_logic; --Erik Jagre 2006-10-24 new s_DMArst signal
342
        -- synchronized ATA inputs
343
        signal sDMARQ, sIORDY, iPIOtip, iDMAtip_out : std_logic;
344
 
345
begin
346
 
347
        --
348
        -- synchronize incoming signals
349
        --
350
        synch_incoming: block
351
                signal cDMARQ : std_logic;                   -- capture DMARQ
352
                signal cIORDY : std_logic;                   -- capture IORDY
353
                signal cINTRQ : std_logic;                   -- capture INTRQ
354
        begin
355
                process(clk)
356
                begin
357
                        if (clk'event and clk = '1') then
358
                                cDMARQ <= DMARQ;
359
                                cIORDY <= IORDY;
360
                                cINTRQ <= INTRQ;
361
 
362
                                sDMARQ <= cDMARQ;
363
                                sIORDY <= cIORDY;
364
                                irq    <= cINTRQ;
365
                        end if;
366
                end process;
367
 
368
                DMA_dmarq <= sDMARQ;
369
        end block synch_incoming;
370
 
371
        --
372
        -- generate ATA signals
373
        --
374
        gen_ata_sigs: block
375
                signal iDDo : std_logic_vector(15 downto 0);
376
        begin
377
                -- generate registers for ATA signals
378
                gen_regs: process(clk, nReset)
379
                begin
380
                        if (nReset = '0') then
381
                                RESETn <= '0';
382
                                DIORn  <= '1';
383
                                DIOWn  <= '1';
384
                                DA     <= (others => '0');
385
                                CS0n      <= '1';
386
                                CS1n      <= '1';
387
                                DDo    <= (others => '0');
388
                                DDoe   <= '0';
389
                                DMACKn <= '1';
390
                        elsif (clk'event and clk = '1') then
391
                                if (rst = '1') then
392
                                        RESETn <= '0';
393
                                        DIORn  <= '1';
394
                                        DIOWn  <= '1';
395
                                        DA     <= (others => '0');
396
                                        CS0n   <= '1';
397
                                        CS1n    <= '1';
398
                                        DDo    <= (others => '0');
399
                                        DDoe   <= '0';
400
                                        DMACKn <= '1';
401
                                else
402
                                        RESETn <= not IDEctrl_rst;
403
                                        DA     <= PIOa(2 downto 0);
404
                                        CS0n      <= not (not PIOa(3) and iPIOtip); -- CS0 asserted when A(3) = '0', negate during DMA transfers
405
                                        CS1n      <= not (    PIOa(3) and iPIOtip); -- CS1 asserted when A(3) = '1', negate during DMA transfers
406
 
407
                                        if (iPIOtip = '1') then
408
                                                DDo   <= PIOd;
409
                                                DDoe  <= PIOoe;
410
                                                DIORn <= not PIOdior;
411
                                                DIOWn <= not PIOdiow;
412
                                        else
413
                                                DDo   <= DMAd;
414
                                                DDoe  <= DMActrl_dir and DMAtip;
415
                                                DIORn <= not DMAdior;
416
                                                DIOWn <= not DMAdiow;
417
                                        end if;
418
 
419
                                        DMACKn <= not DMAtip;
420
                                end if;
421
                        end if;
422
                end process gen_regs;
423
        end block gen_ata_sigs;
424
 
425
        --
426
        -- generate bus controller statemachine
427
        --
428
        statemachine: block
429
                type states is (idle, PIO_state, DMA_state);
430
                signal nxt_state, c_state : states; -- next_state, current_state
431
 
432
                signal iPIOgo, iDMAgo : std_logic :='0';
433
        begin
434
                gen_fifo_rdy : process(r,s_DMATxEmpty,s_DMATxFull,s_DMARxFull,s_DMARxEmpty,force_rdy,s_DMArst,DMActrl_dir) --Erik Jagre 2006-10-30
435
                variable v : reg_type;
436
                begin
437
                  v:=r;
438
                  v.s_DMATxFull:=s_DMATxFull;
439
                  v.s_DMATxEmpty:=s_DMATxEmpty;
440
                  v.s_DMARxFull:=s_DMARxFull;
441
                  v.s_DMARxEmpty:=s_DMARxEmpty;
442
                  v.force_rdy:=force_rdy;
443
                  case DMActrl_dir is
444
                    when '1' => --Tx action mem_to_ata
445
                      if (r.s_DMATxFull='0' and s_DMATxFull='1') or
446
                        (r.force_rdy='0' and force_rdy='1') then
447
                        v.fifo_rdy:='1';
448
                      elsif (r.s_DMATxEmpty='0' and s_DMATxEmpty='1') then
449
                        v.fifo_rdy:='0';
450
                      else
451
                        v.fifo_rdy:=r.fifo_rdy;
452
                      end if;
453
                      if s_DMArst='1' then
454
                        v.fifo_rdy:='0';
455
                      end if;
456
                    when '0' => --Rx action ata_to_mem
457
                      if (s_DMARxEmpty='1') or  --r.s_DMARxEmpty='0' and Jagre 2006-12-04
458
                        (r.force_rdy='0' and force_rdy='1') then --Erik Jagre 2006-11-07
459
                        v.fifo_rdy:='1';
460
                      elsif (r.s_DMARxFull='0' and s_DMARxFull='1') then
461
                        v.fifo_rdy:='0';
462
                      else
463
                        v.fifo_rdy:=r.fifo_rdy;
464
                      end if;
465
                      if s_DMArst='1' then
466
                        v.fifo_rdy:='1';
467
                      end if;
468
                    when others =>
469
                      v.fifo_rdy:=r.fifo_rdy;
470
                  end case;
471
 
472
                  ri<=v;
473
                  s_fifo_rdy<=v.fifo_rdy; --Jagre 2006-12-04
474
                  fifo_rdy<=r.fifo_rdy;
475
                end process gen_fifo_rdy;
476
 
477
                -- generate next state decoder + output decoder
478
--              gen_nxt_state: process(c_state, DMActrl_DMAen, DMActrl_dir, PIOreq, sDMARQ, s_fifo_rdy, s_DMARxFull, PIOdone, DMAdone) --Erik Jagre 2006-10-30
479
                gen_nxt_state: process(c_state, DMActrl_DMAen, PIOreq, sDMARQ, s_fifo_rdy, PIOdone, DMAdone) --Erik Jagre 2007-02-08
480
                begin
481
                        nxt_state <= c_state; -- initialy stay in current state
482
 
483
                        iPIOgo <= '0';
484
                        iDMAgo <= '0';
485
 
486
                        case c_state is
487
                                -- idle
488
                                when idle =>
489
                                        -- DMA transfer pending ?
490
                                        if ( (sDMARQ = '1') and (DMActrl_DMAen = '1') ) then
491
                                                if (s_fifo_rdy='1') then --Erik Jagre 2006-10-30
492
                                                        nxt_state <= DMA_state;                        -- DMA transfer
493
                                                        iDMAgo    <= '1'; -- start DMA timing controller
494
                                                end if;
495
                                        -- PIO transfer pending ?
496
                                        elsif (PIOreq = '1') then
497
                                                nxt_state <= PIO_state;                            -- PIO transfer
498
                                                iPIOgo    <= '1';
499
                                        end if;
500
 
501
                                -- PIO transfer
502
                                when PIO_state =>
503
                                        if (PIOdone = '1') then
504
                                                        nxt_state <= idle;
505
                                        end if;
506
 
507
                                -- DMA transfer
508
                                when DMA_state =>
509
                                        if (DMAdone = '1') then
510
                                                nxt_state <= idle;
511
                                        end if;
512
 
513
                                when others =>
514
                                        nxt_state <= idle;                                   -- go to idle state
515
 
516
                        end case;
517
                end process gen_nxt_state;
518
 
519
                -- generate registers
520
                gen_regs: process(clk, nReset)
521
                begin
522
                        if (nReset = '0') then
523
                                c_state <= idle;
524
                                PIOgo <= '0';
525
                                DMAgo <= '0';
526
                                r<=RESET_VECTOR;
527
                        elsif (clk'event and clk = '1') then
528
                                if (rst = '1') then
529
                                        c_state <= idle;
530
                                        PIOgo <= '0';
531
                                        DMAgo <= '0';
532
                                        r<=RESET_VECTOR;
533
                                else
534
                                        c_state <= nxt_state;
535
                                        PIOgo <= iPIOgo;
536
                                        DMAgo <= iDMAgo;
537
                                        r<=ri;
538
                                end if;
539
                        end if;
540
                end process gen_regs;
541
 
542
                -- generate PIOtip / DMAtip
543
                gen_tip: process(clk, nReset)
544
                begin
545
                        if (nReset = '0') then
546
                                iPIOtip <= '0';
547
                                DMAtip <= '0';
548
                                iDMAtip_out <= '0';
549
                        elsif (clk'event and clk = '1') then
550
                                if (rst = '1') then
551
                                        iPIOtip <= '0';
552
                                        DMAtip <= '0';
553
                                        iDMAtip_out <= '0';
554
                                else
555
                                        iPIOtip     <= iPIOgo or (iPIOtip and not PIOdone);
556
                                        DMAtip     <= iDMAgo                       or (DMAtip     and not ((DMAdone and DMActrl_dir) or (DMAdone and not sDMARQ and not DMActrl_dir)) );
557
                                        iDMAtip_out <= iDMAgo or (not s_DMATxEmpty) or (iDMAtip_out and not ((DMAdone and DMActrl_dir) or (DMAdone and not sDMARQ and not DMActrl_dir)) );
558
                                end if;
559
                        end if;
560
                end process gen_tip;
561
        end block statemachine;
562
 
563
        PIOtip <= iPIOtip; DMAtip_out <= iDMAtip_out;
564
        DMARxEmpty <= s_DMARxEmpty; --Erik Jagre 2006-11-01
565
        DMARxFull <= s_DMARxFull; --Erik Jagre 2006-10-31
566
        s_DMArst <=IDEctrl_rst or (not BM_en); --reset DMA controller when BM not active
567
 
568
        --
569
        -- Hookup PIO controller
570
        --
571
        PIO_control: atahost_pio_controller
572
                generic map(
573
                        TWIDTH => TWIDTH,
574
                        PIO_mode0_T1 => PIO_mode0_T1,
575
                        PIO_mode0_T2 => PIO_mode0_T2,
576
                        PIO_mode0_T4 => PIO_mode0_T4,
577
                        PIO_mode0_Teoc => PIO_mode0_Teoc
578
                )
579
                port map(
580
                        clk    => clk,
581
                        nReset => nReset,
582
                        rst    => rst,
583
                        IDEctrl_IDEen => IDEctrl_IDEen,
584
                        IDEctrl_ppen  => IDEctrl_ppen,
585
                        IDEctrl_FATR0 => IDEctrl_FATR0,
586
                        IDEctrl_FATR1 => IDEctrl_FATR1,
587
                        cmdport_T1    => PIO_cmdport_T1,
588
                        cmdport_T2    => PIO_cmdport_T2,
589
                        cmdport_T4    => PIO_cmdport_T4,
590
                        cmdport_Teoc  => PIO_cmdport_Teoc,
591
                        cmdport_IORDYen => PIO_cmdport_IORDYen,
592
                        dport0_T1     => PIO_dport0_T1,
593
                        dport0_T2     => PIO_dport0_T2,
594
                        dport0_T4     => PIO_dport0_T4,
595
                        dport0_Teoc   => PIO_dport0_Teoc,
596
                        dport0_IORDYen => PIO_dport0_IORDYen,
597
                        dport1_T1     => PIO_dport1_T1,
598
                        dport1_T2     => PIO_dport1_T2,
599
                        dport1_T4     => PIO_dport1_T4,
600
                        dport1_Teoc   => PIO_dport1_Teoc,
601
                        dport1_IORDYen => PIO_dport1_IORDYen,
602
                        sel    => PIOsel,
603
                        ack    => PIOack,
604
                        a      => a,
605
                        we     => we,
606
                        d      => d(15 downto 0),
607
                        q      => PIOq,
608
                        PIOreq => PIOreq,
609
                        PPFull => PIOpp_full,
610
                        go     => PIOgo,
611
                        done   => PIOdone,
612
                        PIOa   => PIOa,
613
                        PIOd   => PIOd,
614
                        SelDev => SelDev,
615
                        DDi    => DDi,
616
                        DDoe   => PIOoe,
617
                        DIOR   => PIOdior,
618
                        DIOW   => PIOdiow,
619
                        IORDY  => sIORDY
620
                );
621
 
622
        --
623
        -- Hookup DMA access controller
624
        --
625
        DMA_control: atahost_dma_actrl
626
                generic map(
627
                        tech => tech,
628
                        fdepth => fdepth,
629
                        TWIDTH => TWIDTH,
630
                        DMA_mode0_Tm => DMA_mode0_Tm,
631
                        DMA_mode0_Td => DMA_mode0_Td,
632
                        DMA_mode0_Teoc => DMA_mode0_Teoc
633
                )
634
                port map(
635
                        clk    => clk,
636
                        nReset => nReset,
637
                        rst    => rst,
638
                        IDEctrl_rst => s_DMArst,--IDEctrl_rst,
639
                        DMActrl_DMAen  => DMActrl_DMAen,
640
                        DMActrl_dir    => DMActrl_dir,
641
                        DMActrl_Bytesw => DMActrl_Bytesw,
642
                        DMActrl_BeLeC0 => DMActrl_BeLeC0,
643
                        DMActrl_BeLeC1 => DMActrl_BeLeC1,
644
                        dev0_Td   => DMA_dev0_Td,
645
                        dev0_Tm   => DMA_dev0_Tm,
646
                        dev0_Teoc => DMA_dev0_Teoc,
647
                        dev1_Td   => DMA_dev1_Td,
648
                        dev1_Tm   => DMA_dev1_Tm,
649
                        dev1_Teoc => DMA_dev1_Teoc,
650
                        sel     => DMAsel,
651
                        ack     => DMAack,
652
                        we      => we,
653
                        TxD     => d,
654
                        TxFull  => s_DMATxFull,
655
                        TxEmpty => s_DMATxEmpty,
656
                        RxQ     => DMAq,
657
                        RxFull  => s_DMARxFull,
658
                        RxEmpty => s_DMARxEmpty,
659
                        DMA_req => DMA_req,
660
                        DMA_ack => DMA_ack,
661
                        SelDev  => SelDev,
662
                        Go      => DMAgo,
663
                        Done    => DMAdone,
664
                        DDi     => DDi,
665
                        DDo     => DMAd,
666
                        DIOR    => DMAdior,
667
                        DIOW    => DMAdiow,
668
                        DMARQ   => sDMARQ
669
                );
670
end architecture structural;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.