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

Subversion Repositories core_arm

[/] [core_arm/] [trunk/] [vhdl/] [sparc/] [cachemem.vhd] - Blame information for rev 5

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

Line No. Rev Author Line
1 2 tarookumic
 
2
 
3
 
4
 
5
----------------------------------------------------------------------------
6
--  This file is a part of the LEON VHDL model
7
--  Copyright (C) 2003  Gaisler Research
8
--
9
--  This library is free software; you can redistribute it and/or
10
--  modify it under the terms of the GNU Lesser General Public
11
--  License as published by the Free Software Foundation; either
12
--  version 2 of the License, or (at your option) any later version.
13
--
14
--  See the file COPYING.LGPL for the full details of the license.
15
 
16
 
17
-----------------------------------------------------------------------------
18
-- Entity:      cachemem
19
-- File:        cachemem.vhd
20
-- Author:      Jiri Gaisler - Gaisler Research
21
-- Description: Contains ram cells for both instruction and data caches
22
------------------------------------------------------------------------------
23
 
24
library IEEE;
25
use IEEE.std_logic_1164.all;
26
use IEEE.std_logic_arith.all;
27
use work.leon_target.all;
28
use work.leon_config.all;
29
use work.mmuconfig.all;
30
use work.leon_iface.all;
31
use work.macro.all;
32
use work.tech_map.all;
33
 
34
entity cachemem is
35
  port (
36
        clk   : in  clk_type;
37
        crami : in  cram_in_type;
38
        cramo : out cram_out_type
39
  );
40
end;
41
 
42
architecture rtl of cachemem is
43
 
44
  constant ITDEPTH : natural := 2**IOFFSET_BITS;
45
  constant DTDEPTH : natural := 2**DOFFSET_BITS;
46
 
47
  -- i/d tag layout
48
  -- +-----+----------+--------+-----+-------+
49
  -- | LRR | LOCK_BIT | MMUCTX | TAG | VALID |
50
  -- +-----+----------+--------+-----+-------+
51
 
52
  constant ITWIDTH : natural := ITAG_BITS + ILRR_BIT + ICLOCK_BIT + MMUCTX_BITS;
53
  constant DTWIDTH : natural := DTAG_BITS + DLRR_BIT + DCLOCK_BIT + MMUCTX_BITS;
54
  constant IDWIDTH : natural := 32;
55
  constant DDWIDTH : natural := 32;
56
 
57
  subtype dtdatain_vector is std_logic_vector(DTWIDTH downto 0);
58
  type dtdatain_type is array (0 to MAXSETS-1) of dtdatain_vector;
59
  subtype itdatain_vector is std_logic_vector(ITWIDTH downto 0);
60
  type itdatain_type is array (0 to MAXSETS-1) of itdatain_vector;
61
 
62
  subtype itdataout_vector is std_logic_vector(ITWIDTH downto 0);
63
  type itdataout_type is array (0 to MAXSETS-1) of itdataout_vector;
64
  subtype iddataout_vector is std_logic_vector(IDWIDTH -1 downto 0);
65
  type iddataout_type is array (0 to MAXSETS-1) of iddataout_vector;
66
  subtype dtdataout_vector is std_logic_vector(DTWIDTH downto 0);
67
  type dtdataout_type is array (0 to MAXSETS-1) of dtdataout_vector;
68
  subtype dddataout_vector is std_logic_vector(DDWIDTH -1 downto 0);
69
  type dddataout_type is array (0 to MAXSETS-1) of dddataout_vector;
70
 
71
 
72
  signal itaddr    : std_logic_vector(IOFFSET_BITS + ILINE_BITS -1 downto ILINE_BITS);
73
  signal idaddr    : std_logic_vector(IOFFSET_BITS + ILINE_BITS -1 downto 0);
74
 
75
 
76
  --signal itdatain  : std_logic_vector(ITWIDTH -1 downto 0);
77
  signal itdatain  : itdatain_type;
78
  signal itdataout : itdataout_type;
79
  signal iddatain  : std_logic_vector(IDWIDTH -1 downto 0);
