OpenCores
URL https://opencores.org/ocsvn/core_arm/core_arm/trunk

Subversion Repositories core_arm

[/] [core_arm/] [trunk/] [vhdl/] [sparc/] [mmutlbcam.vhd] - Blame information for rev 5

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tarookumic
----------------------------------------------------------------------------
2
--  This file is a part of the LEON VHDL model
3
--  Copyright (C) 2003  Gaisler Research, all rights reserved
4
--
5
--  This library is free software; you can redistribute it and/or
6
--  modify it under the terms of the GNU Lesser General Public
7
--  License as published by the Free Software Foundation; either
8
--  version 2 of the License, or (at your option) any later version.
9
--
10
--  See the file COPYING.LGPL for the full details of the license.
11
----------------------------------------------------------------------------
12
 
13
-- Konrad Eisele<eiselekd@web.de> ,2002  
14
 
15
library ieee;
16
use ieee.std_logic_1164.all;
17
use IEEE.std_logic_arith.all;
18
use IEEE.std_logic_unsigned."+";
19
use work.leon_iface.all;
20
use work.mmuconfig.all;
21
use work.macro.all;
22
 
23
entity mmutlbcam is
24
  port (
25
      rst     : in std_logic;
26
      clk     : in clk_type;
27
      tlbcami : in mmutlbcam_in_type;
28
      tlbcamo : out mmutlbcam_out_type
29
  );
30
end mmutlbcam;
31
 
32
architecture rtl of mmutlbcam is
33
 
34
  type tlbcam_rtype is record
35
    btag     : tlbcam_reg;
36
  end record;
37
  signal r,c : tlbcam_rtype;
38
 
39
begin
40
 
41
  p0: process (clk, rst, r, tlbcami)
42
  variable v : tlbcam_rtype;
43
  variable hm, hf                : std_logic;
44
  variable h_i1, h_i2, h_i3, h_c : std_logic;
45
  variable h_l2, h_l3            : std_logic;
46
  variable h_su_cnt              : std_logic;
47
  variable blvl                  : std_logic_vector(1 downto 0);
48
  variable bet                   : std_logic_vector(1 downto 0);
49
  variable bsu                   : std_logic;
50
  variable blvl_decode           : std_logic_vector(3 downto 0);
51
  variable bet_decode            : std_logic_vector(3 downto 0);
52
  variable ref, modified         : std_logic;
53
  variable tlbcamo_pteout        : std_logic_vector(31 downto 0);
54
  variable tlbcamo_LVL           : std_logic_vector(1 downto 0);
55
  variable tlbcamo_NEEDSYNC      : std_logic;
56
  begin
57
 
58
    v := r;
59
    --#init
60
    h_i1 := '0'; h_i2 := '0'; h_i3 := '0'; h_c := '0';
61
    hm := '0';
62
    hf := r.btag.VALID;
63
 
64
    blvl := r.btag.LVL;
65
    bet  := r.btag.ET;
66
    bsu  := r.btag.SU;
67
    bet_decode  := decode(bet);
68
    blvl_decode  := decode(blvl);
69
    ref := r.btag.R;
70
    modified := r.btag.M;
71
 
72
    tlbcamo_pteout := (others => '0');
73
    tlbcamo_lvl := (others => '0');
74
 
75
    -- pragma translate_off
76
    if not (is_x(r.btag.I1) or is_x(r.btag.I2) or is_x(r.btag.I3) or is_x(r.btag.CTX) or
77
            is_x(tlbcami.tagin.I1) or is_x(tlbcami.tagin.I2) or is_x(tlbcami.tagin.I3) or is_x(tlbcami.tagin.CTX)) then
78
    -- pragma translate_on
79
    -- prepare tag comparision
80
    if (r.btag.I1  = tlbcami.tagin.I1)  then h_i1 := '1';  else h_i1 := '0'; end if;
81
    if (r.btag.I2  = tlbcami.tagin.I2)  then h_i2 := '1';  else h_i2 := '0'; end if;
82
    if (r.btag.I3  = tlbcami.tagin.I3)  then h_i3 := '1';  else h_i3 := '0'; end if;
83
    if (r.btag.CTX = tlbcami.tagin.CTX) then h_c  := '1';  else h_c  := '0'; end if;
84
    -- pragma translate_off
85
    end if;
86
    -- pragma translate_on
87
 
88
    -- #level 2 hit (segment)
