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: cache
|
20 |
|
|
-- File: cache.vhd
|
21 |
|
|
-- Author: Jiri Gaisler
|
22 |
|
|
-- Description: Cache controllers and AHB interface
|
23 |
|
|
------------------------------------------------------------------------------
|
24 |
|
|
|
25 |
|
|
library ieee;
|
26 |
|
|
use ieee.std_logic_1164.all;
|
27 |
|
|
library techmap;
|
28 |
|
|
use techmap.gencomp.all;
|
29 |
|
|
library grlib;
|
30 |
|
|
use grlib.amba.all;
|
31 |
|
|
library gaisler;
|
32 |
|
|
use gaisler.libiu.all;
|
33 |
|
|
use gaisler.libcache.all;
|
34 |
|
|
use gaisler.mmuiface.all;
|
35 |
|
|
|
36 |
|
|
entity cache is
|
37 |
|
|
generic (
|
38 |
|
|
hindex : integer := 0;
|
39 |
|
|
dsu : integer range 0 to 1 := 0;
|
40 |
|
|
icen : integer range 0 to 1 := 0;
|
41 |
|
|
irepl : integer range 0 to 2 := 0;
|
42 |
|
|
isets : integer range 1 to 4 := 1;
|
43 |
|
|
ilinesize : integer range 4 to 8 := 4;
|
44 |
|
|
isetsize : integer range 1 to 256 := 1;
|
45 |
|
|
isetlock : integer range 0 to 1 := 0;
|
46 |
|
|
dcen : integer range 0 to 1 := 0;
|
47 |
|
|
drepl : integer range 0 to 2 := 0;
|
48 |
|
|
dsets : integer range 1 to 4 := 1;
|
49 |
|
|
dlinesize : integer range 4 to 8 := 4;
|
50 |
|
|
dsetsize : integer range 1 to 256 := 1;
|
51 |
|
|
dsetlock : integer range 0 to 1 := 0;
|
52 |
|
|
dsnoop : integer range 0 to 6 := 0;
|
53 |
|
|
ilram : integer range 0 to 1 := 0;
|
54 |
|
|
ilramsize : integer range 1 to 512 := 1;
|
55 |
|
|
ilramstart : integer range 0 to 255 := 16#8e#;
|
56 |
|
|
dlram : integer range 0 to 1 := 0;
|
57 |
|
|
dlramsize : integer range 1 to 512 := 1;
|
58 |
|
|
dlramstart : integer range 0 to 255 := 16#8f#;
|
59 |
|
|
cached : integer := 0;
|
60 |
|
|
clk2x : integer := 0;
|
61 |
|
|
memtech : integer range 0 to NTECH := 0;
|
62 |
|
|
scantest : integer := 0);
|
63 |
|
|
port (
|
64 |
|
|
rst : in std_ulogic;
|
65 |
|
|
clk : in std_ulogic;
|
66 |
|
|
ici : in icache_in_type;
|
67 |
|
|
ico : out icache_out_type;
|
68 |
|
|
dci : in dcache_in_type;
|
69 |
|
|
dco : out dcache_out_type;
|
70 |
|
|
ahbi : in ahb_mst_in_type;
|
71 |
|
|
ahbo : out ahb_mst_out_type;
|
72 |
|
|
ahbsi : in ahb_slv_in_type;
|
73 |
|
|
ahbso : in ahb_slv_out_vector;
|
74 |
|
|
crami : out cram_in_type;
|
75 |
|
|
cramo : in cram_out_type;
|
76 |
|
|
fpuholdn : in std_ulogic;
|
77 |
|
|
hclk, sclk : in std_ulogic;
|
78 |
|
|
hclken : in std_ulogic
|
79 |
|
|
);
|
80 |
|
|
end;
|
81 |
|
|
|
82 |
|
|
architecture rtl of cache is
|
83 |
|
|
|
84 |
|
|
signal icol : icache_out_type;
|
85 |
|
|
signal dcol : dcache_out_type;
|
86 |
|
|
signal mcii : memory_ic_in_type;
|
87 |
|
|
signal mcio : memory_ic_out_type;
|
88 |
|
|
signal mcdi : memory_dc_in_type;
|
89 |
|
|
signal mcdo : memory_dc_out_type;
|
90 |
|
|
signal mcmmi : memory_mm_in_type;
|
91 |
|
|
|
92 |
|
|
signal ahbsi2 : ahb_slv_in_type;
|
93 |
|
|
signal ahbi2 : ahb_mst_in_type;
|
94 |
|
|
signal ahbo2 : ahb_mst_out_type;
|
95 |
|
|
signal gnd : std_ulogic;
|
96 |
|
|
|
97 |
|
|
begin
|
98 |
|
|
|
99 |
|
|
icache0 : icache
|
100 |
|
|
generic map (icen, irepl, isets, ilinesize, isetsize, isetlock, ilram,
|
101 |
|
|
ilramsize, ilramstart)
|
102 |
|
|
port map ( rst, clk, ici, icol, dci, dcol, mcii, mcio,
|
103 |
|
|
crami.icramin, cramo.icramo, fpuholdn);
|
104 |
|
|
dcache0 : dcache
|
105 |
|
|
generic map (dsu, dcen, drepl, dsets, dlinesize, dsetsize, dsetlock, dsnoop,
|
106 |
|
|
dlram, dlramsize, dlramstart, ilram, ilramstart, memtech, cached)
|
107 |
|
|
port map ( rst, clk, dci, dcol, icol, mcdi, mcdo, ahbsi2,
|
108 |
|
|
crami.dcramin, cramo.dcramo, fpuholdn, sclk);
|
109 |
|
|
-- a0 : acache
|
110 |
|
|
-- generic map (hindex, ilinesize, cached, clk2x, scantest)
|
111 |
|
|
-- port map (rst, clk, mcii, mcio, mcdi, mcdo, ahbi2, ahbo2, ahbso, hclken);
|
112 |
|
|
a0 : mmu_acache
|
113 |
|
|
generic map (hindex, ilinesize, cached, clk2x, scantest)
|
114 |
|
|
port map (rst, clk, mcii, mcio, mcdi, mcdo, mcmmi, open, ahbi2, ahbo2, ahbso, hclken);
|
115 |
|
|
|
116 |
|
|
mcmmi <= mci_zero;
|
117 |
|
|
ico <= icol;
|
118 |
|
|
dco <= dcol;
|
119 |
|
|
|
120 |
|
|
clk2xgen: if clk2x /= 0 generate
|
121 |
|
|
sync0 : clk2xsync generic map (hindex, clk2x)
|
122 |
|
|
port map (rst, hclk, clk, ahbi, ahbi2, ahbo2, ahbo, ahbsi, ahbsi2, mcii, mcdi, mcdo, gnd, gnd, hclken);
|
123 |
|
|
gnd <= '0';
|
124 |
|
|
end generate;
|
125 |
|
|
|
126 |
|
|
noclk2x : if clk2x = 0 generate
|
127 |
|
|
ahbsi2 <= ahbsi;
|
128 |
|
|
ahbi2 <= ahbi;
|
129 |
|
|
ahbo <= ahbo2;
|
130 |
|
|
end generate;
|
131 |
|
|
|
132 |
|
|
|
133 |
|
|
end ;
|
134 |
|
|
|