80
  signal iddataout : iddataout_type;
81
 
82
  signal itenable  : std_logic;
83
  signal idenable  : std_logic;
84
  signal itwrite   : std_logic_vector(0 to MAXSETS-1);
85
  signal idwrite   : std_logic_vector(0 to MAXSETS-1);
86
 
87
  signal dtaddr    : std_logic_vector(DOFFSET_BITS + DLINE_BITS -1 downto DLINE_BITS);
88
  signal dtaddr2   : std_logic_vector(DOFFSET_BITS + DLINE_BITS -1 downto DLINE_BITS);
89
  signal ddaddr    : std_logic_vector(DOFFSET_BITS + DLINE_BITS -1 downto 0);
90
 
91
  --signal dtdatain  : std_logic_vector(DTWIDTH -1 downto 0);
92
  signal dtdatain  : dtdatain_type;
93
--  signal dtdatain2 : std_logic_vector(DTWIDTH -1 downto 0);
94
  signal dtdatain2 : dtdatain_type;
95
  signal dtdataout : dtdataout_type;
96
  signal dtdataout2: dtdataout_type;
97
  signal dddatain  : std_logic_vector(DDWIDTH -1 downto 0);
98
  signal dddataout : dddataout_type;
99
  signal ldataout  : std_logic_vector(31 downto 0);
100
 
101
  signal dtenable  : std_logic;
102
  signal dtenable2 : std_logic;
103
  signal ddenable  : std_logic;
104
  signal dtwrite   : std_logic_vector(0 to MAXSETS-1);
105
  signal dtwrite2  : std_logic_vector(0 to MAXSETS-1);
106
  signal ddwrite   : std_logic_vector(0 to MAXSETS-1);
107
 
108
  signal vcc, gnd  : std_logic;
109
 
110
begin
111
 
112
  vcc <= '1'; gnd <= '0';
113
  itaddr <= crami.icramin.idramin.address(IOFFSET_BITS + ILINE_BITS -1 downto ILINE_BITS);
114
  idaddr <= crami.icramin.idramin.address;
115
 
116
 
117
  itinsel : process(crami, dtdataout2)
118
 
119
  variable viddatain  : std_logic_vector(IDWIDTH -1 downto 0);
120
  variable vdddatain  : std_logic_vector(DDWIDTH -1 downto 0);
121
  variable vitdatain : itdatain_type;
122
  variable vdtdatain : dtdatain_type;
123
  variable vdtdatain2 : dtdatain_type;
124
  begin
125
    viddatain := (others => '0');
126
    vdddatain := (others => '0');
127
 
128
    viddatain(31 downto 0) := crami.icramin.idramin.data;
129
 
130
    for i in 0 to DSETS-1 loop
131
      vdtdatain(i) := (others => '0');
132
      if M_EN then
133
        vdtdatain(i)((DTWIDTH - (DLRR_BIT+DCLOCK_BIT+1)) downto (DTWIDTH - (DLRR_BIT+DCLOCK_BIT+M_CTX_SZ))) := crami.dcramin.dtramin.ctx;
134
      end if;
135
      vdtdatain(i)(DTWIDTH-(DLRR_BIT + DCLOCK_BIT)) := crami.dcramin.dtramin.lrr(i);
136
      vdtdatain(i)(DTWIDTH-DCLOCK_BIT) := crami.dcramin.dtramin.lock(i);
137
      vdtdatain(i)(DTAG_BITS-1 downto 0) := crami.dcramin.dtramin.tag & crami.dcramin.dtramin.valid;
138
      if (DSETS > 1) and (crami.dcramin.dtramin.flush = '1') then
139
        vdtdatain(i)(DLINE_SIZE+1 downto DLINE_SIZE) :=  std_logic_vector(conv_unsigned(i,2));
140
      end if;
141
    end loop;
142
 
143
    vdtdatain2 := (others => (others => '0'));
144
    for i in 0 to DSETS-1 loop
145
 
