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

Subversion Repositories sdram_ctrl

[/] [sdram_ctrl/] [trunk/] [src/] [sdram_ctrl.vhd] - Blame information for rev 10

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

Line No. Rev Author Line
1 2 ntpqa
------------------------------------------------------------------
2
--                                                              
3
-- sdram_ctrl.vhd                                          
4
--                                                                                          
5
-- Module Description:                                          
6
-- SDRAM small&fast controller
7
-- 
8
--                                                              
9
-- To Do:        
10 7 ntpqa
-- multichipselect support      done
11
-- configurable times           50% 
12 2 ntpqa
-- nios simulation support
13
--                                                              
14
-- Author(s):                                                   
15
-- Aleksey Kuzmenok, ntpqa@opencores.org                      
16
--                                                              
17
------------------------------------------------------------------
18
--                                                              
19
-- Copyright (C) 2006 Aleksey Kuzmenok and OPENCORES.ORG        
20
--                                                              
21
-- This module is free software; you can redistribute it and/or
22
-- modify it under the terms of the GNU Lesser General Public
23
-- License as published by the Free Software Foundation; either
24
-- version 2.1 of the License, or (at your option) any later version.
25
--
26
-- This module is distributed in the hope that it will be useful,
27
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
28
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29
-- Lesser General Public License for more details.
30
--
31
-- You should have received a copy of the GNU Lesser General Public
32
-- License along with this software; if not, write to the Free Software
33
-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA            
34
--                                                              
35
------------------------------------------------------------------
36 7 ntpqa
-- Hardware test results                                                                                                                                                                        
37
-- FPGA                     SDRAM                        CLK (not less than)
38 2 ntpqa
-- EP1C12XXXXC8             MT48LC4M32B2TG-7:G           125 MHz
39
-- EP1C6XXXXC8              IS42S16100C1-7TL             125 MHz   
40
--
41
------------------------------------------------------------------
42 7 ntpqa
-- History
43
-- 22.10.2006   multichipselect functionaly tested        
44
-- 10.11.2006   first successful hardware test
45
-- 07.12.2006   proved to be fully reliable
46 2 ntpqa
 
47
LIBRARY ieee;
48
USE ieee.std_logic_1164.ALL;
49
USE ieee.numeric_std.ALL;
50 7 ntpqa
 
51 2 ntpqa
LIBRARY altera_mf;
52 7 ntpqa
USE altera_mf.altera_mf_components.all;
53 2 ntpqa
 
54
entity sdram_ctrl is
55 7 ntpqa
        generic(
56 2 ntpqa
                DATA_WIDTH: integer:=32;
57 7 ntpqa
                CHIPSELECTS: integer:=1;
58
                LOG2_OF_CS: integer:=0;
59
                BANK_WIDTH: integer:=2;
60 2 ntpqa
                ROW_WIDTH: integer:=12;
61 7 ntpqa
                COLUMN_WIDTH: integer:=8;
62 2 ntpqa
 
63 7 ntpqa
                MODE_REGISTER: integer:=48;     -- 1 word burst, CAS latency=3 
64
 
65
                -- Only two times are configurable
66
                -- tINIT delay between powerup and load mode register = 100 us 
67
                -- tREF refresh period = 15.625 us  (64ms/4096rows)
68
                clk_MHz: integer:=120;
69
                t_INIT_uS: integer:=110;        -- 109.9 us just to be on the save side
70
                t_REF_nS: integer:=15384        -- 15.384 us the same purpose
71
 
72 2 ntpqa
                );
