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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.5/] [rtl/] [bplib/] [nexys2/] [n2_cram_memctl_as.vhd] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 wfjm
-- $Id: n2_cram_memctl_as.vhd 314 2010-07-09 17:38:41Z mueller $
2
--
3
-- Copyright 2010- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4
--
5
-- This program is free software; you may redistribute and/or modify it under
6
-- the terms of the GNU General Public License as published by the Free
7
-- Software Foundation, either version 2, or at your option any later version.
8
--
9
-- This program is distributed in the hope that it will be useful, but
10
-- WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
-- for complete details.
13
-- 
14
------------------------------------------------------------------------------
15
-- Module Name:    n2_cram_memctl_as - syn
16
-- Description:    nexys2: CRAM driver - async and page mode
17
--
18
-- Dependencies:   vlib/xlib/iob_reg_o
19
--                 vlib/xlib/iob_reg_o_gen
20
--                 vlib/xlib/iob_reg_io_gen
21
-- Test bench:     tb/tb_n2_cram_memctl
22
--                 fw_gen/tst_sram/nexys2/tb/tb_tst_sram_n2
23
-- Target Devices: generic
24
-- Tool versions:  xst 11.4; ghdl 0.26
25
--
26
-- Synthesized (xst):
27
-- Date         Rev  ise         Target      flop lutl lutm slic t peri
28
-- 2010-06-03   299  11.4   L68  xc3s1200e-4   91  100    0   96 s  6.7
29
-- 2010-05-24   294  11.4   L68  xc3s1200e-4   91   99    0   95 s  6.7
30
-- 2010-05-23   293  11.4   L68  xc3s1200e-4   91  139    0   99 s  6.7
31
--
32
-- Revision History: 
33
-- Date         Rev Version  Comment
34
-- 2010-06-03   299   1.0.3  add "KEEP" for data iob; MEM_OE='1' on first read
35
--                           cycle;
36
-- 2010-05-30   297   1.0.2  use READ(0|1)DELAY generic
37
-- 2010-05-24   294   1.0.1  more compact n.memdi logic; extra wait in s_rdwait1
38
-- 2010-05-23   293   1.0    Initial version 
39
--
40
-- Notes:
41
--  1. READ1DELAY of 2 is needed even though the timing of the memory suggests
42
--     that 1 cycle is enough (T_apa is 20 ns, so 40 ns round trip is ok). A
43
--     short READ1 delay works in sim, but not on fpga where the data od the
44
--     ADDR(0)=0 cycle is re-read (see notes_tst_sram_n2.txt).
45
--     tb_n2_cram_memctl_as_ISim_tsim works with full sdf even when T_apa is
46
--     40ns or 50 ns, only T_apa 60 ns fails !
47
--     Unclear what is wrong here, the timing of the memory model seems ok.
48
--  2. There is no 'bus-turn-around' cycle needed for a write->read change
49
--     FPGA_OE goes 1->0 and MEM_OE goes 0->1 on the s_wrput1->s_rdinit
50
--     transition simultaneously. The FPGA will go high-Z quickly, the memory
51
--     low-Z delay by the IOB and internal memory delays. No clash.
52
--  3. There is a hidden 'bus-turn-around' cycle for a read->write change.
53
--     MEM_OE goes 1->0 on s_rdget1->s_wrinit and the memory will go high-z with
54
--     some dekal. FPGA_OE goes 0->1 in the next cycle at s_wrinit->s_wrwait0.
55
--     Again no clash due to the 1 cycle delay.
56
--
57
-- Timing of some signals:
58
--
59
-- single read request:
60
--
61
-- state      |_idle  |_rdinit|_rdwt0 |_rdwt0 |_rdget0|_rdwt1 |_rdget1|
62
--                      0      20      40      60      80      100     120
63
-- CLK      __|^^^|___|^^^|___|^^^|___|^^^|___|^^^|___|^^^|___|^^^|___|^^^|___|
64
-- 
65
-- REQ      _______|^^^^^|_____________________________________________
66
-- WE       ___________________________________________________________
67
-- 
68
-- IOB_CE   __________|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^|_
69
-- IOB_OE    _________|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^|_
70
-- 
71
-- DO       oooooooooooooooooooooooooooooooooooooooooo|lllllll|lllllll|h
72
-- BUSY     __________|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^|________________
73
-- ACK_R   ___________________________________________________________|^^^^^^^|_
74
-- 
75
-- single write request:
76
-- 
77
-- state       |_idle  |_wrinit|_wrwt0 |_wrwt0 |_wrwt0 |_wrput0|_idle  |
78
--                       0      20      40      60      80      100     120
79
-- CLK       __|^^^|___|^^^|___|^^^|___|^^^|___|^^^|___|^^^|___|^^^|___|^^^|___|
80
-- 
81
-- REQ       _______|^^^^^|______________________________________
82
-- WE        _______|^^^^^|______________________________________
83
-- 
84
-- IOB_CE    __________|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^|_
85
-- IOB_BE    __________|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^|_
86
-- IOB_OE    ____________________________________________________
87
-- IOB_WE    ______________|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^|_____
88
-- 
89
-- BUSY      __________|^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^|_________
90
-- ACK_W     __________________________________________|^^^^^^^|_
91
-- 
92
------------------------------------------------------------------------------
93
 