146
      vdtdatain2(i)(DTWIDTH-(DLRR_BIT + DCLOCK_BIT)) := dtdataout2(i)(DTWIDTH-(DLRR_BIT+DCLOCK_BIT));
147
      vdtdatain2(i)(DTWIDTH-DCLOCK_BIT) := dtdataout2(i)(DTWIDTH-DCLOCK_BIT);
148
      vdtdatain2(i)(DTAG_BITS-1 downto DLINE_SIZE) := crami.dcramin.dtraminsn.tag;
149
    end loop;
150
    vdddatain(32 - 1 downto 0) := crami.dcramin.ddramin.data;
151
 
152
 
153
    for i in 0 to ISETS-1 loop
154
      vitdatain(i) := (others => '0');
155
      if M_EN then
156
        vitdatain(i)((ITWIDTH - (ILRR_BIT+ICLOCK_BIT+1)) downto (ITWIDTH - (ILRR_BIT+ICLOCK_BIT+M_CTX_SZ))) := crami.icramin.itramin.ctx;
157
      end if;
158
      vitdatain(i)(ITWIDTH-(ILRR_BIT + ICLOCK_BIT)) := crami.icramin.itramin.lrr;
159
      vitdatain(i)(ITWIDTH-ICLOCK_BIT) := crami.icramin.itramin.lock;
160
      vitdatain(i)(ITAG_BITS-1 downto 0) := crami.icramin.itramin.tag & crami.icramin.itramin.valid;
161
      if (ISETS > 1) and (crami.icramin.itramin.flush = '1') then
162
        vitdatain(i)(ILINE_SIZE+1 downto ILINE_SIZE) :=  std_logic_vector(conv_unsigned(i,2));
163
      end if;
164
    end loop;
165
 
166
    itdatain <= vitdatain; iddatain <= viddatain;
167
    dtdatain <= vdtdatain; dtdatain2 <= vdtdatain2; dddatain <= vdddatain;
168
 
169
  end process;
170
 
171
 
172
  itwrite   <= crami.icramin.itramin.write;
173
  idwrite   <= crami.icramin.idramin.write;
174
  itenable  <= crami.icramin.itramin.enable;
175
  idenable  <= crami.icramin.idramin.enable;
176
 
177
  dtaddr <= crami.dcramin.ddramin.address(DOFFSET_BITS + DLINE_BITS -1 downto DLINE_BITS);
178
  dtaddr2 <= crami.dcramin.dtraminsn.address;
179
  ddaddr <= crami.dcramin.ddramin.address;
180
  dtwrite   <= crami.dcramin.dtramin.write;
181
  dtwrite2  <= crami.dcramin.dtraminsn.write;
182
  ddwrite   <= crami.dcramin.ddramin.write;
183
  dtenable  <= crami.dcramin.dtramin.enable;
184
  dtenable2 <= crami.dcramin.dtraminsn.enable;
185
  ddenable  <= crami.dcramin.ddramin.enable;
186
 
187
 
188
  it0 : for i in 0 to ISETS-1 generate
189
    itags0 : syncram
190
      generic map ( dbits => ITWIDTH, abits => IOFFSET_BITS)
191
      port map ( itaddr, clk, itdatain(i)(ITWIDTH-1 downto 0), itdataout(i)(ITWIDTH-1 downto 0), itenable, itwrite(i));
192
  end generate;
193
 
194
  dtags0 : if not DSNOOP generate
195
    dt0 : for i in 0 to DSETS-1 generate
196
      dtags0 : syncram
197
      generic map ( dbits => DTWIDTH, abits => DOFFSET_BITS)
198
      port map ( dtaddr, clk, dtdatain(i)(DTWIDTH-1 downto 0), dtdataout(i)(DTWIDTH-1 downto 0), dtenable, dtwrite(i));
199
    end generate;
200
  end generate;
201
 
202
  dtags1 : if DSNOOP generate
203
    dt0 : for i in 0 to DSETS-1 generate
204
      dtags0 : dpsyncram
205
      generic map ( dbits => DTWIDTH, abits => DOFFSET_BITS)