73
        port(
74
                signal clk : IN STD_LOGIC;
75
                signal reset : IN STD_LOGIC;
76
 
77
                -- IMPORTANT: for this Avalon(tm) interface 
78
                -- 'Minimum Arbitration Shares'=1 
79
                -- 'Max Pending Read Transactions'=9
80
                signal avs_nios_chipselect : IN STD_LOGIC;
81 7 ntpqa
                signal avs_nios_address : IN STD_LOGIC_VECTOR ((LOG2_OF_CS+BANK_WIDTH+ROW_WIDTH+COLUMN_WIDTH-1) DOWNTO 0);
82 2 ntpqa
                signal avs_nios_byteenable : IN STD_LOGIC_VECTOR (((DATA_WIDTH/8)-1) DOWNTO 0);
83
                signal avs_nios_writedata : IN STD_LOGIC_VECTOR ((DATA_WIDTH-1) DOWNTO 0);
84
                signal avs_nios_write : IN STD_LOGIC;
85
                signal avs_nios_read : IN STD_LOGIC;
86
                signal avs_nios_waitrequest : OUT STD_LOGIC;
87
                signal avs_nios_readdata : OUT STD_LOGIC_VECTOR ((DATA_WIDTH-1) DOWNTO 0);
88
                signal avs_nios_readdatavalid : OUT STD_LOGIC;
89
 
90
                -- global export signals
91 7 ntpqa
                signal sdram_cke : OUT STD_LOGIC;                       -- This pin has the fixed state '1'
92 2 ntpqa
                signal sdram_ba : OUT STD_LOGIC_VECTOR ((BANK_WIDTH-1) DOWNTO 0);
93
                signal sdram_addr : OUT STD_LOGIC_VECTOR ((ROW_WIDTH-1) DOWNTO 0);
94 7 ntpqa
                signal sdram_cs_n : OUT STD_LOGIC_VECTOR ((CHIPSELECTS-1) DOWNTO 0);
95 2 ntpqa
                signal sdram_ras_n : OUT STD_LOGIC;
96
                signal sdram_cas_n : OUT STD_LOGIC;
97
                signal sdram_we_n : OUT STD_LOGIC;
98
                signal sdram_dq : INOUT STD_LOGIC_VECTOR ((DATA_WIDTH-1) DOWNTO 0);
99
                signal sdram_dqm : OUT STD_LOGIC_VECTOR (((DATA_WIDTH/8)-1) DOWNTO 0)
100
                );
101
end sdram_ctrl;
102
 
103
architecture behaviour of sdram_ctrl is
104
 
105 7 ntpqa
        CONSTANT FIFO_WIDTH: integer:=LOG2_OF_CS+BANK_WIDTH+ROW_WIDTH+COLUMN_WIDTH+DATA_WIDTH+(DATA_WIDTH/8)+2;
106
        CONSTANT BE_LOW_BIT: integer:=2;
107
        CONSTANT DATA_LOW_BIT: integer:=(DATA_WIDTH/8)+2;
108
        CONSTANT COL_LOW_BIT: integer:=DATA_WIDTH+(DATA_WIDTH/8)+2;
109
        CONSTANT ROW_LOW_BIT: integer:=COLUMN_WIDTH+DATA_WIDTH+(DATA_WIDTH/8)+2;
110
        CONSTANT BANK_LOW_BIT: integer:=ROW_WIDTH+COLUMN_WIDTH+DATA_WIDTH+(DATA_WIDTH/8)+2;
111
        CONSTANT CS_LOW_BIT: integer:=BANK_WIDTH+ROW_WIDTH+COLUMN_WIDTH+DATA_WIDTH+(DATA_WIDTH/8)+2;
112 2 ntpqa
 
113 7 ntpqa
        --CONSTANT MODE: std_logic_vector((sdram_addr'length-1) downto 0):=std_logic_vector(MODE_REGISTER((sdram_addr'length-1) downto 0));
114
        CONSTANT INIT_PAUSE_CLOCKS: integer:=clk_MHz*t_INIT_uS;
115
        CONSTANT REFRESH_PERIOD_CLOCKS: integer:=(clk_MHz*t_REF_nS)/1000;
116
        CONSTANT CAS_LATENCY: integer:=3;                           -- other latencies weren't been tested!
117 2 ntpqa
 
118
        COMPONENT scfifo
