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

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

1) Stat_list : fix retire old and new register bug
2) Stat_list : remove read_counter and valid flag, because validation of destination is in retire step (not in commit step)
3) Model : add class Model (cf Morpheo.sim)
4) Allocation : alloc_interface_begin and alloc_interface_end to delete temporary array.
5) Script : add distexe.sh
6) Add Comparator, Multiplier, Divider. But this component are not implemented
7) Software : add Dhrystone

  • Property svn:keywords set to Id
File size: 14.5 KB
Line 
1/*
2 * $Id: test.cpp 112 2009-03-18 22:36:26Z rosiere $
3 *
4 * [ Description ]
5 *
6 * Test
7 */
8
9#define NB_ITERATION  1024
10#define CYCLE_MAX     (128*NB_ITERATION)
11
12#include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Direction_Glue/SelfTest/include/test.h"
13#include "Common/include/Test.h"
14#include "Common/include/BitManipulation.h"
15#include "Behavioural/include/Allocation.h"
16
17void test (string name,
18           morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction::direction_glue::Parameters * _param)
19{
20  msg(_("<%s> : Simulation SystemC.\n"),name.c_str());
21
22#ifdef STATISTICS
23  morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5,50);
24#endif
25
26  Tusage_t _usage = USE_ALL;
27
28//   _usage = usage_unset(_usage,USE_SYSTEMC              );
29//   _usage = usage_unset(_usage,USE_VHDL                 );
30//   _usage = usage_unset(_usage,USE_VHDL_TESTBENCH       );
31//   _usage = usage_unset(_usage,USE_VHDL_TESTBENCH_ASSERT);
32//   _usage = usage_unset(_usage,USE_POSITION             );
33//   _usage = usage_unset(_usage,USE_STATISTICS           );
34//   _usage = usage_unset(_usage,USE_INFORMATION          );
35
36  Direction_Glue * _Direction_Glue = new Direction_Glue
37    (name.c_str(),
38#ifdef STATISTICS
39     _parameters_statistics,
40#endif
41     _param,
42     _usage);
43 
44#ifdef SYSTEMC
45  /*********************************************************************
46   * Déclarations des signaux
47   *********************************************************************/
48  string rename;
49
50  sc_clock              *  in_CLOCK  = new sc_clock ("clock", 1.0, 0.5);         
51  sc_signal<Tcontrol_t> *  in_NRESET = new sc_signal<Tcontrol_t> ("NRESET");
52
53  ALLOC1_SC_SIGNAL( in_PREDICT_VAL                        ," in_PREDICT_VAL                        ",Tcontrol_t,_param->_nb_inst_predict);
54  ALLOC1_SC_SIGNAL(out_PREDICT_ACK                        ,"out_PREDICT_ACK                        ",Tcontrol_t,_param->_nb_inst_predict);
55  ALLOC1_SC_SIGNAL( in_PREDICT_ADDRESS_SRC                ," in_PREDICT_ADDRESS_SRC                ",Taddress_t,_param->_nb_inst_predict);
56  ALLOC1_SC_SIGNAL( in_PREDICT_STATIC                     ," in_PREDICT_STATIC                     ",Tcontrol_t,_param->_nb_inst_predict);
57  ALLOC1_SC_SIGNAL( in_PREDICT_LAST_TAKE                  ," in_PREDICT_LAST_TAKE                  ",Tcontrol_t,_param->_nb_inst_predict);
58  ALLOC1_SC_SIGNAL(out_PREDICT_HISTORY                    ,"out_PREDICT_HISTORY                    ",Thistory_t,_param->_nb_inst_predict);
59  ALLOC1_SC_SIGNAL(out_PREDICT_DIRECTION                  ,"out_PREDICT_DIRECTION                  ",Tcontrol_t,_param->_nb_inst_predict);
60  ALLOC1_SC_SIGNAL(out_PREDICT_PREDICTOR_VAL              ,"out_PREDICT_PREDICTOR_VAL              ",Tcontrol_t,_param->_nb_inst_predict);
61  ALLOC1_SC_SIGNAL( in_PREDICT_PREDICTOR_ACK              ," in_PREDICT_PREDICTOR_ACK              ",Tcontrol_t,_param->_nb_inst_predict);
62  ALLOC1_SC_SIGNAL(out_PREDICT_PREDICTOR_ADDRESS_SRC      ,"out_PREDICT_PREDICTOR_ADDRESS_SRC      ",Taddress_t,_param->_nb_inst_predict);
63  ALLOC1_SC_SIGNAL( in_PREDICT_PREDICTOR_HISTORY          ," in_PREDICT_PREDICTOR_HISTORY          ",Thistory_t,_param->_nb_inst_predict);
64  ALLOC1_SC_SIGNAL( in_PREDICT_PREDICTOR_DIRECTION        ," in_PREDICT_PREDICTOR_DIRECTION        ",Tcontrol_t,_param->_nb_inst_predict);
65  ALLOC1_SC_SIGNAL( in_UPDATE_VAL                         ," in_UPDATE_VAL                         ",Tcontrol_t,_param->_nb_inst_update);
66  ALLOC1_SC_SIGNAL(out_UPDATE_ACK                         ,"out_UPDATE_ACK                         ",Tcontrol_t,_param->_nb_inst_update);
67  ALLOC1_SC_SIGNAL( in_UPDATE_ADDRESS                     ," in_UPDATE_ADDRESS                     ",Taddress_t,_param->_nb_inst_update);
68  ALLOC1_SC_SIGNAL( in_UPDATE_HISTORY                     ," in_UPDATE_HISTORY                     ",Thistory_t,_param->_nb_inst_update);
69  ALLOC1_SC_SIGNAL( in_UPDATE_DIRECTION                   ," in_UPDATE_DIRECTION                   ",Tcontrol_t,_param->_nb_inst_update);
70  ALLOC1_SC_SIGNAL( in_UPDATE_PREDICTION_IFETCH           ," in_UPDATE_PREDICTION_IFETCH           ",Tcontrol_t,_param->_nb_inst_update);
71  ALLOC1_SC_SIGNAL(out_UPDATE_PREDICTOR_VAL               ,"out_UPDATE_PREDICTOR_VAL               ",Tcontrol_t,_param->_nb_inst_update);
72  ALLOC1_SC_SIGNAL( in_UPDATE_PREDICTOR_ACK               ," in_UPDATE_PREDICTOR_ACK               ",Tcontrol_t,_param->_nb_inst_update);
73  ALLOC1_SC_SIGNAL(out_UPDATE_PREDICTOR_ADDRESS           ,"out_UPDATE_PREDICTOR_ADDRESS           ",Taddress_t,_param->_nb_inst_update);
74  ALLOC1_SC_SIGNAL(out_UPDATE_PREDICTOR_HISTORY           ,"out_UPDATE_PREDICTOR_HISTORY           ",Thistory_t,_param->_nb_inst_update);
75  ALLOC1_SC_SIGNAL(out_UPDATE_PREDICTOR_DIRECTION         ,"out_UPDATE_PREDICTOR_DIRECTION         ",Tcontrol_t,_param->_nb_inst_update);
76  ALLOC1_SC_SIGNAL(out_UPDATE_PREDICTOR_PREDICTION_IFETCH ,"out_UPDATE_PREDICTOR_PREDICTION_IFETCH ",Tcontrol_t,_param->_nb_inst_update);
77
78  /********************************************************
79   * Instanciation
80   ********************************************************/
81 
82  msg(_("<%s> : Instanciation of _Direction_Glue.\n"),name.c_str());
83
84  (*(_Direction_Glue->in_CLOCK))        (*(in_CLOCK));
85  (*(_Direction_Glue->in_NRESET))       (*(in_NRESET));
86
87  INSTANCE1_SC_SIGNAL(_Direction_Glue, in_PREDICT_VAL                        ,_param->_nb_inst_predict);
88  INSTANCE1_SC_SIGNAL(_Direction_Glue,out_PREDICT_ACK                        ,_param->_nb_inst_predict);
89  INSTANCE1_SC_SIGNAL(_Direction_Glue, in_PREDICT_ADDRESS_SRC                ,_param->_nb_inst_predict);
90  INSTANCE1_SC_SIGNAL(_Direction_Glue, in_PREDICT_STATIC                     ,_param->_nb_inst_predict);
91  INSTANCE1_SC_SIGNAL(_Direction_Glue, in_PREDICT_LAST_TAKE                  ,_param->_nb_inst_predict);
92  if (_param->_have_port_history)                                           
93  INSTANCE1_SC_SIGNAL(_Direction_Glue,out_PREDICT_HISTORY                    ,_param->_nb_inst_predict);
94  INSTANCE1_SC_SIGNAL(_Direction_Glue,out_PREDICT_DIRECTION                  ,_param->_nb_inst_predict);
95  if (_param->_have_component_meta_predictor)                               
96    {                                                                       
97  INSTANCE1_SC_SIGNAL(_Direction_Glue,out_PREDICT_PREDICTOR_VAL              ,_param->_nb_inst_predict);
98  INSTANCE1_SC_SIGNAL(_Direction_Glue, in_PREDICT_PREDICTOR_ACK              ,_param->_nb_inst_predict);
99  INSTANCE1_SC_SIGNAL(_Direction_Glue,out_PREDICT_PREDICTOR_ADDRESS_SRC      ,_param->_nb_inst_predict);
100  if (_param->_have_port_history)                                           
101  INSTANCE1_SC_SIGNAL(_Direction_Glue, in_PREDICT_PREDICTOR_HISTORY          ,_param->_nb_inst_predict);
102  INSTANCE1_SC_SIGNAL(_Direction_Glue, in_PREDICT_PREDICTOR_DIRECTION        ,_param->_nb_inst_predict);
103    }                                                                       
104                                                                             
105  INSTANCE1_SC_SIGNAL(_Direction_Glue, in_UPDATE_VAL                         ,_param->_nb_inst_update );
106  INSTANCE1_SC_SIGNAL(_Direction_Glue,out_UPDATE_ACK                         ,_param->_nb_inst_update );
107  INSTANCE1_SC_SIGNAL(_Direction_Glue, in_UPDATE_ADDRESS                     ,_param->_nb_inst_update );
108  if (_param->_have_port_history)                                           
109  INSTANCE1_SC_SIGNAL(_Direction_Glue, in_UPDATE_HISTORY                     ,_param->_nb_inst_update );
110  INSTANCE1_SC_SIGNAL(_Direction_Glue, in_UPDATE_DIRECTION                   ,_param->_nb_inst_update );
111  INSTANCE1_SC_SIGNAL(_Direction_Glue, in_UPDATE_PREDICTION_IFETCH           ,_param->_nb_inst_update );
112  if (_param->_have_component_meta_predictor)                               
113    {                                                                       
114  INSTANCE1_SC_SIGNAL(_Direction_Glue,out_UPDATE_PREDICTOR_VAL               ,_param->_nb_inst_update );
115  INSTANCE1_SC_SIGNAL(_Direction_Glue, in_UPDATE_PREDICTOR_ACK               ,_param->_nb_inst_update );
116  INSTANCE1_SC_SIGNAL(_Direction_Glue,out_UPDATE_PREDICTOR_ADDRESS           ,_param->_nb_inst_update );
117  if (_param->_have_port_history)                                           
118  INSTANCE1_SC_SIGNAL(_Direction_Glue,out_UPDATE_PREDICTOR_HISTORY           ,_param->_nb_inst_update );
119  INSTANCE1_SC_SIGNAL(_Direction_Glue,out_UPDATE_PREDICTOR_DIRECTION         ,_param->_nb_inst_update );
120  INSTANCE1_SC_SIGNAL(_Direction_Glue,out_UPDATE_PREDICTOR_PREDICTION_IFETCH ,_param->_nb_inst_update );
121    }
122
123  msg(_("<%s> : Start Simulation ............\n"),name.c_str());
124   
125  Time * _time = new Time();
126
127  /********************************************************
128   * Simulation - Begin
129   ********************************************************/
130
131  // Initialisation
132
133  const uint32_t seed = 0;
134//const uint32_t seed = static_cast<uint32_t>(time(NULL));
135
136  srand(seed);
137
138  SC_START(0);
139  LABEL("Initialisation");
140
141  LABEL("Reset");
142  in_NRESET->write(0);
143  SC_START(5);
144  in_NRESET->write(1); 
145
146  LABEL("Loop of Test");
147
148  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
149    {
150      LABEL("Iteration %d",iteration);
151
152      for (uint32_t i=0; i<_param->_nb_inst_predict; i++)
153        {
154          in_PREDICT_VAL                 [i]->write(rand()%2);
155          in_PREDICT_ADDRESS_SRC         [i]->write(range<Taddress_t>(rand(),_param->_size_instruction_address));
156          in_PREDICT_STATIC              [i]->write(rand()%2);
157          in_PREDICT_LAST_TAKE           [i]->write(rand()%2);
158          in_PREDICT_PREDICTOR_ACK       [i]->write(rand()%2);
159          in_PREDICT_PREDICTOR_HISTORY   [i]->write(range<Thistory_t>(rand(),_param->_size_history));
160          in_PREDICT_PREDICTOR_DIRECTION [i]->write(rand()%2);
161        }
162
163      for (uint32_t i=0; i<_param->_nb_inst_update; i++)
164        {
165          in_UPDATE_VAL                  [i]->write(rand()%2);
166          in_UPDATE_ADDRESS              [i]->write(range<Taddress_t>(rand(),_param->_size_instruction_address));
167          in_UPDATE_HISTORY              [i]->write(range<Thistory_t>(rand(),_param->_size_history));
168          in_UPDATE_DIRECTION            [i]->write(rand()%2);
169          in_UPDATE_PREDICTION_IFETCH    [i]->write(rand()%2);
170          in_UPDATE_PREDICTOR_ACK        [i]->write(rand()%2);
171        }
172
173      SC_START(0);
174
175      for (uint32_t i=0; i<_param->_nb_inst_predict; i++)
176        {
177          switch (_param->_predictor_scheme)
178            {
179            case PREDICTOR_NEVER_TAKE  :
180              {
181                TEST(Tcontrol_t,out_PREDICT_ACK                   [i]->read(), 1);
182                TEST(Tcontrol_t,out_PREDICT_DIRECTION             [i]->read(), 0);
183                break;
184              }
185            case PREDICTOR_ALWAYS_TAKE :
186              {
187                TEST(Tcontrol_t,out_PREDICT_ACK                   [i]->read(), 1);
188                TEST(Tcontrol_t,out_PREDICT_DIRECTION             [i]->read(), 1);
189                break;
190              }
191            case PREDICTOR_STATIC      :
192              {
193                TEST(Tcontrol_t,out_PREDICT_ACK                   [i]->read(), 1);
194                TEST(Tcontrol_t,out_PREDICT_DIRECTION             [i]->read(), in_PREDICT_STATIC               [i]->read());
195                break;
196              }
197            case PREDICTOR_LAST_TAKE   :
198              {
199                TEST(Tcontrol_t,out_PREDICT_DIRECTION             [i]->read(), in_PREDICT_LAST_TAKE            [i]->read());
200                break;
201              }
202            case PREDICTOR_COUNTER     :
203            case PREDICTOR_LOCAL       :
204            case PREDICTOR_GLOBAL      :
205            case PREDICTOR_META        :
206            case PREDICTOR_CUSTOM      :
207              {
208                TEST(Tcontrol_t,out_PREDICT_ACK                   [i]->read(), in_PREDICT_PREDICTOR_ACK        [i]->read());
209                TEST(Thistory_t,out_PREDICT_HISTORY               [i]->read(), in_PREDICT_PREDICTOR_HISTORY    [i]->read());
210                TEST(Tcontrol_t,out_PREDICT_DIRECTION             [i]->read(), in_PREDICT_PREDICTOR_DIRECTION  [i]->read());
211                TEST(Tcontrol_t,out_PREDICT_PREDICTOR_VAL         [i]->read(), in_PREDICT_VAL                  [i]->read());
212                TEST(Taddress_t,out_PREDICT_PREDICTOR_ADDRESS_SRC [i]->read(), in_PREDICT_ADDRESS_SRC          [i]->read());
213               
214                break;
215              }
216            default :
217              {
218                break;
219              }
220            }
221        }
222
223      for (uint32_t i=0; i<_param->_nb_inst_update; i++)
224        {
225
226
227          switch (_param->_predictor_scheme)
228            {
229            case PREDICTOR_COUNTER     :
230            case PREDICTOR_LOCAL       :
231            case PREDICTOR_GLOBAL      :
232            case PREDICTOR_META        :
233            case PREDICTOR_CUSTOM      :
234              {
235                TEST(Tcontrol_t,out_UPDATE_ACK                        [i]->read(), in_UPDATE_PREDICTOR_ACK       [i]->read());
236                TEST(Tcontrol_t,out_UPDATE_PREDICTOR_VAL              [i]->read(), in_UPDATE_VAL                 [i]->read());
237                TEST(Taddress_t,out_UPDATE_PREDICTOR_ADDRESS          [i]->read(), in_UPDATE_ADDRESS             [i]->read());
238                TEST(Thistory_t,out_UPDATE_PREDICTOR_HISTORY          [i]->read(), in_UPDATE_HISTORY             [i]->read());
239                TEST(Tcontrol_t,out_UPDATE_PREDICTOR_DIRECTION        [i]->read(), in_UPDATE_DIRECTION           [i]->read());
240                TEST(Tcontrol_t,out_UPDATE_PREDICTOR_PREDICTION_IFETCH[i]->read(), in_UPDATE_PREDICTION_IFETCH   [i]->read());
241               
242                break;
243              }
244            case PREDICTOR_NEVER_TAKE  :
245            case PREDICTOR_ALWAYS_TAKE :
246            case PREDICTOR_STATIC      :
247            case PREDICTOR_LAST_TAKE   :
248            default :
249              {
250                TEST(Tcontrol_t,out_UPDATE_ACK                 [i]->read(), 1);
251
252                break;
253              }
254            }
255        }
256
257      SC_START(1);
258    }
259
260  /********************************************************
261   * Simulation - End
262   ********************************************************/
263
264  TEST_OK ("End of Simulation");
265  delete _time;
266
267  msg(_("<%s> : ............ Stop Simulation\n"),name.c_str());
268
269  delete in_CLOCK;
270  delete in_NRESET;
271
272  delete []  in_PREDICT_VAL                  ;
273  delete [] out_PREDICT_ACK                  ;
274  delete []  in_PREDICT_ADDRESS_SRC          ;
275  delete []  in_PREDICT_STATIC               ;
276  delete []  in_PREDICT_LAST_TAKE            ;
277  delete [] out_PREDICT_HISTORY              ;
278  delete [] out_PREDICT_DIRECTION            ;
279  delete [] out_PREDICT_PREDICTOR_VAL        ;
280  delete []  in_PREDICT_PREDICTOR_ACK        ;
281  delete [] out_PREDICT_PREDICTOR_ADDRESS_SRC;
282  delete []  in_PREDICT_PREDICTOR_HISTORY    ;
283  delete []  in_PREDICT_PREDICTOR_DIRECTION  ;
284  delete []  in_UPDATE_VAL                   ;
285  delete [] out_UPDATE_ACK                   ;
286  delete []  in_UPDATE_ADDRESS               ;
287  delete []  in_UPDATE_HISTORY               ;
288  delete []  in_UPDATE_DIRECTION             ;
289  delete []  in_UPDATE_PREDICTION_IFETCH     ;
290  delete [] out_UPDATE_PREDICTOR_VAL         ;
291  delete []  in_UPDATE_PREDICTOR_ACK         ;
292  delete [] out_UPDATE_PREDICTOR_ADDRESS     ;
293  delete [] out_UPDATE_PREDICTOR_HISTORY     ;
294  delete [] out_UPDATE_PREDICTOR_DIRECTION   ;
295  delete [] out_UPDATE_PREDICTOR_PREDICTION_IFETCH;
296#endif
297
298  delete _Direction_Glue;
299#ifdef STATISTICS
300  delete _parameters_statistics;
301#endif
302}
Note: See TracBrowser for help on using the repository browser.