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/] [leon3/] [mmuconfig.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
-- Package:     mmuconfig
20
-- File:        mmuconfig.vhd
21
-- Author:      Konrad Eisele, Jiri Gaisler, Gaisler Research
22
-- Description: MMU types and constants
23
------------------------------------------------------------------------------
24
 
25
library ieee;
26
use ieee.std_logic_1164.all;
27
library grlib;
28
use grlib.stdlib.all;
29
library gaisler;
30
 
31
package mmuconfig is
32
 
33
constant M_CTX_SZ       : integer := 8;
34
constant M_ENT_MAX      : integer := 64;
35
constant XM_ENT_MAX_LOG : integer := log2(M_ENT_MAX);
36
constant M_ENT_MAX_LOG  : integer := XM_ENT_MAX_LOG;
37
 
38
type mmu_idcache is (id_icache, id_dcache);
39
 
40
-- ##############################################################
41
--     1.0 virtual address [sparc V8: p.243,Appx.H,Figure H-4]               
42
--     +--------+--------+--------+---------------+
43
--  a) | INDEX1 | INDEX2 | INDEX3 |    OFFSET     |  
44
--     +--------+--------+--------+---------------+
45
--      31    24 23    18 17    12 11            0
46
 
47
constant VA_I1_SZ : integer := 8;
48
constant VA_I2_SZ : integer := 6;
49
constant VA_I3_SZ : integer := 6;
50
constant VA_I_SZ  : integer := VA_I1_SZ+VA_I2_SZ+VA_I3_SZ;
51
constant VA_I_MAX : integer := 8;
52
 
53
constant VA_I1_U  : integer := 31;
54
constant VA_I1_D  : integer := 32-VA_I1_SZ;
55
constant VA_I2_U  : integer := 31-VA_I1_SZ;
56
constant VA_I2_D  : integer := 32-VA_I1_SZ-VA_I2_SZ;
57
constant VA_I3_U  : integer := 31-VA_I1_SZ-VA_I2_SZ;
58
constant VA_I3_D  : integer := 32-VA_I_SZ;
59
constant VA_I_U   : integer := 31;
60
constant VA_I_D   : integer := 32-VA_I_SZ;
61
constant VA_OFF_U : integer := 31-VA_I_SZ;
62
constant VA_OFF_D : integer := 0;
63
 
64
constant VA_OFFCTX_U : integer := 31;
65
constant VA_OFFCTX_D : integer := 0;
66
constant VA_OFFREG_U : integer := 31-VA_I1_SZ;
67
constant VA_OFFREG_D : integer := 0;
68
constant VA_OFFSEG_U : integer := 31-VA_I1_SZ-VA_I2_SZ;
69
constant VA_OFFSEG_D : integer := 0;
70
constant VA_OFFPAG_U : integer := 31-VA_I_SZ;
71
constant VA_OFFPAG_D : integer := 0;
72
 
73
-- ##############################################################
74
--     2.0 PAGE TABE DESCRIPTOR (PTD) [sparc V8: p.247,Appx.H,Figure H-7]                             
75
--                                                                  
76
--     +-------------------------------------------------+---+---+      
77
--     |    Page Table Pointer (PTP)                     | 0 | 0 |      
78
--     +-------------------------------------------------+---+---+      
79
--      31                                              2  1   0        
80
--
81
--     2.1 PAGE TABE ENTRY (PTE) [sparc V8: p.247,Appx.H,Figure H-8]
82
--                                                                                       
83
--     +-----------------------------+---+---+---+-----------+---+
84
--     |Physical Page Number (PPN)   | C | M | R |     ACC   | ET¦   
85
--     +-----------------------------+---+---+---+-----------+---+
86
--      31                          8  7   6   5  4         2 1 0
87
--                                                                     
88
constant PTD_PTP_U : integer := 31;   -- PTD: page table pointer
89
constant PTD_PTP_D : integer := 2;
90
constant PTD_PTP32_U : integer := 27;   -- PTD: page table pointer 32 bit
91
constant PTD_PTP32_D : integer := 2;
92
constant PTE_PPN_U : integer := 31;   -- PTE: physical page number
93
constant PTE_PPN_D : integer := 8;
94
constant PTE_PPN_S : integer := (PTE_PPN_U+1)-PTE_PPN_D;  -- PTE: pysical page number size
95
constant PTE_PPN32_U : integer := 27; -- PTE: physical page number 32 bit addr
96
constant PTE_PPN32_D : integer := 8;
97
constant PTE_PPN32_S : integer := (PTE_PPN32_U+1)-PTE_PPN32_D;  -- PTE: pysical page number 32 bit size
98
constant PTE_PPN32REG_U : integer := PTE_PPN32_U;  -- PTE: pte part of merged result address
99
constant PTE_PPN32REG_D : integer := PTE_PPN32_U+1-VA_I1_SZ;
100
constant PTE_PPN32SEG_U : integer := PTE_PPN32_U;
101
constant PTE_PPN32SEG_D : integer := PTE_PPN32_U+1-VA_I1_SZ-VA_I2_SZ;
102
constant PTE_PPN32PAG_U : integer := PTE_PPN32_U;
103
constant PTE_PPN32PAG_D : integer := PTE_PPN32_U+1-VA_I_SZ;
104
 