119
                GENERIC (
120
                        add_ram_output_register         : STRING;
121
                        intended_device_family          : STRING;
122
                        lpm_numwords            : NATURAL;
123
                        lpm_showahead           : STRING;
124
                        lpm_type                : STRING;
125
                        lpm_width               : NATURAL;
126
                        lpm_widthu              : NATURAL;
127
                        overflow_checking               : STRING;
128
                        underflow_checking              : STRING;
129
                        use_eab         : STRING
130
                        );
131
                PORT (
132
                        rdreq   : IN STD_LOGIC ;
133
                        empty   : OUT STD_LOGIC ;
134
                        aclr    : IN STD_LOGIC ;
135
                        clock   : IN STD_LOGIC ;
136
                        q       : OUT STD_LOGIC_VECTOR ((FIFO_WIDTH-1) DOWNTO 0);
137
                        wrreq   : IN STD_LOGIC ;
138
                        data    : IN STD_LOGIC_VECTOR ((FIFO_WIDTH-1) DOWNTO 0);
139
                        full    : OUT STD_LOGIC
140
                        );
141
        END COMPONENT;
142
 
143
        -- If you ask me why there are so many states, I'll answer that all times are fixed.
144
        -- The top speed for MT48LC4M32B2TG-7:G is 7 ns, therefore all times were based on it.
145
        -- tRP PRECHARGE command period = 3 clocks
146
        -- tRFC AUTO REFRESH period = 10 clocks 
147
        -- tMRD LOAD MODE REGISTER command to ACTIVE or REFRESH command = 2 clocks
148
        -- tRCD ACTIVE to READ or WRITE delay = 3 clocks
149
        -- tRAS ACTIVE to PRECHARGE command = 7 clocks 
150
        -- tRC ACTIVE to ACTIVE command period = 10 clocks
151
        -- tWR2 Write recovery time = 2 clocks
152
        type states is (
153
        INIT0,INIT1,INIT2,INIT3,INIT4,INIT5,INIT6,INIT7,
154
        INIT8,INIT9,INIT10,INIT11,INIT12,INIT13,INIT14,INIT15,
155
        INIT16,INIT17,INIT18,INIT19,INIT20,INIT21,INIT22,INIT23,INIT24,
156
        REFRESH0,REFRESH1,REFRESH2,REFRESH3,REFRESH4,REFRESH5,REFRESH6,REFRESH7,
157
        REFRESH8,REFRESH9,REFRESH10,REFRESH11,REFRESH12,REFRESH13,REFRESH14,
158
        ACTIVE0,ACTIVE1,ACTIVE2,ACTIVE3,ACTIVE4,
159
        IDLE,READ0,WRITE0);
160
        signal operation: states;
161
 
162
        signal fifo_q: std_logic_vector((FIFO_WIDTH-1) downto 0);
163
 
164
        signal init_counter: unsigned(15 downto 0):=to_unsigned(INIT_PAUSE_CLOCKS,16);
165
        signal refresh_counter: unsigned(15 downto 0);
166
        signal active_counter: unsigned(2 downto 0);
167 7 ntpqa
        signal active_address: unsigned((LOG2_OF_CS+BANK_WIDTH+ROW_WIDTH-1) downto 0);
168 2 ntpqa
 
169 7 ntpqa
        signal chipselect: std_logic_vector(LOG2_OF_CS downto 0);
