source: trunk/IPs/systemC/Environment/Cache/selftest/main.cpp @ 81

Last change on this file since 81 was 81, checked in by rosiere, 16 years ago
  • Finish Environment (and test)
  • Continue predictor_unit
  • Add external tools
  • svn keyword "Id" set
  • Property svn:keywords set to Id
File size: 29.8 KB
Line 
1#include "../include/Cache.h"
2#include <iostream>
3
4using namespace std;
5using namespace environment;
6using namespace environment::cache;
7
8#define TEST(x,y)                                                       \
9  {                                                                     \
10    if (x==y)                                                           \
11      {                                                                 \
12        cout << "Line " << __LINE__ << " : " << "Test OK" << endl;      \
13      }                                                                 \
14    else                                                                \
15      {                                                                 \
16        cout << "Line " << __LINE__ << " : " << "Test KO" << endl;      \
17        exit (EXIT_FAILURE);                                            \
18      }                                                                 \
19  } while (0)
20   
21
22
23#ifdef SYSTEMC
24int sc_main (int argc, char * argv[])
25#else
26int    main (int argc, char * argv[])
27#endif
28{
29  cout << "<main> Begin" << endl;
30
31  {
32    cache_onelevel::Parameters * param = new cache_onelevel::Parameters
33      (
34       4, // nb_port     
35       32, // nb_line     
36       8, // size_line   
37       4,// size_word   
38       4, // associativity
39       2, // hit_latence 
40       3 // miss_penality
41       );
42
43//     cout << *param << endl;
44
45    cache_onelevel::Cache_OneLevel * cache = new cache_onelevel::Cache_OneLevel ("my_cache",param);
46    cache->reset();
47   
48//     cout << *cache << endl;
49   
50    cache->transition();
51    cache->transition();
52
53//     cout << *cache << endl;
54
55    TEST(cache->access(0, 0x100, 0, CACHED, WRITE), MISS);
56    TEST(cache->latence(0), 5);
57    cache->transition(); // miss cycle 1
58
59    TEST(cache->access(0, 0x100, 0, CACHED, WRITE), HIT_WRITE_BUFFER);
60    TEST(cache->latence(0), 4);
61    cache->transition(); // miss cycle 2
62
63    TEST(cache->access(0, 0x100, 0, CACHED, WRITE), HIT_WRITE_BUFFER);
64    TEST(cache->latence(0), 3);
65    cache->transition(); // miss cycle 3
66
67    TEST(cache->access(0, 0x100, 0, CACHED, WRITE), HIT_CACHE); //word 0
68    TEST(cache->latence(0), 2);
69
70    TEST(cache->access(0, 0x104, 0, CACHED, WRITE), HIT_CACHE); //word 1
71    TEST(cache->access(0, 0x108, 0, CACHED, WRITE), HIT_CACHE); //word 2
72    TEST(cache->access(0, 0x10c, 0, CACHED, WRITE), HIT_CACHE); //word 3
73    TEST(cache->access(0, 0x110, 0, CACHED, WRITE), HIT_CACHE); //word 4
74    TEST(cache->access(0, 0x114, 0, CACHED, WRITE), HIT_CACHE); //word 5
75    TEST(cache->access(0, 0x118, 0, CACHED, WRITE), HIT_CACHE); //word 6
76    TEST(cache->access(0, 0x11c, 0, CACHED, WRITE), HIT_CACHE); //word 7
77    TEST(cache->access(0, 0x120, 0, CACHED, WRITE), MISS      );
78    TEST(cache->access(1, 0x140, 0, CACHED, WRITE), MISS      );
79    TEST(cache->access(2, 0x160, 0, CACHED, WRITE), MISS      );
80    TEST(cache->access(3, 0x144, 0, CACHED, WRITE), HIT_BYPASS);
81
82    TEST(cache->latence(0), 5);
83    TEST(cache->latence(1), 5);
84    TEST(cache->latence(2), 5);
85    TEST(cache->latence(3), 5);
86
87    cache->transition(); // miss access   
88    TEST(cache->access(0, 0x180, 0, CACHED, WRITE), MISS      );
89    TEST(cache->access(1, 0x1a0, 0, CACHED, WRITE), MISS      );
90    TEST(cache->access(2, 0x1c0, 0, CACHED, WRITE), MISS      );
91    TEST(cache->access(3, 0x1e0, 0, CACHED, WRITE), MISS      );
92
93    cache->transition(); // miss cycle 1
94//     cout << *cache << endl;
95
96    TEST(cache->access(0, 0x200, 0, CACHED, WRITE), MISS      );
97    TEST(cache->access(1, 0x300, 0, CACHED, WRITE), MISS      );
98    TEST(cache->access(2, 0x400, 0, CACHED, WRITE), MISS      );
99
100    cache->transition(); // miss cycle 0
101    cache->transition(); // miss cycle 1
102    cache->transition(); // miss cycle 2
103    cache->transition(); // miss cycle 3
104//     cout << *cache << endl;
105
106    // line 0 : all way is use
107    TEST(cache->access(0, 0x118, 0,  CACHED, WRITE), HIT_CACHE );
108    TEST(cache->access(1, 0x204, 0,  CACHED, WRITE), HIT_CACHE );
109    TEST(cache->access(2, 0x100, 0,UNCACHED, WRITE), MISS      );
110    TEST(cache->access(3, 0x118, 0,  CACHED, WRITE), HIT_BYPASS);
111
112    TEST(cache->latence(0), 2);
113    TEST(cache->latence(1), 2);
114    TEST(cache->latence(2), 5);
115    TEST(cache->latence(3), 2);
116
117    cache->transition();
118//     cout << *cache << endl;
119   
120    TEST(cache->access(0, 0x500, 0,  CACHED, WRITE), MISS      );
121
122    cache->transition(); // miss cycle 1
123    TEST(cache->access(0, 0x100, 0,  CACHED, WRITE), HIT_CACHE );
124    TEST(cache->access(1, 0x200, 0,  CACHED, WRITE), HIT_CACHE );
125    TEST(cache->access(2, 0x300, 0,  CACHED, WRITE), HIT_CACHE );
126    TEST(cache->access(3, 0x400, 0,  CACHED, WRITE), HIT_CACHE );
127
128    cache->transition(); // miss cycle 2
129
130    TEST(cache->access(0, 0x100, 0,  CACHED, WRITE), HIT_CACHE );
131    TEST(cache->access(1, 0x200, 0,  CACHED, WRITE), HIT_CACHE );
132    TEST(cache->access(2, 0x300, 0,  CACHED, WRITE), HIT_CACHE );
133    TEST(cache->access(3, 0x400, 0,  CACHED, WRITE), HIT_CACHE );
134
135    cache->transition(); // miss cycle 3
136    TEST(cache->access(0, 0x100, 0,  CACHED, WRITE), HIT_CACHE );
137    TEST(cache->access(1, 0x200, 0,  CACHED, WRITE), HIT_CACHE );
138    TEST(cache->access(2, 0x300, 0,  CACHED, WRITE), HIT_CACHE );
139    TEST(cache->access(3, 0x400, 0,  CACHED, WRITE), MISS );
140
141    TEST(cache->latence(0), 2);
142    TEST(cache->latence(1), 2);
143    TEST(cache->latence(2), 2);
144    TEST(cache->latence(3), 5);
145   
146//     cout << *cache << endl;
147
148    delete cache;
149    delete param;
150  }
151
152  {
153    uint32_t * nb_line       = new uint32_t [3];
154    uint32_t * size_line     = new uint32_t [3];
155    uint32_t * size_word     = new uint32_t [3];
156    uint32_t * associativity = new uint32_t [3];
157    uint32_t * hit_latence   = new uint32_t [3];
158    uint32_t * miss_penality = new uint32_t [3];
159
160    nb_line       [0] = 4 ; nb_line       [1] = 4 ; nb_line       [2] = 4 ;
161    size_line     [0] = 8 ; size_line     [1] = 8 ; size_line     [2] = 8 ;
162    size_word     [0] = 4 ; size_word     [1] = 4 ; size_word     [2] = 4 ;
163    associativity [0] = 1 ; associativity [1] = 2 ; associativity [2] = 4 ;
164    hit_latence   [0] = 1 ; hit_latence   [1] = 2 ; hit_latence   [2] = 2 ;
165    miss_penality [0] = 3 ; miss_penality [1] = 5 ; miss_penality [2] = 7 ;
166
167    cache_multilevel::Parameters * param = new cache_multilevel::Parameters
168      (
169       3,  // nb_level
170       4,  // nb_port     
171       nb_line      ,
172       size_line    ,
173       size_word    ,
174       associativity,
175       hit_latence  ,
176       miss_penality
177       );
178
179//     cout << *param << endl;
180 
181    cache_multilevel::Cache_MultiLevel * cache = new cache_multilevel::Cache_MultiLevel ("my_cache",param);
182
183    cache->reset();
184//     cout << *cache << endl;
185 
186    cache_multilevel::Access access;
187
188    access = cache->access (0, 0x100, 0, CACHED, WRITE);
189    cache->update_access(access);
190
191    TEST(access.num_port     , 0);
192    TEST(access.hit          , MISS);
193    TEST(access.latence      , 20);
194    TEST(access.last_nb_level, 2);
195
196    cache->transition(); //19
197    cache->transition(); //18
198    cache->transition(); //17
199    cache->transition(); //16
200    cache->transition(); //15
201    cache->transition(); //14
202    cache->transition(); //13
203    cache->transition(); //12
204    cache->transition(); //11
205    cache->transition(); //10
206//     cout << *cache << endl;
207
208    access = cache->access (0, 0x100, 0, CACHED, WRITE);
209    cache->update_access(access);
210
211    TEST(access.num_port     , 0);
212    TEST(access.hit          , HIT_WRITE_BUFFER);
213    TEST(access.latence      , 10);
214    TEST(access.last_nb_level, 0);
215
216    cache->transition(); // 9
217    cache->transition(); // 8
218    cache->transition(); // 7
219    cache->transition(); // 6
220    cache->transition(); // 5
221    cache->transition(); // 4
222    cache->transition(); // 3
223    cache->transition(); // 2
224
225    access = cache->access (0, 0x100, 0, CACHED, WRITE);
226    cache->update_access(access);
227
228    TEST(access.num_port     , 0);
229    TEST(access.hit          , HIT_WRITE_BUFFER);
230    TEST(access.latence      , 2);
231    TEST(access.last_nb_level, 0);
232
233    cache->transition(); // 1
234
235    access = cache->access (0, 0x100, 0, CACHED, WRITE);
236    cache->update_access(access);
237
238    TEST(access.num_port     , 0);
239    TEST(access.hit          , HIT_CACHE);
240    TEST(access.latence      , 1);
241    TEST(access.last_nb_level, 0);
242//     cout << *cache << endl;
243
244    cache->transition();
245
246    access = cache->access (0, 0x100, 0, CACHED, WRITE);
247    cache->update_access(access);
248
249    TEST(access.num_port     , 0);
250    TEST(access.hit          , HIT_CACHE);
251    TEST(access.latence      , 1);
252    TEST(access.last_nb_level, 0);
253
254
255    access = cache->access (0, 0x100, 0, CACHED, WRITE);
256    cache->update_access(access);
257
258    TEST(access.num_port     , 0);
259    TEST(access.hit          , HIT_CACHE);
260    TEST(access.latence      , 1);
261    TEST(access.last_nb_level, 0);
262
263    access = cache->access (1, 0x200, 0, CACHED, WRITE);
264    cache->update_access(access);
265
266    TEST(access.num_port     , 1);
267    TEST(access.hit          , MISS);
268    TEST(access.latence      , 20);
269    TEST(access.last_nb_level, 2);
270
271    access = cache->access (2, 0x100, 0, CACHED, WRITE);
272    cache->update_access(access);
273
274    TEST(access.num_port     , 2);
275    TEST(access.hit          , HIT_BYPASS);
276    TEST(access.latence      , 1);
277    TEST(access.last_nb_level, 0);
278
279    access = cache->access (3, 0x200, 0, CACHED, WRITE);
280    cache->update_access(access);
281
282    TEST(access.num_port     , 3);
283    TEST(access.hit          , HIT_BYPASS);
284    TEST(access.latence      , 20);
285    TEST(access.last_nb_level, 0);
286
287    cache->transition(); //19
288    cache->transition(); //18
289    cache->transition(); //17
290    cache->transition(); //16
291    cache->transition(); //15
292
293
294//     access = cache->access (1, 0x300, 0, CACHED, WRITE);
295//     cache->update_access(access);
296
297//     TEST(access.num_port     , 1);
298//     TEST(access.hit          , MISS);
299//     TEST(access.latence      , 20);
300//     TEST(access.last_nb_level, 2);
301
302    cache->transition(); //14
303    cache->transition(); //13
304    cache->transition(); //12
305    cache->transition(); //11
306    cache->transition(); //10
307//     cout << *cache << endl;
308
309    access = cache->access (0, 0x100, 0, CACHED, WRITE);
310    cache->update_access(access);
311
312    TEST(access.num_port     , 0);
313    TEST(access.hit          , HIT_CACHE);
314    TEST(access.latence      , 1);
315    TEST(access.last_nb_level, 0);
316
317    access = cache->access (1, 0x200, 0, CACHED, WRITE);
318    cache->update_access(access);
319
320    TEST(access.num_port     , 1);
321    TEST(access.hit          , HIT_WRITE_BUFFER);
322    TEST(access.latence      , 10);
323    TEST(access.last_nb_level, 0);
324
325    access = cache->access (2, 0x100, 0, CACHED, WRITE);
326    cache->update_access(access);
327
328    TEST(access.num_port     , 2);
329    TEST(access.hit          , HIT_BYPASS);
330    TEST(access.latence      , 1);
331    TEST(access.last_nb_level, 0);
332
333    access = cache->access (3, 0x200, 0, CACHED, WRITE);
334    cache->update_access(access);
335
336    TEST(access.num_port     , 3);
337    TEST(access.hit          , HIT_WRITE_BUFFER);
338    TEST(access.latence      , 10);
339    TEST(access.last_nb_level, 0);
340
341    cache->transition(); //9
342
343    access = cache->access (1, 0x400, 0, CACHED, WRITE);
344    cache->update_access(access);
345
346    TEST(access.num_port     , 1);
347    TEST(access.hit          , MISS);
348    TEST(access.latence      , 20);
349    TEST(access.last_nb_level, 2);
350
351    cache->transition(); //8
352    cache->transition(); //7
353    cache->transition(); //6
354    cache->transition(); //5
355    cache->transition(); //4
356    cache->transition(); //3
357    cache->transition(); //2
358    cache->transition(); //1
359    cache->transition(); //0
360
361    access = cache->access (1, 0x100, 0, CACHED, WRITE);
362//     cout << access<< endl;
363   
364    cache->update_access(access);
365
366    TEST(access.num_port     , 1);
367    TEST(access.hit          , HIT_CACHE);
368    TEST(access.latence      , 6 );
369    TEST(access.last_nb_level, 1);
370
371//     cout << *cache << endl;
372    delete cache;
373    delete param;
374    delete [] nb_line      ;
375    delete [] size_line    ;
376    delete [] size_word    ;
377    delete [] associativity;
378    delete [] hit_latence  ;
379    delete [] miss_penality;
380  }
381
382  {
383    uint32_t * cache_shared_nb_line       = new uint32_t [1];
384    uint32_t * cache_shared_size_line     = new uint32_t [1];
385    uint32_t * cache_shared_size_word     = new uint32_t [1];
386    uint32_t * cache_shared_associativity = new uint32_t [1];
387    uint32_t * cache_shared_hit_latence   = new uint32_t [1];
388    uint32_t * cache_shared_miss_penality = new uint32_t [1];
389
390    cache_shared_nb_line       [0] = 8 ;
391    cache_shared_size_line     [0] = 8 ;
392    cache_shared_size_word     [0] = 4 ;
393    cache_shared_associativity [0] = 8 ;
394    cache_shared_hit_latence   [0] = 2 ;
395    cache_shared_miss_penality [0] = 5 ;
396
397    uint32_t  * icache_nb_level      = new uint32_t   [2];
398    uint32_t  * icache_nb_port       = new uint32_t   [2];
399    uint32_t ** icache_nb_line       = new uint32_t * [2];
400    uint32_t ** icache_size_line     = new uint32_t * [2];
401    uint32_t ** icache_size_word     = new uint32_t * [2];
402    uint32_t ** icache_associativity = new uint32_t * [2];
403    uint32_t ** icache_hit_latence   = new uint32_t * [2];
404    uint32_t ** icache_miss_penality = new uint32_t * [2];
405
406    icache_nb_level      [0]    = 1;
407    icache_nb_port       [0]    = 2;
408    icache_nb_line       [0]    = new uint32_t [1];
409    icache_size_line     [0]    = new uint32_t [1];
410    icache_size_word     [0]    = new uint32_t [1];
411    icache_associativity [0]    = new uint32_t [1];
412    icache_hit_latence   [0]    = new uint32_t [1];
413    icache_miss_penality [0]    = new uint32_t [1];
414
415    icache_nb_line       [0][0] = 8;
416    icache_size_line     [0][0] = 8;
417    icache_size_word     [0][0] = 4;
418    icache_associativity [0][0] = 1;
419    icache_hit_latence   [0][0] = 1;
420    icache_miss_penality [0][0] = 3;
421
422    icache_nb_level      [1]    = 2;
423    icache_nb_port       [1]    = 2;
424    icache_nb_line       [1]    = new uint32_t [2];
425    icache_size_line     [1]    = new uint32_t [2];
426    icache_size_word     [1]    = new uint32_t [2];
427    icache_associativity [1]    = new uint32_t [2];
428    icache_hit_latence   [1]    = new uint32_t [2];
429    icache_miss_penality [1]    = new uint32_t [2];
430   
431    icache_nb_line       [1][0] = 4;
432    icache_size_line     [1][0] = 8;
433    icache_size_word     [1][0] = 4;
434    icache_associativity [1][0] = 1;
435    icache_hit_latence   [1][0] = 1;
436    icache_miss_penality [1][0] = 3;
437
438    icache_nb_line       [1][1] = 4;
439    icache_size_line     [1][1] = 8;
440    icache_size_word     [1][1] = 4;
441    icache_associativity [1][1] = 4;
442    icache_hit_latence   [1][1] = 1;
443    icache_miss_penality [1][1] = 4;
444
445    uint32_t  * dcache_nb_level      = new uint32_t   [2];
446    uint32_t  * dcache_nb_port       = new uint32_t   [2];
447    uint32_t ** dcache_nb_line       = new uint32_t * [2];
448    uint32_t ** dcache_size_line     = new uint32_t * [2];
449    uint32_t ** dcache_size_word     = new uint32_t * [2];
450    uint32_t ** dcache_associativity = new uint32_t * [2];
451    uint32_t ** dcache_hit_latence   = new uint32_t * [2];
452    uint32_t ** dcache_miss_penality = new uint32_t * [2];
453
454    dcache_nb_level      [0]    = 1;
455    dcache_nb_port       [0]    = 2;
456    dcache_nb_line       [0]    = new uint32_t [1];
457    dcache_size_line     [0]    = new uint32_t [1];
458    dcache_size_word     [0]    = new uint32_t [1];
459    dcache_associativity [0]    = new uint32_t [1];
460    dcache_hit_latence   [0]    = new uint32_t [1];
461    dcache_miss_penality [0]    = new uint32_t [1];
462
463    dcache_nb_line       [0][0] = 8;
464    dcache_size_line     [0][0] = 8;
465    dcache_size_word     [0][0] = 4;
466    dcache_associativity [0][0] = 1;
467    dcache_hit_latence   [0][0] = 1;
468    dcache_miss_penality [0][0] = 3;
469
470    dcache_nb_level      [1]    = 2;
471    dcache_nb_port       [1]    = 8; // to test
472    dcache_nb_line       [1]    = new uint32_t [2];
473    dcache_size_line     [1]    = new uint32_t [2];
474    dcache_size_word     [1]    = new uint32_t [2];
475    dcache_associativity [1]    = new uint32_t [2];
476    dcache_hit_latence   [1]    = new uint32_t [2];
477    dcache_miss_penality [1]    = new uint32_t [2];
478   
479    dcache_nb_line       [1][0] = 4;
480    dcache_size_line     [1][0] = 8;
481    dcache_size_word     [1][0] = 4;
482    dcache_associativity [1][0] = 1;
483    dcache_hit_latence   [1][0] = 1;
484    dcache_miss_penality [1][0] = 3;
485
486    dcache_nb_line       [1][1] = 4;
487    dcache_size_line     [1][1] = 8;
488    dcache_size_word     [1][1] = 4;
489    dcache_associativity [1][1] = 4;
490    dcache_hit_latence   [1][1] = 1;
491    dcache_miss_penality [1][1] = 4;
492
493    Parameters * param = new Parameters
494      (2,//nb_cache_dedicated
495       
496       icache_nb_level      ,
497       icache_nb_port       ,
498       icache_nb_line       ,
499       icache_size_line     ,
500       icache_size_word     ,
501       icache_associativity ,
502       icache_hit_latence   ,
503       icache_miss_penality ,
504       
505       dcache_nb_level      ,
506       dcache_nb_port       ,
507       dcache_nb_line       ,
508       dcache_size_line     ,
509       dcache_size_word     ,
510       dcache_associativity ,
511       dcache_hit_latence   ,
512       dcache_miss_penality ,
513     
514       1,  // nb_level
515       cache_shared_nb_line      ,
516       cache_shared_size_line    ,
517       cache_shared_size_word    ,
518       cache_shared_associativity,
519       cache_shared_hit_latence  ,
520       cache_shared_miss_penality
521       );
522
523//     cout << *param << endl;
524
525    cache::Cache * cache = new cache::Cache ("my_cache",param);
526
527    cache->reset();
528//     cout << *cache << endl;
529
530    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 16);
531    cache->transition();
532    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 15);
533    cache->transition();
534    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 14);
535    cache->transition();
536    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 13);
537    cache->transition();
538    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 12);
539    cache->transition();
540    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 11);
541    cache->transition();
542    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 10);
543    cache->transition();
544    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  9);
545    cache->transition();
546    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  8);
547    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 16); // miss thread !=
548    TEST(cache->latence (DATA_CACHE, 0, 0, 0x100, 0, CACHED, WRITE),  6); // miss L1, hit L2
549    cache->transition();
550    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  7);
551    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 15);
552    cache->transition();
553    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  6);
554    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 14);
555    cache->transition();
556    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  5);
557    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 13);
558    cache->transition();
559    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  4);
560    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 12);
561    cache->transition();
562    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  3);
563    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 11);
564    cache->transition();
565    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  2);
566    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE), 10);
567    cache->transition();
568    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  1);
569    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE),  9);
570    cache->transition();
571    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  1);
572    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE),  8);
573    cache->transition();
574    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  1);
575    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE),  7);
576    cache->transition();
577    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  1);
578    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE),  6);
579    cache->transition();
580    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  1);
581    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE),  5);
582    cache->transition();
583    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  1);
584    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE),  4);
585    cache->transition();
586    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  1);
587    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE),  3);
588    cache->transition();
589    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  1);
590    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE),  2);
591    cache->transition();
592
593    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  5); // L1 is direct map, hit L2
594    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE),  1); // write in L1
595    TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE), 16);
596    TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 16);
597    cache->transition();
598
599    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  4);
600    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE),  1);
601    TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE), 15);
602    TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 15);
603    cache->transition();
604    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  3);
605    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE),  1);
606    TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE), 14);
607    TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 14);
608    TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE), 16);
609    TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE), 16);
610    cache->transition();
611    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  2);
612    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE),  1);
613    TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE), 13);
614    TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 13);
615    TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE), 15);
616    TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE), 15);
617
618
619    cache->transition();
620    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  1);
621    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE),  5);
622    TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE), 12);
623    TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 12);
624    TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE), 14);
625    TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE), 14);
626
627
628    cache->transition();
629    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  1);
630    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE),  4);
631    TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE), 11);
632    TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 11);
633    TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE), 13);
634    TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE), 13);
635
636    // in cache L2 : context 0,1,2,3
637
638    cache->transition();
639    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  1);
640    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE),  3);
641    TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE), 10);
642    TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 10);
643    TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE), 12);
644    TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE), 12);
645
646    cache->transition();
647    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  1);
648    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE),  2);
649    TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE),  9);
650    TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE),  9);
651    TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE), 11);
652    TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE), 11);
653
654    cache->transition();
655    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  5);
656    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE),  1);
657    TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE),  8);
658    TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE),  8);
659    TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE), 10); // write in L2
660    TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE), 10); // write in L2
661
662    cache->transition();
663    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  4);
664    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE),  1);
665    TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE),  7);
666    TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE),  7);
667    TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE),  9);
668    TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE),  9);
669
670    cache->transition();
671    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  3);
672    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE),  1);
673    TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE),  6);
674    TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE),  6);
675    TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE),  8);
676    TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE),  8);
677
678    cache->transition();
679    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  2);
680    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE),  1);
681    TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE),  5);
682    TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE),  5);
683    TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE),  7);
684    TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE),  7);
685
686    cache->transition();
687    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  1);
688    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE),  5);
689    TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE),  4);
690    TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE),  4);
691    TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE),  6);
692    TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE),  6);
693
694    cache->transition();
695    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  1);
696    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE),  4);
697    TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE),  3);
698    TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE),  3);
699    TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE),  5);
700    TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE),  5);
701
702    cache->transition();
703    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE),  1);
704    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE),  3);
705    TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE),  2);
706    TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE),  2);
707    TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE),  4);
708    TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE),  4);
709
710    cout << *cache << endl;
711
712    cache->transition();
713    // In L2 : context 1,2,4,5 : also context 0 and 3 miss L1 and L2, hit L3
714    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 11);
715    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE),  2);
716    TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE),  1);
717    TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 11);
718    TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE),  3);
719    TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE),  3);
720
721    cache->transition();
722    TEST(cache->latence (DATA_CACHE, 1, 0, 0x100, 0, CACHED, WRITE), 10);
723    TEST(cache->latence (DATA_CACHE, 1, 1, 0x100, 1, CACHED, WRITE),  1);
724    TEST(cache->latence (DATA_CACHE, 1, 2, 0x100, 2, CACHED, WRITE),  5);
725    TEST(cache->latence (DATA_CACHE, 1, 3, 0x100, 3, CACHED, WRITE), 10);
726    TEST(cache->latence (DATA_CACHE, 1, 4, 0x100, 4, CACHED, WRITE),  2);
727    TEST(cache->latence (DATA_CACHE, 1, 5, 0x100, 5, CACHED, WRITE),  2);
728
729// //     cout << *cache << endl;
730
731    delete    cache;
732
733    delete    param;
734    delete [] cache_shared_nb_line      ;
735    delete [] cache_shared_size_line    ;
736    delete [] cache_shared_size_word    ;
737    delete [] cache_shared_associativity;
738    delete [] cache_shared_hit_latence  ;
739    delete [] cache_shared_miss_penality;
740    delete [] icache_nb_level      ;
741    delete [] icache_nb_port       ;
742    delete [] icache_nb_line       [0];
743    delete [] icache_size_line     [0];
744    delete [] icache_size_word     [0];
745    delete [] icache_associativity [0];
746    delete [] icache_hit_latence   [0];
747    delete [] icache_miss_penality [0];
748    delete [] icache_nb_line       [1];
749    delete [] icache_size_line     [1];
750    delete [] icache_size_word     [1];
751    delete [] icache_associativity [1];
752    delete [] icache_hit_latence   [1];
753    delete [] icache_miss_penality [1];
754    delete [] icache_nb_line       ;
755    delete [] icache_size_line     ;
756    delete [] icache_size_word     ;
757    delete [] icache_associativity ;
758    delete [] icache_hit_latence   ;
759    delete [] icache_miss_penality ;
760    delete [] dcache_nb_level      ;
761    delete [] dcache_nb_port       ;
762    delete [] dcache_nb_line       [0];
763    delete [] dcache_size_line     [0];
764    delete [] dcache_size_word     [0];
765    delete [] dcache_associativity [0];
766    delete [] dcache_hit_latence   [0];
767    delete [] dcache_miss_penality [0];
768    delete [] dcache_nb_line       [1];
769    delete [] dcache_size_line     [1];
770    delete [] dcache_size_word     [1];
771    delete [] dcache_associativity [1];
772    delete [] dcache_hit_latence   [1];
773    delete [] dcache_miss_penality [1];
774    delete [] dcache_nb_line       ;
775    delete [] dcache_size_line     ;
776    delete [] dcache_size_word     ;
777    delete [] dcache_associativity ;
778    delete [] dcache_hit_latence   ;
779    delete [] dcache_miss_penality ;
780  }
781
782  cout << "<main> End" << endl;
783 
784  return EXIT_SUCCESS;
785}
Note: See TracBrowser for help on using the repository browser.