89
    h_l2 := h_i1 and h_i2 ;
90
    -- #level 3 hit (page)
91
    h_l3 := h_i1 and h_i2 and h_i3;
92
    -- # context + su
93
    h_su_cnt := h_c or bsu;
94
 
95
    --# translation (match) op
96
    case blvl is
97
      when LVL_PAGE    => hm := h_l3 and h_c and r.btag.VALID;
98
      when LVL_SEGMENT => hm := h_l2 and h_c and r.btag.VALID;
99
      when LVL_REGION  => hm := h_i1 and h_c and r.btag.VALID;
100
      when LVL_CTX     => hm :=          h_c and r.btag.VALID;
101
      when others      => hm := 'X';
102
    end case;
103
 
104
    --# translation: update ref/mod bit
105
    tlbcamo_NEEDSYNC := '0';
106
    if (tlbcami.trans_op and hm  ) = '1' then
107
      v.btag.R := '1';
108
      v.btag.M := r.btag.M or tlbcami.tagin.M;
109
      tlbcamo_NEEDSYNC := (not r.btag.R) or (tlbcami.tagin.M and (not r.btag.M));  -- cam: ref/modified changed, write back synchronously
110
    end if;
111
 
112
    --# flush operation
113
    -- tlbcam only stores PTEs, tlb does not store PTDs
114
    case tlbcami.tagin.TYP is
115
      when FPTY_PAGE =>                        -- page
116
        hf := hf and h_su_cnt and h_l3 and (blvl_decode(0));  -- only level 3 (page)
117
      when FPTY_SEGMENT =>                     -- segment
118
        hf := hf and h_su_cnt and h_l2 and (blvl_decode(0) or blvl_decode(1));  -- only level 2+3 (segment,page)
119
      when FPTY_REGION =>                      -- region
120
        hf := hf and h_su_cnt and h_i1 and (not blvl_decode(3));  -- only level 1+2+3 (region,segment,page)
121
      when FPTY_CTX =>                         -- context
122
        hf := hf and (h_c and (not bsu));
123
      when FPTY_N  =>                          -- entire
124
      when others =>
125
        hf := '0';
126
    end case;
127
 
128
    --# flush: invalidate on flush hit
129
    --if (tlbcami.flush_op and hf ) = '1' then
130
    if (tlbcami.flush_op  ) = '1' then
131
      v.btag.VALID := '0';
132
    end if;
133
 
134
    --# write op
135
    if ( tlbcami.write_op  = '1' ) then
136
      v.btag := tlbcami.tagwrite;
137
    end if;
138
 
139
    --# reset
140
    if (rst = '0' or tlbcami.mmuen = '0') then
141
      v.btag.VALID := '0';
142
    end if;
143
 
144
    tlbcamo_pteout(PTE_PPN_U downto PTE_PPN_D) := r.btag.PPN;
145
    tlbcamo_pteout(PTE_C) := r.btag.C;
146
    tlbcamo_pteout(PTE_M) := r.btag.M;
147
    tlbcamo_pteout(PTE_R) := r.btag.R;
148
    tlbcamo_pteout(PTE_ACC_U downto PTE_ACC_D) := r.btag.ACC;
149
    tlbcamo_pteout(PT_ET_U downto PT_ET_D) := r.btag.ET;
150
    tlbcamo_LVL(1 downto 0) := r.btag.LVL;
151
 
152
    --# drive signals
153
    tlbcamo.pteout   <= tlbcamo_pteout;
154
    tlbcamo.LVL      <= tlbcamo_LVL;
155
    tlbcamo.hit      <= (tlbcami.trans_op and hm) or (tlbcami.flush_op and hf);
156
    tlbcamo.ctx      <= r.btag.CTX;       -- for diagnostic only
157
    tlbcamo.valid    <= r.btag.VALID;     -- for diagnostic only
158
    tlbcamo.vaddr    <= r.btag.I1 & r.btag.I2 & r.btag.I3 & "000000000000"; -- for diagnostic only
159
    tlbcamo.NEEDSYNC <= tlbcamo_NEEDSYNC;
160
 
161
    --#dump
162
    -- pragma translate_off
163
    -- pragma translate_on
164
 
165
    c <= v;
166
  end process p0;
167
 
168
  p1: process (clk, c)
169
  begin if rising_edge(clk) then r <= c; end if;
170
  end process p1;
171
 
172
end rtl;

powered by: WebSVN 2.1.0

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