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

Subversion Repositories ata

[/] [ata/] [trunk/] [rtl/] [vhdl/] [ocidec2/] [atahost_top.vhd] - Blame information for rev 26

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 26 rherveille
---------------------------------------------------------------------
2
----                                                             ----
3
----  OpenCores IDE Controller                                   ----
4
----  ATA/ATAPI-5 Controller (OCIDEC-2)                          ----
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.0a Removed references to records.vhd, make core compatible with VHDL to Verilog translator tools
37
-- rev.: 1.1  june 18th, 2001. Changed wishbone address input from ADR_I(4 downto 0) to ADR_I(6 downto 2)
38
-- rev.: 1.1a june 19th, 2001. Simplified DAT_O output multiplexor.
39
--
40
--  CVS Log
41
--
42
--  $Id: atahost_top.vhd,v 1.1 2002-02-18 14:30:48 rherveille Exp $
43
--
44
--  $Date: 2002-02-18 14:30:48 $
45
--  $Revision: 1.1 $
46
--  $Author: rherveille $
47
--  $Locker:  $
48
--  $State: Exp $
49
--
50
-- Change History:
51
--               $Log: not supported by cvs2svn $
52
--
53
 
54
 
55
--
56
-- DeviceType: OCIDEC-2: OpenCores IDE Controller type2
57
-- Features: PIO Compatible Timing, PIO Fast Timing 0/1
58
-- DeviceID: 0x02
59
-- RevNo : 0x00
60
 
61
--
62
-- Host signals:
63
-- Reset
64
-- DIOR-                read strobe. The falling edge enables data from device onto DD. The rising edge latches data at the host.
65
-- DIOW-                write strobe. The rising edge latches data from DD into the device.
66
-- DA(2:0)              3bit binary coded adress
67
-- CS0-         select command block registers
68
-- CS1-         select control block registers
69
 
70
library ieee;
71
use ieee.std_logic_1164.all;
72
use ieee.std_logic_arith.all;
73
 
74
entity atahost_top is
75
        generic(
76
                ARST_LVL : std_logic := '0';                -- asynchronous reset level
77
 
78
                TWIDTH : natural := 8;                      -- counter width
79
 
80
                -- PIO mode 0 settings (@100MHz clock)
81
                PIO_mode0_T1 : natural := 6;                -- 70ns
82
                PIO_mode0_T2 : natural := 28;               -- 290ns
83
                PIO_mode0_T4 : natural := 2;                -- 30ns
84
                PIO_mode0_Teoc : natural := 23              -- 240ns ==> T0 - T1 - T2 = 600 - 70 - 290 = 240
85
        );
86
        port(
87
                -- WISHBONE SYSCON signals
88
                wb_clk_i  : in std_logic;                       -- master clock in
89
                arst_i    : in std_logic := '1';                -- asynchronous active low reset
90
                wb_rst_i  : in std_logic := '0';                -- synchronous active high reset
91
 
92
                -- WISHBONE SLAVE signals
93
                wb_cyc_i  : in std_logic;                       -- valid bus cycle input
94
                wb_stb_i  : in std_logic;                       -- strobe/core select input
95
                wb_ack_o  : out std_logic;                      -- strobe acknowledge output
96
                wb_err_o  : out std_logic;                      -- error output
97
                wb_adr_i  : in unsigned(6 downto 2);            -- A6 = '1' ATA devices selected
98
                                                                --          A5 = '1' CS1- asserted, '0' CS0- asserted
99
                                                                --          A4..A2 ATA address lines
100
                                                                -- A6 = '0' ATA controller selected
101
                wb_dat_i  : in std_logic_vector(31 downto 0);   -- Databus in
102
                wb_dat_o  : out std_logic_vector(31 downto 0);  -- Databus out
103
                wb_sel_i  : in std_logic_vector(3 downto 0);    -- Byte select signals
104
                wb_we_i   : in std_logic;                       -- Write enable input
105
                wb_inta_o : out std_logic;                      -- interrupt request signal IDE0
106
 
107
                -- ATA signals
108
                resetn_pad_o : out std_logic;
109
                dd_pad_i     : in  std_logic_vector(15 downto 0);
110
                dd_pad_o     : out std_logic_vector(15 downto 0);
111
                dd_padoe_o   : out std_logic;
112
                da_pad_o     : out unsigned(2 downto 0);
113
                cs0n_pad_o   : out std_logic;
114
                cs1n_pad_o   : out std_logic;
115
 
116
                diorn_pad_o     : out std_logic;
117
                diown_pad_o     : out std_logic;
118
                iordy_pad_i     : in  std_logic;
119
                intrq_pad_i     : in  std_logic
120
        );
