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

Last change on this file since 131 was 131, checked in by rosiere, 15 years ago

1) add constant method
2) test with systemc 2.2.0

  • Property svn:keywords set to Id
File size: 7.1 KB
Line 
1/*
2 * $Id: Direction_Glue.cpp 131 2009-07-08 18:40:08Z rosiere $
3 *
4 * [ Description ]
5 *
6 */
7
8#include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Direction_Glue/include/Direction_Glue.h"
9
10namespace morpheo                    {
11namespace behavioural {
12namespace core {
13namespace multi_front_end {
14namespace front_end {
15namespace prediction_unit {
16namespace direction {
17namespace direction_glue {
18
19
20#undef  FUNCTION
21#define FUNCTION "Direction_Glue::Direction_Glue"
22  Direction_Glue::Direction_Glue
23  (
24#ifdef SYSTEMC
25   sc_module_name name,
26#else
27   string name,
28#endif
29#ifdef STATISTICS
30   morpheo::behavioural::Parameters_Statistics * param_statistics,
31#endif
32   morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction::direction_glue::Parameters * param,
33   morpheo::behavioural::Tusage_t usage
34   ):
35    _name              (name)
36    ,_param            (param)
37    ,_usage            (usage)
38  {
39    log_printf(FUNC,Direction_Glue,FUNCTION,"Begin");
40
41
42// #if DEBUG_Direction_Glue == true
43//     log_printf(INFO,Direction_Glue,FUNCTION,_("<%s> Parameters"),_name.c_str());
44
45//     std::cout << *param << std::endl;
46// #endif   
47
48    log_printf(INFO,Direction_Glue,FUNCTION,"Allocation");
49
50    allocation (
51#ifdef STATISTICS
52                param_statistics
53#endif
54                );
55
56#ifdef STATISTICS
57    if (usage_is_set(_usage,USE_STATISTICS))
58      { 
59        log_printf(INFO,Direction_Glue,FUNCTION,"Allocation of statistics");
60
61        statistics_allocation(param_statistics);
62      }
63#endif
64
65#ifdef VHDL
66    if (usage_is_set(_usage,USE_VHDL))
67      {
68        // generate the vhdl
69        log_printf(INFO,Direction_Glue,FUNCTION,"Generate the vhdl");
70       
71        vhdl();
72      }
73#endif
74
75#ifdef SYSTEMC
76    if (usage_is_set(_usage,USE_SYSTEMC))
77      {
78        bool need_genmealy_predict = true;
79        bool need_genmealy_update  = true;
80
81        // Constant
82        if (not _param->_have_component_meta_predictor)
83          {
84            // no need update
85            need_genmealy_update = false;
86
87            // always ack
88            for (uint32_t i=0; i<_param->_nb_inst_predict; i++)
89              {
90                // constant direction : never / always
91                switch (_param->_predictor_scheme)
92                  {
93                  case PREDICTOR_NEVER_TAKE  :
94                    {
95                      need_genmealy_predict = false;
96                      break;
97                    }
98                  case PREDICTOR_ALWAYS_TAKE :
99                    {
100                      need_genmealy_predict = false;
101                      break;
102                    }
103                  default : break;
104                  }
105              }
106          }
107
108#ifdef SYSTEMCASS_SPECIFIC
109        constant();
110#else
111        log_printf(INFO,Direction_Glue,FUNCTION,"Method - constant");
112       
113        SC_METHOD (constant);
114//      dont_initialize ();
115       
116#  ifdef SYSTEMCASS_SPECIFIC
117        // List dependency information
118#  endif   
119#endif
120
121# if defined(STATISTICS) or defined(VHDL_TESTBENCH)
122        log_printf(INFO,Direction_Glue,FUNCTION,"Method - transition");
123       
124        SC_METHOD (transition);
125        dont_initialize ();
126        sensitive << (*(in_CLOCK)).pos();
127       
128#  ifdef SYSTEMCASS_SPECIFIC
129        // List dependency information
130#  endif   
131# endif
132
133        if (need_genmealy_predict)
134          {
135            log_printf(INFO,Direction_Glue,FUNCTION,"Method - genMealy_predict");
136           
137            SC_METHOD (genMealy_predict);
138            dont_initialize ();
139//          sensitive << (*(in_CLOCK)).neg(); // don't use internal register
140            for (uint32_t i=0; i<_param->_nb_inst_predict; i++)
141              {
142                switch (_param->_predictor_scheme)
143                  {
144                  case PREDICTOR_STATIC      :
145                    {
146                      sensitive << (*(in_PREDICT_STATIC               [i]));
147                      break;
148                    }
149                  case PREDICTOR_LAST_TAKE   :
150                    {
151                      sensitive << (*(in_PREDICT_LAST_TAKE            [i]));
152                      break;
153                    }
154                  case PREDICTOR_COUNTER     :
155                  case PREDICTOR_LOCAL       :
156                  case PREDICTOR_GLOBAL      :
157                  case PREDICTOR_META        :
158                  case PREDICTOR_CUSTOM      :
159                    {
160                      sensitive << (*(in_PREDICT_VAL                  [i]))
161                                << (*(in_PREDICT_ADDRESS_SRC          [i]))
162                                << (*(in_PREDICT_PREDICTOR_ACK        [i]))
163                                << (*(in_PREDICT_PREDICTOR_HISTORY    [i]))
164                                << (*(in_PREDICT_PREDICTOR_DIRECTION  [i]));
165                      break;
166                    }
167                  default :
168                    {
169                      break;
170                    }
171                  }
172              }
173
174#  ifdef SYSTEMCASS_SPECIFIC
175//          // List dependency information
176//          for (uint32_t i=0; i<_param->_nb_inst_predict; i++)
177//            {
178
179//              switch (_param->_predictor_scheme)
180//                {
181//                case PREDICTOR_STATIC      :
182//                  {
183//                    (*(out_PREDICT_DIRECTION             [i])) (*(in_PREDICT_STATIC               [i]));
184
185//                    break;
186//                  }
187//                case PREDICTOR_LAST_TAKE   :
188//                  {
189//                    (*(out_PREDICT_DIRECTION             [i])) (*(in_PREDICT_LAST_TAKE            [i]));
190
191//                    break;
192//                  }
193//                case PREDICTOR_COUNTER     :
194//                case PREDICTOR_LOCAL       :
195//                case PREDICTOR_GLOBAL      :
196//                case PREDICTOR_META        :
197//                case PREDICTOR_CUSTOM      :
198//                  {
199//                    (*(out_PREDICT_ACK                   [i])) (*(in_PREDICT_PREDICTOR_ACK        [i]));
200//                    (*(out_PREDICT_HISTORY               [i])) (*(in_PREDICT_PREDICTOR_HISTORY    [i]));
201//                    (*(out_PREDICT_DIRECTION             [i])) (*(in_PREDICT_PREDICTOR_DIRECTION  [i]));
202//                    (*(out_PREDICT_PREDICTOR_VAL         [i])) (*(in_PREDICT_VAL                  [i]));
203//                    (*(out_PREDICT_PREDICTOR_ADDRESS_SRC [i])) (*(in_PREDICT_ADDRESS_SRC          [i]));
204
205//                    break;
206//                  }
207//                default :
208//                  {
209//                    break;
210//                  }
211//                }
212//            }
213#  endif   
214          }
215
216        if (need_genmealy_update)
217          {
218            log_printf(INFO,Direction_Glue,FUNCTION,"Method - genMealy_update");
219           
220            SC_METHOD (genMealy_update);
221            dont_initialize ();
222//          sensitive << (*(in_CLOCK)).neg(); // don't use internal register
223            for (uint32_t i=0; i<_param->_nb_inst_update; i++)
224              sensitive << (*(in_UPDATE_VAL               [i]))
225                        << (*(in_UPDATE_PREDICTOR_ACK     [i]))
226                        << (*(in_UPDATE_ADDRESS           [i]))
227                        << (*(in_UPDATE_HISTORY           [i]))
228                        << (*(in_UPDATE_DIRECTION         [i]))
229                        << (*(in_UPDATE_PREDICTION_IFETCH [i]))
230                ;
231
232#  ifdef SYSTEMCASS_SPECIFIC
233//          // List dependency information
234//          for (uint32_t i=0; i<_param->_nb_inst_update; i++)
235//            {
236//              (*(out_UPDATE_PREDICTOR_VAL       [i])) (*(in_UPDATE_VAL           [i]));
237//              (*(out_UPDATE_ACK                 [i])) (*(in_UPDATE_PREDICTOR_ACK [i]));
238//              (*(out_UPDATE_PREDICTOR_ADDRESS   [i])) (*(in_UPDATE_ADDRESS       [i]));
239//              (*(out_UPDATE_PREDICTOR_HISTORY   [i])) (*(in_UPDATE_HISTORY       [i]));
240//              (*(out_UPDATE_PREDICTOR_DIRECTION [i])) (*(in_UPDATE_DIRECTION     [i]));
241//            }
242#  endif   
243          }
244#endif
245      }
246    log_printf(FUNC,Direction_Glue,FUNCTION,"End");
247  };
248   
249#undef  FUNCTION
250#define FUNCTION "Direction_Glue::~Direction_Glue"
251  Direction_Glue::~Direction_Glue (void)
252  {
253    log_printf(FUNC,Direction_Glue,FUNCTION,"Begin");
254
255#ifdef STATISTICS
256    if (usage_is_set(_usage,USE_STATISTICS))
257      {
258        statistics_deallocation();
259      }
260#endif
261
262    log_printf(INFO,Direction_Glue,FUNCTION,"Deallocation");
263    deallocation ();
264
265    log_printf(FUNC,Direction_Glue,FUNCTION,"End");
266  };
267
268}; // end namespace direction_glue
269}; // end namespace direction
270}; // end namespace prediction_unit
271}; // end namespace front_end
272}; // end namespace multi_front_end
273}; // end namespace core
274
275}; // end namespace behavioural
276}; // end namespace morpheo             
Note: See TracBrowser for help on using the repository browser.