开发者

CPU Cache implementation in C or C++ or SystemC

I need a very basic C or C++ source code of CPU cache. Google didnt help me find a proper one. The implementation only needs to provide the most fundamental functionality of a cache. For ex, in C++:

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

Does someone know some source code as such?

Thanks!!


my 2 cents: use the strategy pattern so to be able to model different "most fundamental functionality of a cache" ideas. obviously, you already have some kind of implementation. one thing you might consider is looking at your code include cache sizes parameters, to try simulate L1 versus L2 (although it is much more complicate in real life)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