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

Subversion Repositories core_arm

[/] [core_arm/] [trunk/] [vhdl/] [mem/] [cache/] [setrepl.vhd] - Blame information for rev 6

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

Line No. Rev Author Line
1 2 tarookumic
-- $(lic)
2
-- $(help_generic)
3
-- $(help_local)
4
 
5
library ieee;
6
use ieee.std_logic_1164.all;
7
use IEEE.std_logic_unsigned.conv_integer;
8
use IEEE.std_logic_arith.conv_unsigned;
9
use work.int.all;
10
use work.cache_config.all;
11
use work.cache_comp.all;
12
 
13
entity setrepl is
14
  generic (
15
    SETSIZE      : integer := 1;
16
    SETSIZE_logx : integer := 1;
17
    SETREPL_TYPE : cfg_repl_type := cfg_repl_rnd
18
  );
19
  port (
20
    rst     : in  std_logic;
21
    clk     : in  std_logic;
22
    setfree : in std_logic_vector(SETSIZE-1 downto 0);
23
    setlock : in std_logic_vector(SETSIZE-1 downto 0);
24
    useset : in std_logic;
25
    locked : out std_logic;
26
    free   : out std_logic;
27
    setrep_free : out std_logic_vector(SETSIZE_logx-1 downto 0);
28
    setrep_repl : out std_logic_vector(SETSIZE_logx-1 downto 0)
29
    );
30
end setrepl;
31
 
32
architecture rtl of setrepl is
33
 
34
  type setrepl_tmp_type is record
35
    locked : std_logic;
36
    free   : std_logic;
37
    setrep_free : integer;
38
    setrep_repl : integer;
39
  end record;
40
  type setrepl_reg_type is record
41
    repl_rnd_cnt      : std_logic_vector(SETSIZE_logx-1 downto 0);
42
  end record;
43
  type setrepl_dbg_type is record
44
     dummy : std_logic;
45
     -- pragma translate_off
46
     dbg : setrepl_tmp_type;
47
     -- pragma translate_on
48
  end record;
49
  signal r, c       : setrepl_reg_type;
50
  signal rdbg, cdbg : setrepl_dbg_type;
51
 
52
  constant GDCL_SET_ZERO : std_logic_vector(SETSIZE-1 downto 0) := (others => '0');
53
  constant GDCL_SET_ONE : std_logic_vector(SETSIZE-1 downto 0) := (others => '1');
54
 
55
begin
56
 
57
  p0: process (clk, rst, r, setfree, setlock, useset )
58
    variable v    : setrepl_reg_type;
59
    variable t    : setrepl_tmp_type;
60
    variable vdbg : setrepl_dbg_type;
61
  begin
62
 
63
    -- $(init(t:setrepl_tmp_type))
64
    v := r;
65
 
66
    t.free := '0';
67
    t.locked := '0';
68
    if SETSIZE = 1 then
69
      t.setrep_repl := 0;
70
    else
71
      t.setrep_repl := lin_convint(r.repl_rnd_cnt);
72
    end if;
73
    t.setrep_free := 0;
74
    if setfree = GDCL_SET_ZERO then
75
      t.free := '0';
76
      if setlock = GDCL_SET_ONE then
77
        t.locked := '1';
78
      else
79
        if setlock(t.setrep_repl) = '1' then
80
L2:       for i in SETSIZE-1 downto 0 loop
81
            if setlock(i) = '1' then
82
              t.setrep_repl := i;
83
              exit L2;
84
            end if;
85
          end loop;  -- i
86
        end if;
87
        if useset = '1' then
88
          lin_incdec(r.repl_rnd_cnt, v.repl_rnd_cnt,'1','1');
89
        end if;
90
      end if;
91
    else
92
      t.free := '1';
93
L1:   for i in SETSIZE-1 downto 0 loop
94
        if setfree(i) = '1' then
95
          t.setrep_free := i;
96
          exit L1;
97
        end if;
98
      end loop;  -- i
99
    end if;
100
 
101
    -- reset
102
    if ( rst = '0' ) then
103
      v.repl_rnd_cnt := (others => '0');
104
    end if;
105
 
106
    c <= v;
107
 
108
    locked <= t.locked;
109
    free <= t.free;
110
    setrep_free <= std_logic_vector(conv_unsigned(t.setrep_free,SETSIZE_logx));
111
    setrep_repl <= std_logic_vector(conv_unsigned(t.setrep_repl,SETSIZE_logx));
112
 
113
    -- pragma translate_off
114
    vdbg := rdbg;
115
    vdbg.dbg := t;
116
    cdbg <= vdbg;
117
    -- pragma translate_on  
118
 
119
  end process p0;
120
 
121
  pregs : process (clk, c)
122
  begin
123
    if rising_edge(clk) then
124
      r <= c;
125
      -- pragma translate_off
126
      rdbg <= cdbg;
127
      -- pragma translate_on
128
    end if;
129
  end process;
130
 
131
end rtl;

powered by: WebSVN 2.1.0

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