1 |
2 |
dimamali |
---------------------------------------------------------------------
|
2 |
|
|
---- ----
|
3 |
|
|
---- OpenCores IDE Controller ----
|
4 |
|
|
---- DMA (single- and multiword) mode timing statemachine ----
|
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 |
|
|
--
|
38 |
|
|
-- CVS Log
|
39 |
|
|
--
|
40 |
|
|
-- $Id: atahost_dma_tctrl.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_dma_tctrl.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 |
|
|
--
|
65 |
|
|
---------------------------
|
66 |
|
|
-- DMA Timing Controller --
|
67 |
|
|
---------------------------
|
68 |
|
|
--
|
69 |
|
|
|
70 |
|
|
--
|
71 |
|
|
-- Timing DMA mode transfers
|
72 |
|
|
----------------------------------------------
|
73 |
|
|
-- T0: cycle time
|
74 |
|
|
-- Td: DIOR-/DIOW- asserted pulse width
|
75 |
|
|
-- Te: DIOR- data access
|
76 |
|
|
-- Tf: DIOR- data hold
|
77 |
|
|
-- Tg: DIOR-/DIOW- data setup
|
78 |
|
|
-- Th: DIOW- data hold
|
79 |
|
|
-- Ti: DMACK to DIOR-/DIOW- setup
|
80 |
|
|
-- Tj: DIOR-/DIOW- to DMACK hold
|
81 |
|
|
-- Tkr: DIOR- negated pulse width
|
82 |
|
|
-- Tkw: DIOW- negated pulse width
|
83 |
|
|
-- Tm: CS(1:0) valid to DIOR-/DIOW-
|
84 |
|
|
-- Tn: CS(1:0) hold
|
85 |
|
|
--
|
86 |
|
|
--
|
87 |
|
|
-- Transfer sequence
|
88 |
|
|
----------------------------------
|
89 |
|
|
-- 1) wait for Tm
|
90 |
|
|
-- 2) assert DIOR-/DIOW-
|
91 |
|
|
-- when write action present data (Timing spec. Tg always honored)
|
92 |
|
|
-- output enable is controlled by DMA-direction and DMACK-
|
93 |
|
|
-- 3) wait for Td
|
94 |
|
|
-- 4) negate DIOR-/DIOW-
|
95 |
|
|
-- when read action, latch data
|
96 |
|
|
-- 5) wait for Teoc (T0 - Td - Tm) or Tkw, whichever is greater
|
97 |
|
|
-- Th, Tj, Tk, Tn always honored
|
98 |
|
|
-- 6) start new cycle
|
99 |
|
|
--
|
100 |
|
|
|
101 |
|
|
library ieee;
|
102 |
|
|
use ieee.std_logic_1164.all;
|
103 |
|
|
use ieee.std_logic_arith.all;
|
104 |
|
|
|
105 |
|
|
entity atahost_dma_tctrl is
|
106 |
|
|
generic(
|
107 |
|
|
TWIDTH : natural := 8; -- counter width
|
108 |
|
|
|
109 |
|
|
-- DMA mode 0 settings (@100MHz clock)
|
110 |
|
|
DMA_mode0_Tm : natural := 4; -- 50ns
|
111 |
|
|
DMA_mode0_Td : natural := 21; -- 215ns
|
112 |
|
|
DMA_mode0_Teoc : natural := 21 -- 215ns ==> T0 - Td - Tm = 480 - 50 - 215 = 215
|
113 |
|
|
);
|
114 |
|
|
port(
|
115 |
|
|
clk : in std_logic; -- master clock
|
116 |
|
|
nReset : in std_logic; -- asynchronous active low reset
|
117 |
|
|
rst : in std_logic; -- synchronous active high reset
|
118 |
|
|
|
119 |
|
|
-- timing register settings
|
120 |
|
|
Tm : in std_logic_vector(TWIDTH -1 downto 0); -- Tm time (in clk-ticks)
|
121 |
|
|
Td : in std_logic_vector(TWIDTH -1 downto 0); -- Td time (in clk-ticks)
|
122 |
|
|
Teoc : in std_logic_vector(TWIDTH -1 downto 0); -- end of cycle time
|
123 |
|
|
|
124 |
|
|
-- control signals
|
125 |
|
|
go : in std_logic; -- DMA controller selected (strobe signal)
|
126 |
|
|
we : in std_logic; -- DMA direction '1' = write, '0' = read
|
127 |
|
|
|
128 |
|
|
-- return signals
|
129 |
|
|
done : out std_logic; -- finished cycle
|
130 |
|
|
dstrb : out std_logic; -- data strobe
|
131 |
|
|
|
132 |
|
|
-- ATA signals
|
133 |
|
|
DIOR, -- IOread signal, active high
|
134 |
|
|
DIOW : out std_logic -- IOwrite signal, active high
|
135 |
|
|
);
|
136 |
|
|
end entity atahost_dma_tctrl;
|
137 |
|
|
|
138 |
|
|
architecture structural of atahost_dma_tctrl is
|
139 |
|
|
component ro_cnt is
|
140 |
|
|
generic(
|
141 |
|
|
SIZE : natural := 8;
|
142 |
|
|
UD : integer := 0; -- default count down
|
143 |
|
|
ID : natural := 0 -- initial data after reset
|
144 |
|
|
);
|
145 |
|
|
port(
|
146 |
|
|
clk : in std_logic; -- master clock
|
147 |
|
|
nReset : in std_logic := '1'; -- asynchronous active low reset
|
148 |
|
|
rst : in std_logic := '0'; -- synchronous active high reset
|
149 |
|
|
|
150 |
|
|
cnt_en : in std_logic := '1'; -- count enable
|
151 |
|
|
go : in std_logic; -- load counter and start sequence
|
152 |
|
|
done : out std_logic; -- done counting
|
153 |
|
|
d : in std_logic_vector(SIZE -1 downto 0); -- load counter value
|
154 |
|
|
q : out std_logic_vector(SIZE -1 downto 0) -- current counter value
|
155 |
|
|
);
|
156 |
|
|
end component ro_cnt;
|
157 |
|
|
|
158 |
|
|
signal Tmdone, Tddone : std_logic;
|
159 |
|
|
signal iDIOR, iDIOW : std_logic;
|
160 |
|
|
begin
|
161 |
|
|
|
162 |
|
|
DIOR <= iDIOR; DIOW <= iDIOW;
|
163 |
|
|
-- 1) hookup Tm counter
|
164 |
|
|
tm_cnt : ro_cnt
|
165 |
|
|
generic map (
|
166 |
|
|
SIZE => TWIDTH,
|
167 |
|
|
UD => 0,
|
168 |
|
|
ID => DMA_mode0_Tm
|
169 |
|
|
)
|
170 |
|
|
port map (
|
171 |
|
|
clk => clk,
|
172 |
|
|
nReset => nReset,
|
173 |
|
|
rst => rst,
|
174 |
|
|
go => go,
|
175 |
|
|
D => Tm,
|
176 |
|
|
done => Tmdone
|
177 |
|
|
);
|
178 |
|
|
|
179 |
|
|
-- 2) set (and reset) DIOR-/DIOW-
|
180 |
|
|
T2proc: process(clk, nReset)
|
181 |
|
|
begin
|
182 |
|
|
if (nReset = '0') then
|
183 |
|
|
iDIOR <= '0';
|
184 |
|
|
iDIOW <= '0';
|
185 |
|
|
elsif (clk'event and clk = '1') then
|
186 |
|
|
if (rst = '1') then
|
187 |
|
|
iDIOR <= '0';
|
188 |
|
|
iDIOW <= '0';
|
189 |
|
|
else
|
190 |
|
|
iDIOR <= (not we and Tmdone) or (iDIOR and not Tddone);
|
191 |
|
|
iDIOW <= ( we and Tmdone) or (iDIOW and not Tddone);
|
192 |
|
|
end if;
|
193 |
|
|
end if;
|
194 |
|
|
end process T2proc;
|
195 |
|
|
|
196 |
|
|
-- 3) hookup Td counter
|
197 |
|
|
td_cnt : ro_cnt
|
198 |
|
|
generic map (
|
199 |
|
|
SIZE => TWIDTH,
|
200 |
|
|
UD => 0,
|
201 |
|
|
ID => DMA_mode0_Td
|
202 |
|
|
)
|
203 |
|
|
port map (
|
204 |
|
|
clk => clk,
|
205 |
|
|
nReset => nReset,
|
206 |
|
|
rst => rst,
|
207 |
|
|
go => Tmdone,
|
208 |
|
|
D => Td,
|
209 |
|
|
done => Tddone
|
210 |
|
|
);
|
211 |
|
|
|
212 |
|
|
-- generate data_strobe
|
213 |
|
|
gen_dstrb: process(clk)
|
214 |
|
|
begin
|
215 |
|
|
if (clk'event and clk = '1') then
|
216 |
|
|
dstrb <= Tddone; -- capture data at rising edge of DIOR-
|
217 |
|
|
end if;
|
218 |
|
|
end process gen_dstrb;
|
219 |
|
|
|
220 |
|
|
-- 4) negate DIOR-/DIOW- when Tddone
|
221 |
|
|
-- 5) hookup end_of_cycle counter
|
222 |
|
|
eoc_cnt : ro_cnt
|
223 |
|
|
generic map (
|
224 |
|
|
SIZE => TWIDTH,
|
225 |
|
|
UD => 0,
|
226 |
|
|
ID => DMA_mode0_Teoc
|
227 |
|
|
)
|
228 |
|
|
port map (
|
229 |
|
|
clk => clk,
|
230 |
|
|
nReset => nReset,
|
231 |
|
|
rst => rst,
|
232 |
|
|
go => Tddone,
|
233 |
|
|
D => Teoc,
|
234 |
|
|
done => done
|
235 |
|
|
);
|
236 |
|
|
end architecture structural;
|