121
end entity atahost_top;
122
 
123
architecture structural of atahost_top is
124
        --
125
        -- constants
126
        --
127
 
128
        -- Device ID
129
        constant DeviceId : unsigned(3 downto 0) := x"2";
130
        constant RevisionNo : unsigned(3 downto 0) := x"0";
131
 
132
        --
133
        -- component declarations
134
        --
135
        component atahost_wb_slave is
136
        generic(
137
                DeviceID   : unsigned(3 downto 0) := x"0";
138
                RevisionNo : unsigned(3 downto 0) := x"0";
139
 
140
                -- PIO mode 0 settings (@100MHz clock)
141
                PIO_mode0_T1 : natural := 6;                -- 70ns
142
                PIO_mode0_T2 : natural := 28;               -- 290ns
143
                PIO_mode0_T4 : natural := 2;                -- 30ns
144
                PIO_mode0_Teoc : natural := 23;             -- 240ns ==> T0 - T1 - T2 = 600 - 70 - 290 = 240
145
 
146
                -- Multiword DMA mode 0 settings (@100MHz clock)
147
                DMA_mode0_Tm : natural := 4;                -- 50ns
148
                DMA_mode0_Td : natural := 21;               -- 215ns
149
                DMA_mode0_Teoc : natural := 21              -- 215ns ==> T0 - Td - Tm = 480 - 50 - 215 = 215
150
        );
151
        port(
152
                -- WISHBONE SYSCON signals
153
                clk_i  : in std_logic;                      -- master clock in
154
                arst_i : in std_logic := '1';               -- asynchronous active low reset
155
                rst_i  : in std_logic := '0';               -- synchronous active high reset
156
 
157
                -- WISHBONE SLAVE signals
158
                cyc_i : in std_logic;                       -- valid bus cycle input
159
                stb_i : in std_logic;                       -- strobe/core select input
160
                ack_o : out std_logic;                      -- strobe acknowledge output
161
                rty_o : out std_logic;                      -- retry output
162
                err_o : out std_logic;                      -- error output
163
                adr_i : in unsigned(6 downto 2);            -- A6 = '1' ATA devices selected
164
                                                            --          A5 = '1' CS1- asserted, '0' CS0- asserted
165
                                                            --          A4..A2 ATA address lines
166
                                                            -- A6 = '0' ATA controller selected
167
                dat_i  : in std_logic_vector(31 downto 0);  -- Databus in
168
                dat_o  : out std_logic_vector(31 downto 0); -- Databus out
169
                sel_i  : in std_logic_vector(3 downto 0);   -- Byte select signals
170
                we_i   : in std_logic;                      -- Write enable input
171
                inta_o : out std_logic;                     -- interrupt request signal IDE0
172
 
173
                -- PIO control input
174
                PIOsel     : buffer std_logic;
175
                PIOtip,                                         -- PIO transfer in progress
176
                PIOack     : in std_logic;                      -- PIO acknowledge signal
177
                PIOq       : in std_logic_vector(15 downto 0);  -- PIO data input
178
                PIOpp_full : in std_logic;                      -- PIO write-ping-pong buffers full
179
                irq        : in std_logic;                      -- interrupt signal input
180
 
181
                -- DMA control inputs
182
                DMAsel    : out std_logic;
183
                DMAtip,                                     -- DMA transfer in progress
184
                DMAack,                                     -- DMA transfer acknowledge
185
                DMARxEmpty,                                 -- DMA receive buffer empty
186
                DMATxFull,                                  -- DMA transmit buffer full
187
                DMA_dmarq : in std_logic;                   -- wishbone DMA request
188
                DMAq      : in std_logic_vector(31 downto 0);
189
 
190
                -- outputs
191
                -- control register outputs
192
                IDEctrl_rst,
193
                IDEctrl_IDEen,
194
                IDEctrl_FATR1,
195
                IDEctrl_FATR0,
196
                IDEctrl_ppen,
197
                DMActrl_DMAen,
198
                DMActrl_dir,
199
                DMActrl_BeLeC0,
200
                DMActrl_BeLeC1 : out std_logic;
201
 
202
                -- CMD port timing registers
203
                PIO_cmdport_T1,
204
                PIO_cmdport_T2,
205
                PIO_cmdport_T4,
206
                PIO_cmdport_Teoc    : buffer unsigned(7 downto 0);
207
                PIO_cmdport_IORDYen : out std_logic;
208
 
209
                -- data-port0 timing registers
210
                PIO_dport0_T1,
211
                PIO_dport0_T2,
212
                PIO_dport0_T4,
213
                PIO_dport0_Teoc    : buffer unsigned(7 downto 0);
214
                PIO_dport0_IORDYen : out std_logic;
215
 
216
                -- data-port1 timing registers
217
                PIO_dport1_T1,
218
                PIO_dport1_T2,
219
                PIO_dport1_T4,
220
                PIO_dport1_Teoc    : buffer unsigned(7 downto 0);
221
                PIO_dport1_IORDYen : out std_logic;
222
 
223
                -- DMA device0 timing registers
224
                DMA_dev0_Tm,
225
                DMA_dev0_Td,
226
                DMA_dev0_Teoc    : buffer unsigned(7 downto 0);
227
 
228
                -- DMA device1 timing registers
229
                DMA_dev1_Tm,
230
                DMA_dev1_Td,
231
                DMA_dev1_Teoc    : buffer unsigned(7 downto 0)
232
        );
