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/] [mmutlbcam.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
-- Entity:      mmutlbcam
20
-- File:        mmutlbcam.vhd
21
-- Author:      Konrad Eisele, Jiri Gaisler, Gaisler Research
22
-- Description: MMU TLB logic
23
------------------------------------------------------------------------------
24
 
25
library ieee;
26
use ieee.std_logic_1164.all;
27
library grlib;
28
use grlib.amba.all;
29
use grlib.stdlib.all;
30
library gaisler;
31
use gaisler.libiu.all;
32
use gaisler.libcache.all;
33
use gaisler.leon3.all;
34
use gaisler.mmuconfig.all;
35
use gaisler.mmuiface.all;
36
 
37
entity mmutlbcam is
38
  generic (
39
    tlb_type  : integer range 0 to 3 := 1
40
  );
41
  port (
42
      rst     : in std_logic;
43
      clk     : in std_logic;
44
      tlbcami : in mmutlbcam_in_type;
45
      tlbcamo : out mmutlbcam_out_type
46
  );
47
end mmutlbcam;
48
 
49
architecture rtl of mmutlbcam is
50
 
51
  constant M_TLB_FASTWRITE : integer range 0 to 3 := conv_integer(conv_std_logic_vector(tlb_type,2) and conv_std_logic_vector(2,2));   -- fast writebuffer
52
 
53
  type tlbcam_rtype is record
54
    btag     : tlbcam_reg;
55
  end record;
56
  signal r,c : tlbcam_rtype;
57
 
58
begin
59
 
60
  p0: process (rst, r, tlbcami)
61
  variable v : tlbcam_rtype;
62
  variable hm, hf                : std_logic;
63
  variable h_i1, h_i2, h_i3, h_c : std_logic;
64
  variable h_l2, h_l3            : std_logic;
65
  variable h_su_cnt              : std_logic;
66
  variable blvl                  : std_logic_vector(1 downto 0);
67
  variable bet                   : std_logic_vector(1 downto 0);
68
  variable bsu                   : std_logic;
69
  variable blvl_decode           : std_logic_vector(3 downto 0);
70
  variable bet_decode            : std_logic_vector(3 downto 0);
71
  variable ref, modified         : std_logic;
72
  variable tlbcamo_pteout        : std_logic_vector(31 downto 0);
73
  variable tlbcamo_LVL           : std_logic_vector(1 downto 0);
74
  variable tlbcamo_NEEDSYNC      : std_logic;
75
  variable tlbcamo_WBNEEDSYNC    : std_logic;
76
  begin
77
 
78
    v := r;
79
    --#init
80
    h_i1 := '0'; h_i2 := '0'; h_i3 := '0'; h_c := '0';
81
    hm := '0';
82
    hf := r.btag.VALID;
83
 
84
    blvl := r.btag.LVL;
85
    bet  := r.btag.ET;
86
    bsu  := r.btag.SU;
87
    bet_decode  := decode(bet);
88
    blvl_decode  := decode(blvl);
89
    ref := r.btag.R;
90
    modified := r.btag.M;
91
 
92
    tlbcamo_pteout := (others => '0');
93
    tlbcamo_lvl := (others => '0');
94
 
95
    -- prepare tag comparision
96
    if (r.btag.I1  = tlbcami.tagin.I1)  then h_i1 := '1';  else h_i1 := '0'; end if;
97
    if (r.btag.I2  = tlbcami.tagin.I2)  then h_i2 := '1';  else h_i2 := '0'; end if;
98
    if (r.btag.I3  = tlbcami.tagin.I3)  then h_i3 := '1';  else h_i3 := '0'; end if;
99
    if (r.btag.CTX = tlbcami.tagin.CTX) then h_c  := '1';  else h_c  := '0'; end if;
100
 
101
    -- #level 2 hit (segment)
102
    h_l2 := h_i1 and h_i2 ;
103
    -- #level 3 hit (page)
104
    h_l3 := h_i1 and h_i2 and h_i3;
105
    -- # context + su
106
    h_su_cnt := h_c or bsu;
107
 
108
    --# translation (match) op
109
    case blvl is
110
      when LVL_PAGE    => hm := h_l3 and h_c and r.btag.VALID;
111
      when LVL_SEGMENT => hm := h_l2 and h_c and r.btag.VALID;
112
      when LVL_REGION  => hm := h_i1 and h_c and r.btag.VALID;
113
      when LVL_CTX     => hm :=          h_c and r.btag.VALID;
114
      when others      => hm := 'X';
115
    end case;
116
 
117
    --# translation: update ref/mod bit
118
    tlbcamo_NEEDSYNC := '0';
119
    if (tlbcami.trans_op and hm  ) = '1' then
120
      v.btag.R := '1';
121
      v.btag.M := r.btag.M or tlbcami.tagin.M;
122
      tlbcamo_NEEDSYNC := (not r.btag.R) or (tlbcami.tagin.M and (not r.btag.M));  -- cam: ref/modified changed, write back synchronously
123
    end if;
124
    tlbcamo_WBNEEDSYNC := '0';
125
    if ( hm  ) = '1' then
126
      tlbcamo_WBNEEDSYNC := (not r.btag.R) or (tlbcami.tagin.M and (not r.btag.M));  -- cam: ref/modified changed, write back synchronously
127
    end if;
128
 
129
    --# flush operation
130
    -- tlbcam only stores PTEs, tlb does not store PTDs
131
    case tlbcami.tagin.TYP is
132
      when FPTY_PAGE =>                        -- page
133
        hf := hf and h_su_cnt and h_l3 and (blvl_decode(0));  -- only level 3 (page)
134
      when FPTY_SEGMENT =>                     -- segment
135
        hf := hf and h_su_cnt and h_l2 and (blvl_decode(0) or blvl_decode(1));  -- only level 2+3 (segment,page)
136
      when FPTY_REGION =>                      -- region
137
        hf := hf and h_su_cnt and h_i1 and (not blvl_decode(3));  -- only level 1+2+3 (region,segment,page)
138
      when FPTY_CTX =>                         -- context
139
        hf := hf and (h_c and (not bsu));
140
      when FPTY_N  =>                          -- entire
141
      when others =>
142
        hf := '0';
143
    end case;
144
 
145
    --# flush: invalidate on flush hit
146
    --if (tlbcami.flush_op and hf ) = '1' then
147
    if (tlbcami.flush_op  ) = '1' then
148
      v.btag.VALID := '0';
149
    end if;
150
 
151
    --# write op
152
    if ( tlbcami.write_op  = '1' ) then
153
      v.btag := tlbcami.tagwrite;
154
    end if;
155
 
156
    --# reset
157
    if (rst = '0' or tlbcami.mmuen = '0') then
158
      v.btag.VALID := '0';
159
    end if;
160
 
161
    tlbcamo_pteout(PTE_PPN_U downto PTE_PPN_D) := r.btag.PPN;
162
    tlbcamo_pteout(PTE_C) := r.btag.C;
163
    tlbcamo_pteout(PTE_M) := r.btag.M;
164
    tlbcamo_pteout(PTE_R) := r.btag.R;
165
    tlbcamo_pteout(PTE_ACC_U downto PTE_ACC_D) := r.btag.ACC;
166
    tlbcamo_pteout(PT_ET_U downto PT_ET_D) := r.btag.ET;
167
    tlbcamo_LVL(1 downto 0) := r.btag.LVL;
168
 
169
    --# drive signals
170
    tlbcamo.pteout   <= tlbcamo_pteout;
171
    tlbcamo.LVL      <= tlbcamo_LVL;
172
    --tlbcamo.hit      <= (tlbcami.trans_op and hm) or (tlbcami.flush_op and hf);
173
    tlbcamo.hit      <= (hm) or (tlbcami.flush_op and hf);
174
    tlbcamo.ctx      <= r.btag.CTX;       -- for diagnostic only
175
    tlbcamo.valid    <= r.btag.VALID;     -- for diagnostic only
176
    tlbcamo.vaddr    <= r.btag.I1 & r.btag.I2 & r.btag.I3 & "000000000000"; -- for diagnostic only
177
    tlbcamo.NEEDSYNC <= tlbcamo_NEEDSYNC;
178
    tlbcamo.WBNEEDSYNC <= tlbcamo_WBNEEDSYNC;
179
 
180
 
181
    c <= v;
182
  end process p0;
183
 
184
  p1: process (clk, c)
185
  begin if rising_edge(clk) then r <= c; end if;
186
  end process p1;
187
 
188
end rtl;

powered by: WebSVN 2.1.0

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