206
      port map ( dtaddr, clk, dtdatain(i)(DTWIDTH-1 downto 0), dtdataout(i)(DTWIDTH-1 downto 0), dtenable, dtwrite(i),
207
                 dtaddr2, dtdatain2(i)(DTWIDTH-1 downto 0), dtdataout2(i)(DTWIDTH-1 downto 0), dtenable2, dtwrite2(i));
208
    end generate;
209
  end generate;
210
 
211
  id0 : for i in 0 to ISETS-1 generate
212
    idata0 : syncram
213
      generic map ( dbits => IDWIDTH, abits => IOFFSET_BITS+ILINE_BITS)
214
      port map ( idaddr, clk, iddatain, iddataout(i), idenable, idwrite(i));
215
  end generate;
216
 
217
  dd0 : for i in 0 to DSETS-1 generate
218
    ddata0 : syncram
219
     generic map ( dbits => DDWIDTH, abits => DOFFSET_BITS+DLINE_BITS)
220
      port map ( ddaddr, clk, dddatain, dddataout(i), ddenable, ddwrite(i));
221
  end generate;
222
 
223
  ld0 : if LOCAL_RAM generate
224
    ldata0 : syncram
225
     generic map ( dbits => 32, abits => LOCAL_RAM_BITS)
226
      port map ( crami.dcramin.ldramin.address, clk, dddatain, ldataout,
227
                crami.dcramin.ldramin.enable, crami.dcramin.ldramin.write);
228
  end generate;
229
 
230
  itx : for i in 0 to ISETS-1 generate
231
    itdataout(i)(ITWIDTH) <= '0';
232
    cramo.icramout.itramout(i).valid <= itdataout(i)(ILINE_SIZE -1 downto 0);
233
    cramo.icramout.itramout(i).tag <= itdataout(i)(ITAG_BITS-1 downto ILINE_SIZE);
234
    cramo.icramout.itramout(i).lrr <= itdataout(i)(ITWIDTH - (ILRR_BIT+ICLOCK_BIT));
235
    cramo.icramout.itramout(i).lock <= itdataout(i)(ITWIDTH-ICLOCK_BIT);
236
    cramo.icramout.itramout(i).ctx <= itdataout(i)((ITWIDTH - (ILRR_BIT+ICLOCK_BIT+1)) downto (ITWIDTH - (ILRR_BIT+ICLOCK_BIT+M_CTX_SZ)));
237
    cramo.icramout.idramout(i).data <= iddataout(i)(31 downto 0);
238
 
239
  end generate;
240
 
241
 
242
  itd : for i in 0 to DSETS-1 generate
243
    dtdataout(i)(DTWIDTH) <= '0';
244
    dtdataout2(i)(DTWIDTH) <= '0';
245
    cramo.dcramout.dtramout(i).valid <= dtdataout(i)(DLINE_SIZE -1 downto 0);
246
    cramo.dcramout.dtramout(i).tag <= dtdataout(i)(DTAG_BITS-1 downto DLINE_SIZE);
247
    cramo.dcramout.dtramout(i).lrr <= dtdataout(i)(DTWIDTH-(DLRR_BIT+DCLOCK_BIT));
248
    cramo.dcramout.dtramout(i).lock <= dtdataout(i)(DTWIDTH-DCLOCK_BIT);
249
    cramo.dcramout.dtramout(i).ctx <= dtdataout(i)((DTWIDTH - (DLRR_BIT+DCLOCK_BIT+1)) downto (DTWIDTH - (DLRR_BIT+DCLOCK_BIT+M_CTX_SZ)));
250
    cramo.dcramout.dtramoutsn(i).tag <= dtdataout2(i)(DTAG_BITS-1 downto DLINE_SIZE);
251
    cramo.dcramout.ddramout(i).data <= ldataout when LOCAL_RAM and (crami.dcramin.ldramin.read = '1')
252
    else dddataout(i)(31 downto 0);
253
 
254
  end generate;
255
 
256
end ;
257
 

powered by: WebSVN 2.1.0

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