source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/src/Parameters.cpp @ 88

Last change on this file since 88 was 88, checked in by rosiere, 16 years ago

Almost complete design
with Test and test platform

  • Property svn:keywords set to Id
File size: 5.1 KB
Line 
1/*
2 * $Id: Parameters.cpp 88 2008-12-10 18:31:39Z rosiere $
3 *
4 * [ Description ]
5 *
6 */
7
8#include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/include/Parameters.h"
9
10namespace morpheo {
11namespace behavioural {
12namespace core {
13namespace multi_front_end {
14namespace front_end {
15namespace prediction_unit {
16namespace direction {
17
18
19#undef  FUNCTION
20#define FUNCTION "Direction::Parameters"
21  Parameters::Parameters (Tpredictor_t predictor_scheme          ,
22                          uint32_t     nb_inst_predict           ,
23                          uint32_t     nb_inst_update            ,
24                          uint32_t     size_address              ,
25                          bool         have_bht               [3],
26                          uint32_t     bht_size_shifter       [3],
27                          uint32_t     bht_nb_shifter         [3],
28                          bool         have_pht               [3],
29                          uint32_t     pht_size_counter       [3],
30                          uint32_t     pht_nb_counter         [3],
31                          uint32_t     pht_size_address_share [3],
32                          bool         is_toplevel)
33  {
34    log_printf(FUNC,Direction,FUNCTION,"Begin");
35
36    _predictor_scheme       = predictor_scheme      ;
37    _nb_inst_predict        = nb_inst_predict       ;
38    _nb_inst_update         = nb_inst_update        ;
39//  _size_address           = size_address          ;
40   
41    for (uint32_t i=0; i<3; i++)
42      {
43        _have_bht               [i] = have_bht               [i];
44        _bht_size_shifter       [i] = bht_size_shifter       [i];
45        _bht_nb_shifter         [i] = bht_nb_shifter         [i];
46        _have_pht               [i] = have_pht               [i];
47        _pht_size_counter       [i] = pht_size_counter       [i];
48        _pht_nb_counter         [i] = pht_nb_counter         [i];
49        _pht_size_address_share [i] = pht_size_address_share [i];
50      }
51
52    switch (predictor_scheme)
53      {
54      case PREDICTOR_NEVER_TAKE  :
55      case PREDICTOR_ALWAYS_TAKE :
56      case PREDICTOR_STATIC      :
57      case PREDICTOR_LAST_TAKE   : 
58        {
59          _have_component_meta_predictor = false;
60
61          for (uint32_t i=0; i<3; i++)
62            {
63              _have_bht [i] = false;
64              _have_pht [i] = false;
65            }
66
67          break;
68        }
69      case PREDICTOR_COUNTER     :
70        {
71          _have_bht [0] = false;
72          _have_pht [0] = true ;
73          for (uint32_t i=1; i<3; i++)
74            {
75              _have_bht [i] = false;
76              _have_pht [i] = false;
77            }
78
79          _have_component_meta_predictor = true;
80          break;
81        }
82      case PREDICTOR_LOCAL       :
83        {
84          _have_bht       [0] = true;
85          _have_pht       [0] = true;
86          _bht_nb_shifter [0] = (_bht_nb_shifter [0]<2)?2:_bht_nb_shifter [0]; // min : 2
87          for (uint32_t i=1; i<3; i++)
88            {
89              _have_bht [i] = false;
90              _have_pht [i] = false;
91            }
92
93          _have_component_meta_predictor = true;
94          break;
95        }
96      case PREDICTOR_GLOBAL      :
97        {
98         
99          _have_bht       [0] = true;
100          _have_pht       [0] = true;
101          _bht_nb_shifter [0] = 1; // one global shifter
102          for (uint32_t i=1; i<3; i++)
103            {
104              _have_bht [i] = false;
105              _have_pht [i] = false;
106            }
107
108          _have_component_meta_predictor = true;
109          break;
110        }
111      case PREDICTOR_META        :
112        {
113          // predictor_0 = global
114          // predictor_1 = local
115          // predictor_2 = counter : select between predictor_0 and predictor_1
116          _have_bht       [0] = true;
117          _have_pht       [0] = true;
118          _bht_nb_shifter [0] = (_bht_nb_shifter [0]<2)?2:_bht_nb_shifter [0]; // min : 2
119          _have_bht       [1] = true;
120          _have_pht       [1] = true;
121          _bht_nb_shifter [1] = 1; // one global shifter
122          _have_bht       [2] = false;
123          _have_pht       [2] = true;
124
125          _have_component_meta_predictor = true;
126          break;
127        }
128      case PREDICTOR_CUSTOM      :
129        {
130          // keep user define
131          _have_component_meta_predictor = true;
132          break;
133        }
134      }
135
136    _size_history = 0;
137   
138    for (uint32_t i=0; i<3; i++)
139      _size_history += (((_have_bht [i])?_bht_size_shifter [i]:0) + 
140                        ((_have_pht [i])?_pht_size_counter [i]:0));
141   
142    _have_port_history = (_size_history > 0);
143
144    test();
145
146    _param_glue = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction::direction_glue::Parameters
147      (_predictor_scheme,
148       _nb_inst_predict ,
149       _nb_inst_update  ,
150        size_address    ,
151       _size_history    );
152
153    if (is_toplevel)
154      {
155        _size_instruction_address = size_address;
156
157        copy ();
158      }
159   
160    log_printf(FUNC,Direction,FUNCTION,"End");
161  };
162 
163// #undef  FUNCTION
164// #define FUNCTION "Direction::Parameters (copy)"
165//   Parameters::Parameters (Parameters & param)
166//   {
167//     log_printf(FUNC,Direction,FUNCTION,"Begin");
168//     test();
169//     log_printf(FUNC,Direction,FUNCTION,"End");
170//   };
171
172#undef  FUNCTION
173#define FUNCTION "Direction::~Parameters"
174  Parameters::~Parameters () 
175  {
176    log_printf(FUNC,Direction,FUNCTION,"Begin");
177
178    delete _param_glue;
179    log_printf(FUNC,Direction,FUNCTION,"End");
180  };
181
182#undef  FUNCTION
183#define FUNCTION "Direction::copy"
184  void Parameters::copy (void) 
185  {
186    log_printf(FUNC,Direction,FUNCTION,"Begin");
187
188    COPY(_param_glue);
189
190    log_printf(FUNC,Direction,FUNCTION,"End");
191  };
192
193}; // end namespace direction
194}; // end namespace prediction_unit
195}; // end namespace front_end
196}; // end namespace multi_front_end
197}; // end namespace core
198
199}; // end namespace behavioural
200}; // end namespace morpheo             
Note: See TracBrowser for help on using the repository browser.