Implementation of CPU Cache in C or C ++ or SystemC

I need very simple C or C ++ source code for the processor cache. Google did not help me find the right one. Implementation should provide only the most fundamental functions of the cache. For example, in C ++:

class Cache{
  ... //parameter setup of way, capacity, etc
  public: access(addr){
             miss=inspect(addr);
             if(miss){ fetch_mem(addr); replace_policy...;}
             else{...}              
           }
 ...
};

Does anyone know some kind of source code as such?

Thank!!

+3
source share
1 answer

my 2 cents: use a strategy template to be able to model different ideas of the "most fundamental cache functionality." obviously you already have some kind of implementation. one thing you can consider is to look at your code, including cache size options, try to simulate L1 compared to L2 (although in real life it is much more complicated)

+1
source

Source: https://habr.com/ru/post/1786273/


All Articles