105
constant PTE_C : integer := 7;        -- PTE: Cacheable bit
106
constant PTE_M : integer := 6;        -- PTE: Modified bit 
107
constant PTE_R : integer := 5;        -- PTE: Reference Bit - a "1" indicates an PTE 
108
 
109
constant PTE_ACC_U : integer := 4;    -- PTE: Access field 
110
constant PTE_ACC_D : integer := 2;
111
constant ACC_W : integer := 2;        -- PTE::ACC : write permission
112
constant ACC_E : integer := 3;        -- PTE::ACC : exec permission
113
constant ACC_SU : integer := 4;       -- PTE::ACC : privileged
114
 
115
constant PT_ET_U : integer := 1;      -- PTD/PTE: PTE Type
116
constant PT_ET_D : integer := 0;
117
constant ET_INV : std_logic_vector(1 downto 0) := "00";
118
constant ET_PTD : std_logic_vector(1 downto 0) := "01";
119
constant ET_PTE : std_logic_vector(1 downto 0) := "10";
120
constant ET_RVD : std_logic_vector(1 downto 0) := "11";
121
 
122
constant PADDR_PTD_U : integer := 31;
123
constant PADDR_PTD_D : integer := 6;
124
 
125
-- ##############################################################
126
--     3.0 TLBCAM TAG hardware representation (TTG)
127
--
128
type tlbcam_reg is record
129
   ET     : std_logic_vector(1 downto 0);              -- et field 
130
   ACC    : std_logic_vector(2 downto 0);              -- on flush/probe this will become FPTY
131
   M      : std_logic;                                 -- modified
132
   R      : std_logic;                                 -- referenced
133
   SU     : std_logic;                                 -- equal ACC >= 6
134
   VALID  : std_logic;
135
   LVL    : std_logic_vector(1 downto 0);              -- level in pth
136
   I1     : std_logic_vector(7 downto 0);              -- vaddr
137
   I2     : std_logic_vector(5 downto 0);
138
   I3     : std_logic_vector(5 downto 0);
139
   CTX    : std_logic_vector(M_CTX_SZ-1 downto 0);     -- ctx number
140
   PPN    : std_logic_vector(PTE_PPN_S-1 downto 0);    -- physical page number
141
   C      : std_logic;                                 -- cachable
142
end record;
143
 
144
constant tlbcam_reg_none : tlbcam_reg := ("00", "000", '0', '0', '0', '0',
145
        "00", "00000000", "000000", "000000", "00000000", (others => '0'), '0');
146
-- tlbcam_reg::LVL 
147
constant LVL_PAGE    : std_logic_vector(1 downto 0) := "00"; -- equal tlbcam_tfp::TYP FPTY_PAGE
148
constant LVL_SEGMENT : std_logic_vector(1 downto 0) := "01"; -- equal tlbcam_tfp::TYP FPTY_SEGMENT
149
constant LVL_REGION  : std_logic_vector(1 downto 0) := "10"; -- equal tlbcam_tfp::TYP FPTY_REGION
150
constant LVL_CTX     : std_logic_vector(1 downto 0) := "11"; -- equal tlbcam_tfp::TYP FPTY_CTX
151
 
152
-- ##############################################################
153
--     4.0 TLBCAM tag i/o for translation/flush/(probe)
154
--
155
type tlbcam_tfp is record
156
   TYP    : std_logic_vector(2 downto 0);        -- f/(p) type
157
   I1     : std_logic_vector(7 downto 0);        -- vaddr
158
   I2     : std_logic_vector(5 downto 0);
159
   I3     : std_logic_vector(5 downto 0);
160
   CTX    : std_logic_vector(M_CTX_SZ-1 downto 0);  -- ctx number
161
   M      : std_logic;
162
end record;
163
 
164
constant tlbcam_tfp_none : tlbcam_tfp := ("000", "00000000", "000000", "000000", "00000000", '0');
165
 
166
--tlbcam_tfp::TYP
167
constant FPTY_PAGE    : std_logic_vector(2 downto 0) := "000";  -- level 3 PTE  match I1+I2+I3
168
constant FPTY_SEGMENT : std_logic_vector(2 downto 0) := "001";  -- level 2/3 PTE/PTD match I1+I2
169
constant FPTY_REGION  : std_logic_vector(2 downto 0) := "010";  -- level 1/2/3 PTE/PTD match I1
170
constant FPTY_CTX     : std_logic_vector(2 downto 0) := "011";  -- level 0/1/2/3 PTE/PTD ctx
171
constant FPTY_N       : std_logic_vector(2 downto 0) := "100";  -- entire tlb
172
 
