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/] [techmap/] [axcelerator/] [memory_axcelerator.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:      various
20
-- File:        mem_axcelerator_gen.vhd
21
-- Author:      Jiri Gaisler Gaisler Research
22
-- Description: Memory generators for Actel AX rams
23
------------------------------------------------------------------------------
24
 
25
library ieee;
26
use ieee.std_logic_1164.all;
27
-- pragma translate_off
28
library axcelerator;
29
use axcelerator.RAM64K36;
30
-- pragma translate_on
31
 
32
entity axcel_ssram is
33
  generic (abits : integer := 16; dbits : integer := 36);
34
  port (
35
    wa, ra       : in  std_logic_vector(15 downto 0);
36
    wclk, rclk   : in  std_ulogic;
37
    di           : in  std_logic_vector(dbits -1 downto 0);
38
    do           : out std_logic_vector(dbits -1 downto 0);
39
    width        : in  std_logic_vector(2 downto 0);
40
    ren, wen     : in  std_ulogic
41
   );
42
end;
43
 
44
architecture rtl of axcel_ssram is
45
 component RAM64K36
46
    port(
47
    WRAD0, WRAD1, WRAD2, WRAD3, WRAD4, WRAD5, WRAD6, WRAD7, WRAD8, WRAD9, WRAD10,
48
    WRAD11, WRAD12, WRAD13, WRAD14, WRAD15, WD0, WD1, WD2, WD3, WD4, WD5, WD6,
49
    WD7, WD8, WD9, WD10, WD11, WD12, WD13, WD14, WD15, WD16, WD17, WD18, WD19,
50
    WD20, WD21, WD22, WD23, WD24, WD25, WD26, WD27, WD28, WD29, WD30, WD31, WD32,
51
    WD33, WD34, WD35, WEN, DEPTH0, DEPTH1, DEPTH2, DEPTH3, WW0, WW1, WW2, WCLK,
52
    RDAD0, RDAD1, RDAD2, RDAD3, RDAD4, RDAD5, RDAD6, RDAD7, RDAD8, RDAD9, RDAD10,
53
    RDAD11, RDAD12, RDAD13, RDAD14, RDAD15, REN, RW0, RW1, RW2, RCLK : in std_logic;
54
    RD0, RD1, RD2, RD3, RD4, RD5, RD6, RD7, RD8, RD9, RD10, RD11, RD12, RD13,
55
    RD14, RD15, RD16, RD17, RD18, RD19, RD20, RD21, RD22, RD23, RD24, RD25, RD26,
56
    RD27, RD28, RD29, RD30, RD31, RD32, RD33, RD34, RD35 : out std_logic);
57
  end component;
58
signal gnd : std_ulogic;
59
signal depth : std_logic_vector(4 downto 0);
60
signal d, q : std_logic_vector(36 downto 0);
61
begin
62
  depth <= "00000";
63
  do <= q(dbits-1 downto 0);
64
  d(dbits-1 downto 0) <= di;
65
  d(36 downto dbits) <= (others => '0');
66
    u0 : RAM64K36
67
    port map (
68
      WRAD0 => wa(0), WRAD1 => wa(1), WRAD2 => wa(2), WRAD3 => wa(3),
69
      WRAD4 => wa(4), WRAD5 => wa(5), WRAD6 => wa(6), WRAD7 => wa(7),
70
      WRAD8 => wa(8), WRAD9 => wa(9), WRAD10 => wa(10), WRAD11 => wa(11),
71
      WRAD12 => wa(12), WRAD13 => wa(13), WRAD14 => wa(14), WRAD15 => wa(15),
72
      WD0 => d(0), WD1 => d(1), WD2 => d(2), WD3 => d(3), WD4 => d(4),
73
      WD5 => d(5), WD6 => d(6), WD7 => d(7), WD8 => d(8), WD9 => d(9),
74
      WD10 => d(10), WD11 => d(11), WD12 => d(12), WD13 => d(13), WD14 => d(14),
75
      WD15 => d(15), WD16 => d(16), WD17 => d(17), WD18 => d(18), WD19 => d(19),
76
      WD20 => d(20), WD21 => d(21), WD22 => d(22), WD23 => d(23), WD24 => d(24),
77
      WD25 => d(25), WD26 => d(26), WD27 => d(27), WD28 => d(28), WD29 => d(29),
78
      WD30 => d(30), WD31 => d(31), WD32 => d(32), WD33 => d(33), WD34 => d(34),
79
      WD35 => d(35), WEN => wen, DEPTH0 => depth(0),
80
      DEPTH1 => depth(1), DEPTH2 => depth(2), DEPTH3 => depth(3),
81
      WW0 => width(0), WW1 => width(1), WW2 => width(2), WCLK => wclk,
82
      RDAD0 => ra(0), RDAD1 => ra(1), RDAD2 => ra(2), RDAD3 => ra(3),
83
      RDAD4 => ra(4), RDAD5 => ra(5), RDAD6 => ra(6), RDAD7 => ra(7),
84
      RDAD8 => ra(8), RDAD9 => ra(9), RDAD10 => ra(10), RDAD11 => ra(11),
85
      RDAD12 => ra(12), RDAD13 => ra(13), RDAD14 => ra(14), RDAD15 => ra(15),
86
      REN => ren, RW0 => width(0), RW1 => width(1), RW2 => width(2),
87
      RCLK => rclk,
88
      RD0 => q(0), RD1 => q(1), RD2 => q(2), RD3 => q(3), RD4 => q(4),
89
      RD5 => q(5), RD6 => q(6), RD7 => q(7), RD8 => q(8), RD9 => q(9),
90
      RD10 => q(10), RD11 => q(11), RD12 => q(12), RD13 => q(13), RD14 => q(14),
91
      RD15 => q(15), RD16 => q(16), RD17 => q(17), RD18 => q(18), RD19 => q(19),
92
      RD20 => q(20), RD21 => q(21), RD22 => q(22), RD23 => q(23), RD24 => q(24),
93
      RD25 => q(25), RD26 => q(26), RD27 => q(27), RD28 => q(28), RD29 => q(29),
94
      RD30 => q(30), RD31 => q(31), RD32 => q(32), RD33 => q(33), RD34 => q(34),
95
      RD35 => q(35));
96
 
97
end;
98
 
99
library ieee;
100
use ieee.std_logic_1164.all;
101
library techmap;
102
 
103
entity axcel_syncram_2p is
104
  generic ( abits : integer := 10; dbits : integer := 8 );
105
  port (
106
    rclk  : in std_ulogic;
107
    rena  : in std_ulogic;
108
    raddr : in std_logic_vector (abits -1 downto 0);
109
    dout  : out std_logic_vector (dbits -1 downto 0);
110
    wclk  : in std_ulogic;
111
    waddr : in std_logic_vector (abits -1 downto 0);
112
    din   : in std_logic_vector (dbits -1 downto 0);
113
    write : in std_ulogic);
114
end;
115
 
116
architecture rtl of axcel_syncram_2p is
117
component axcel_ssram
118
  generic (abits : integer := 16; dbits : integer := 36);
119
  port (
120
    wa, ra       : in  std_logic_vector(15 downto 0);
121
    wclk, rclk   : in  std_ulogic;
122
    di           : in  std_logic_vector(dbits -1 downto 0);
123
    do           : out std_logic_vector(dbits -1 downto 0);
124
    width        : in  std_logic_vector(2 downto 0);
125
    ren, wen     : in  std_ulogic
126
   );
127
end component;
128
 
129
type dwtype is array (1 to 24) of integer;
130
constant dwmap : dwtype := (36, 36, 36, 36, 36, 36, 36, 18, 9, 4, 2, others => 1);
131
constant xbits : integer := dwmap(abits);
132
constant dw : integer := dbits + 36;
133
signal wen, gnd : std_ulogic;
134
signal ra, wa : std_logic_vector(31 downto 0);
135
signal d, q : std_logic_vector(dw downto 0);
136
signal ren  : std_ulogic;
137
signal width : std_logic_vector(2 downto 0);
138
constant READFAST : std_ulogic := '0';
139
begin
140
  width <= "101" when abits <= 7 else
141
           "100" when abits = 8 else
142
           "011" when abits = 9 else
143
           "010" when abits = 10 else
144
           "001" when abits = 11 else
145
           "000";
146
  wen <= write; ren <= rena or READFAST; gnd <= '0';
147
  ra(31 downto abits) <= (others =>'0'); wa(31 downto abits) <= (others =>'0');
148
  ra(abits-1 downto 0) <= raddr(abits-1 downto 0);
149
  wa(abits-1 downto 0) <= waddr(abits-1 downto 0);
150
  d(dw downto dbits) <= (others =>'0');
151
  d(dbits-1 downto 0) <= din(dbits-1 downto 0);
152
  dout <= q(dbits-1 downto 0);
153
 
154
 
155
  a7 : if abits <= 7 generate
156
    agen : for i in 0 to (dbits-1)/xbits generate
157
      u0 : axcel_ssram
158
      generic map (abits => 7, dbits => xbits)
159
      port map (ra => ra(15 downto 0), wa => wa(15 downto 0),
160
         di => d(xbits*(i+1)-1 downto xbits*i), wen => wen, width => width,
161
         wclk => wclk, ren => ren, rclk => rclk,
162
         do => q(xbits*(i+1)-1 downto xbits*i));
163
    end generate;
164
  end generate;
165
  a8to12 : if (abits > 7) and (abits <= 12) generate
166
    agen : for i in 0 to (dbits-1)/xbits generate
167
      u0 : axcel_ssram
168
      generic map (abits => abits, dbits => xbits)
169
      port map (ra => ra(15 downto 0), wa => wa(15 downto 0),
170
         di => d(xbits*(i+1)-1 downto xbits*i), wen => wen, width => width,
171
         wclk => wclk, ren => ren, rclk => rclk,
172
         do => q(xbits*(i+1)-1 downto xbits*i));
173
    end generate;
174
  end generate;
175
-- pragma translate_off
176
  a_to_high : if abits > 12 generate
177
    x : process
178
    begin
179
      assert false
180
      report  "Address depth larger than 12 not supported for AX rams"
181
      severity failure;
182
      wait;
183
    end process;
184
  end generate;
185
-- pragma translate_on
186
end;
187
 
188
library ieee;
189
use ieee.std_logic_1164.all;
190
use ieee.numeric_std.all;
191
 
192
entity axcel_syncram is
193
  generic ( abits : integer := 10; dbits : integer := 8 );
194
  port (
195
    clk      : in std_ulogic;
196
    address  : in std_logic_vector((abits -1) downto 0);
197
    datain   : in std_logic_vector((dbits -1) downto 0);
198
    dataout  : out std_logic_vector((dbits -1) downto 0);
199
    enable   : in std_ulogic;
200
    write    : in std_ulogic
201
   );
202
end;
203
 
204
architecture rtl of axcel_syncram is
205
 
206
 component axcel_syncram_2p
207
  generic ( abits : integer := 10; dbits : integer := 8 );
208
  port (
209
    rclk  : in std_ulogic;
210
    rena  : in std_ulogic;
211
    raddr : in std_logic_vector (abits -1 downto 0);
212
    dout  : out std_logic_vector (dbits -1 downto 0);
213
    wclk  : in std_ulogic;
214
    waddr : in std_logic_vector (abits -1 downto 0);
215
    din   : in std_logic_vector (dbits -1 downto 0);
216
    write : in std_ulogic);
217
  end component;
218
 
219
  component axcel_ssram
220
  generic (abits : integer := 16; dbits : integer := 36);
221
  port (
222
    wa, ra       : in  std_logic_vector(15 downto 0);
223
    wclk, rclk   : in  std_ulogic;
224
    di           : in  std_logic_vector(dbits -1 downto 0);
225
    do           : out std_logic_vector(dbits -1 downto 0);
226
    width        : in  std_logic_vector(2 downto 0);
227
    ren, wen     : in  std_ulogic
228
   );
229
  end component;
230
 
231
  type d_type is array (0 to 3) of std_logic_vector(35 downto 0);
232
 
233
  signal wen : std_logic_vector(3 downto 0);
234
  signal q   : d_type;
235
  signal addr : std_logic_vector(15 downto 0);
236
 
237
  signal addrreg : std_logic_vector(1 downto 0);
238
 
239
begin
240
 
241
  a : if not ((abits = 10 or abits = 11) and dbits = 36) generate
242
    u0 : axcel_syncram_2p generic map (abits, dbits)
243
      port map (clk, enable, address, dataout, clk, address, datain, write);
244
  end generate;
245
 
246
 
247
  -- Special case for 4 or 8 KB cache with FT: 36x1024 or 2048: 2 or 4 banks of 4*9*512 
248
  a10to11d36 : if (abits = 10 or abits = 11) and dbits = 36 generate
249
 
250
    addr_reg : process (clk)
251
      begin
252
        if rising_edge(clk) then addrreg(abits-10 downto 0) <= address(abits-1 downto 9); end if;
253
      end process;
254
 
255
    addr(15 downto 9)  <= (others => '0');
256
    addr(8 downto 0) <= address(8 downto 0);
257
 
258
    decode : process (address, write)
259
      variable vwen : std_logic_vector(3 downto 0);
260
    begin
261
      vwen := (others => '0');
262
      if write = '1' then
263
        vwen( to_integer(unsigned(address(abits-1 downto 9))) ) := '1';
264
      end if;
265
      wen <= vwen;
266
    end process;
267
 
268
    loop0 : for b in 0 to 2*(abits-9)-1 generate
269
      agen0 : for i in 0 to 3 generate
270
        u0 : axcel_ssram
271
          generic map (abits => 9, dbits => 9)
272
          port map (ra => addr, wa =>  addr,
273
                    di => datain(9*(i+1)-1 downto 9*i), wen => wen(b), width => "011",
274
                    wclk => clk, ren => enable, rclk => clk,
275
                    do => q(b)(9*(i+1)-1 downto 9*i));
276
      end generate;
277
    end generate;
278
 
279
    dout10: if abits = 10 generate
280
      dataout <= q(0) when addrreg(0)='0' else q(1);
281
    end generate;
282
    dout11: if abits = 11 generate
283
      dataout <= q(0) when addrreg(1 downto 0)="00" else q(1) when addrreg(1 downto 0)="01" else
284
                 q(2) when addrreg(1 downto 0)="10" else q(3);
285
    end generate;
286
 
287
  end generate;
288
 
289
end;
290
 

powered by: WebSVN 2.1.0

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