233
        end component atahost_wb_slave;
234
 
235
 
236
        component atahost_controller is
237
        generic(
238
                TWIDTH : natural := 8;                   -- counter width
239
 
240
                -- PIO mode 0 settings (@100MHz clock)
241
                PIO_mode0_T1 : natural := 6;             -- 70ns
242
                PIO_mode0_T2 : natural := 28;            -- 290ns
243
                PIO_mode0_T4 : natural := 2;             -- 30ns
244
                PIO_mode0_Teoc : natural := 23           -- 240ns ==> T0 - T1 - T2 = 600 - 70 - 290 = 240
245
        );
246
        port(
247
                clk : in std_logic;                                       -- master clock in
248
                nReset : in std_logic := '1';                 -- asynchronous active low reset
249
                rst : in std_logic := '0';                    -- synchronous active high reset
250
 
251
                irq : out std_logic;                          -- interrupt request signal
252
 
253
                -- control / registers
254
                IDEctrl_rst,
255
                IDEctrl_IDEen,
256
                IDEctrl_FATR0,
257
                IDEctrl_FATR1 : in std_logic;
258
 
259
                -- PIO registers
260
                cmdport_T1,
261
                cmdport_T2,
262
                cmdport_T4,
263
                cmdport_Teoc : in unsigned(7 downto 0);
264
                cmdport_IORDYen : in std_logic;            -- PIO command port / non-fast timing
265
 
266
                dport0_T1,
267
                dport0_T2,
268
                dport0_T4,
269
                dport0_Teoc : in unsigned(7 downto 0);
270
                dport0_IORDYen : in std_logic;             -- PIO mode data-port / fast timing device 0
271
 
272
                dport1_T1,
273
                dport1_T2,
274
                dport1_T4,
275
                dport1_Teoc : in unsigned(7 downto 0);
276
                dport1_IORDYen : in std_logic;             -- PIO mode data-port / fast timing device 1
277
 
278
                PIOreq : in std_logic;                        -- PIO transfer request
279
                PIOack : buffer std_logic;                    -- PIO transfer ended
280
                PIOa : in unsigned(3 downto 0);               -- PIO address
281
                PIOd : in std_logic_vector(15 downto 0);      -- PIO data in
282
                PIOq : out std_logic_vector(15 downto 0);     -- PIO data out
283
                PIOwe : in std_logic;                         -- PIO direction bit '1'=write, '0'=read
284
 
285
                -- ATA signals
286
                RESETn  : out std_logic;
287
                DDi     : in std_logic_vector(15 downto 0);
288
                DDo : out std_logic_vector(15 downto 0);
289
                DDoe : out std_logic;
290
                DA      : out unsigned(2 downto 0);
291
                CS0n    : out std_logic;
292
                CS1n    : out std_logic;
293
 
294
                DIORn   : out std_logic;
295
                DIOWn   : out std_logic;
296
                IORDY   : in std_logic;
297
                INTRQ   : in std_logic
298
        );
