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_tctrl.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
---------------------------------------------------------------------
2
----                                                             ----
3
----  OpenCores ATA/ATAPI-5 Host Controller                      ----
4
----  PIO Timing Controller (common for all OCIDEC cores)        ----
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  7th, 2001. Initial release
37
-- rev.: 1.1 July  11th, 2001. Changed 'igo' & 'hold_go' signal generation.
38
--
39
--
40
--  CVS Log
41
--
42
--  $Id: atahost_pio_tctrl.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_tctrl.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
--
68
---------------------------
69
-- PIO Timing controller --
70
---------------------------
71
--
72
 
73
--
74
-- Timing       PIO mode transfers
75
----------------------------------------------
76
-- T0:  cycle time
77
-- T1:  address valid to DIOR-/DIOW-
78
-- T2:  DIOR-/DIOW- pulse width
79
-- T2i: DIOR-/DIOW- recovery time
80
-- T3:  DIOW- data setup
81
-- T4:  DIOW- data hold
82
-- T5:  DIOR- data setup
83
-- T6:  DIOR- data hold
84
-- T9:  address hold from DIOR-/DIOW- negated
85
-- Trd: Read data valid to IORDY asserted
86
-- Ta:  IORDY setup time
87
-- Tb:  IORDY pulse width
88
--
89
-- Transfer sequence
90
----------------------------------
91
-- 1)   set address (DA, CS0-, CS1-)
92
-- 2)   wait for T1
93
-- 3)   assert DIOR-/DIOW-
94
--         when write action present Data (timing spec. T3 always honored), enable output enable-signal
95
-- 4)   wait for T2
96
-- 5)   check IORDY
97
--         when not IORDY goto 5
98
--        when IORDY negate DIOW-/DIOR-, latch data (if read action)
99
--    when write, hold data for T4, disable output-enable signal
100
-- 6)   wait end_of_cycle_time. This is T2i or T9 or (T0-T1-T2) whichever takes the longest
101
-- 7)   start new cycle
102
 
103
library ieee;
104
use ieee.std_logic_1164.all;
105
library grlib;
106
use grlib.amba.all;
107
use grlib.stdlib.all;
108
 
109
entity atahost_pio_tctrl is
110
        generic(
111
                TWIDTH : natural := 8;                   -- counter width
112
 
113
                -- PIO mode 0 settings (@100MHz clock)
114
                PIO_mode0_T1 : natural := 6;             -- 70ns
115
                PIO_mode0_T2 : natural := 28;            -- 290ns
116
                PIO_mode0_T4 : natural := 2;             -- 30ns
117
                PIO_mode0_Teoc : natural := 23           -- 240ns ==> T0 - T1 - T2 = 600 - 70 - 290 = 240
118
        );
119
        port(
120
                clk    : in std_logic;                   -- master clock
121
                nReset : in std_logic;                   -- asynchronous active low reset
122
                rst    : in std_logic;                   -- synchronous active high reset
123
 
124
                -- timing/control register settings
125
                IORDY_en : in std_logic;                 -- use IORDY (or not)
126
                T1   : in std_logic_vector(TWIDTH -1 downto 0);  -- T1 time (in clk-ticks)
127
                T2   : in std_logic_vector(TWIDTH -1 downto 0);  -- T2 time (in clk-ticks)
128
                T4   : in std_logic_vector(TWIDTH -1 downto 0);  -- T4 time (in clk-ticks)
129
                Teoc : in std_logic_vector(TWIDTH -1 downto 0);  -- end of cycle time
130
 
131
                -- control signals
132
                go : in std_logic;                       -- PIO controller selected (strobe signal)
133
                we : in std_logic;                       -- write enable signal. '0'=read from device, '1'=write to device
134
 
135
                -- return signals
136
                oe    : out std_logic;                -- output enable signal
137
                done  : out std_logic;                   -- finished cycle
138
                dstrb : out std_logic;                   -- data strobe, latch data (during read)
139
 
140
                -- ATA signals
141
                DIOR,                                    -- IOread signal, active high
142
                DIOW  : out std_logic;                -- IOwrite signal, active high
143
                IORDY : in std_logic                     -- IORDY signal
144
        );
145
end entity atahost_pio_tctrl;
146
 
147
architecture structural of atahost_pio_tctrl is
148
        component ro_cnt is
149
        generic(
150
                SIZE : natural := 8;
151
                UD   : integer := 0; -- default count down
152
                ID   : natural := 0      -- initial data after reset
153
        );
154
        port(
155
                clk    : in  std_logic;                  -- master clock
156
                nReset : in  std_logic := '1';           -- asynchronous active low reset
157
                rst    : in  std_logic := '0';           -- synchronous active high reset
158
 
159
                cnt_en : in  std_logic := '1';           -- count enable
160
                go     : in  std_logic;                  -- load counter and start sequence
161
                done   : out std_logic;                  -- done counting
162
                d      : in  std_logic_vector(SIZE -1 downto 0); -- load counter value
163
                q      : out std_logic_vector(SIZE -1 downto 0)  -- current counter value
164
        );
