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_pio_actrl.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
----  PIO Access Controller (common for OCIDEC 2 and above)      ----
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 9th, 2001
37
-- rev.: 1.0a april 12th, 2001 Removed references to records.vhd
38
--
39
--
40
--  CVS Log
41
--
42
--  $Id: atahost_pio_actrl.vhd,v 1.1 2002/02/18 14:32:12 rherveille Exp $
43
--
44
--  $Date: 2002/02/18 14:32:12 $
45
--  $Revision: 1.1 $
46
--  $Author: rherveille $
47
--  $Locker:  $
48
--  $State: Exp $
49
--
50
-- Change History:
51
--               $Log: atahost_pio_actrl.vhd,v $
52
--               Revision 1.1  2002/02/18 14:32:12  rherveille
53
--               renamed all files to 'atahost_***.vhd'
54
--               broke-up 'counter.vhd' into 'ud_cnt.vhd' and 'ro_cnt.vhd'
55
--               changed resD input to generic RESD in ud_cnt.vhd
56
--               changed ID input to generic ID in ro_cnt.vhd
57
--               changed core to reflect changes in ro_cnt.vhd
58
--               removed references to 'count' library
59
--               changed IO names
60
--               added disclaimer
61
--               added CVS log
62
--               moved registers and wishbone signals into 'atahost_wb_slave.vhd'
63
--
64
 
65
--
66
---------------------------
67
-- PIO Access controller --
68
---------------------------
69
--
70
 
71
library ieee;
72
use ieee.std_logic_1164.all;
73
use ieee.std_logic_arith.all;
74
 
75
entity atahost_pio_actrl is
76
        generic(
77
                TWIDTH : natural := 8;                     -- counter width
78
 
79
                -- PIO mode 0 settings (@100MHz clock)
80
                PIO_mode0_T1 : natural := 6;               -- 70ns
81
                PIO_mode0_T2 : natural := 28;              -- 290ns
82
                PIO_mode0_T4 : natural := 2;               -- 30ns
83
                PIO_mode0_Teoc : natural := 23             -- 240ns ==> T0 - T1 - T2 = 600 - 70 - 290 = 240
84
        );
85
        port(
86
                clk    : in std_logic;                     -- master clock
87
                nReset : in std_logic;                     -- asynchronous active low reset
88
                rst    : in std_logic;                     -- synchronous active high reset
89
 
90
                IDEctrl_FATR0,
91
                IDEctrl_FATR1 : in std_logic;
92
 
93
                cmdport_T1,
94
                cmdport_T2,
95
                cmdport_T4,
96
                cmdport_Teoc : in std_logic_vector(7 downto 0);
97
                cmdport_IORDYen : in std_logic;            -- PIO command port / non-fast timing
98
 
99
                dport0_T1,
100
                dport0_T2,
101
                dport0_T4,
102
                dport0_Teoc : in std_logic_vector(7 downto 0);
103
                dport0_IORDYen : in std_logic;             -- PIO mode data-port / fast timing device 0
104
 
105
                dport1_T1,
106
                dport1_T2,
107
                dport1_T4,
108
                dport1_Teoc : in std_logic_vector(7 downto 0);
109
                dport1_IORDYen : in std_logic;             -- PIO mode data-port / fast timing device 1
110
 
111
                SelDev : in std_logic;                     -- Selected device   
112
 
113
                go   : in  std_logic;                      -- Start transfer sequence
114
                done : out std_logic;                      -- Transfer sequence done
115
                dir  : in  std_logic;                      -- Transfer direction '1'=write, '0'=read
116
                a    : in  std_logic_vector(3 downto 0):="0000";           -- PIO transfer address
117
                q    : out std_logic_vector(15 downto 0);  -- Data read from ATA devices
118
 
119
                DDi : in std_logic_vector(15 downto 0);    -- Data from ATA DD bus
120
                oe  : out std_logic;                    -- DDbus output-enable signal
121
 
122
                DIOR,
123
                DIOW  : out std_logic;
124
                IORDY : in std_logic
125
        );
126
end entity atahost_pio_actrl;
127
 
128
architecture structural of atahost_pio_actrl is
129
        --
130
        -- Component declarations
131
        --
132
        component atahost_pio_tctrl is
133
        generic(
134
                TWIDTH : natural := 8;                   -- counter width
135
 
136
                -- PIO mode 0 settings (@100MHz clock)
137
                PIO_mode0_T1 : natural := 6;             -- 70ns
138
                PIO_mode0_T2 : natural := 28;            -- 290ns
139
                PIO_mode0_T4 : natural := 2;             -- 30ns
140
                PIO_mode0_Teoc : natural := 23           -- 240ns ==> T0 - T1 - T2 = 600 - 70 - 290 = 240
141
        );
