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: Complete cache sub-system with controllers and rams
|
23 |
|
|
------------------------------------------------------------------------------
|
24 |
|
|
|
25 |
|
|
library ieee;
|
26 |
|
|
use ieee.std_logic_1164.all;
|
27 |
|
|
library grlib;
|
28 |
|
|
use grlib.amba.all;
|
29 |
|
|
library techmap;
|
30 |
|
|
use techmap.gencomp.all;
|
31 |
|
|
library gaisler;
|
32 |
|
|
use gaisler.libiu.all;
|
33 |
|
|
use gaisler.libcache.all;
|
34 |
|
|
use gaisler.mmuconfig.all;
|
35 |
|
|
use gaisler.mmuiface.all;
|
36 |
|
|
use gaisler.libmmu.all;
|
37 |
|
|
|
38 |
|
|
entity mmu_cache is
|
39 |
|
|
generic (
|
40 |
|
|
hindex : integer := 0;
|
41 |
|
|
memtech : integer range 0 to NTECH := 0;
|
42 |
|
|
dsu : integer range 0 to 1 := 0;
|
43 |
|
|
icen : integer range 0 to 1 := 0;
|
44 |
|
|
irepl : integer range 0 to 2 := 0;
|
45 |
|
|
isets : integer range 1 to 4 := 1;
|
46 |
|
|
ilinesize : integer range 4 to 8 := 4;
|
47 |
|
|
isetsize : integer range 1 to 256 := 1;
|
48 |
|
|
isetlock : integer range 0 to 1 := 0;
|
49 |
|
|
dcen : integer range 0 to 1 := 0;
|
50 |
|
|
drepl : integer range 0 to 2 := 0;
|
51 |
|
|
dsets : integer range 1 to 4 := 1;
|
52 |
|
|
dlinesize : integer range 4 to 8 := 4;
|
53 |
|
|
dsetsize : integer range 1 to 256 := 1;
|
54 |
|
|
dsetlock : integer range 0 to 1 := 0;
|
55 |
|
|
dsnoop : integer range 0 to 6 := 0;
|
56 |
|
|
itlbnum : integer range 2 to 64 := 8;
|
57 |
|
|
dtlbnum : integer range 2 to 64 := 8;
|
58 |
|
|
tlb_type : integer range 0 to 3 := 1;
|
59 |
|
|
tlb_rep : integer range 0 to 1 := 0;
|
60 |
|
|
cached : integer := 0;
|
61 |
|
|
clk2x : integer := 0;
|
62 |
|
|
scantest : integer := 0
|
63 |
|
|
);
|
64 |
|
|
port (
|
65 |
|
|
rst : in std_ulogic;
|
66 |
|
|
clk : in std_ulogic;
|
67 |
|
|
ici : in icache_in_type;
|
68 |
|
|
ico : out icache_out_type;
|
69 |
|
|
dci : in dcache_in_type;
|
70 |
|
|
dco : out dcache_out_type;
|
71 |
|
|
ahbi : in ahb_mst_in_type;
|
72 |
|
|
ahbo : out ahb_mst_out_type;
|
73 |
|
|
ahbsi : in ahb_slv_in_type;
|
74 |
|
|
ahbso : in ahb_slv_out_vector;
|
75 |
|
|
crami : out cram_in_type;
|
76 |
|
|
cramo : in cram_out_type;
|
77 |
|
|
fpuholdn : in std_ulogic;
|
78 |
|
|
hclk, sclk : in std_ulogic;
|
79 |
|
|
hclken : in std_ulogic
|
80 |
|
|
);
|
81 |
|
|
end;
|
82 |
|
|
|
83 |
|
|
architecture rtl of mmu_cache is
|
84 |
|
|
|
85 |
|
|
signal icol : icache_out_type;
|
86 |
|
|
signal dcol : dcache_out_type;
|
87 |
|
|
signal mcii : memory_ic_in_type;
|
88 |
|
|
signal mcio : memory_ic_out_type;
|
89 |
|
|
signal mcdi : memory_dc_in_type;
|
90 |
|
|
signal mcdo : memory_dc_out_type;
|
91 |
|
|
|
92 |
|
|
signal mcmmi : memory_mm_in_type;
|
93 |
|
|
signal mcmmo : memory_mm_out_type;
|
94 |
|
|
|
95 |
|
|
signal mmudci : mmudc_in_type;
|
96 |
|
|
signal mmudco : mmudc_out_type;
|
97 |
|
|
signal mmuici : mmuic_in_type;
|
98 |
|
|
signal mmuico : mmuic_out_type;
|
99 |
|
|
|
100 |
|
|
signal ahbsi2 : ahb_slv_in_type;
|
101 |
|
|
signal ahbi2 : ahb_mst_in_type;
|
102 |
|
|
signal ahbo2 : ahb_mst_out_type;
|
103 |
|
|
|
104 |
|
|
begin
|
105 |
|
|
|
106 |
|
|
-- instruction cache controller
|
107 |
|
|
icache0 : mmu_icache
|
108 |
|
|
generic map (irepl=>irepl, isets=>isets, ilinesize=>ilinesize, isetsize=>isetsize, isetlock=>isetlock)
|
109 |
|
|
port map ( rst, clk, ici, icol, dci, dcol, mcii, mcio,
|
110 |
|
|
crami.icramin, cramo.icramo, fpuholdn, mmudci, mmuici, mmuico);
|
111 |
|
|
|
112 |
|
|
-- data cache controller
|
113 |
|
|
dcache0 : mmu_dcache
|
114 |
|
|
generic map (dsu=>dsu, drepl=>drepl, dsets=>dsets, dlinesize=>dlinesize, dsetsize=>dsetsize, dsetlock=>dsetlock, dsnoop=>dsnoop,
|
115 |
|
|
itlbnum=>itlbnum, dtlbnum=>dtlbnum, tlb_type=>tlb_type, memtech=>memtech, cached => cached)
|
116 |
|
|
port map ( rst, clk, dci, dcol, icol, mcdi, mcdo, ahbsi2,
|
117 |
|
|
crami.dcramin, cramo.dcramo, fpuholdn, mmudci, mmudco, sclk);
|
118 |
|
|
|
119 |
|
|
-- AMBA AHB interface
|
120 |
|
|
a0 : mmu_acache
|
121 |
|
|
generic map (hindex, ilinesize, cached, clk2x, scantest)
|
122 |
|
|
port map (rst, clk, mcii, mcio, mcdi, mcdo, mcmmi, mcmmo, ahbi2, ahbo2, ahbso, hclken);
|
123 |
|
|
|
124 |
|
|
-- MMU
|
125 |
|
|
m0 : mmu
|
126 |
|
|
generic map (memtech, itlbnum, dtlbnum, tlb_type, tlb_rep)
|
127 |
|
|
port map (rst, clk, mmudci, mmudco, mmuici, mmuico, mcmmo, mcmmi);
|
128 |
|
|
|
129 |
|
|
ico <= icol;
|
130 |
|
|
dco <= dcol;
|
131 |
|
|
|
132 |
|
|
|
133 |
|
|
clk2xgen: if clk2x /= 0 generate
|
134 |
|
|
sync0 : clk2xsync generic map (hindex, clk2x)
|
135 |
|
|
port map (rst, hclk, clk, ahbi, ahbi2, ahbo2, ahbo, ahbsi, ahbsi2, mcii, mcdi, mcdo, mcmmi.req, mcmmo.grant, hclken);
|
136 |
|
|
end generate;
|
137 |
|
|
|
138 |
|
|
noclk2x : if clk2x = 0 generate
|
139 |
|
|
ahbsi2 <= ahbsi;
|
140 |
|
|
ahbi2 <= ahbi;
|
141 |
|
|
ahbo <= ahbo2;
|
142 |
|
|
end generate;
|
143 |
|
|
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
end ;
|
147 |
|
|
|