173
-- ##############################################################
174
--     5.0 MMU Control Register [sparc V8: p.253,Appx.H,Figure H-10]
175
--
176
--     +-------+-----+------------------+-----+-------+--+--+      
177
--     |  IMPL | VER |        SC        | PSO | resvd |NF|E |      
178
--     +-------+-----+------------------+-----+-------+--+--+
179
--      31  28  27 24 23               8   7   6     2  1  0
180
--      
181
--     MMU Context Pointer [sparc V8: p.254,Appx.H,Figure H-11]                      
182
--     +-------------------------------------------+--------+
183
--     |         Context Table Pointer             |  resvd |      
184
--     +-------------------------------------------+--------+
185
--      31                                        2 1      0                
186
--
187
--     MMU Context Number [sparc V8: p.255,Appx.H,Figure H-12]                                                          
188
--     +----------------------------------------------------+
189
--     |              Context Table Pointer                 |      
190
--     +----------------------------------------------------+
191
--      31                                                 0
192
--      
193
--     fault status/address register [sparc V8: p.256,Appx.H,Table H-13/14] 
194
--     +------------+-----+---+----+----+-----+----+
195
--     |   reserved | EBE | L | AT | FT | FAV | OW |     
196
--     +------------+-----+---+----+----+-----+----+
197
--     31         18 17 10 9 8 7  5 4  2   1    0
198
--
199
--     +----------------------------------------------------+
200
--     |              fault address register                |      
201
--     +----------------------------------------------------+
202
--      31                                                 0                
203
 
204
constant MMCTRL_CTXP_SZ : integer := 30;
205
constant MMCTRL_PTP32_U : integer := 25;
206
constant MMCTRL_PTP32_D : integer := 0;
207
 
208
constant MMCTRL_E  : integer := 0;
209
constant MMCTRL_NF : integer := 1;
210
constant MMCTRL_PSO : integer := 7;
211
constant MMCTRL_SC_U : integer := 23;
212
constant MMCTRL_SC_D : integer := 8;
213
constant MMCTRL_VER_U : integer := 27;
214
constant MMCTRL_VER_D : integer := 24;
215
constant MMCTRL_IMPL_U : integer := 31;
216
constant MMCTRL_IMPL_D : integer := 28;
217
constant MMCTRL_TLBDIS : integer := 31;
218
 
219
constant MMCTXP_U : integer := 31;
220
constant MMCTXP_D : integer := 2;
221
 
222
constant MMCTXNR_U : integer := M_CTX_SZ-1;
223
constant MMCTXNR_D : integer := 0;
224
 
225
constant FS_SZ : integer := 18;  -- fault status size
226
 
227
constant FS_EBE_U : integer := 17;
228
constant FS_EBE_D : integer := 10;
229
 
230
constant FS_L_U : integer := 9;
231
constant FS_L_D : integer := 8;
232
constant FS_L_CTX : std_logic_vector(1 downto 0) := "00";
233
constant FS_L_L1 : std_logic_vector(1 downto 0) := "01";
234
constant FS_L_L2 : std_logic_vector(1 downto 0) := "10";
235
constant FS_L_L3 : std_logic_vector(1 downto 0) := "11";
236
 
237
constant FS_AT_U : integer := 7;
238
constant FS_AT_D : integer := 5;
239
constant FS_AT_LS : natural := 7;       --L=0 S=1
240
constant FS_AT_ID : natural := 6;       --D=0 I=1
241
constant FS_AT_SU : natural := 5;       --U=0 SU=1
242
constant FS_AT_LUDS : std_logic_vector(2 downto 0) := "000";
243
constant FS_AT_LSDS : std_logic_vector(2 downto 0) := "001";
244
constant FS_AT_LUIS : std_logic_vector(2 downto 0) := "010";
245
constant FS_AT_LSIS : std_logic_vector(2 downto 0) := "011";
246
constant FS_AT_SUDS : std_logic_vector(2 downto 0) := "100";
247
constant FS_AT_SSDS : std_logic_vector(2 downto 0) := "101";
248
constant FS_AT_SUIS : std_logic_vector(2 downto 0) := "110";
249
constant FS_AT_SSIS : std_logic_vector(2 downto 0) := "111";
250
 
