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

Subversion Repositories ata

[/] [ata/] [trunk/] [rtl/] [vhdl/] [ocidec1/] [atahost_top.vhd] - Blame information for rev 25

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

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

powered by: WebSVN 2.1.0

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