165
        end component ro_cnt;
166
 
167
        signal T1done, T2done, T4done, Teoc_done, IORDY_done : std_logic;
168
        signal busy, hold_go, igo, hT2done : std_logic;
169
        signal iDIOR, iDIOW, ioe : std_logic;
170
begin
171
 
172
        DIOR <= iDIOR; DIOW <= iDIOW; oe <= ioe;
173
        -- generate internal go strobe
174
        -- strecht go until ready for new cycle
175
        process(clk, nReset)
176
        begin
177
                if (nReset = '0') then
178
                        busy <= '0';
179
                        hold_go <= '0';
180
                elsif (clk'event and clk = '1') then
181
                        if (rst = '1') then
182
                                busy <= '0';
183
                                hold_go <= '0';
184
                        else
185
                                busy <= (igo or busy) and not Teoc_done;
186
                                hold_go <= (go or (hold_go and busy)) and not igo;
187
                        end if;
188
                end if;
189
        end process;
190
        igo <= (go or hold_go) and not busy;
191
 
192
        -- 1)   hookup T1 counter
193
        t1_cnt : ro_cnt
194
                generic map (
195
                        SIZE => TWIDTH,
196
                        UD   => 0,
197
                        ID   => PIO_mode0_T1
198
                )
199
                port map (
200
                        clk => clk,
201
                        nReset => nReset,
202
                        rst => rst,
203
                        go => igo,
204
                        D => T1,
205
                        done => T1done
206
                );
207
 
208
        -- 2)   set (and reset) DIOR-/DIOW-, set output-enable when writing to device
209
        T2proc: process(clk, nReset)
210
        begin
211
                if (nReset = '0') then
212
                        iDIOR <= '0';
213
                        iDIOW <= '0';
214
                        ioe   <= '0';
215
                elsif (clk'event and clk = '1') then
216
                        if (rst = '1') then
217
                                iDIOR <= '0';
218
                                iDIOW <= '0';
219
                                ioe   <= '0';
220
                        else
221
                                iDIOR <= (not we and T1done) or (iDIOR and not IORDY_done);
222
                                iDIOW <= (    we and T1done) or (iDIOW and not IORDY_done);
223
                                ioe   <= ( (we and igo) or ioe) and not T4done; -- negate oe when t4-done
224
                        end if;
225
                end if;
226
        end process T2proc;
227
 
228
        -- 3)   hookup T2 counter
229
        t2_cnt : ro_cnt
230
                generic map (
231
                        SIZE => TWIDTH,
232
                        UD   => 0,
233
                        ID   => PIO_mode0_T2
234
                )
235
                port map (
236
                        clk => clk,
237
                        nReset => nReset,
238
                        rst => rst,
239
                        go => T1done,
240
                        D => T2,
241
                        done => T2done
242
                );
243
 
244
        -- 4)   check IORDY (if used), generate release_DIOR-/DIOW- signal (ie negate DIOR-/DIOW-)
245
        -- hold T2done
246
        gen_hT2done: process(clk, nReset)
247
        begin
248
                if (nReset = '0') then
249
                        hT2done <= '0';
250
                elsif (clk'event and clk = '1') then
251
                        if (rst = '1') then
252
                                hT2done <= '0';
253
                        else
254
                                hT2done <= (T2done or hT2done) and not IORDY_done;
255
                        end if;
256
                end if;
257
        end process gen_hT2done;
258
        IORDY_done <= (T2done or hT2done) and (IORDY or not IORDY_en);
259
 
260
        -- generate datastrobe, capture data at rising DIOR- edge
261
        gen_dstrb: process(clk)
262
        begin
263
                if (clk'event and clk = '1') then
264
                        dstrb <= IORDY_done;
265
                end if;
266
        end process gen_dstrb;
267
 
268
        -- hookup data hold counter
269
        dhold_cnt : ro_cnt
270
                generic map (
271
                        SIZE => TWIDTH,
272
                        UD   => 0,
273
                        ID   => PIO_mode0_T4
274
                )
275
                port map (
276
                        clk => clk,
277
                        nReset => nReset,
278
                        rst => rst,
279
                        go => IORDY_done,
280
                        D => T4,
281
                        done => T4done
282
                );
283
        done <= T4done; -- placing done here provides the fastest return possible, 
284
                      -- while still guaranteeing data and address hold-times
285
 
286
        -- 5)   hookup end_of_cycle counter
287
        eoc_cnt : ro_cnt
288
                generic map (
289
                        SIZE => TWIDTH,
290
                        UD   => 0,
291
                        ID   => PIO_mode0_Teoc
292
                )
293
                port map (
294
                        clk => clk,
295
                        nReset => nReset,
296
                        rst => rst,
297
                        go => IORDY_done,
298
                        D => Teoc,
299
                        done => Teoc_done
300
                );
301
 
302
end architecture structural;

powered by: WebSVN 2.1.0

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