source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Victim/Victim_Pseudo_LRU/include/Types.h @ 78

Last change on this file since 78 was 78, checked in by rosiere, 16 years ago

Add :

  • Execute_loop (must be test systemC)
  • Prediction
    • Direction : predifined scheme
    • Branch Target Buffer
  • iFetch_unit
    • ifetch_queue
    • pc management
  • Decod_unit
    • coming soon : support for custom operation
  • Rename_unit
    • RAT
    • Free_list
    • Dependence RAW check
    • Load store unit pointer
  • New Environnement (hierarchy_memory will remove in a next version)


Modif :

  • Manage Custom Operation
  • All component in execute_loop to use the new statistics management

Not Finish :

  • Return Address Stack
  • Environnement
File size: 3.1 KB
Line 
1#ifndef morpheo_behavioural_generic_victim_victim_pseudo_lru_Type_h
2#define morpheo_behavioural_generic_victim_victim_pseudo_lru_Type_h
3
4/*
5 * $Id$
6 *
7 * [ Description ]
8 *
9 */
10
11#include "Behavioural/Generic/Victim/include/Types.h"
12
13namespace morpheo {
14namespace behavioural {
15namespace generic {
16namespace victim {
17namespace victim_pseudo_lru {
18
19  class entry_t
20  {
21    // Numerotation of victim_pseudo_lru's tree
22    // Tree of Pseudo-LRU
23    //
24    // | d2              [3]                 |
25    // |          0_______|_______1          |
26    // |          |               |          |
27    // | d1      [1]             [5]         |
28    // |      0___|___1       0___|___1      |
29    // |      |       |       |       |      |
30    // | d0  [0]     [2]     [4]     [6]     |
31    // |    0_|_1   0_|_1   0_|_1   0_|_1    |
32    // |    |   |   |   |   |   |   |   |    |
33    // |   Way Way Way Way Way Way Way Way   |
34    // |    0   1   2   3   4   5   6   7    |
35    //
36    // Access :  Way N with N=2*n   -> bit 2*n = 0
37    //                 with N=2*n+1 -> bit 2*n = 1
38    //
39    // if bit = B, depth = D, next_B = B+D if B==1
40    //                               = B-D if B==0
41    //
42    // Update :
43
44  private : bool    * _entry;
45  private : uint32_t  _size;
46   
47  public  : entry_t () 
48    {
49    };
50  public  : entry_t (uint32_t size) : _size (size)
51    {
52      _entry = new bool [size];
53     
54      // initialisation
55      for (uint32_t i=0; i<size; i++)
56        _entry [i] = false;
57    }
58   
59  public : ~entry_t ()
60    {
61      delete _entry;
62    }
63   
64  private : uint32_t one_access (uint32_t index, uint32_t offset)
65    {
66      bool val = _entry[index];
67     
68      // Compute next slot
69      if (val == true)
70        return index + offset;
71      else
72        return index - offset;
73    }
74
75  public : uint32_t access ()
76    {
77      uint32_t index = (_size>>1)-1; // middle
78
79      for (int32_t i=static_cast<uint32_t>(log2(_size)-1); i>= 1; i--)
80        {
81          index = one_access (index,(1<<(i-1)));
82        }
83      index = one_access (index,0);
84     
85      // reverse by one_access make always a reverse
86      uint32_t offset = (_entry[index]==true)?1:0; 
87
88      return index+offset;
89    }
90
91  private : uint32_t one_update (uint32_t index, uint32_t offset, uint32_t value)
92    {
93      uint32_t mask = (offset==0)?1:(offset<<1);
94      bool     val  = ((value & mask) != 0);
95
96      // reverse
97      _entry[index] = not val;
98
99      if (val == true)
100      // Compute next slot
101        return index + offset;
102      else
103        return index - offset;
104    }
105  public : void update (uint32_t value)
106    {
107      uint32_t index = (_size>>1)-1; // middle
108
109      for (int32_t i=static_cast<uint32_t>(log2(_size)-1); i>=1; i--)
110        {
111          index = one_update (index,1<<(i-1),value);
112        }
113      index = one_update (index,0,value);
114    }
115
116  public : std::string print ()
117    {
118      std::string res = "";
119
120      for (int32_t i=static_cast<int32_t>(_size)-1; i>=0; i--)
121        res += toString(_entry[i]) + " ";
122
123      return res;
124    }
125  };
126
127}; // end namespace victim_pseudo_lru
128}; // end namespace victim
129}; // end namespace generic
130}; // end namespace behavioural
131}; // end namespace morpheo             
132
133#endif
Note: See TracBrowser for help on using the repository browser.