299
        end component atahost_controller;
300
 
301
        -- asynchronous reset signal
302
        signal arst_signal : std_logic;
303
 
304
        -- primary address decoder
305
        signal PIOsel  : std_logic;  -- controller select, IDE devices select
306
 
307
        -- registers
308
        -- control register
309
        signal IDEctrl_rst, IDEctrl_IDEen, IDEctrl_FATR0, IDEctrl_FATR1 : std_logic;
310
        -- compatible mode timing register
311
        signal PIO_cmdport_T1, PIO_cmdport_T2, PIO_cmdport_T4, PIO_cmdport_Teoc : unsigned(7 downto 0);
312
        signal PIO_cmdport_IORDYen : std_logic;
313
        -- data port0 timing register
314
        signal PIO_dport0_T1, PIO_dport0_T2, PIO_dport0_T4, PIO_dport0_Teoc : unsigned(7 downto 0);
315
        signal PIO_dport0_IORDYen : std_logic;
316
        -- data port1 timing register
317
        signal PIO_dport1_T1, PIO_dport1_T2, PIO_dport1_T4, PIO_dport1_Teoc : unsigned(7 downto 0);
318
        signal PIO_dport1_IORDYen : std_logic;
319
 
320
        signal PIOack : std_logic;
321
        signal PIOq : std_logic_vector(15 downto 0);
322
 
323
        signal irq : std_logic; -- ATA bus IRQ signal
324
 
325
begin
326
        -- generate asynchronous reset level
327
        arst_signal <= arst_i xor ARST_LVL;
328
 
329
        --
330
        -- hookup wishbone slave
331
        --
332
        u0: atahost_wb_slave
333
                generic map(
334
                        DeviceID   => DeviceID,
335
                        RevisionNo => RevisionNo,
336
 
337
                        -- PIO mode 0 settings
338
                        PIO_mode0_T1 => PIO_mode0_T1,
339
                        PIO_mode0_T2 => PIO_mode0_T2,
340
                        PIO_mode0_T4 => PIO_mode0_T4,
341
                        PIO_mode0_Teoc => PIO_mode0_Teoc,
342
 
343
                        -- Multiword DMA mode 0 settings
344
                        -- OCIDEC-1 does not support DMA, set registers to zero
345
                        DMA_mode0_Tm   => 0,
346
                        DMA_mode0_Td   => 0,
347
                        DMA_mode0_Teoc => 0
348
                )
349
                port map(
350
                        -- WISHBONE SYSCON signals
351
                        clk_i => wb_clk_i,
352
                        arst_i => arst_signal,
353
                        rst_i  => wb_rst_i,
354
 
355
                        -- WISHBONE SLAVE signals
356
                        cyc_i => wb_cyc_i,
357
                        stb_i => wb_stb_i,
358
                        ack_o => wb_ack_o,
359
                        err_o => wb_err_o,
360
                        adr_i => wb_adr_i,
361
                        dat_i => wb_dat_i,
362
                        dat_o => wb_dat_o,
363
                        sel_i => wb_sel_i,
364
                        we_i  => wb_we_i,
365
                        inta_o => wb_inta_o,
366
 
367
                        -- PIO control input
368
                        --      PIOtip is only asserted during a PIO transfer (No shit! ;)
369
                        --      Since it is impossible to read the status register and access the PIO registers at the same time
370
                        --      this bit is useless (besides using-up resources)
371
                        PIOtip     => '0',
372
                        PIOack     => PIOack,
373
                        PIOq       => PIOq,
374
                        PIOsel     => PIOsel,
375
                        PIOpp_full => '0', -- OCIDEC-1 does not support PIO-write PingPong, negate signal
376
                        irq        => irq,
377
 
378
                        -- DMA control inputs (negate all of them)
379
                        DMAtip     => '0',
380
                        DMAack     => '0',
381
                        DMARxEmpty => '0',
382
                        DMATxFull  => '0',
383
                        DMA_dmarq  => '0',
384
                        DMAq       => x"00000000",
385
 
386
                        -- outputs
387
                        -- control register outputs
388
                        IDEctrl_rst   => IDEctrl_rst,
389
                        IDEctrl_IDEen => IDEctrl_IDEen,
390
                        IDEctrl_FATR0 => IDEctrl_FATR0,
391
                        IDEctrl_FATR1 => IDEctrl_FATR1,
392
 
393
                        -- CMD port timing registers
394
                        PIO_cmdport_T1 => PIO_cmdport_T1,
395
                        PIO_cmdport_T2 => PIO_cmdport_T2,
396
                        PIO_cmdport_T4 => PIO_cmdport_T4,
397
                        PIO_cmdport_Teoc => PIO_cmdport_Teoc,
398
                        PIO_cmdport_IORDYen => PIO_cmdport_IORDYen,
399
 
400
                        -- data-port0 timing registers
401
                        PIO_dport0_T1 => PIO_dport0_T1,
402
                        PIO_dport0_T2 => PIO_dport0_T2,
403
                        PIO_dport0_T4 => PIO_dport0_T4,
404
                        PIO_dport0_Teoc => PIO_dport0_Teoc,
405
                        PIO_dport0_IORDYen => PIO_dport0_IORDYen,
406
 
407
                        -- data-port1 timing registers
408
                        PIO_dport1_T1 => PIO_dport1_T1,
409
                        PIO_dport1_T2 => PIO_dport1_T2,
410
                        PIO_dport1_T4 => PIO_dport1_T4,
411
                        PIO_dport1_Teoc => PIO_dport1_Teoc,
412
                        PIO_dport1_IORDYen => PIO_dport1_IORDYen
413
                );