94
library ieee;
95
use ieee.std_logic_1164.all;
96
use ieee.std_logic_arith.all;
97
 
98
use work.slvtypes.all;
99
use work.xlib.all;
100
 
101
entity n2_cram_memctl_as is             -- CRAM driver (async+page mode)
102
  generic (
103
    READ0DELAY : positive := 2;         -- read word 0 delay in clock cycles
104
    READ1DELAY : positive := 2;         -- read word 1 delay in clock cycles
105
    WRITEDELAY : positive := 3);        -- write delay in clock cycles
106
  port (
107
    CLK : in slbit;                     -- clock
108
    RESET : in slbit;                   -- reset
109
    REQ   : in slbit;                   -- request
110
    WE    : in slbit;                   -- write enable
111
    BUSY : out slbit;                   -- controller busy
112
    ACK_R : out slbit;                  -- acknowledge read
113
    ACK_W : out slbit;                  -- acknowledge write
114
    ACT_R : out slbit;                  -- signal active read
115
    ACT_W : out slbit;                  -- signal active write
116
    ADDR : in slv22;                    -- address  (32 bit word address)
117
    BE : in slv4;                       -- byte enable
118
    DI : in slv32;                      -- data in  (memory view)
119
    DO : out slv32;                     -- data out (memory view)
120
    O_MEM_CE_N : out slbit;             -- cram: chip enable   (act.low)
121
    O_MEM_BE_N : out slv2;              -- cram: byte enables  (act.low)
122
    O_MEM_WE_N : out slbit;             -- cram: write enable  (act.low)
123
    O_MEM_OE_N : out slbit;             -- cram: output enable (act.low)
124
    O_MEM_ADV_N : out slbit;            -- cram: address valid (act.low)
125
    O_MEM_CLK : out slbit;              -- cram: clock
126
    O_MEM_CRE : out slbit;              -- cram: command register enable
127
    I_MEM_WAIT : in slbit;              -- cram: mem wait
128
    O_FLA_CE_N : out slbit;             -- flash ce..          (act.low)
129
    O_MEM_ADDR  : out slv23;            -- cram: address lines
130
    IO_MEM_DATA : inout slv16           -- cram: data lines
131
  );
132
end n2_cram_memctl_as;
133
 
134
 
135
architecture syn of n2_cram_memctl_as is
136
 
137
  type state_type is (
138
    s_idle,                             -- s_idle: wait for req
139
    s_rdinit,                           -- s_rdinit:  read init cycle
140
    s_rdwait0,                          -- s_rdwait0: read wait low word
141
    s_rdget0,                           -- s_rdget0:  read get low word
142
    s_rdwait1,                          -- s_rdwait1: read wait high word
143
    s_rdget1,                           -- s_rdget1:  read get high word
144
    s_wrinit,                           -- s_wrinit:  write init cycle
145
    s_wrwait0,                          -- s_rdwait0: write wait 1st word
146
    s_wrput0,                           -- s_rdput0:  write put 1st word
147
    s_wrini1,                           -- s_wrini1:  write init 2nd word
148
    s_wrwait1,                          -- s_wrwait1: write wait 2nd word
149
    s_wrput1                            -- s_wrput1:  write put 2nd word
150
  );
151
 
152
  type regs_type is record
153
    state : state_type;                 -- state
154
    ackr : slbit;                       -- signal ack_r
155
    addr0 : slbit;                      -- current addr0
156
    be2nd : slv2;                       -- be's of 2nd write cycle
157
    cntdly : slv2;                      -- wait delay counter
158
    cntce : slv7;                       -- ce counter
159
    fidle : slbit;                      -- force idle flag
