source:
trunk/src/cache_store.h
@
8
Last change on this file since 8 was 5, checked in by , 16 years ago | |
---|---|
File size: 1.9 KB |
Line | |
---|---|
1 | #ifndef CACHE_STORE_H |
2 | #define CACHE_STORE_H |
3 | #include <list> |
4 | #include "address.h" |
5 | |
6 | using namespace std; |
7 | |
8 | typedef enum associativity { |
9 | FULLY_ASSOCIATIVE = 0, |
10 | DIRECT_MAPPING = 1, |
11 | WAY_2 = 2, |
12 | WAY_4 = 4, |
13 | WAY_8 = 8 |
14 | } t_assoc; |
15 | |
16 | class CacheStore { |
17 | |
18 | private: |
19 | unsigned int cache_size; |
20 | unsigned int line_width; |
21 | t_assoc associativity; |
22 | unsigned int num_lines; |
23 | unsigned int num_sets; |
24 | |
25 | // loaded cache lines : stores |
26 | list<int> *cache_lines; |
27 | |
28 | public: |
29 | CacheStore( int cache_size, |
30 | int line_width, |
31 | t_assoc associativity ) { |
32 | |
33 | // attributes initialization |
34 | this->cache_size = cache_size; |
35 | this->line_width = line_width; |
36 | this->associativity = associativity; |
37 | |
38 | this->num_lines = cache_size / line_width; |
39 | if (associativity != FULLY_ASSOCIATIVE) |
40 | this->num_sets = num_lines / associativity; |
41 | else |
42 | this->num_sets = 1; |
43 | this->cache_lines = new list<int>[num_sets]; |
44 | |
45 | // cache lines array initialization |
46 | for (unsigned int i=0; i < num_sets; i++) { |
47 | cache_lines[i] = list<int>(); |
48 | } |
49 | |
50 | // Print parameters |
51 | cout << ">>> parameters:" << endl; |
52 | cout << " cache_size = " << cache_size << endl; |
53 | cout << " line_width = " << line_width << endl; |
54 | cout << " associativity = " << associativity << endl; |
55 | cout << " number of lines = " << num_lines << endl << endl; |
56 | } |
57 | |
58 | //bool is_loaded(list<int> *lines, int line); |
59 | bool is_loaded(Address address); |
60 | |
61 | //void do_load(list<int> *lines, int line); |
62 | void do_load(Address address); |
63 | |
64 | int get_line_width(); |
65 | |
66 | ~CacheStore() { |
67 | delete [] cache_lines; |
68 | } |
69 | }; |
70 | |
71 | #endif |
Note: See TracBrowser
for help on using the repository browser.