142
        port(
143
                clk    : in std_logic;                   -- master clock
144
                nReset : in std_logic;                   -- asynchronous active low reset
145
                rst    : in std_logic;                   -- synchronous active high reset
146
 
147
                -- timing/control register settings
148
                IORDY_en : in std_logic;                 -- use IORDY (or not)
149
                T1   : in std_logic_vector(TWIDTH -1 downto 0);  -- T1 time (in clk-ticks)
150
                T2   : in std_logic_vector(TWIDTH -1 downto 0);  -- T2 time (in clk-ticks)
151
                T4   : in std_logic_vector(TWIDTH -1 downto 0);  -- T4 time (in clk-ticks)
152
                Teoc : in std_logic_vector(TWIDTH -1 downto 0);  -- end of cycle time
153
 
154
                -- control signals
155
                go : in std_logic;                       -- PIO controller selected (strobe signal)
156
                we : in std_logic;                       -- write enable signal. '0'=read from device, '1'=write to device
157
 
158
                -- return signals
159
                oe    : out std_logic;                -- output enable signal
160
                done  : out std_logic;                   -- finished cycle
161
                dstrb : out std_logic;                   -- data strobe, latch data (during read)
162
 
163
                -- ATA signals
164
                DIOR,                                    -- IOread signal, active high
165
                DIOW  : out std_logic;                -- IOwrite signal, active high
166
                IORDY : in std_logic                     -- IORDY signal
167
        );
168
        end component atahost_pio_tctrl;
169
 
170
        signal dstrb : std_logic;
171
        signal T1, T2, T4, Teoc : std_logic_vector(TWIDTH -1 downto 0);
172
        signal IORDYen : std_logic;
173
 
174
begin
175
        --
176
        --------------------------
177
        -- PIO transfer control --
178
        --------------------------
179
        --
180
        -- capture ATA data for PIO access
181
        gen_PIOq: process(clk)
182
        begin
183
                if (clk'event and clk = '1') then
184
                        if (dstrb = '1') then
185
                                q <= DDi;
186
                        end if;
187
                end if;
188
        end process gen_PIOq;
189
 
190
        --
191
        -- PIO timing controllers
192
        --
193
 
194
        -- select timing settings for the addressed port
195
        sel_port_t: process(clk)
196
                variable Asel : std_logic; -- address selected
197
                variable iT1, iT2, iT4, iTeoc : std_logic_vector(TWIDTH -1 downto 0);
198
                variable iIORDYen : std_logic;
199
        begin
200
            if (clk'event and clk = '1') then
201
                -- initially set timing registers to compatible timing
202
                iT1      := cmdport_T1;
203
                iT2      := cmdport_T2;
204
                iT4      := cmdport_T4;
205
                iTeoc    := cmdport_Teoc;
206
                iIORDYen := cmdport_IORDYen;
207
 
208
                -- detect data-port access
209
                Asel := not a(3) and not a(2) and not a(1) and not a(0); -- data port
210
                if (Asel = '1') then                                     -- data port selected, 16bit transfers
211
                        if ((SelDev = '1') and (IDEctrl_FATR1 = '1')) then    -- data port1 selected and enabled ?
212
                                iT1      := dport1_T1;
213
                                iT2      := dport1_T2;
214
                                iT4      := dport1_T4;
215
                                iTeoc    := dport1_Teoc;
216
                                iIORDYen := dport1_IORDYen;
217
                        elsif((SelDev = '0') and (IDEctrl_FATR0 = '1')) then       -- data port0 selected and enabled ?
218
                                iT1      := dport0_T1;
219
                                iT2      := dport0_T2;
220
                                iT4      := dport0_T4;
221
                                iTeoc    := dport0_Teoc;
222
                                iIORDYen := dport0_IORDYen;
223
                        end if;
224
                end if;
225
 
226
                T1      <= iT1;
227
                T2      <= iT2;
228
                T4      <= iT4;
229
                Teoc    <= iTeoc;
230
                IORDYen <= iIORDYen;
231
            end if;
232
        end process sel_port_t;
233
 
234
        --
235
        -- hookup timing controller
236
        --
237
        PIO_timing_controller: atahost_pio_tctrl
238
                generic map (
239
                        TWIDTH => TWIDTH,
240
                        PIO_mode0_T1 => PIO_mode0_T1,
241
                        PIO_mode0_T2 => PIO_mode0_T2,
242
                        PIO_mode0_T4 => PIO_mode0_T4,
243
                        PIO_mode0_Teoc => PIO_mode0_Teoc
244
                )
245
                port map (
246
                        clk => clk,
247
                        nReset => nReset,
248
                        rst => rst,
249
                        IORDY_en => IORDYen,
250
                        T1 => T1,
251
                        T2 => T2,
252
                        T4 => T4,
253
                        Teoc => Teoc,
254
                        go => go,
255
                        we => dir,
256
                        oe => oe,
257
                        done => done,
258
                        dstrb => dstrb,
259
                        DIOR => dior,
260
                        DIOW => diow,
261
                        IORDY => IORDY
262
                );
263
end architecture structural;
264
 

powered by: WebSVN 2.1.0

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