1 |
2 |
dimamali |
------------------------------------------------------------------------------
|
2 |
|
|
-- This file is a part of the GRLIB VHDL IP LIBRARY
|
3 |
|
|
-- Copyright (C) 2003, Gaisler Research
|
4 |
|
|
--
|
5 |
|
|
-- This program is free software; you can redistribute it and/or modify
|
6 |
|
|
-- it under the terms of the GNU General Public License as published by
|
7 |
|
|
-- the Free Software Foundation; either version 2 of the License, or
|
8 |
|
|
-- (at your option) any later version.
|
9 |
|
|
--
|
10 |
|
|
-- This program is distributed in the hope that it will be useful,
|
11 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
|
|
-- GNU General Public License for more details.
|
14 |
|
|
--
|
15 |
|
|
-- You should have received a copy of the GNU General Public License
|
16 |
|
|
-- along with this program; if not, write to the Free Software
|
17 |
|
|
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
18 |
|
|
-----------------------------------------------------------------------------
|
19 |
|
|
-- File: ddrrec.vhd
|
20 |
|
|
-- Author: David Lindh - Gaisler Research
|
21 |
|
|
-- Description: DDR-RAM memory controller interface records
|
22 |
|
|
------------------------------------------------------------------------------
|
23 |
|
|
|
24 |
|
|
library ieee;
|
25 |
|
|
use ieee.std_logic_1164.all;
|
26 |
|
|
library grlib;
|
27 |
|
|
use grlib.amba.all;
|
28 |
|
|
use grlib.stdlib.all;
|
29 |
|
|
library gaisler;
|
30 |
|
|
use grlib.devices.all;
|
31 |
|
|
use gaisler.memctrl.all;
|
32 |
|
|
library techmap;
|
33 |
|
|
use techmap.gencomp.all;
|
34 |
|
|
use techmap.allmem.all;
|
35 |
|
|
|
36 |
|
|
package ddrrec is
|
37 |
|
|
|
38 |
|
|
-------------------------------------------------------------------------------
|
39 |
|
|
-- Options
|
40 |
|
|
-------------------------------------------------------------------------------
|
41 |
|
|
-- This can be changed
|
42 |
|
|
constant buffersize : integer := 4; -- Data buffer size, 2,4,8.,.-1024 (8 word) bursts
|
43 |
|
|
-------------------------------------------------------------------------------
|
44 |
|
|
-- Data sizes, should not haveto be changed
|
45 |
|
|
-------------------------------------------------------------------------------
|
46 |
|
|
type dm_arr is array(4 to 16) of integer;
|
47 |
|
|
constant dmvector : dm_arr := (2,others => 1);
|
48 |
|
|
constant maxdqsize : integer := 64;
|
49 |
|
|
constant maxdmsize : integer := 16;
|
50 |
|
|
constant maxstrobesize : integer := 16;
|
51 |
|
|
constant adrbits : integer := 16; -- BA + row/col address -1 (2+14-1)
|
52 |
|
|
constant ahbadr : integer := 32; -- AHB addressbits
|
53 |
|
|
constant ahbdata : integer := 32; -- AHB databits
|
54 |
|
|
constant bufferadr : integer := log2(buffersize)+2;
|
55 |
|
|
constant ddrcfg_reset : std_logic_vector(31 downto 0):=
|
56 |
|
|
'1' & --refresh
|
57 |
|
|
"00" & -- CAS
|
58 |
|
|
"00" & -- Memcmd
|
59 |
|
|
"10" & -- Burst length
|
60 |
|
|
'0' & -- Auto Precharge
|
61 |
|
|
"11" & -- Read prediction
|
62 |
|
|
"00" & -- Write protection
|
63 |
|
|
x"00000";
|
64 |
|
|
|
65 |
|
|
--Memory commands (RAS, CAS, WE)
|
66 |
|
|
constant CMD_READ : std_logic_vector(2 downto 0) := "101";
|
67 |
|
|
constant CMD_WRITE : std_logic_vector(2 downto 0) := "100";
|
68 |
|
|
constant CMD_NOP : std_logic_vector(2 downto 0) := "111";
|
69 |
|
|
constant CMD_ACTIVE : std_logic_vector(2 downto 0) := "011";
|
70 |
|
|
constant CMD_BT : std_logic_vector(2 downto 0) := "110";
|
71 |
|
|
constant CMD_PRE : std_logic_vector(2 downto 0) := "010";
|
72 |
|
|
constant CMD_AR : std_logic_vector(2 downto 0) := "001";
|
73 |
|
|
constant CMD_LMR : std_logic_vector(2 downto 0) := "000";
|
74 |
|
|
|
75 |
|
|
constant BANK0 : std_logic_vector(1 downto 0) := "10";
|
76 |
|
|
constant BANK1 : std_logic_vector(1 downto 0) := "01";
|
77 |
|
|
constant BANK01 : std_logic_vector(1 downto 0) := "00";
|
78 |
|
|
|
79 |
|
|
type burst_mask_type is array (buffersize-1 downto 0) of integer range 1 to 8;
|
80 |
|
|
type two_burst_mask_type is array (1 downto 0) of burst_mask_type;
|
81 |
|
|
type two_buf_adr_type is array (1 downto 0) of std_logic_vector((log2(buffersize)-1) downto 0);
|
82 |
|
|
type two_buf_data_type is array (1 downto 0) of std_logic_vector((bufferadr-1) downto 0);
|
83 |
|
|
type pre_row_type is array (7 downto 0) of std_logic_vector(adrbits-1 downto 0);
|
84 |
|
|
type two_ddr_adr_type is array (1 downto 0) of std_logic_vector(adrbits-1 downto 0);
|
85 |
|
|
type two_ddr_bank_type is array (1 downto 0) of std_logic_vector(1 downto 0);
|
86 |
|
|
type two_pre_bank_type is array (1 downto 0) of integer range 0 to 7;
|
87 |
|
|
type blwaittype is array (6 downto 0) of integer range 2 to 8;
|
88 |
|
|
type mlwaittype is array (1 downto 0) of integer range 1 to 8;
|
89 |
|
|
type bufwaittype is array (6 downto 0) of std_logic_vector((log2(buffersize)-1) downto 0);
|
90 |
|
|
type ahbwaittype is array (6 downto 0) of integer range 0 to 1;
|
91 |
|
|
|
92 |
|
|
-------------------------------------------------------------------------------
|
93 |
|
|
-- Records
|
94 |
|
|
-------------------------------------------------------------------------------
|
95 |
|
|
-- APB controller
|
96 |
|
|
type apb_ctrl_in_type is record
|
97 |
|
|
apbsi : apb_slv_in_type;
|
98 |
|
|
apb_cmd_done : std_ulogic;
|
99 |
|
|
ready : std_ulogic;
|
100 |
|
|
end record;
|
101 |
|
|
type apb_ctrl_out_type is record
|
102 |
|
|
apbso : apb_slv_out_type;
|
103 |
|
|
ddrcfg_reg : std_logic_vector(31 downto 0);
|
104 |
|
|
end record;
|
105 |
|
|
|
106 |
|
|
-------------------------------------------------------------------------------
|
107 |
|
|
-- Sync ram dp (data-fifo)
|
108 |
|
|
type syncram_dp_in_type is record
|
109 |
|
|
address1 : std_logic_vector((bufferadr -1) downto 0);
|
110 |
|
|
datain1 : std_logic_vector(2*(maxdqsize+maxdmsize)-1 downto 0);
|
111 |
|
|
enable1 : std_ulogic;
|
112 |
|
|
write1 : std_ulogic;
|
113 |
|
|
address2 : std_logic_vector((bufferadr-1) downto 0);
|
114 |
|
|
datain2 : std_logic_vector(2*(maxdqsize+maxdmsize)-1 downto 0);
|
115 |
|
|
enable2 : std_ulogic;
|
116 |
|
|
write2 : std_ulogic;
|
117 |
|
|
end record;
|
118 |
|
|
type syncram_dp_out_type is record
|
119 |
|
|
dataout1 : std_logic_vector(2*(maxdqsize+maxdmsize)-1 downto 0);
|
120 |
|
|
dataout2 : std_logic_vector(2*(maxdqsize+maxdmsize)-1 downto 0);
|
121 |
|
|
end record;
|
122 |
|
|
type two_syncram_dp_out_type is array (1 downto 0) of syncram_dp_out_type;
|
123 |
|
|
type two_syncram_dp_in_type is array (1 downto 0) of syncram_dp_in_type;
|
124 |
|
|
|
125 |
|
|
-------------------------------------------------------------------------------
|
126 |
|
|
-- Sync ram 2p (adr-fifo)
|
127 |
|
|
type syncram_2p_in_type is record
|
128 |
|
|
renable : std_ulogic;
|
129 |
|
|
raddress : std_logic_vector((log2(buffersize) -1) downto 0);
|
130 |
|
|
write : std_ulogic;
|
131 |
|
|
waddress : std_logic_vector((log2(buffersize)-1) downto 0);
|
132 |
|
|
datain : std_logic_vector((ahbadr-1+1) downto 0);
|
133 |
|
|
end record;
|
134 |
|
|
type syncram_2p_out_type is record
|
135 |
|
|
dataout : std_logic_vector((ahbadr-1+1) downto 0);
|
136 |
|
|
end record;
|
137 |
|
|
|
138 |
|
|
-----------------------------------------------------------------------------
|
139 |
|
|
-- High speed interface towards memory
|
140 |
|
|
type hs_in_type is record
|
141 |
|
|
bl : integer range 2 to 8;
|
142 |
|
|
ml : integer range 1 to 8;
|
143 |
|
|
cas : std_logic_vector(1 downto 0);
|
144 |
|
|
buf : std_logic_vector((log2(buffersize)-1) downto 0);
|
145 |
|
|
ahb : integer range 0 to 1;
|
146 |
|
|
cs : std_logic_vector(1 downto 0);
|
147 |
|
|
adr : std_logic_vector(adrbits-1 downto 0);
|
148 |
|
|
cmd : std_logic_vector(2 downto 0);
|
149 |
|
|
cmd_valid : std_ulogic;
|
150 |
|
|
dsramso : two_syncram_dp_out_type;
|
151 |
|
|
ddso : ddrmem_out_type;
|
152 |
|
|
end record;
|
153 |
|
|
type hs_out_type is record
|
154 |
|
|
hs_busy : std_ulogic;
|
155 |
|
|
cmdDone : two_buf_adr_type;
|
156 |
|
|
dsramsi : two_syncram_dp_in_type;
|
157 |
|
|
ddsi : ddrmem_in_type;
|
158 |
|
|
end record;
|
159 |
|
|
|
160 |
|
|
-----------------------------------------------------------------------------
|
161 |
|
|
-- AHB controller
|
162 |
|
|
type ahb_ctrl_in_type is record
|
163 |
|
|
ahbsi : ahb_slv_in_type;
|
164 |
|
|
asramsi : syncram_2p_in_type;
|
165 |
|
|
dsramsi : syncram_dp_in_type;
|
166 |
|
|
burstlength : integer range 2 to 8;
|
167 |
|
|
r_predict : std_ulogic;
|
168 |
|
|
w_prot : std_ulogic;
|
169 |
|
|
locked : std_ulogic;
|
170 |
|
|
rw_cmd_done : std_logic_vector((log2(buffersize) -1) downto 0);
|
171 |
|
|
end record;
|
172 |
|
|
type ahb_ctrl_out_type is record
|
173 |
|
|
ahbso : ahb_slv_out_type;
|
174 |
|
|
asramso : syncram_2p_out_type;
|
175 |
|
|
dsramso : syncram_dp_out_type;
|
176 |
|
|
rw_cmd_valid : std_logic_vector((log2(buffersize) -1) downto 0);
|
177 |
|
|
w_data_valid : std_logic_vector((log2(buffersize) -1) downto 0);
|
178 |
|
|
burst_dm : burst_mask_type;
|
179 |
|
|
end record;
|
180 |
|
|
type two_ahb_ctrl_out_type is array (1 downto 0) of ahb_ctrl_out_type;
|
181 |
|
|
type two_ahb_ctrl_in_type is array (1 downto 0) of ahb_ctrl_in_type;
|
182 |
|
|
|
183 |
|
|
-----------------------------------------------------------------------------
|
184 |
|
|
-- Main controller
|
185 |
|
|
type main_ctrl_in_type is record
|
186 |
|
|
apbctrlso : apb_ctrl_out_type;
|
187 |
|
|
ahbctrlso : two_ahb_ctrl_out_type;
|
188 |
|
|
hsso : hs_out_type;
|
189 |
|
|
end record;
|
190 |
|
|
type main_ctrl_out_type is record
|
191 |
|
|
apbctrlsi : apb_ctrl_in_type;
|
192 |
|
|
ahbctrlsi : two_ahb_ctrl_in_type;
|
193 |
|
|
hssi : hs_in_type;
|
194 |
|
|
end record;
|
195 |
|
|
|
196 |
|
|
-------------------------------------------------------------------------------
|
197 |
|
|
-- DDRCFG register
|
198 |
|
|
type config_out_type is record
|
199 |
|
|
refresh : std_ulogic;
|
200 |
|
|
cas : std_logic_vector(1 downto 0);
|
201 |
|
|
memcmd : std_logic_vector(1 downto 0);
|
202 |
|
|
bl : std_logic_vector(1 downto 0);
|
203 |
|
|
autopre : std_ulogic;
|
204 |
|
|
r_predict : std_logic_vector(1 downto 0);
|
205 |
|
|
w_prot : std_logic_vector(1 downto 0);
|
206 |
|
|
ready : std_ulogic;
|
207 |
|
|
end record;
|
208 |
|
|
|
209 |
|
|
-------------------------------------------------------------------------------
|
210 |
|
|
-- State machines
|
211 |
|
|
-------------------------------------------------------------------------------
|
212 |
|
|
type apbcycletype is (idle, refresh, cmd, wait_lmr1, wait_lmr2, cmdlmr, cmdDone, cmdDone2);
|
213 |
|
|
type timercycletype is (t1, t2, t3, t4);
|
214 |
|
|
type initcycletype is (idle, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11);
|
215 |
|
|
type maincycletype is (init, idle, pre1, act1, w1, r1, rw, c1, c2);
|
216 |
|
|
type rwcycletype is (idle, r, w);
|
217 |
|
|
type cmdbuffercycletype is (no_cmd, new_cmd);
|
218 |
|
|
type cmdcycletype is(idle, hold);
|
219 |
|
|
|
220 |
|
|
-----------------------------------------------------------------------------
|
221 |
|
|
-- AHB - Local variables
|
222 |
|
|
type ahb_reg_type is record
|
223 |
|
|
readcounter : integer range 0 to 8;
|
224 |
|
|
writecounter : integer range 0 to 8;
|
225 |
|
|
blockburstlength : integer range 0 to 8;
|
226 |
|
|
hready : std_ulogic;
|
227 |
|
|
hresp : std_logic_vector(1 downto 0);
|
228 |
|
|
rwadrbuffer : std_logic_vector((ahbadr-1) downto 0);
|
229 |
|
|
use_read_buffer : std_logic_vector((log2(buffersize)-1) downto 0);
|
230 |
|
|
pre_read_buffer : std_logic_vector((log2(buffersize)-1) downto 0);
|
231 |
|
|
pre_read_adr : std_logic_vector((ahbadr-1) downto 0);
|
232 |
|
|
pre_read_valid : std_ulogic;
|
233 |
|
|
use_write_buffer : std_logic_vector((log2(buffersize)-1) downto 0);
|
234 |
|
|
rw_cmd_valid : std_logic_vector((log2(buffersize)-1) downto 0);
|
235 |
|
|
w_data_valid : std_logic_vector((log2(buffersize)-1) downto 0);
|
236 |
|
|
|
237 |
|
|
sync_adr : std_logic_vector((bufferadr-1) downto 0);
|
238 |
|
|
sync_wdata : std_logic_vector(2*(maxdqsize+maxdmsize)-1 downto 0);
|
239 |
|
|
sync_write : std_ulogic;
|
240 |
|
|
sync_busy : std_ulogic;
|
241 |
|
|
sync_busy_adr : std_logic_vector((bufferadr-1) downto 0);
|
242 |
|
|
sync2_adr : std_logic_vector((log2(buffersize)-1) downto 0);
|
243 |
|
|
sync2_wdata : std_logic_vector((ahbadr-1+1) downto 0);
|
244 |
|
|
sync2_write : std_ulogic;
|
245 |
|
|
sync2_busy : std_ulogic;
|
246 |
|
|
|
247 |
|
|
doRead : std_ulogic;
|
248 |
|
|
doWrite : std_ulogic;
|
249 |
|
|
new_burst : std_ulogic;
|
250 |
|
|
startp : integer range 0 to 7;
|
251 |
|
|
ahbstartp : integer range 0 to 7;
|
252 |
|
|
even_odd_write : integer range 0 to 1;
|
253 |
|
|
burst_hsize : integer range 1 to 8;
|
254 |
|
|
offset : std_logic_vector(2 downto 0);
|
255 |
|
|
ahboffset : std_logic_vector(2 downto 0);
|
256 |
|
|
read_data : std_logic_vector(maxdqsize-1 downto 0);
|
257 |
|
|
cur_hrdata : std_logic_vector((ahbdata-1) downto 0);
|
258 |
|
|
cur_hready : std_ulogic;
|
259 |
|
|
cur_hresp : std_logic_vector(1 downto 0);
|
260 |
|
|
prev_retry : std_ulogic;
|
261 |
|
|
prev_error : std_ulogic;
|
262 |
|
|
burst_dm : burst_mask_type;
|
263 |
|
|
end record;
|
264 |
|
|
|
265 |
|
|
-------------------------------------------------------------------------------
|
266 |
|
|
-- APB controller - Local variables
|
267 |
|
|
type apb_reg_type is record
|
268 |
|
|
ddrcfg_reg : std_logic_vector(31 downto 0);
|
269 |
|
|
end record;
|
270 |
|
|
|
271 |
|
|
-------------------------------------------------------------------------------
|
272 |
|
|
-- High speed RW - Local variables
|
273 |
|
|
type rw_reg_type is record
|
274 |
|
|
cbufstate : cmdbuffercycletype;
|
275 |
|
|
cmdstate : cmdcycletype;
|
276 |
|
|
rwstate : rwcycletype;
|
277 |
|
|
cur_buf : two_buf_adr_type;
|
278 |
|
|
cur_ahb : integer range 0 to 1;
|
279 |
|
|
use_bl : integer range 2 to 8;
|
280 |
|
|
use_ml : integer range 1 to 8;
|
281 |
|
|
use_buf : std_logic_vector((log2(buffersize)-1) downto 0);
|
282 |
|
|
use_ahb : integer range 0 to 1;
|
283 |
|
|
use_cas : std_ulogic;
|
284 |
|
|
rw_cmd : std_logic_vector(2 downto 0);
|
285 |
|
|
rw_bl : integer range 2 to 8;
|
286 |
|
|
rw_cas : integer range 2 to 3;
|
287 |
|
|
next_bl : integer range 2 to 8;
|
288 |
|
|
next_ml : integer range 1 to 8;
|
289 |
|
|
next_buf : std_logic_vector((log2(buffersize)-1) downto 0);
|
290 |
|
|
next_ahb : integer range 0 to 1;
|
291 |
|
|
next_cas : std_logic_vector(1 downto 0);
|
292 |
|
|
next_adr : std_logic_vector(adrbits-1 downto 0);
|
293 |
|
|
next_cs : std_logic_vector(1 downto 0);
|
294 |
|
|
next_cmd : std_logic_vector(2 downto 0);
|
295 |
|
|
set_cmd : std_logic_vector(2 downto 0);
|
296 |
|
|
set_adr : std_logic_vector(adrbits-1 downto 0);
|
297 |
|
|
set_cs : std_logic_vector(1 downto 0);
|
298 |
|
|
set_cke : std_ulogic;
|
299 |
|
|
hs_busy : std_ulogic;
|
300 |
|
|
cmdDone : two_buf_adr_type;
|
301 |
|
|
begin_read : std_ulogic;
|
302 |
|
|
begin_write : std_ulogic;
|
303 |
|
|
dq_dqs_oe : std_ulogic;
|
304 |
|
|
w_ce : std_ulogic;
|
305 |
|
|
r_ce : std_ulogic;
|
306 |
|
|
cnt : integer range 0 to 8;
|
307 |
|
|
holdcnt : integer range 0 to 31;
|
308 |
|
|
r2wholdcnt : integer range 0 to 15;
|
309 |
|
|
act2precnt : integer range 0 to 15;
|
310 |
|
|
wait_time : integer range 0 to 31;
|
311 |
|
|
readwait : std_logic_vector(6 downto 0);
|
312 |
|
|
writewait : std_logic_vector(1 downto 0);
|
313 |
|
|
bufwait : bufwaittype;
|
314 |
|
|
ahbwait : ahbwaittype;
|
315 |
|
|
blwait : blwaittype;
|
316 |
|
|
mlwait : mlwaittype;
|
317 |
|
|
caswait : std_logic_vector(6 downto 0);
|
318 |
|
|
dm1_o : std_logic_vector((maxdmsize-1) downto 0);
|
319 |
|
|
dm2_o : std_logic_vector((maxdmsize-1) downto 0);
|
320 |
|
|
dqs1_o : std_ulogic;
|
321 |
|
|
sync_adr : two_buf_data_type;
|
322 |
|
|
sync_write : std_logic_vector(1 downto 0);
|
323 |
|
|
sync_wdata : std_logic_vector(2*(maxdqsize+maxdmsize)-1 downto 0);
|
324 |
|
|
end record;
|
325 |
|
|
-------------------------------------------------------------------------------
|
326 |
|
|
-- High speed CMD - Local variables
|
327 |
|
|
type cmd_reg_type is record
|
328 |
|
|
cur_cmd : std_logic_vector(2 downto 0);
|
329 |
|
|
cur_cs : std_logic_vector(1 downto 0);
|
330 |
|
|
cur_adr : std_logic_vector(adrbits-1 downto 0);
|
331 |
|
|
next_cmd : std_logic_vector(2 downto 0);
|
332 |
|
|
next_cs : std_logic_vector(1 downto 0);
|
333 |
|
|
next_adr : std_logic_vector(adrbits-1 downto 0);
|
334 |
|
|
end record;
|
335 |
|
|
-------------------------------------------------------------------------------
|
336 |
|
|
-- Main controller - Local variables
|
337 |
|
|
type main_reg_type is record
|
338 |
|
|
-- For main controller
|
339 |
|
|
mainstate : maincycletype;
|
340 |
|
|
loadcmdbuffer : std_ulogic;
|
341 |
|
|
cmdbufferdata : std_logic_vector(2 downto 0);
|
342 |
|
|
adrbufferdata : std_logic_vector(adrbits-1 downto 0);
|
343 |
|
|
use_ahb : integer range 0 to 1;
|
344 |
|
|
use_bl : integer range 2 to 8;
|
345 |
|
|
use_cas : std_logic_vector(1 downto 0);
|
346 |
|
|
use_buf : std_logic_vector((log2(buffersize)-1) downto 0);
|
347 |
|
|
burstlength : integer range 2 to 8;
|
348 |
|
|
rw_cmd_done : two_buf_adr_type;
|
349 |
|
|
lmradr : std_logic_vector(adrbits-1 downto 0);
|
350 |
|
|
memCmdDone : std_ulogic;
|
351 |
|
|
lockAHB : std_logic_vector(1 downto 0);
|
352 |
|
|
pre_row : pre_row_type;
|
353 |
|
|
pre_chg : std_logic_vector(7 downto 0);
|
354 |
|
|
pre_bankadr : two_pre_bank_type;
|
355 |
|
|
sync2_adr : two_buf_adr_type;
|
356 |
|
|
|
357 |
|
|
-- For init statemachine
|
358 |
|
|
initstate : initcycletype;
|
359 |
|
|
doMemInit : std_ulogic;
|
360 |
|
|
memInitDone : std_ulogic;
|
361 |
|
|
initDelay : integer range 0 to 255;
|
362 |
|
|
cs : std_logic_vector(1 downto 0);
|
363 |
|
|
|
364 |
|
|
-- For address calculator
|
365 |
|
|
coladdress : two_ddr_adr_type;
|
366 |
|
|
tmpcoladdress : two_ddr_adr_type;
|
367 |
|
|
rowaddress : two_ddr_adr_type;
|
368 |
|
|
addressrange : integer range 0 to 31;
|
369 |
|
|
tmpcolbits : integer range 0 to 15;
|
370 |
|
|
colbits : integer range 0 to 15;
|
371 |
|
|
rowbits : integer range 0 to 15;
|
372 |
|
|
bankselect : two_ddr_bank_type;
|
373 |
|
|
intbankbits : two_ddr_bank_type;
|
374 |
|
|
|
375 |
|
|
-- For refresh timer statemachine
|
376 |
|
|
timerstate : timercycletype;
|
377 |
|
|
doRefresh : std_ulogic;
|
378 |
|
|
refreshDone : std_ulogic;
|
379 |
|
|
refreshTime : integer range 0 to 4095;
|
380 |
|
|
maxRefreshTime : integer range 0 to 32767;
|
381 |
|
|
idlecnt : integer range 0 to 10;
|
382 |
|
|
refreshcnt : integer range 0 to 65535;
|
383 |
|
|
|
384 |
|
|
-- For DDRCFG register (APB)
|
385 |
|
|
apbstate : apbcycletype;
|
386 |
|
|
apb_cmd_done : std_ulogic;
|
387 |
|
|
ready : std_ulogic;
|
388 |
|
|
ddrcfg : config_out_type;
|
389 |
|
|
end record;
|
390 |
|
|
|
391 |
|
|
-------------------------------------------------------------------------------
|
392 |
|
|
-- Components
|
393 |
|
|
-------------------------------------------------------------------------------
|
394 |
|
|
|
395 |
|
|
component ahb_slv
|
396 |
|
|
generic (
|
397 |
|
|
hindex : integer := 0;
|
398 |
|
|
haddr : integer := 0;
|
399 |
|
|
hmask : integer := 16#f80#;
|
400 |
|
|
sepclk : integer := 0;
|
401 |
|
|
dqsize : integer := 64;
|
402 |
|
|
dmsize : integer := 8;
|
403 |
|
|
tech : integer := virtex2);
|
404 |
|
|
port (
|
405 |
|
|
rst : in std_ulogic;
|
406 |
|
|
hclk : in std_ulogic;
|
407 |
|
|
clk0 : in std_ulogic;
|
408 |
|
|
csi : in ahb_ctrl_in_type;
|
409 |
|
|
cso : out ahb_ctrl_out_type);
|
410 |
|
|
end component;
|
411 |
|
|
|
412 |
|
|
component ddr_in
|
413 |
|
|
generic (
|
414 |
|
|
tech : integer);
|
415 |
|
|
port (
|
416 |
|
|
Q1 : out std_ulogic;
|
417 |
|
|
Q2 : out std_ulogic;
|
418 |
|
|
C1 : in std_ulogic;
|
419 |
|
|
C2 : in std_ulogic;
|
420 |
|
|
CE : in std_ulogic;
|
421 |
|
|
-- DQS : in std_logic; -- used for lattice
|
422 |
|
|
-- DDRCLKPOL: in std_logic; -- used for lattice
|
423 |
|
|
D : in std_ulogic;
|
424 |
|
|
R : in std_ulogic;
|
425 |
|
|
S : in std_ulogic);
|
426 |
|
|
end component;
|
427 |
|
|
|
428 |
|
|
|
429 |
|
|
component ddr_out
|
430 |
|
|
generic (
|
431 |
|
|
tech : integer);
|
432 |
|
|
port (
|
433 |
|
|
Q : out std_ulogic;
|
434 |
|
|
C1 : in std_ulogic;
|
435 |
|
|
C2 : in std_ulogic;
|
436 |
|
|
CE : in std_ulogic;
|
437 |
|
|
D1 : in std_ulogic;
|
438 |
|
|
D2 : in std_ulogic;
|
439 |
|
|
R : in std_ulogic;
|
440 |
|
|
S : in std_ulogic);
|
441 |
|
|
end component;
|
442 |
|
|
|
443 |
|
|
|
444 |
|
|
component hs
|
445 |
|
|
generic(
|
446 |
|
|
tech : in integer;
|
447 |
|
|
dqsize : in integer;
|
448 |
|
|
dmsize : in integer;
|
449 |
|
|
strobesize: in integer;
|
450 |
|
|
clkperiod : in integer);
|
451 |
|
|
port (
|
452 |
|
|
rst : in std_ulogic;
|
453 |
|
|
clk0 : in std_ulogic;
|
454 |
|
|
clk90 : in std_ulogic;
|
455 |
|
|
clk180 : in std_ulogic;
|
456 |
|
|
clk270 : in std_ulogic;
|
457 |
|
|
hclk : in std_ulogic;
|
458 |
|
|
hssi : in hs_in_type;
|
459 |
|
|
hsso : out hs_out_type);
|
460 |
|
|
end component;
|
461 |
|
|
|
462 |
|
|
end ddrrec;
|
463 |
|
|
|
464 |
|
|
|
465 |
|
|
|
466 |
|
|
|