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/] [libmmu.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:     leon3
20
-- File:        leon3.vhd
21
-- Author:      Konrad Eisele, Jiri Gaisler, Gaisler Research
22
-- Description: MMU component declaration
23
------------------------------------------------------------------------------
24
 
25
library ieee;
26
use ieee.std_logic_1164.all;
27
library grlib;
28
use grlib.stdlib.all;
29
library techmap;
30
use techmap.gencomp.all;
31
library gaisler;
32
use gaisler.mmuconfig.all;
33
use gaisler.mmuiface.all;
34
 
35
package libmmu is
36
 
37
  component mmu
38
    generic (
39
      tech      : integer range 0 to NTECH := 0;
40
      itlbnum   : integer range 2 to 64 := 8;
41
      dtlbnum   : integer range 2 to 64 := 8;
42
      tlb_type  : integer range 0 to 3 := 1;
43
      tlb_rep   : integer range 0 to 1 := 0
44
      );
45
    port (
46
      rst  : in std_logic;
47
      clk  : in std_logic;
48
 
49
      mmudci : in  mmudc_in_type;
50
      mmudco : out mmudc_out_type;
51
 
52
      mmuici : in  mmuic_in_type;
53
      mmuico : out mmuic_out_type;
54
 
55
      mcmmo  : in  memory_mm_out_type;
56
      mcmmi  : out memory_mm_in_type
57
    );
58
  end component;
59
 
60
 
61
  function TLB_CreateCamWrite( two_data  : std_logic_vector(31 downto 0);
62
                               read      : std_logic;
63
                               lvl       : std_logic_vector(1 downto 0);
64
                               ctx       : std_logic_vector(M_CTX_SZ-1 downto 0);
65
                               vaddr     : std_logic_vector(31 downto 0)
66
                               ) return tlbcam_reg;
67
 
68
  procedure TLB_CheckFault( ACC        : in  std_logic_vector(2 downto 0);
69
                            isid       : in  mmu_idcache;
70
                            su         : in  std_logic;
71
                            read       : in  std_logic;
72
                            fault_pro  : out std_logic;
73
                            fault_pri  : out std_logic );
74
 
75
  procedure TLB_MergeData( LVL         : in  std_logic_vector(1 downto 0);
76
                           PTE         : in  std_logic_vector(31 downto 0);
77
                           data        : in  std_logic_vector(31 downto 0);
78
                           transdata   : out std_logic_vector(31 downto 0));
79
 
80
  function TLB_CreateCamTrans( vaddr     : std_logic_vector(31 downto 0);
81
                               read      : std_logic;
82
                               ctx       : std_logic_vector(M_CTX_SZ-1 downto 0)
83
                             ) return tlbcam_tfp;
84
 
85
  function TLB_CreateCamFlush( data      : std_logic_vector(31 downto 0);
86
                               ctx       : std_logic_vector(M_CTX_SZ-1 downto 0)
87
                             ) return tlbcam_tfp;
88
 
89
 
90
end;
91
 
92
package body libmmu is
93
 
94
procedure TLB_CheckFault( ACC        : in  std_logic_vector(2 downto 0);
95
                          isid       : in  mmu_idcache;
96
                          su         : in  std_logic;
97
                          read       : in  std_logic;
98
                          fault_pro  : out std_logic;
99
                          fault_pri  : out std_logic ) is
100
variable c_isd    : std_logic;
101
begin
102
  fault_pro := '0';
103
  fault_pri := '0';
104
 
105
  -- use '0' == icache '1' == dcache
106
  if isid = id_icache then
107
    c_isd := '0';
108
  else
109
    c_isd := '1';
110
  end if;
111
  --# fault, todo: should we flush on a fault?
112
  case ACC is
113
    when "000" => fault_pro := (not c_isd) or (not read);
114
    when "001" => fault_pro := (not c_isd);
115
    when "010" => fault_pro := (not read);
116
    when "011" => null;
117
    when "100" => fault_pro := (c_isd);
118
    when "101" => fault_pro := (not c_isd) or ((not read) and (not su));
119
    when "110" => fault_pri := (not su);
120
                  fault_pro := (not read);
121
    when "111" => fault_pri := (not su);
122
    when others => null;
123
  end case;
124
end;
125
 
126
procedure TLB_MergeData( LVL         : in  std_logic_vector(1 downto 0);
127
                         PTE         : in  std_logic_vector(31 downto 0);
128
                         data        : in  std_logic_vector(31 downto 0);
129
                         transdata   : out std_logic_vector(31 downto 0) ) is
130
begin
131
 
132
  --# merge data
133
  transdata := (others => '0');
134
  case LVL is
135
    when LVL_PAGE    => transdata := PTE(PTE_PPN32PAG_U downto PTE_PPN32PAG_D) & data(VA_OFFPAG_U downto VA_OFFPAG_D);
136
    when LVL_SEGMENT => transdata := PTE(PTE_PPN32SEG_U downto PTE_PPN32SEG_D) & data(VA_OFFSEG_U downto VA_OFFSEG_D);
137
    when LVL_REGION  => transdata := PTE(PTE_PPN32REG_U downto PTE_PPN32REG_D) & data(VA_OFFREG_U downto VA_OFFREG_D);
138
    when LVL_CTX     => transdata :=                                             data(VA_OFFCTX_U downto VA_OFFCTX_D);
139
    when others      => transdata := (others => 'X');
140
  end case;
141
end;
142
 
143
function TLB_CreateCamWrite( two_data  : std_logic_vector(31 downto 0);
144
                             read      : std_logic;
145
                             lvl       : std_logic_vector(1 downto 0);
146
                             ctx       : std_logic_vector(M_CTX_SZ-1 downto 0);
147
                             vaddr     : std_logic_vector(31 downto 0)
148
                             ) return tlbcam_reg is
149
variable tlbcam_tagwrite      : tlbcam_reg;
150
begin
151
 
152
    tlbcam_tagwrite.ET    := two_data(PT_ET_U downto PT_ET_D);
153
    tlbcam_tagwrite.ACC   := two_data(PTE_ACC_U downto PTE_ACC_D);
154
    tlbcam_tagwrite.M     := two_data(PTE_M) or (not read); -- tw : p-update modified
155
    tlbcam_tagwrite.R     := '1';
156
    case tlbcam_tagwrite.ACC is      -- tw : p-su ACC >= 6
157
      when "110" | "111" => tlbcam_tagwrite.SU := '1';
158
      when others =>        tlbcam_tagwrite.SU := '0';
159
    end case;
160
    tlbcam_tagwrite.VALID := '1';
161
    tlbcam_tagwrite.LVL   := lvl;
162
    tlbcam_tagwrite.I1    := vaddr(VA_I1_U downto VA_I1_D);
163
    tlbcam_tagwrite.I2    := vaddr(VA_I2_U downto VA_I2_D);
164
    tlbcam_tagwrite.I3    := vaddr(VA_I3_U downto VA_I3_D);
165
    tlbcam_tagwrite.CTX   := ctx;
166
    tlbcam_tagwrite.PPN   := two_data(PTE_PPN_U downto PTE_PPN_D);
167
    tlbcam_tagwrite.C     := two_data(PTE_C);
168
    return tlbcam_tagwrite;
169
end;
170
 
171
function TLB_CreateCamTrans( vaddr     : std_logic_vector(31 downto 0);
172
                             read      : std_logic;
173
                             ctx       : std_logic_vector(M_CTX_SZ-1 downto 0)
174
                             ) return tlbcam_tfp is
175
variable mtag            : tlbcam_tfp;
176
begin
177
    mtag.TYP := (others => '0');
178
    mtag.I1 := vaddr(VA_I1_U downto VA_I1_D);
179
    mtag.I2 := vaddr(VA_I2_U downto VA_I2_D);
180
    mtag.I3 := vaddr(VA_I3_U downto VA_I3_D);
181
    mtag.CTX :=  ctx;
182
    mtag.M :=  not (read);
183
    return mtag;
184
end;
185
 
186
function TLB_CreateCamFlush( data      : std_logic_vector(31 downto 0);
187
                             ctx       : std_logic_vector(M_CTX_SZ-1 downto 0)
188
                             ) return tlbcam_tfp is
189
variable ftag            : tlbcam_tfp;
190
begin
191
    ftag.TYP := data(FPTY_U downto FPTY_D);
192
    ftag.I1  := data(FPA_I1_U downto FPA_I1_D);
193
    ftag.I2  := data(FPA_I2_U downto FPA_I2_D);
194
    ftag.I3  := data(FPA_I3_U downto FPA_I3_D);
195
    ftag.CTX :=  ctx;
196
    ftag.M   := '0';
197
    return ftag;
198
end;
199
 
200
end;
201
 

powered by: WebSVN 2.1.0

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