251
constant FS_FT_U : integer := 4;
252
constant FS_FT_D : integer := 2;
253
constant FS_FT_NONE : std_logic_vector(2 downto 0) := "000";
254
constant FS_FT_INV : std_logic_vector(2 downto 0)  := "001";
255
constant FS_FT_PRO : std_logic_vector(2 downto 0)  := "010";
256
constant FS_FT_PRI : std_logic_vector(2 downto 0)  := "011";
257
constant FS_FT_TRANS : std_logic_vector(2 downto 0):= "110";
258
constant FS_FT_BUS : std_logic_vector(2 downto 0)  := "101";
259
constant FS_FT_INT : std_logic_vector(2 downto 0)  := "110";
260
constant FS_FT_RVD : std_logic_vector(2 downto 0)  := "111";
261
 
262
constant FS_FAV : natural := 1;
263
constant FS_OW : natural := 0;
264
 
265
--# mmu ctrl reg
266
type mmctrl_type1 is record
267
  e       : std_logic;                                  -- enable
268
  nf      : std_logic;                                  -- no fault
269
  pso     : std_logic;                                  -- partial store order
270
--  pre     : std_logic;                            -- pretranslation source
271
--  pri     : std_logic;                            -- i/d priority 
272
  ctx     : std_logic_vector(M_CTX_SZ-1 downto 0);-- context nr
273
  ctxp    : std_logic_vector(MMCTRL_CTXP_SZ-1 downto 0);  -- context table pointer
274
  tlbdis  : std_logic;                            -- tlb disabled
275
  bar     : std_logic_vector(1 downto 0);         -- preplace barrier
276
end record;
277
 
278
--# fault status reg
279
type mmctrl_fs_type is record
280
  ow    : std_logic;
281
  fav   : std_logic;
282
  ft    : std_logic_vector(2 downto 0);            -- fault type
283
  at_ls : std_logic;                              -- access type, load/store
284
  at_id : std_logic;                              -- access type, i/dcache
285
  at_su : std_logic;                              -- access type, su/user
286
  l     : std_logic_vector(1 downto 0);           -- level 
287
  ebe   : std_logic_vector(7 downto 0);
288
end record;
289
 
290
type mmctrl_type2 is record
291
  fs    : mmctrl_fs_type;
292
  valid : std_logic;
293
  fa    : std_logic_vector(VA_I_SZ-1 downto 0);   -- fault address register
294
end record;
295
 
296
-- ##############################################################
297
--     6. Virtual Flush/Probe address [sparc V8: p.249,Appx.H,Figure H-9]
298
--     +---------------------------------------+--------+-------+
299
--     |   VIRTUAL FLUSH&Probe Address (VFPA)  |  type  |  rvd  |      
300
--     +---------------------------------------+--------+-------+  
301
--      31                                   12 11     8 7      0         
302
--     
303
--
304
subtype FPA is natural range  31 downto 12;
305
constant FPA_I1_U : integer := 31;
306
constant FPA_I1_D : integer := 24;
307
constant FPA_I2_U : integer := 23;
308
constant FPA_I2_D : integer := 18;
309
constant FPA_I3_U : integer := 17;
310
constant FPA_I3_D : integer := 12;
311
constant FPTY_U : integer := 10;        -- only 3 bits
312
constant FPTY_D : integer := 8;
313
 
314
-- ##############################################################
315
--     7. control register virtual address [sparc V8: p.253,Appx.H,Table H-5] 
316
--     +---------------------------------+-----+--------+
317
--     |                                 | CNR |  rsvd  |      
318
--     +---------------------------------+-----+--------+  
319
--      31                                10  8 7      0
320
 
321
constant CNR_U        : integer := 10;
322
constant CNR_D        : integer := 8;
323
constant CNR_CTRL     : std_logic_vector(2 downto 0) := "000";
324
constant CNR_CTXP     : std_logic_vector(2 downto 0) := "001";
325
constant CNR_CTX      : std_logic_vector(2 downto 0) := "010";
326
constant CNR_F        : std_logic_vector(2 downto 0) := "011";
327
constant CNR_FADDR    : std_logic_vector(2 downto 0) := "100";
328
 
329
-- ##############################################################
330
--     8. Precise flush (ASI 0x10-14) [sparc V8: p.266,Appx.I]
331
--        supported: ASI_FLUSH_PAGE
332
--                   ASI_FLUSH_CTX
333
 
334
constant PFLUSH_PAGE : std_logic := '0';
335
constant PFLUSH_CTX  : std_logic := '1';
336
 
337
-- ##############################################################
338
--     9. Diagnostic access
339
--        
340
constant DIAGF_LVL_U : integer := 1;
341
constant DIAGF_LVL_D : integer := 0;
342
constant DIAGF_WR    : integer := 3;
343
constant DIAGF_HIT   : integer := 4;
344
constant DIAGF_CTX_U : integer := 12;
345
constant DIAGF_CTX_D : integer := 5;
346
constant DIAGF_VALID : integer := 13;
347
end mmuconfig;
348
 
349
 
350
 

powered by: WebSVN 2.1.0

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