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/] [gaisler/] [ddr/] [ahb_slv.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
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
-- Entity:      ahb_slv
20
-- File:        ahb_slv.vhd
21
-- Author:      David Lindh - Gaisler Research
22
-- Description: AMBA AHB slave interface for DDR-RAM memory controller
23
------------------------------------------------------------------------------
24
 
25
 
26
library ieee;
27
use ieee.std_logic_1164.all;
28
library grlib;
29
use grlib.amba.all;
30
use grlib.stdlib.all;
31
library gaisler;
32
use grlib.devices.all;
33
use gaisler.memctrl.all;
34
library techmap;
35
use techmap.gencomp.all;
36
use techmap.allmem.all;
37
use gaisler.ddrrec.all;
38
 
39
entity ahb_slv is
40
  generic (
41
    hindex      :     integer := 0;
42
    haddr       :     integer := 0;
43
    hmask       :     integer := 16#f80#;
44
    sepclk      :     integer := 0;
45
    dqsize      :     integer := 64;
46
    dmsize      :     integer := 8;
47
    tech        :     integer := virtex2);
48
  port (
49
    rst      : in  std_ulogic;
50
    hclk     : in  std_ulogic;
51
    clk0     : in  std_ulogic;
52
    csi      : in  ahb_ctrl_in_type;
53
    cso      : out ahb_ctrl_out_type);
54
end ahb_slv;
55
 
56
architecture rtl of ahb_slv is
57
 
58
  -- Configuration for AMBA PlugNplay
59
  constant REVISION : integer         := 0;
60
  constant HCONFIG  : ahb_config_type := (
61
 
62
    4      => ahb_membar(haddr, '1', '1', hmask),
63
    others => zero32);
64
 
65
  type burst_mask_type is array (buffersize-1 downto 0) of integer range 1 to 8;
66
  type hsize_type is array (4 downto 0) of integer range 8 to 128;
67
  constant hsize_array : hsize_type := (128, 64, 32, 16, 8);
68
 
69
  signal ahbr       : ahb_reg_type;
70
  signal ahbri      : ahb_reg_type;
71
  signal csi_synced : ahb_ctrl_in_type;
72
  signal DSRAM_i    : syncram_dp_in_type;
73
  signal DSRAM_o    : syncram_dp_out_type;
74
  signal ASRAM_i    : syncram_2p_in_type;
75
  signal ASRAM_o    : syncram_2p_out_type;
76
  signal vcc        : std_ulogic;
77
 
78
begin  -- rtl 
79
 
80
  vcc <= '1';
81
 
82
 -------------------------------------------------------------------------------
83
   --AMBA AHB control combinatiorial part
84
 -------------------------------------------------------------------------------  
85
  ahbcomb : process(ahbr, rst, csi, csi_synced, DSRAM_o)
86
 
87
    variable v : ahb_reg_type;          -- local variables for registers
88
    variable next_rw_cmd_valid : std_logic_vector((log2(buffersize)-1) downto 0);
89
 
90
  begin
91
    v                 := ahbr;
92
    next_rw_cmd_valid := v.rw_cmd_valid +1;
93
    v.new_burst := '0';
94
    v.sync_write := '0';
95
    v.sync2_write := '0';
96
 
97
 -------------------------------------------------------------------------------
98
     -- Give respons on prevoius address cycle  (DATA CYCLE)
99
 -------------------------------------------------------------------------------        
100
 
101
    -- If read and read prediction in previos cycle. Both couldn't be
102
    -- written into address syncram (sync2)
103
    if ahbr.sync2_busy = '1' then
104
      v.sync2_adr   := v.pre_read_buffer;
105
      v.sync2_wdata := '0' & ahbr.pre_read_adr;
106
      v.sync2_write := '1';
107
      v.sync2_busy  := '0';
108
    end if;
109
 
110
 
111
 
112
 
113
 
114
     -- In case of a write followed by a read both will try to use sync_ram
115
     -- in same cycle, delays read.
116
    if ahbr.sync_busy = '1' then
117
      v.sync_adr    := ahbr.sync_busy_adr;
118
      v.doRead      := '1';
119
 
120
 
121
 
122
 
123
      -- Write data to address given in previous cycle
124
    elsif ahbr.doWrite = '1' then
125
      -- If first word set all datamasks
126
      if conv_std_logic_vector(v.writecounter,4)(0) = '0' then
127
        v.sync_wdata((2*(dmsize+dqsize))-1 downto 2*dqsize) :=  (others => '1');
128
      end if;
129
      -- Write data to syncram
130
      v.even_odd_write := (conv_integer(conv_std_logic_vector(v.writecounter,4)(0)));
131
      for i in 0 to dqsize-1 loop
132
        if i >= v.startp*8  and i < (v.startp+v.burst_hsize)*8  then
133
          v.sync_wdata(i + v.even_odd_write*dqsize) := csi.ahbsi.hwdata(i+(v.ahbstartp-v.startp)*8);
134
        end if;
135
      end loop;
136
      -- Clear masks for valid bytes
137
      for i in 0 to dmsize-1 loop
138
        if i >= v.startp and i < (v.startp+v.burst_hsize) then
139
          v.sync_wdata((2*dqsize)+v.even_odd_write*dmsize+i) := '0';
140
        end if;
141
      end loop;
142
      v.sync_adr    := v.use_write_buffer & conv_std_logic_vector(v.writecounter,4)(2 downto 1);
143
      v.sync_write  := '1';
144
      -- Increase mask counter
145
      v.burst_dm(conv_integer(v.use_write_buffer)) := v.writecounter+1;
146
      v.doWrite            := '0';
147
    end if;
148
 
149
 
150
 
151
 
152
 
153
 
154
-------------------------------------------------------------------------------
155
    -- Analyze incomming command on AHB   (ADDRESS CYCLE)
156
-------------------------------------------------------------------------------
157
    v.sync_busy   := '0';
158
 
159
    -- An error occured in previous address cycle
160
    if ahbr.prev_error = '1' then
161
      v.hresp := HRESP_ERROR;
162
      v.hready := '1';
163
      v.prev_retry := '0';
164
      v.prev_error := '0';
165
 
166
      -- A retry occured in previous address cycle
167
    elsif ahbr.prev_retry = '1' then
168
      v.hresp := HRESP_RETRY;
169
      v.hready := '1';
170
      v.prev_retry := '0';
171
      v.prev_error := '0';
172
 
173
      -- Slave selected and previous transfer complete
174
    elsif csi.ahbsi.hsel(hindex) = '1' and csi.ahbsi.hready = '1' then
175
      v.prev_retry := '0';
176
      v.prev_error := '0';
177
 
178
 
179
      -- Check if hsize is within range
180
      if hsize_array(conv_integer(csi.ahbsi.hsize)) > dqsize and csi.ahbsi.htrans(1) = '1' then
181
        assert false report "AHB HSIZE cannot be greater then DQ size" severity error;
182
        v.hresp := HRESP_ERROR;
183
        v.hready := '0';
184
        v.prev_error := '1';
185
 
186
 
187
        -- BUSY or IDLE command
188
      elsif csi.ahbsi.htrans(1) = '0' then
189
        v.hresp  := HRESP_OKAY;
190
        v.hready := '1';
191
 
192
        -- If idle, begin write burst (if waiting)
193
        if csi.ahbsi.htrans = HTRANS_IDLE then
194
          v.w_data_valid := v.rw_cmd_valid;
195
          v.pre_read_valid := '0';
196
        end if;
197
 
198
        -- SEQ or NONSEQ command
199
      else
200
        -- Calculate valid bits for transfer according to big endian
201
 
202
        case ahbdata is
203
          when 8 =>  v.ahboffset := "000";
204
          when 16 => v.ahboffset := "00" & csi.ahbsi.haddr(0);
205
          when 32 => v.ahboffset := "0" & csi.ahbsi.haddr(1 downto 0);
206
          when 64 => v.ahboffset := csi.ahbsi.haddr(2 downto 0);
207
          when others => null;
208
        end case;
209
 
210
 
211
        case dqsize is
212
          when 8  => v.rwadrbuffer  := csi.ahbsi.haddr;
213
                     v.offset       := "000";
214
          when 16 => v.rwadrbuffer  := "0" & csi.ahbsi.haddr(31 downto 1);
215
                     v.offset       := "00" & csi.ahbsi.haddr(0);
216
          when 32 => v.rwadrbuffer  := "00" & csi.ahbsi.haddr(31 downto 2);
217
                     v.offset       := "0" & csi.ahbsi.haddr(1 downto 0);
218
          when 64 => v.rwadrbuffer  := "000" & csi.ahbsi.haddr(31 downto 3);
219
                     v.offset       := csi.ahbsi.haddr(2 downto 0);
220
          when others => null;
221
        end case;
222
 
223
 
224
        case csi.ahbsi.hsize is
225
          when "000" => v.burst_hsize:= 1;
226
                        v.startp:= ((dqsize-8)/8) - conv_integer(v.offset);
227
                        v.ahbstartp := ((ahbdata-8)/8) - conv_integer(v.ahboffset);
228
          when "001" => v.burst_hsize:= 2; v.offset(0):= '0';
229
                        v.startp:= ((dqsize-16)/8) - conv_integer(v.offset);
230
                        v.ahbstartp:= ((ahbdata-16)/8) - conv_integer(v.ahboffset);
231
          when "010" => v.burst_hsize:= 4; v.offset(1 downto 0) := "00";
232
                        v.startp:= ((dqsize-32)/8) - conv_integer(v.offset);
233
                        v.ahbstartp:= ((ahbdata-32)/8) - conv_integer(v.ahboffset);
234
          when "011" => v.burst_hsize:= 8; v.offset(2 downto 0) := "000";
235
                        v.startp:= 0;
236
                        v.ahbstartp := 0;
237
          when others =>
238
            assert false report "Too large HSIZE" severity error;
239
            v.hresp := HRESP_ERROR;
240
            v.hready := '0';
241
            v.prev_error := '1';
242
        end case;
243
 
244
 
245
 
246
 
247
 
248
-------------------------------------------------------------------------------
249
 -- SEQUENCIAL, continuation of burst
250
 
251
 -- Read (seq)
252
      if (csi.ahbsi.hwrite = '0' and csi.ahbsi.htrans = HTRANS_SEQ and
253
          csi.ahbsi.hburst = HBURST_INCR and v.offset /= "000") then
254
        -- Do nothing, requested data is in the same ahb word as
255
        -- already is on ahb bus
256
 
257
      elsif (csi.ahbsi.hwrite = '0' and csi.ahbsi.htrans = HTRANS_SEQ and
258
             csi.ahbsi.hburst = HBURST_INCR)
259
      then
260
        -- Check that new command can be part of current burst
261
        if v.readcounter /= v.blockburstlength then
262
          -- Read from Syncram
263
          v.sync_write  := '0';
264
          v.doRead      := '1';
265
        else
266
          if csi_synced.locked = '0' then
267
            -- Check if a prediction was made that matches this new address
268
            if v.pre_read_valid = '1' then
269
              v.use_read_buffer := v.pre_read_buffer;
270
              v.readcounter := 0;
271
              v.blockburstlength := csi_synced.burstlength;
272
              -- Read from Syncram
273
              v.sync_write  := '0';
274
              v.doRead      := '1';
275
              v.pre_read_valid := '0';
276
 
277
              -- Make new read prediction if buffer not full
278
              if (v.pre_read_buffer+1) /= csi_synced.rw_cmd_done and csi_synced.r_predict = '1' then
279
                v.pre_read_adr     := v.rwadrbuffer + csi_synced.burstlength;
280
                v.pre_read_buffer  := v.pre_read_buffer +1;
281
                v.pre_read_valid   := '1';
282
                v.sync2_write      := '1';
283
                v.sync2_wdata      := '0' & v.pre_read_adr;
284
                v.sync2_adr        := v.pre_read_buffer;
285
                v.rw_cmd_valid     := v.pre_read_buffer;
286
                v.w_data_valid     := v.pre_read_buffer;
287
              end if;
288
 
289
              -- No prediction was made, treat as non sequencial
290
            else
291
              v.new_burst := '1';
292
            end if;
293
          else
294
            v.new_burst := '1';
295
          end if;
296
        end if;
297
 
298
 
299
 
300
 
301
  -- Write (seq) 
302
      elsif csi.ahbsi.hwrite = '1' and csi.ahbsi.htrans = HTRANS_SEQ then
303
        v.pre_read_valid := '0';
304
 
305
        -- Check that new command can be part of current burst
306
        if v.offset /= "000" then
307
          v.doWrite := '1';
308
          v.hresp              := HRESP_OKAY;
309
          v.hready             := '1';
310
        elsif v.writecounter+1 /= v.blockburstlength and csi_synced.locked = '0' then
311
          v.writecounter := v.writecounter +1;
312
          v.doWrite := '1';
313
          v.hresp              := HRESP_OKAY;
314
          v.hready             := '1';
315
          -- Command has to start new burst
316
        else
317
          v.w_data_valid := v.rw_cmd_valid;
318
          v.rw_cmd_valid := v.use_write_buffer;
319
          v.new_burst := '1';
320
        end if;
321
      end if;
322
 
323
 
324
 
325
 
326
-------------------------------------------------------------------------------            
327
-- NON SEQUENCIAL, start of new burst
328
      if (csi.ahbsi.htrans = HTRANS_NONSEQ or v.new_burst = '1') then
329
        v.pre_read_valid := '0';
330
 
331
        -- Determine how many words that is valid until DRRMEM
332
        -- will wrap within block
333
        case csi_synced.burstlength is
334
          when 2      => v.blockburstlength := csi_synced.burstlength - conv_integer(v.rwadrbuffer(0));
335
          when 4      => v.blockburstlength := csi_synced.burstlength - conv_integer(v.rwadrbuffer(1 downto 0));
336
          when 8      => v.blockburstlength := csi_synced.burstlength - conv_integer(v.rwadrbuffer(2 downto 0));
337
          when others => null;
338
        end case;
339
 
340
 
341
        -- Commandbuffer full or AHB interface locked
342
        if next_rw_cmd_valid = csi_synced.rw_cmd_done or csi_synced.locked = '1' then
343
          v.hresp := HRESP_RETRY;
344
          v.hready := '0';
345
          v.prev_retry := '1';
346
 
347
          -- Put new command into command buffer
348
        else
349
          v.sync2_adr     := next_rw_cmd_valid;
350
 
351
 
352
 
353
 
354
-------------------------------------------------------------------------------
355
-- Read (non-seq)
356
          if csi.ahbsi.hwrite = '0' then
357
            v.hready           := '0';
358
            v.readcounter      := 0;
359
            v.use_read_buffer  := next_rw_cmd_valid;
360
            v.rw_cmd_valid     := next_rw_cmd_valid;
361
            v.w_data_valid     := next_rw_cmd_valid;  -- keep in phase for read
362
            v.sync2_wdata      := '0' & v.rwadrbuffer;
363
            v.sync2_write      := '1';
364
 
365
            -- Wait one cycle (maybe write before)
366
            v.sync_busy_adr    :=  next_rw_cmd_valid & "00";
367
            v.sync_busy        := '1';
368
            v.doRead           := '0';
369
 
370
            -- Predict (if space in buffer and option choosen) next read
371
            next_rw_cmd_valid   := next_rw_cmd_valid +1;
372
            if next_rw_cmd_valid /= csi_synced.rw_cmd_done and csi_synced.r_predict = '1' then
373
              v.pre_read_buffer := next_rw_cmd_valid;
374
              v.pre_read_adr    :=  v.rwadrbuffer + v.blockburstlength;
375
              v.pre_read_valid  := '1';
376
              v.rw_cmd_valid    := next_rw_cmd_valid;
377
              v.w_data_valid    := next_rw_cmd_valid;  -- keep in phase
378
 
379
              -- Address cannot be saved due to syncram busy, write in
380
              -- next cycle
381
              v.sync2_busy      := '1';
382
 
383
            end if;
384
 
385
 
386
 
387
 
388
-------------------------------------------------------------------------------
389
-- Write (non-seq)
390
          elsif csi_synced.w_prot = '0' then
391
            v.pre_read_valid     := '0';
392
 
393
            v.w_data_valid       := v.rw_cmd_valid;
394
            v.rw_cmd_valid       := next_rw_cmd_valid;
395
            v.writecounter       := 0;
396
            v.use_write_buffer   := next_rw_cmd_valid;
397
            v.sync2_wdata        := '1' & v.rwadrbuffer;
398
            v.sync2_write        := '1';
399
            v.doWrite            := '1';
400
            v.hresp              := HRESP_OKAY;
401
            v.hready             := '1';
402
 
403
            -- Write protection error
404
          else
405
            assert false report "Write when write protection enabled" severity warning;
406
            v.hresp := HRESP_ERROR;
407
            v.hready := '0';
408
            v.prev_error := '1';
409
          end if;                 -- write
410
        end if;                   -- cmdbuffer not full
411
      end if;                     -- non seq transfer
412
    end if;                       -- seq or non seq
413
 
414
 
415
    -- Slave not selected
416
  else
417
    v.w_data_valid := v.rw_cmd_valid;
418
    v.hready := '1';
419
    v.hresp  := HRESP_OKAY;
420
  end if;
421
 
422
 
423
  -- Always set HRDATA (to improve timing)
424
  if conv_std_logic_vector(v.readcounter,4)(0) = '0' then -- Even word
425
    v.read_data((dqsize-1) downto 0) := DSRAM_o.dataout1((dqsize-1) downto 0);
426
  else -- Odd word
427
    v.read_data((dqsize-1) downto 0) := DSRAM_o.dataout1((2*dqsize)-1 downto dqsize);
428
  end if;
429
  --Read data from syncram    
430
  for i in 0 to ahbdata-1 loop
431
    if i >= v.ahbstartp*8  and i < (v.ahbstartp+v.burst_hsize)*8  then
432
      v.cur_hrdata(i) := v.read_data(i+(v.startp-v.ahbstartp)*8);
433
    end if;
434
  end loop;
435
 
436
 
437
 
438
 
439
  -- Calculate for next clk cycle
440
 
441
  -- If read cmd, dont try to read from syncram since maybe write before
442
  if v.sync_busy = '1' then
443
    v.cur_hready := '0';
444
    v.cur_hresp  := HRESP_OKAY;
445
  -- Read data is avalible
446
  elsif (csi_synced.rw_cmd_done = v.use_read_buffer or
447
         (csi_synced.rw_cmd_done = v.pre_read_buffer and
448
          v.pre_read_valid = '1')) and v.doRead = '1' then
449
    -- Set address for next read
450
    v.readcounter := v.readcounter +1;
451
     if v.readcounter = v.blockburstlength then
452
       v.sync_adr := (v.use_read_buffer+1) & "00";
453
     else
454
       v.sync_adr := v.use_read_buffer & conv_std_logic_vector(v.readcounter,3)(2 downto 1);
455
     end if;
456
    v.doRead := '0';
457
    v.cur_hready := '1';
458
    v.cur_hresp  := HRESP_OKAY;
459
  -- Waiting for read data
460
  elsif v.doRead = '1' then
461
    v.cur_hready := '0';
462
    v.cur_hresp  := HRESP_OKAY;
463
  else
464
    v.cur_hready := v.hready;
465
    v.cur_hresp  := v.hresp;
466
  end if;
467
 
468
-------------------------------------------------------------------------------
469
-- Reset
470
  if rst = '0' then
471
    v.readcounter     := 0;
472
    v.writecounter    := 0;
473
    v.blockburstlength:= 0;
474
    v.hready          := '1';
475
    v.hresp           := HRESP_OKAY;
476
    v.rwadrbuffer     := (others => '0');
477
    v.use_read_buffer := (others => '1');
478
    v.pre_read_buffer := (others => '1');
479
    v.pre_read_adr    := (others => '0');
480
    v.pre_read_valid  := '0';
481
    v.use_write_buffer:= (others => '1');
482
    v.rw_cmd_valid    := (others => '1');
483
    v.w_data_valid    := (others => '1');
484
 
485
    v.sync_adr        := (others => '0');
486
    v.sync_wdata      := (others => '0');
487
    v.sync_write      := '0';
488
    v.sync_busy       := '0';
489
    v.sync_busy_adr   := (others => '0');
490
    v.sync2_adr       := (others => '0');
491
    v.sync2_wdata     := (others => '0');
492
    v.sync2_write     := '0';
493
    v.sync2_busy      := '0';
494
 
495
    v.doRead          := '0';
496
    v.doWrite         := '0';
497
    v.new_burst       := '0';
498
    v.startp          := 0;
499
    v.ahbstartp       := 0;
500
    v.even_odd_write  := 0;
501
    v.burst_hsize     := 1;
502
    v.offset          := "000";
503
    v.ahboffset       := "000";
504
    v.read_data       := (others => '0');
505
    v.cur_hready      := '0';
506
    v.cur_hresp       := HRESP_OKAY;
507
    v.prev_retry      := '0';
508
    v.prev_error      := '0';
509
 
510
  end if;
511
-------------------------------------------------------------------------------
512
-- Set output signals
513
 
514
  ahbri <= v;
515
 
516
  cso.ahbso.hsplit <= (others => '0');
517
  cso.ahbso.hcache <= '1';
518
  cso.ahbso.hirq   <= (others => '0');
519
  cso.ahbso.hindex <= hindex;
520
 
521
 
522
  DSRAM_i.address1 <= v.sync_adr;
523
  DSRAM_i.datain1 <= v.sync_wdata;
524
  DSRAM_i.write1 <= v.sync_write;
525
 
526
  ASRAM_i.waddress <= v.sync2_adr;
527
  ASRAM_i.datain <= v.sync2_wdata;
528
  ASRAM_i.write <= v.sync2_write;
529
 
530
 
531
  end process;
532
-------------------------------------------------------------------------------
533
  -- Purely combinatorial (no process)
534
  cso.ahbso.hconfig <= HCONFIG;
535
 
536
  DSRAM_i.address2 <= csi.dsramsi.address2;
537
  DSRAM_i.datain2 <= csi.dsramsi.datain2;
538
  DSRAM_i.write2 <= csi.dsramsi.write2;
539
  ASRAM_i.raddress <= csi.asramsi.raddress;
540
 
541
  cso.asramso <= ASRAM_o;
542
  cso.dsramso <= DSRAM_o;
543
 
544
-------------------------------------------------------------------------------
545
-- AMBA AHB control clocked register
546
  ahbclk : process(hclk)
547
  begin
548
 
549
    if rising_edge(hclk) then
550
      ahbr          <= ahbri;
551
 
552
      -- Registred outputs
553
      cso.rw_cmd_valid <= ahbri.rw_cmd_valid;
554
      cso.w_data_valid <= ahbri.w_data_valid;
555
      cso.burst_dm     <= ahbri.burst_dm;
556
 
557
      cso.ahbso.hrdata <= ahbri.cur_hrdata;
558
      cso.ahbso.hresp   <= ahbri.cur_hresp;
559
      cso.ahbso.hready  <= ahbri.cur_hready;
560
 
561
    end if;
562
  end process;
563
 
564
 
565
-- Register for incoming signals if separete clock domains
566
  sept :  if sepclk = 1 generate
567
    sepp : process(hclk)
568
    begin
569
      if rising_edge(hclk) then
570
        csi_synced.burstlength            <= csi.burstlength;
571
        csi_synced.r_predict              <= csi.r_predict;
572
        csi_synced.w_prot                 <= csi.w_prot;
573
        csi_synced.locked                 <= csi.locked;
574
        csi_synced.rw_cmd_done            <= csi.rw_cmd_done;
575
      end if;
576
    end process;
577
  end generate;
578
  sepf :  if sepclk = 0 generate
579
    csi_synced.burstlength            <= csi.burstlength;
580
    csi_synced.r_predict              <= csi.r_predict;
581
    csi_synced.w_prot                 <= csi.w_prot;
582
    csi_synced.locked                 <= csi.locked;
583
    -- This sync below required since the current used syncram cannot write
584
    -- and read from the same location in the same cycle
585
    sepp : process(hclk)
586
     begin
587
       if rising_edge(hclk) then
588
        csi_synced.rw_cmd_done            <= csi.rw_cmd_done;
589
       end if;
590
     end process;
591
  end generate;
592
-------------------------------------------------------------------------------
593
-- SyncRAM
594
 
595
-- Data syncram
596
  S0: syncram_dp
597
    generic map(
598
      tech      => tech,
599
      abits     => bufferadr,
600
      dbits     => 2*(dqsize+dmsize))
601
    port map(
602
      clk1      => hclk,
603
      address1  => DSRAM_i.address1,
604
      datain1   => DSRAM_i.datain1(2*(dqsize+dmsize)-1 downto 0),
605
      dataout1  => DSRAM_o.dataout1(2*(dqsize+dmsize)-1 downto 0),
606
      enable1   => vcc,
607
      write1    => DSRAM_i.write1,
608
      clk2      => clk0,
609
      address2  => DSRAM_i.address2,
610
      datain2   => DSRAM_i.datain2(2*(dqsize+dmsize)-1 downto 0),
611
      dataout2  => DSRAM_o.dataout2(2*(dqsize+dmsize)-1 downto 0),
612
      enable2   => vcc,
613
      write2    => DSRAM_i.write2);
614
 
615
-- Address syncram
616
  S1: syncram_2p
617
    generic map(
618
      tech      => tech*0,
619
      abits     => log2(buffersize),
620
      dbits     => ahbadr+1,
621
      sepclk    => sepclk,
622
      wrfst     => syncram_2p_write_through(tech))
623
    port map(
624
      rclk      => clk0,
625
      renable   => vcc,
626
      raddress  => ASRAM_i.raddress,
627
      dataout   => ASRAM_o.dataout,
628
      wclk      => hclk,
629
      write     => ASRAM_i.write,
630
      waddress  => ASRAM_i.waddress,
631
      datain    => ASRAM_i.datain);
632
 
633
 
634
 
635
 
636
 
637
 
638
 
639
-- End of AHB controller
640
-------------------------------------------------------------------------------
641
end rtl;

powered by: WebSVN 2.1.0

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