160
    memdo0 : slv16;                     -- mem data out, low word
161
    memdi : slv32;                      -- mem data in
162
  end record regs_type;
163
 
164
  constant regs_init : regs_type := (
165
    s_idle,                             --
166
    '0',                                -- ackr
167
    '0',                                -- addr0
168
    "00",                               -- be2nd
169
    (others=>'0'),                      -- cntdly
170
    (others=>'0'),                      -- cntce
171
    '0',                                -- fidle
172
    (others=>'0'),                      -- memdo0
173
    (others=>'0')                       -- memdi
174
  );
175
 
176
  signal R_REGS : regs_type := regs_init;  -- state registers
177
  signal N_REGS : regs_type := regs_init;  -- next value state regs
178
 
179
  signal CLK_180  : slbit := '0';
180
  signal MEM_CE_N : slbit := '1';
181
  signal MEM_BE_N : slv2  := "11";
182
  signal MEM_WE_N : slbit := '1';
183
  signal MEM_OE_N : slbit := '1';
184
  signal BE_CE    : slbit := '0';
185
  signal ADDRH_CE : slbit := '0';
186
  signal ADDR0_CE : slbit := '0';
187
  signal ADDR0    : slbit := '0';
188
  signal DATA_CEI : slbit := '0';
189
  signal DATA_CEO : slbit := '0';
190
  signal DATA_OE  : slbit := '0';
191
  signal MEM_DO   : slv16 := (others=>'0');
192
  signal MEM_DI   : slv16 := (others=>'0');
193
 
194
-- these attributes aren't accepted by ghdl 0.26
195
--  attribute s : string;
196
--  attribute s of I_MEM_WAIT : signal is "true";
197
 
198
begin
199
 
200
  CLK_180 <= not CLK;
201
 
202
  IOB_MEM_CE : iob_reg_o
203
    generic map (
204
      INIT   => '1')
205
    port map (
206
      CLK => CLK,
207
      CE  => '1',
208
      DO  => MEM_CE_N,
209
      PAD => O_MEM_CE_N
210
    );
211
 
212
  IOB_MEM_BE : iob_reg_o_gen
213
    generic map (
214
      DWIDTH => 2,
215
      INIT   => '1')
216
    port map (
217
      CLK => CLK,
218
      CE  => BE_CE,
219
      DO  => MEM_BE_N,
220
      PAD => O_MEM_BE_N
221
    );
222
 
223
  IOB_MEM_WE : iob_reg_o
224
    generic map (
225
      INIT   => '1')
226
    port map (
227
      CLK => CLK_180,
228
      CE  => '1',
229
      DO  => MEM_WE_N,
230
      PAD => O_MEM_WE_N
231
    );
232
 
233
  IOB_MEM_OE : iob_reg_o
234
    generic map (
235
      INIT   => '1')
236
    port map (
237
      CLK => CLK,
238
      CE  => '1',
239
      DO  => MEM_OE_N,
240
      PAD => O_MEM_OE_N
241
    );
242
 
243
  IOB_MEM_ADDRH : iob_reg_o_gen
244
    generic map (
245
      DWIDTH => 22)
246
    port map (
247
      CLK => CLK,
248
      CE  => ADDRH_CE,
249
      DO  => ADDR,
250
      PAD => O_MEM_ADDR(22 downto 1)
251
    );
252
 
253
  IOB_MEM_ADDR0 : iob_reg_o
254
    port map (
255
      CLK => CLK,
256
      CE  => ADDR0_CE,
257
      DO  => ADDR0,
258
      PAD => O_MEM_ADDR(0)
259
    );
260
 
261
  IOB_MEM_DATA : iob_reg_io_gen
262
    generic map (
263
      DWIDTH => 16,
264
      PULL   => "KEEP")
265
    port map (
266
      CLK => CLK,
267
      CEI => DATA_CEI,
268
      CEO => DATA_CEO,
269
      OE  => DATA_OE,
270
      DI  => MEM_DO,
271
      DO  => MEM_DI,
272
      PAD => IO_MEM_DATA
273
    );
274
 
275
  O_MEM_ADV_N <= '0';
276
  O_MEM_CLK   <= '0';
277
  O_MEM_CRE   <= '0';
278
  O_FLA_CE_N  <= '1';
279
 
280
  proc_regs: process (CLK)
281
  begin
282
 
283
    if CLK'event and CLK='1' then
284
      if RESET = '1' then
285
        R_REGS <= regs_init;
286
      else
287
        R_REGS <= N_REGS;