414
 
415
        --
416
        -- hookup controller section
417
        --
418
        u1: atahost_controller
419
                generic map(
420
                        TWIDTH => TWIDTH,
421
                        PIO_mode0_T1 => PIO_mode0_T1,
422
                        PIO_mode0_T2 => PIO_mode0_T2,
423
                        PIO_mode0_T4 => PIO_mode0_T4,
424
                        PIO_mode0_Teoc => PIO_mode0_Teoc
425
                )
426
                port map(
427
                        clk => wb_clk_i,
428
                        nReset => arst_signal,
429
                        rst => wb_rst_i,
430
                        irq => irq,
431
                        IDEctrl_rst => IDEctrl_rst,
432
                        IDEctrl_IDEen => IDEctrl_IDEen,
433
                        IDEctrl_FATR0 => IDEctrl_FATR0,
434
                        IDEctrl_FATR1 => IDEctrl_FATR1,
435
                        cmdport_T1 => PIO_cmdport_T1,
436
                        cmdport_T2 => PIO_cmdport_T2,
437
                        cmdport_T4 => PIO_cmdport_T4,
438
                        cmdport_Teoc => PIO_cmdport_Teoc,
439
                        cmdport_IORDYen => PIO_cmdport_IORDYen,
440
                        dport0_T1 => PIO_dport0_T1,
441
                        dport0_T2 => PIO_dport0_T2,
442
                        dport0_T4 => PIO_dport0_T4,
443
                        dport0_Teoc => PIO_dport0_Teoc,
444
                        dport0_IORDYen => PIO_dport0_IORDYen,
445
                        dport1_T1 => PIO_dport1_T1,
446
                        dport1_T2 => PIO_dport1_T2,
447
                        dport1_T4 => PIO_dport1_T4,
448
                        dport1_Teoc => PIO_dport1_Teoc,
449
                        dport1_IORDYen => PIO_dport1_IORDYen,
450
                        PIOreq => PIOsel,
451
                        PIOack => PIOack,
452
                        PIOa => wb_adr_i(5 downto 2),
453
                        PIOd => wb_dat_i(15 downto 0),
454
                        PIOq => PIOq,
455
                        PIOwe => wb_we_i,
456
                        RESETn => resetn_pad_o,
457
                        DDi    => dd_pad_i,
458
                        DDo    => dd_pad_o,
459
                        DDoe   => dd_padoe_o,
460
                        DA     => da_pad_o,
461
                        CS0n   => cs0n_pad_o,
462
                        CS1n   => cs1n_pad_o,
463
                        DIORn  => diorn_pad_o,
464
                        DIOWn  => diown_pad_o,
465
                        IORDY  => iordy_pad_i,
466
                        INTRQ  => intrq_pad_i
467
                );
468
end architecture structural;
469
 

powered by: WebSVN 2.1.0

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