170 2 ntpqa
        signal bank: std_logic_vector((sdram_ba'length-1) downto 0);
171
        signal row: std_logic_vector((sdram_addr'length-1) downto 0);
172 7 ntpqa
        signal column: std_logic_vector((COLUMN_WIDTH-1) downto 0);
173
        signal data: std_logic_vector((sdram_dq'length-1) downto 0);
174
        signal be: std_logic_vector((sdram_dqm'length-1) downto 0);
175 2 ntpqa
 
176
        signal do_init,do_refresh,do_active,read_is_active,ready,tRCD_not_expired: std_logic:='0';
177
 
178
        signal fifo_rdreq,fifo_empty: std_logic;
179
 
180
        signal read_latency: std_logic_vector(CAS_LATENCY downto 0);
181
 
182
        signal fifo_data: std_logic_vector((FIFO_WIDTH-1) downto 0);
183
        signal fifo_wrreq,fifo_wrfull: std_logic;
184
 
185 7 ntpqa
        signal i_command : STD_LOGIC_VECTOR(2 downto 0);
186
        CONSTANT NOP: STD_LOGIC_VECTOR((i_command'length-1) downto 0):="111";
187
        CONSTANT ACTIVE: STD_LOGIC_VECTOR((i_command'length-1) downto 0):="011";
188
        CONSTANT READ: STD_LOGIC_VECTOR((i_command'length-1) downto 0):="101";
189
        CONSTANT WRITE: STD_LOGIC_VECTOR((i_command'length-1) downto 0):="100";
190
        CONSTANT PRECHARGE: STD_LOGIC_VECTOR((i_command'length-1) downto 0):="010";
191
        CONSTANT AUTO_REFRESH: STD_LOGIC_VECTOR((i_command'length-1) downto 0):="001";
192
        CONSTANT LOAD_MODE_REGISTER: STD_LOGIC_VECTOR((i_command'length-1) downto 0):="000";
193 2 ntpqa
 
194 7 ntpqa
        signal i_address : STD_LOGIC_VECTOR((sdram_addr'length-1) DOWNTO 0);
195
        signal i_chipselect: STD_LOGIC_VECTOR((sdram_cs_n'length-1) downto 0);
196 2 ntpqa
        signal i_bank : STD_LOGIC_VECTOR((sdram_ba'length-1) DOWNTO 0);
197
        signal i_dqm : STD_LOGIC_VECTOR((sdram_dqm'length-1) DOWNTO 0);
198
        signal i_data : STD_LOGIC_VECTOR((sdram_dq'length-1) DOWNTO 0);
199
        attribute ALTERA_ATTRIBUTE : string;
200
        attribute ALTERA_ATTRIBUTE of i_command : signal is "FAST_OUTPUT_REGISTER=ON";
201
        attribute ALTERA_ATTRIBUTE of i_address : signal is "FAST_OUTPUT_REGISTER=ON";
202 7 ntpqa
        attribute ALTERA_ATTRIBUTE of i_chipselect : signal is "FAST_OUTPUT_REGISTER=ON";
203 2 ntpqa
        attribute ALTERA_ATTRIBUTE of i_bank : signal is "FAST_OUTPUT_REGISTER=ON";
204
        attribute ALTERA_ATTRIBUTE of i_dqm : signal is "FAST_OUTPUT_REGISTER=ON";
205
        attribute ALTERA_ATTRIBUTE of i_data : signal is "FAST_OUTPUT_REGISTER=ON";
206 7 ntpqa
        attribute ALTERA_ATTRIBUTE of avs_nios_readdata : signal is "FAST_INPUT_REGISTER=ON";
207
 
208
        function DECODE(hex: std_logic_vector; size: integer) return std_logic_vector is
209
                variable result : std_logic_vector((size-1) downto 0);
210
        begin
211
                result:=(others=>'1');
212
                result(to_integer(unsigned(hex))):='0';
213
                return result;
214
        end;
215 2 ntpqa
begin
216 7 ntpqa
        sdram_cke<='1';
217
        (sdram_ras_n,sdram_cas_n,sdram_we_n) <= i_command;
218
        sdram_cs_n <= i_chipselect;
219 2 ntpqa
        sdram_addr <= i_address;
220
        sdram_ba <= i_bank;
221
        sdram_dqm <= i_dqm;
222
        sdram_dq <= i_data;
223
 
224
        fifo_data<=avs_nios_address & avs_nios_writedata & avs_nios_byteenable & avs_nios_write & avs_nios_read;
225
        fifo_wrreq<=(avs_nios_write or avs_nios_read) and avs_nios_chipselect and not fifo_wrfull;
226
 
227
        avs_nios_waitrequest<=fifo_wrfull;
228
 
229
        fifo_rdreq<=not fifo_empty and not do_refresh and not do_active and not read_is_active and ready;
230
 
231 7 ntpqa
        do_active<='0' when active_address=unsigned(fifo_q((fifo_q'length-1) downto (column'length+data'length+be'length+2))) else '1';
232 2 ntpqa
        read_is_active<='1' when read_latency(CAS_LATENCY-1 downto 0)>"000" and fifo_q(1)='1' else '0';
233
        ready<='1' when operation=IDLE or operation=READ0 or operation=WRITE0 else '0';
234
 
235
        operation_machine:process(reset,clk)
236
        begin
237
                if reset='1'
238
                        then
239
                        operation<=INIT0;
240
                        active_address<=(others=>'1');
241
                elsif rising_edge(clk)
242
                        then
243 7 ntpqa
                        if CHIPSELECTS>1
244
                                then
245
                                chipselect<='0'&fifo_q((FIFO_WIDTH-1) downto CS_LOW_BIT);
246
                                bank<=fifo_q((CS_LOW_BIT-1) downto BANK_LOW_BIT);
247
                        else
248
                                chipselect<=(others=>'0');
249
                                bank<=fifo_q((FIFO_WIDTH-1) downto BANK_LOW_BIT);
250
                        end if;
251 2 ntpqa
 
252 7 ntpqa
                        row<=   fifo_q((BANK_LOW_BIT-1) downto ROW_LOW_BIT);
253
                        column<=fifo_q((ROW_LOW_BIT-1)  downto COL_LOW_BIT);
254
                        data<=  fifo_q((COL_LOW_BIT-1)  downto DATA_LOW_BIT);
255
                        be<=    fifo_q((DATA_LOW_BIT-1) downto BE_LOW_BIT);
256 2 ntpqa
 
257
                        case operation is
258
                                when INIT0=>
259
                                if do_init='1'
260
                                        then operation<=INIT1;row(10)<='1';
261
                                end if;
262
                                when INIT1=>operation<=INIT2;
263
                                when INIT2=>operation<=INIT3;
264
                                when INIT3=>operation<=INIT4;
265
                                when INIT4=>operation<=INIT5;
266
                                when INIT5=>operation<=INIT6;
267
                                when INIT6=>operation<=INIT7;
268
                                when INIT7=>operation<=INIT8;
269
                                when INIT8=>operation<=INIT9;
270
                                when INIT9=>operation<=INIT10;
271
                                when INIT10=>operation<=INIT11;
272
                                when INIT11=>operation<=INIT12;
273
                                when INIT12=>operation<=INIT13;
274
                                when INIT13=>operation<=INIT14;
275
                                when INIT14=>operation<=INIT15;
276
                                when INIT15=>operation<=INIT16;
277
                                when INIT16=>operation<=INIT17;
278
                                when INIT17=>operation<=INIT18;
279
                                when INIT18=>operation<=INIT19;
280
                                when INIT19=>operation<=INIT20;
281
                                when INIT20=>operation<=INIT21;
282
                                when INIT21=>operation<=INIT22;
283
                                when INIT22=>operation<=INIT23;
284 7 ntpqa
                                when INIT23=>operation<=INIT24;row<=std_logic_vector(to_unsigned(MODE_REGISTER,row'length));
285 2 ntpqa
                                when INIT24=>operation<=IDLE;
286
 
287
                                when REFRESH0=>operation<=REFRESH1;
288
                                when REFRESH1=>operation<=REFRESH2;
289
                                when REFRESH2=>operation<=REFRESH3;
290
                                when REFRESH3=>operation<=REFRESH4;
291
                                when REFRESH4=>operation<=REFRESH5;
292
                                when REFRESH5=>operation<=REFRESH6;
293
                                when REFRESH6=>operation<=REFRESH7;
294
                                when REFRESH7=>operation<=REFRESH8;
295
                                when REFRESH8=>operation<=REFRESH9;
296
                                when REFRESH9=>operation<=REFRESH10;
297
                                when REFRESH10=>operation<=REFRESH11;
298
                                when REFRESH11=>operation<=REFRESH12;
299
                                when REFRESH12=>operation<=REFRESH13;
300 7 ntpqa
                                active_address<=unsigned(fifo_q((fifo_q'length-1) downto ROW_LOW_BIT));
301 2 ntpqa
                                when REFRESH13=>operation<=REFRESH14;
302
                                when REFRESH14=>operation<=IDLE;
303
 
304
                                when ACTIVE0=>operation<=ACTIVE1;
305
                                when ACTIVE1=>operation<=ACTIVE2;
306
                                when ACTIVE2=>operation<=ACTIVE3;
307 7 ntpqa
                                active_address<=unsigned(fifo_q((fifo_q'length-1) downto ROW_LOW_BIT));
308 2 ntpqa
                                when ACTIVE3=>operation<=ACTIVE4;
309
                                when ACTIVE4=>operation<=IDLE;
310
 
311
                                when others=>
312
                                if do_refresh='1'
313
                                        then
314
                                        if tRCD_not_expired='0' and operation=IDLE
315
                                                then operation<=REFRESH0;row(10)<='1';
316
                                        else operation<=IDLE;
317
                                        end if;
318
                                elsif do_active='1'
319
                                        then
320
                                        if tRCD_not_expired='0' and operation=IDLE
321
                                                then operation<=ACTIVE0;row(10)<='1';
322
                                        else operation<=IDLE;
323
                                        end if;
324
                                elsif fifo_empty='1'
325
                                        then
326
                                        operation<=IDLE;
327
                                elsif fifo_q(1)='1' --write
328
                                        then
329
                                        if read_latency(CAS_LATENCY-1 downto 0)>"000"
330
                                                then operation<=IDLE;
331
                                        else operation<=WRITE0;
332
                                        end if;
333
                                elsif fifo_q(0)='1'      --read
334
                                        then
335
                                        operation<=READ0;
336
                                end if;
337
                        end case;
338
                end if;
339
        end process;
340
 
341
        control_latency:process(reset,clk)
342
        begin
343
                if reset='1'
344
                        then
345
                        read_latency<=(others=>'0');
346
                elsif rising_edge(clk)
347
                        then
348
                        read_latency<=std_logic_vector(unsigned(read_latency) SLL 1);
349
                        if operation=READ0
350
                                then read_latency(0)<='1';
351
                        else read_latency(0)<='0';
352
                        end if;
353
                end if;
354
        end process;
355
        latch_readdata:process(reset,clk)
356
        begin
357
                if reset='1'
358
                        then
359
                        avs_nios_readdata<=(others=>'0');
360
                        avs_nios_readdatavalid<='0';
361
                elsif rising_edge(clk)
362
                        then
363
                        avs_nios_readdata<=sdram_dq;
364
                        avs_nios_readdatavalid<=read_latency(CAS_LATENCY);
365
                end if;
366
        end process;
367
        initialization:process(reset,clk)
368
        begin
369
                if rising_edge(clk)
370
                        then
371
                        if init_counter>0
372
                                then
373
                                init_counter<=init_counter-1;
374
                        else do_init<='1';
375
                        end if;
376
                end if;
377
        end process;
378
        refreshing:process(clk,reset)
379
        begin
380
                if reset='1'
381
                        then
382
                        refresh_counter<=to_unsigned(REFRESH_PERIOD_CLOCKS,16);
383
                        do_refresh<='0';
384
                elsif rising_edge(clk)
385
                        then
386
                        if refresh_counter=to_unsigned(0,refresh_counter'length)
387
                                then refresh_counter<=to_unsigned(REFRESH_PERIOD_CLOCKS,16);
388
                                do_refresh<='1';
389
                        else refresh_counter<=refresh_counter-1;
390
                        end if;
391
                        if operation=REFRESH0 or operation=REFRESH5
392
                                then do_refresh<='0';
393
                        end if;
394
                end if;
395
        end process;
396
        active_period:process(reset,clk)
397
        begin
398
                if reset='1'
399
                        then
400
                        active_counter<=(others=>'0');
401
                        tRCD_not_expired<='0';
402
                elsif rising_edge(clk)
403
                        then
404
                        if operation=ACTIVE3 or operation=REFRESH13
405
                                then active_counter<=to_unsigned(5,active_counter'length);
406
                        elsif active_counter>0
407
                                then active_counter<=active_counter-1;
408
                        end if;
409
                end if;
410
                if active_counter>0
411
                        then tRCD_not_expired<='1';
412
                else tRCD_not_expired<='0';
413
                end if;
414
        end process;
415
        latch_controls:process(clk,reset)
416
        begin
417
                if reset='1'
418
                        then
419
                        i_command<=NOP;
420
                        i_address<=(others=>'0');
421
                        i_bank<=(others=>'0');
422
                        i_dqm<=(others=>'0');
423 7 ntpqa
                        i_data<=(others=>'Z');
424
                        i_chipselect<=(others=>'1');
425 2 ntpqa
                elsif rising_edge(clk)
426
                        then
427 7 ntpqa
                        i_command<=NOP;
428
                        i_chipselect<=DECODE(chipselect,i_chipselect'length);
429 2 ntpqa
                        i_bank<=bank;
430
                        i_address<=(others=>'0');
431
                        i_address((column'length-1) downto 0)<=column;
432
                        i_data<=(others=>'Z');
433
                        i_dqm<=(others=>'0');
434
 
435
                        case operation is
436
                                when INIT1|REFRESH0|ACTIVE0 =>
437
                                i_command<=PRECHARGE;
438 7 ntpqa
                                i_address<=row;
439
                                i_chipselect<=(others=>'0');
440 2 ntpqa
                                when INIT4|INIT14|REFRESH3 =>
441 7 ntpqa
                                i_command<=AUTO_REFRESH;
442
                                i_chipselect<=(others=>'0');
443 2 ntpqa
                                when INIT24=>
444
                                i_command<=LOAD_MODE_REGISTER;
445 7 ntpqa
                                i_address<=row;
446
                                i_chipselect<=(others=>'0');
447 2 ntpqa
                                when ACTIVE3|REFRESH13 =>
448
                                i_command<=ACTIVE;
449 7 ntpqa
                                i_address<=row;
450 2 ntpqa
                                when READ0 =>
451
                                i_command<=READ;
452
                                when WRITE0 =>
453
                                i_command<=WRITE;
454
                                i_dqm<=not be;
455
                                i_data<=data;
456
                                when OTHERS =>
457
                        end case;
458
                end if;
459
        end process;
460
 
461
        fifo: scfifo
462
        GENERIC MAP (
463
                add_ram_output_register => "ON",
464 7 ntpqa
                intended_device_family => "Auto",
465 2 ntpqa
                lpm_numwords => 4,
466
                lpm_showahead => "ON",
467
                lpm_type => "scfifo",
468
                lpm_width => FIFO_WIDTH,
469
                lpm_widthu => 2,
470
                overflow_checking => "ON",
471
                underflow_checking => "ON",
472
                use_eab => "ON"
473
                )
474
        PORT MAP (
475
                rdreq => fifo_rdreq,
476
                aclr => reset,
477
                clock => clk,
478
                wrreq => fifo_wrreq,
479
                data => fifo_data,
480
                empty => fifo_empty,
481
                q => fifo_q,
482
                full => fifo_wrfull
483
                );
484
end behaviour;

powered by: WebSVN 2.1.0

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