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

Subversion Repositories core_arm

[/] [core_arm/] [trunk/] [vhdl/] [sparc/] [mmulru.vhd] - Blame information for rev 4

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 work.leon_iface.all;
18
use work.leon_config.all;
19
use work.mmuconfig.all;
20
 
21
entity mmulru is
22
  generic (
23
    entries  : integer := 8
24
    );
25
    port (
26
    rst   : in std_logic;
27
    clk   : in clk_type;
28
    lrui  : in mmulru_in_type;
29
    lruo  : out mmulru_out_type
30
    );
31
end mmulru;
32
 
33
architecture rtl of mmulru is
34
 
35
  constant entries_log : integer := log2(entries);
36
  component mmulrue
37
  generic (
38
    position : integer;
39
    entries  : integer := 8
40
    );
41
  port (
42
    rst      : in std_logic;
43
    clk      : in clk_type;
44
    lruei    : in mmulrue_in_type;
45
    lrueo    : out mmulrue_out_type
46
  );
47
  end component;
48
 
49
  type lru_rtype is record
50
    bar   : std_logic_vector(1 downto 0);
51
    clear : std_logic_vector(M_ENT_MAX-1 downto 0);
52
 
53
    -- pragma translate_off
54
    reinit : std_logic;
55
    pos    : std_logic_vector(entries_log-1 downto 0);
56
    -- pragma translate_on
57
  end record;
58
 
59
  signal c,r   : lru_rtype;
60
  signal lruei : mmulruei_a (entries-1 downto 0);
61
  signal lrueo : mmulrueo_a (entries-1 downto 0);
62
begin
63
 
64
  p0: process (clk, rst, r, c, lrui, lrueo)
65
    variable v : lru_rtype;
66
    variable reinit : std_logic;
67
    variable v_lruei_clk : std_logic;
68
    variable pos : std_logic_vector(entries_log-1 downto 0);
69
    variable touch : std_logic;
70
  begin
71
    v := r;
72
    -- #init
73
    reinit := '0';
74
    v_lruei_clk := rst;
75
 
76
    --# eather element in luri or element 0 to top
77
    pos := lrui.pos(entries_log-1 downto 0);
78
    touch := lrui.touch;
79
    if (lrui.touchmin) = '1' then
80
      pos := lrueo(0).pos(entries_log-1 downto 0);
81
      touch := '1';
82
    end if;
83
    for i in entries-1 downto 0 loop
84
      lruei(i).pos(entries_log-1 downto 0)   <= pos;
85
      lruei(i).touch <= touch;
86
      lruei(i).clear <= r.clear((entries-1)-i);  -- reverse order
87
    end loop;
88
 
89
    lruei(entries-1).fromleft  <= '0';
90
    lruei(entries-1).fromright <= lrueo(entries-2).movetop;
91
    lruei(entries-1).right(entries_log-1 downto 0)     <= lrueo(entries-2).pos(entries_log-1 downto 0);
92
 
93
    for i in entries-2 downto 1 loop
94
      lruei(i).left(entries_log-1 downto 0)      <= lrueo(i+1).pos(entries_log-1 downto 0);
95
      lruei(i).right(entries_log-1 downto 0)     <= lrueo(i-1).pos(entries_log-1 downto 0);
96
      lruei(i).fromleft  <= lrueo(i+1).movetop;
97
      lruei(i).fromright <= lrueo(i-1).movetop;
98
    end loop;
99
 
100
    lruei(0).fromleft <= lrueo(1).movetop;
101
    lruei(0).fromright  <= '0';
102
    lruei(0).left(entries_log-1 downto 0)     <= lrueo(1).pos(entries_log-1 downto 0);
103
 
104
    if not (r.bar = lrui.mmctrl1.bar) then
105
      reinit := '1';
106
    end if;
107
    -- pragma translate_off
108
 
109
    -- pragma translate_on
110
    if (rst) = '0' then
111
       v.bar := lrui.mmctrl1.bar;
112
       reinit := '1';
113
    end if;
114
 
115
    if (reinit) = '1' then
116
      v.bar := lrui.mmctrl1.bar;
117
      v.clear := (others => '0');
118
      case lrui.mmctrl1.bar is
119
        when "01"  =>
120
           v.clear(1 downto 0)  := "11";  -- reverse order
121
        when "10"  =>
122
           v.clear(2 downto 0)  := "111";  -- reverse order
123
        when "11"  =>
124
           v.clear(4 downto 0)  := "11111"; -- reverse order
125
        when others =>
126
           v.clear(0)  := '1';
127
      end case;
128
    end if;
129
 
130
    --# drive signals
131
 
132
    -- pragma translate_off
133
    v.reinit := reinit;
134
    v.pos    := pos;
135
    -- pragma translate_on
136
 
137
    lruo.pos  <= lrueo(0).pos;
138
 
139
    c <= v;
140
 
141
  end process p0;
142
 
143
  p1: process (clk)
144
  begin if rising_edge(clk) then r <= c; end if;
145
  end process p1;
146
 
147
  --# lru entries
148
  lrue0: for i in entries-1 downto 0 generate
149
    l1 : mmulrue
150
      generic map ( position => i,
151
                    entries => entries )
152
      port map (rst, clk, lruei(i), lrueo(i));
153
  end generate lrue0;
154
 
155
end rtl;

powered by: WebSVN 2.1.0

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