source: trunk/IPs/systemC/Environment/Cache/include/Cache_OneLevel_Parameters.h @ 143

Last change on this file since 143 was 143, checked in by rosiere, 14 years ago

1) change environment.sh
2) add lot of include

  • Property svn:keywords set to Id
File size: 3.1 KB
Line 
1#ifndef ENVIRONMENT_CACHE_CACHE_ONELEVEL_PARAMETERS_H
2#define ENVIRONMENT_CACHE_CACHE_ONELEVEL_PARAMETERS_H
3
4#include <iostream>
5#include <sstream>
6#include <math.h>
7#include <stdint.h>
8#include <stdlib.h>
9
10namespace environment {
11namespace cache {
12namespace cache_onelevel {
13
14  class Parameters
15  {
16  public : uint32_t nb_port      ;
17  public : uint32_t nb_line      ;
18  public : uint32_t size_line    ;
19  public : uint32_t size_word    ;
20  public : uint32_t associativity;
21  public : uint32_t hit_latence  ;
22  public : uint32_t miss_penality;
23   
24  public : Parameters (uint32_t nb_port      ,
25                       uint32_t nb_line      ,
26                       uint32_t size_line    ,
27                       uint32_t size_word    ,
28                       uint32_t associativity,
29                       uint32_t hit_latence  ,
30                       uint32_t miss_penality)
31    {
32      this->nb_port       = nb_port      ;
33      this->nb_line       = nb_line      ;
34      this->size_line     = size_line    ;
35      this->size_word     = size_word    ;
36      this->associativity = associativity;
37      this->hit_latence   = hit_latence  ;
38      this->miss_penality = miss_penality;
39
40      if ((nb_line * size_line * associativity) == 0)
41        {
42          std::cerr << "{Cache_OneLevel} all parameter must be greater that 0" << std::endl;
43          exit(1);
44        }
45      if ((nb_line % associativity) != 0)
46        {
47          std::cerr << "{Cache_OneLevel} nb_line must be a mutiple of associativity" << std::endl;
48          exit(1);
49        }
50     
51      if ((double)nb_line    != ::pow(2,::log2(nb_line)))
52        {
53          std::cerr << "{Cache_OneLevel} nb_line must be a mutiple of 2^n" << std::endl;
54          exit(1);
55        }
56     
57      if ((double)size_line != ::pow(2,::log2(size_line)))
58        {
59          std::cerr << "{Cache_OneLevel} size_line must be a mutiple of 2^n" << std::endl;
60          exit(1);
61        }
62     
63      if ((double)size_word != ::pow(2,::log2(size_word)))
64        {
65          std::cerr << "{Cache_OneLevel} size_word must be a mutiple of 2^n" << std::endl;
66          exit(1);
67        }
68    }
69
70  public : std::string print (uint32_t depth)
71    {
72      std::string tab (depth,'\t');
73      std::stringstream str;
74
75      str << tab << "* Capacity              : " << (nb_line * size_line * size_word) << " bytes" << std::endl
76          << tab << "  * Nb line             : " << nb_line       << std::endl
77          << tab << "  * Size line           : " << size_line     << std::endl
78          << tab << "  * Size word (in byte) : " << size_word     << std::endl
79          << tab << "* Timing                : " << std::endl
80          << tab << "  * Hit  latence        : " << hit_latence   << std::endl
81          << tab << "  * Miss penality       : " << miss_penality << std::endl
82          << tab << "* Other                 : " << std::endl
83          << tab << "  * Associativity       : " << associativity << std::endl
84          << tab << "  * Nb port             : " << nb_port       << std::endl;
85
86      if (associativity == 1)
87        str << tab << "  * Cache Direct Map";
88      else
89        if (associativity == nb_line)
90          str << tab << "  * Cache Full Associative";
91        else
92          str << tab << "  * Cache Semi Associative";
93      return str.str();
94    }
95   
96   
97    friend std::ostream& operator<< (std::ostream& output, Parameters &x)
98    {
99      output << x.print(0);
100      return output;
101    }
102  };
103
104};
105};
106};
107#endif
Note: See TracBrowser for help on using the repository browser.