288
      end if;
289
    end if;
290
 
291
  end process proc_regs;
292
 
293
  proc_next: process (R_REGS, REQ, WE, BE, DI, MEM_DO)
294
 
295
    variable r : regs_type := regs_init;
296
    variable n : regs_type := regs_init;
297
    variable ibusy : slbit := '0';
298
    variable iackw : slbit := '0';
299
    variable iactr : slbit := '0';
300
    variable iactw : slbit := '0';
301
    variable imem_ce : slbit := '0';
302
    variable imem_be : slv2  := "00";
303
    variable imem_we : slbit := '0';
304
    variable imem_oe : slbit := '0';
305
    variable ibe_ce    : slbit := '0';
306
    variable iaddrh_ce : slbit := '0';
307
    variable iaddr0_ce : slbit := '0';
308
    variable iaddr0    : slbit := '0';
309
    variable idata_cei : slbit := '0';
310
    variable idata_ceo : slbit := '0';
311
    variable idata_oe  : slbit := '0';
312
 
313
    procedure do_dispatch(nstate  : out state_type;
314
                          iaddrh_ce : out slbit;
315
                          iaddr0_ce : out slbit;
316
                          iaddr0  : out slbit;
317
                          ibe_ce  : out slbit;
318
                          imem_be : out slv2;
319
                          imem_ce : out slbit;
320
                          imem_oe : out slbit;
321
                          nbe2nd  : out slv2) is
322
    begin
323
      iaddrh_ce := '1';                 -- latch address (high part)
324
      iaddr0_ce := '1';                 -- latch address 0 bit
325
      ibe_ce    := '1';                 -- latch be's
326
      imem_ce   := '1';                 -- ce CRAM next cycle
327
      nbe2nd    := "00";                -- assume no 2nd write cycle
328
      if WE = '0' then                  -- if READ requested
329
        iaddr0  := '0';                   -- go first for low word
330
        imem_be := "11";                  -- on read always on
331
        imem_oe := '1';                   -- oe CRAM next cycle
332
        nstate  := s_rdinit;              -- next: read init part
333
      else                              -- if WRITE requested
334
        if BE(1 downto 0) /= "00" then    -- low word write
335
          iaddr0  := '0';                   -- access word 0 
336
          imem_be := BE(1 downto 0);        -- set be's for 1st cycle
337
          nbe2nd  := BE(3 downto 2);        -- keep be's for 2nd cycle
338
        else                              -- high word write
339
          iaddr0  := '1';                   -- access word 1 
340
          imem_be := BE(3 downto 2);        -- set be's for 1st cycle
341
        end if;
342
        nstate := s_wrinit;               -- next: write init part
343
      end if;
344
    end procedure do_dispatch;
345
 
346
  begin
347
 
348
    r := R_REGS;
349
    n := R_REGS;
350
    n.ackr := '0';
351
 
352
    ibusy := '0';
353
    iackw := '0';
354
    iactr := '0';
355
    iactw := '0';
356
 
357
    imem_ce := '0';
358
    imem_be := "11";
359
    imem_we := '0';
360
    imem_oe := '0';
361
    ibe_ce    := '0';
362
    iaddrh_ce := '0';
363
    iaddr0_ce := '0';
364
    iaddr0    := '0';
365
    idata_cei := '0';
366
    idata_ceo := '0';
367
    idata_oe  := '0';
368
 
369
    if unsigned(r.cntdly) /= 0 then
370
      n.cntdly := unsigned(r.cntdly) - 1;
371
    end if;
372
 
373
    case r.state is
374
      when s_idle =>                    -- s_idle: wait for req
375
        if REQ = '1' then                 -- if IO requested
376
          do_dispatch(n.state, iaddrh_ce, iaddr0_ce, iaddr0,
377
                               ibe_ce, imem_be, imem_ce, imem_oe, n.be2nd);
378
        end if;
379
 
380
      when s_rdinit =>                  -- s_rdinit:  read init cycle
381
        ibusy   := '1';                   -- signal busy, unable to handle req
382
        iactr   := '1';                   -- signal mem read
383
        imem_ce := '1';                   -- ce CRAM next cycle
384
        imem_oe := '1';                   -- oe CRAM next cycle
