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/] [mmulru.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:      mmulru
20
-- File:        mmulru.vhd
21
-- Author:      Konrad Eisele, Jiri Gaisler, Gaisler Research
22
-- Description: MMU LRU 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 mmulru is
38
  generic (
39
    entries  : integer := 8
40
    );
41
    port (
42
    rst   : in std_logic;
43
    clk   : in std_logic;
44
    lrui  : in mmulru_in_type;
45
    lruo  : out mmulru_out_type
46
    );
47
end mmulru;
48
 
49
architecture rtl of mmulru is
50
 
51
  constant entries_log : integer := log2(entries);
52
  component mmulrue
53
  generic (
54
    position : integer;
55
    entries  : integer := 8
56
    );
57
  port (
58
    rst      : in std_logic;
59
    clk      : in std_logic;
60
    lruei    : in mmulrue_in_type;
61
    lrueo    : out mmulrue_out_type
62
  );
63
  end component;
64
 
65
  type lru_rtype is record
66
    bar   : std_logic_vector(1 downto 0);
67
    clear : std_logic_vector(M_ENT_MAX-1 downto 0);
68
 
69
    -- pragma translate_off
70
    reinit : std_logic;
71
    pos    : std_logic_vector(entries_log-1 downto 0);
72
    -- pragma translate_on
73
  end record;
74
 
75
  signal c,r   : lru_rtype;
76
  signal lruei : mmulruei_a (entries-1 downto 0);
77
  signal lrueo : mmulrueo_a (entries-1 downto 0);
78
begin
79
 
80
  p0: process (rst, r, c, lrui, lrueo)
81
    variable v : lru_rtype;
82
    variable reinit : std_logic;
83
    variable v_lruei_clk : std_logic;
84
    variable pos : std_logic_vector(entries_log-1 downto 0);
85
    variable touch : std_logic;
86
  begin
87
    v := r;
88
    -- #init
89
    reinit := '0';
90
    v_lruei_clk := rst;
91
 
92
    --# eather element in luri or element 0 to top
93
    pos := lrui.pos(entries_log-1 downto 0);
94
    touch := lrui.touch;
95
    if (lrui.touchmin) = '1' then
96
      pos := lrueo(0).pos(entries_log-1 downto 0);
97
      touch := '1';
98
    end if;
99
    for i in entries-1 downto 0 loop
100
      lruei(i).pos <= (others => '0');  -- this is really ugly ...
101
      lruei(i).left <= (others => '0');
102
      lruei(i).right <= (others => '0');
103
      lruei(i).pos(entries_log-1 downto 0)   <= pos;
104
      lruei(i).touch <= touch;
105
      lruei(i).clear <= r.clear((entries-1)-i);  -- reverse order
106
      lruei(i).flush <= lrui.flush;
107
    end loop;
108
 
109
    lruei(entries-1).fromleft  <= '0';
110
    lruei(entries-1).fromright <= lrueo(entries-2).movetop;
111
    lruei(entries-1).right(entries_log-1 downto 0)     <= lrueo(entries-2).pos(entries_log-1 downto 0);
112
 
113
    for i in entries-2 downto 1 loop
114
      lruei(i).left(entries_log-1 downto 0)      <= lrueo(i+1).pos(entries_log-1 downto 0);
115
      lruei(i).right(entries_log-1 downto 0)     <= lrueo(i-1).pos(entries_log-1 downto 0);
116
      lruei(i).fromleft  <= lrueo(i+1).movetop;
117
      lruei(i).fromright <= lrueo(i-1).movetop;
118
    end loop;
119
 
120
    lruei(0).fromleft <= lrueo(1).movetop;
121
    lruei(0).fromright  <= '0';
122
    lruei(0).left(entries_log-1 downto 0)     <= lrueo(1).pos(entries_log-1 downto 0);
123
 
124
    if not (r.bar = lrui.mmctrl1.bar) then
125
      reinit := '1';
126
    end if;
127
    -- pragma translate_off
128
 
129
    -- pragma translate_on
130
    if (rst) = '0' then
131
       v.bar := lrui.mmctrl1.bar;
132
       reinit := '1';
133
    end if;
134
 
135
    if (reinit) = '1' then
136
      v.bar := lrui.mmctrl1.bar;
137
      v.clear := (others => '0');
138
      case lrui.mmctrl1.bar is
139
        when "01"  =>
140
           v.clear(1 downto 0)  := "11";  -- reverse order
141
        when "10"  =>
142
           v.clear(2 downto 0)  := "111";  -- reverse order
143
        when "11"  =>
144
           v.clear(4 downto 0)  := "11111"; -- reverse order
145
        when others =>
146
           v.clear(0)  := '1';
147
      end case;
148
    end if;
149
 
150
    --# drive signals
151
 
152
    -- pragma translate_off
153
    v.reinit := reinit;
154
    v.pos    := pos;
155
    -- pragma translate_on
156
 
157
    lruo.pos  <= lrueo(0).pos;
158
 
159
    c <= v;
160
 
161
  end process p0;
162
 
163
  p1: process (clk)
164
  begin if rising_edge(clk) then r <= c; end if;
165
  end process p1;
166
 
167
  --# lru entries
168
  lrue0: for i in entries-1 downto 0 generate
169
    l1 : mmulrue
170
      generic map ( position => i,
171
                    entries => entries )
172
      port map (rst, clk, lruei(i), lrueo(i));
173
  end generate lrue0;
174
 
175
end rtl;

powered by: WebSVN 2.1.0

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