385
        n.cntdly:= conv_std_logic_vector(READ0DELAY-1, n.cntdly'length);
386
        n.state := s_rdwait0;             -- next: wait
387
 
388
      when s_rdwait0 =>                  -- s_rdwait0: read wait low word
389
        ibusy   := '1';                   -- signal busy, unable to handle req
390
        iactr   := '1';                   -- signal mem read
391
        imem_ce := '1';                   -- ce CRAM next cycle
392
        imem_oe := '1';                   -- oe CRAM next cycle
393
        if unsigned(r.cntdly) = 0 then    -- wait expired ?
394
          n.state := s_rdget0;              -- next: get low word
395
        end if;
396
 
397
      when s_rdget0 =>                  -- s_rdget0: read get low word
398
        ibusy   := '1';                   -- signal busy, unable to handle req
399
        iactr   := '1';                   -- signal mem read
400
        imem_ce := '1';                   -- ce CRAM next cycle
401
        imem_oe := '1';                   -- oe CRAM next cycle
402
        idata_cei := '1';                 -- latch input data
403
        iaddr0_ce := '1';                 -- latch address 0 bit
404
        iaddr0    := '1';                 -- now go for high word
405
        n.cntdly:= conv_std_logic_vector(READ1DELAY-1, n.cntdly'length);
406
        n.state := s_rdwait1;             -- next: wait high word
407
 
408
      when s_rdwait1 =>                 -- s_rdwait1: read wait high word
409
        ibusy   := '1';                   -- signal busy, unable to handle req
410
        iactr   := '1';                   -- signal mem read
411
        imem_ce := '1';                   -- ce CRAM next cycle
412
        imem_oe := '1';                   -- oe CRAM next cycle
413
        if unsigned(r.cntdly) = 0 then    -- wait expired ?
414
          n.state := s_rdget1;              -- next: get low word
415
        end if;                             --
416
 
417
      when s_rdget1 =>                  -- s_rdget1: read get high word
418
        iactr   := '1';                   -- signal mem read
419
        n.memdo0:= MEM_DO;                -- save low word data
420
        idata_cei := '1';                 -- latch input data
421
        n.ackr  := '1';                   -- ACK_R next cycle
422
        n.state := s_idle;                -- next: wait next request
423
        if r.fidle = '1' then             -- forced idle cycle
424
          ibusy   := '1';                   -- signal busy, unable to handle req
425
        else
426
          if REQ = '1' then                 -- if IO requested            
427
            do_dispatch(n.state, iaddrh_ce, iaddr0_ce, iaddr0,
428
                                 ibe_ce, imem_be, imem_ce, imem_oe, n.be2nd);
429
          end if;
430
        end if;
431
 
432
      when s_wrinit =>                  -- s_wrinit:  write init cycle
433
        ibusy := '1';                     -- signal busy, unable to handle req
434
        iactw := '1';                     -- signal mem write
435
        iackw := '1';                     -- signal write done (all latched)
436
        idata_ceo:= '1';                  -- latch output data
437
        idata_oe := '1';                  -- oe FPGA next cycle
438
        imem_ce  := '1';                  -- ce CRAM next cycle
439
        imem_we  := '1';                  -- we CRAM in half cycle
440
        n.cntdly:= conv_std_logic_vector(WRITEDELAY-1, n.cntdly'length);
441
        n.state := s_wrwait0;             -- next: wait
442
 
443
      when s_wrwait0 =>                 -- s_rdput0:  write wait 1st word
444
        ibusy := '1';                     -- signal busy, unable to handle req
445
        iactw := '1';                     -- signal mem write
446
        idata_oe := '1';                  -- oe FPGA next cycle
447
        imem_ce  := '1';                  -- ce CRAM next cycle
448
        imem_we  := '1';                  -- we CRAM next cycle
449
        if unsigned(r.cntdly) = 0 then    -- wait expired ?
450
          n.state := s_wrput0;            -- next: put 1st word
451
        end if;
452
 
453
      when s_wrput0 =>                  -- s_rdput0:  write put 1st word
454
        iactw := '1';                     -- signal mem write
455
        imem_we  := '0';                  -- deassert we CRAM in half cycle
456
        if r.be2nd /= "00" then
457
          ibusy := '1';                     -- signal busy, unable to handle req
458
          imem_ce  := '1';                  -- ce CRAM next cycle
459
          iaddr0_ce := '1';                 -- latch address 0 bit
460
          iaddr0    := '1';                 -- now go for high word
461
          ibe_ce    := '1';                 -- latch be's
462
          imem_be   := r.be2nd;             -- now be's of high word
463
          n.state := s_wrini1;              -- next: start 2nd write
464
        else
465
          n.state := s_idle;                -- next: wait next request
466
          if r.fidle = '1' then             -- forced idle cycle
467
            ibusy   := '1';                   -- signal busy
468
          else
469
            if REQ = '1' then                 -- if IO requested            
470
              do_dispatch(n.state, iaddrh_ce, iaddr0_ce, iaddr0,
471
                                   ibe_ce, imem_be, imem_ce, imem_oe, n.be2nd);
472
            end if;
473
          end if;
474
        end if;
475
 
476
      when s_wrini1 =>                  -- s_wrini1:  write init 2nd word
477
        ibusy := '1';                     -- signal busy, unable to handle req
478
        iactw := '1';                     -- signal mem write
479
        idata_ceo:= '1';                  -- latch output data
480
        idata_oe := '1';                  -- oe FPGA next cycle
481
        imem_ce  := '1';                  -- ce CRAM next cycle
482
        imem_we  := '1';                  -- we CRAM in half cycle
483
        n.cntdly:= conv_std_logic_vector(WRITEDELAY-1, n.cntdly'length);
484
        n.state := s_wrwait1;             -- next: wait
485
 
486
      when s_wrwait1 =>                 -- s_wrwait1: write wait 2nd word
487
        ibusy := '1';                     -- signal busy, unable to handle req
488
        iactw := '1';                     -- signal mem write
489
        idata_oe := '1';                  -- oe FPGA next cycle
490
        imem_ce  := '1';                  -- ce CRAM next cycle
491
        imem_we  := '1';                  -- we CRAM next cycle
492
        if unsigned(r.cntdly) = 0 then    -- wait expired ?
493
          n.state := s_wrput1;            -- next: put 2nd word
494
        end if;
495
 
496
      when s_wrput1 =>                  -- s_wrput1:  write put 2nd word
497
        iactw := '1';                     -- signal mem write
498
        imem_we  := '0';                  -- deassert we CRAM in half cycle
499
        n.state := s_idle;                -- next: wait next request
500
        if r.fidle = '1' then             -- forced idle cycle
501
          ibusy   := '1';                   -- signal busy, unable to handle req
502
        else
503
          if REQ = '1' then                 -- if IO requested            
504
            do_dispatch(n.state, iaddrh_ce, iaddr0_ce, iaddr0,
505
                                 ibe_ce, imem_be, imem_ce, imem_oe, n.be2nd);
506
          end if;
507
        end if;
508
 
509
      when others => null;
510
    end case;
511
 
512
    if imem_ce = '0' then               -- if cmem not active
513
      n.cntce := (others=>'0');           -- clear counter 
514
      n.fidle := '0';                     -- clear force idle flag
515
    else                                -- if cmem active
516
      if unsigned(r.cntce) >= 127 then    -- if max ce count expired
517
        n.fidle := '1';                     -- set forced idle flag
518
      else                                -- if max ce count not yet reached
519
        n.cntce := unsigned(r.cntce) + 1;   -- increment counter
520
      end if;
521
    end if;
522
 
523
    if iaddrh_ce = '1' then             -- if addresses are latched
524
      n.memdi := DI;                      -- latch data too...
525
    end if;
526
 
527
    if iaddr0_ce = '1' then             -- if address bit 0 changed
528
      n.addr0 := iaddr0;                  -- mirror it in state regs
529
    end if;
530
 
531
    N_REGS <= n;
532
 
533
    MEM_CE_N <= not imem_ce;
534
    MEM_WE_N <= not imem_we;
535
    MEM_BE_N <= not imem_be;
536
    MEM_OE_N <= not imem_oe;
537
 
538
    if r.addr0 = '0' then
539
      MEM_DI <= r.memdi(15 downto 0);
540
    else
541
      MEM_DI <= r.memdi(31 downto 16);
542
    end if;
543
 
544
    BE_CE    <= ibe_ce;
545
    ADDRH_CE <= iaddrh_ce;
546
    ADDR0_CE <= iaddr0_ce;
547
    ADDR0    <= iaddr0;
548
    DATA_CEI <= idata_cei;
549
    DATA_CEO <= idata_ceo;
550
    DATA_OE  <= idata_oe;
551
 
552
    BUSY  <= ibusy;
553
    ACK_R <= r.ackr;
554
    ACK_W <= iackw;
555
    ACT_R <= iactr;
556
    ACT_W <= iactw;
557
 
558
    DO    <= MEM_DO & r.memdo0;
559
 
560
  end process proc_next;
561
 
562
end syn;

powered by: WebSVN 2.1.0

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