source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Meta_Predictor_Glue/SelfTest/src/test.cpp @ 111

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

1) Decod_queue : multi implementation (one_fifo, multi_fifo)
2) Issue_queue : multi implementation (in_order, out_of_order)
3) Direction : Add Meta predictor
4) Context_State : re add Branch_complete, More priority to Load miss (is not speculative)
5) Return_Address_Stack : update reg_PREDICT pointer on decod miss prediction
6) UPT : Fix bug in multi event
7) Prediction_glue : in read_stack case, insert in UPT pc_next
8) Rename select : when rob have an event (need flush), read_r{a,b,c} and write_r{d,e} is set at 0

  • Property svn:keywords set to Id
File size: 9.9 KB
Line 
1/*
2 * $Id: test.cpp 111 2009-02-27 18:37:40Z rosiere $
3 *
4 * [ Description ]
5 *
6 * Test
7 */
8
9#include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Meta_Predictor_Glue/SelfTest/include/test.h"
10#include "Behavioural/include/Allocation.h"
11
12void test (string name,
13           morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction::meta_predictor::meta_predictor_glue::Parameters * _param)
14{
15  msg(_("<%s> : Simulation SystemC.\n"),name.c_str());
16
17  if (setlocale (LC_ALL, "") == NULL)
18    msg(_("setlocale ko.\n"));
19
20#ifdef STATISTICS
21  morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5,CYCLE_MAX);
22#endif
23
24  Tusage_t _usage = USE_ALL;
25
26//   _usage = usage_unset(_usage,USE_SYSTEMC              );
27//   _usage = usage_unset(_usage,USE_VHDL                 );
28//   _usage = usage_unset(_usage,USE_VHDL_TESTBENCH       );
29//   _usage = usage_unset(_usage,USE_VHDL_TESTBENCH_ASSERT);
30//   _usage = usage_unset(_usage,USE_POSITION             );
31//   _usage = usage_unset(_usage,USE_STATISTICS           );
32//   _usage = usage_unset(_usage,USE_INFORMATION          );
33
34  Meta_Predictor_Glue * _Meta_Predictor_Glue = new Meta_Predictor_Glue
35    (name.c_str(),
36#ifdef STATISTICS
37     _parameters_statistics,
38#endif
39     _param,
40     _usage);
41 
42#ifdef SYSTEMC
43  if (usage_is_set(_usage,USE_SYSTEMC))
44    {
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(out_PREDICT_HISTORY                ,"out_PREDICT_HISTORY                ",Thistory_t,_param->_nb_inst_predict);
56  ALLOC1_SC_SIGNAL(out_PREDICT_DIRECTION              ,"out_PREDICT_DIRECTION              ",Tcontrol_t,_param->_nb_inst_predict);
57  ALLOC2_SC_SIGNAL(out_PREDICT_PREDICTOR_VAL          ,"out_PREDICT_PREDICTOR_VAL          ",Tcontrol_t,_param->_nb_predictor,_param->_nb_inst_predict);
58  ALLOC2_SC_SIGNAL( in_PREDICT_PREDICTOR_ACK          ," in_PREDICT_PREDICTOR_ACK          ",Tcontrol_t,_param->_nb_predictor,_param->_nb_inst_predict);
59  ALLOC2_SC_SIGNAL( in_PREDICT_PREDICTOR_HISTORY      ," in_PREDICT_PREDICTOR_HISTORY      ",Thistory_t,_param->_nb_predictor,_param->_nb_inst_predict);
60  ALLOC2_SC_SIGNAL( in_PREDICT_PREDICTOR_DIRECTION    ," in_PREDICT_PREDICTOR_DIRECTION    ",Tcontrol_t,_param->_nb_predictor,_param->_nb_inst_predict);
61  ALLOC2_SC_SIGNAL(out_PREDICT_PREDICTOR_DIRECTION_VAL,"out_PREDICT_PREDICTOR_DIRECTION_VAL",Tcontrol_t,_param->_nb_predictor,_param->_nb_inst_predict); // if update_on_prediction
62  ALLOC2_SC_SIGNAL(out_PREDICT_PREDICTOR_DIRECTION    ,"out_PREDICT_PREDICTOR_DIRECTION    ",Tcontrol_t,_param->_nb_predictor,_param->_nb_inst_predict); // if update_on_prediction
63  ALLOC1_SC_SIGNAL( in_UPDATE_VAL                     ," in_UPDATE_VAL                     ",Tcontrol_t,_param->_nb_inst_update);
64  ALLOC1_SC_SIGNAL(out_UPDATE_ACK                     ,"out_UPDATE_ACK                     ",Tcontrol_t,_param->_nb_inst_update);
65  ALLOC1_SC_SIGNAL( in_UPDATE_HISTORY                 ," in_UPDATE_HISTORY                 ",Thistory_t,_param->_nb_inst_update);
66  ALLOC1_SC_SIGNAL( in_UPDATE_DIRECTION               ," in_UPDATE_DIRECTION               ",Tcontrol_t,_param->_nb_inst_update);
67  ALLOC2_SC_SIGNAL(out_UPDATE_PREDICTOR_VAL           ,"out_UPDATE_PREDICTOR_VAL           ",Tcontrol_t,_param->_nb_predictor,_param->_nb_inst_update);
68  ALLOC2_SC_SIGNAL( in_UPDATE_PREDICTOR_ACK           ," in_UPDATE_PREDICTOR_ACK           ",Tcontrol_t,_param->_nb_predictor,_param->_nb_inst_update);
69  ALLOC2_SC_SIGNAL(out_UPDATE_PREDICTOR_HISTORY       ,"out_UPDATE_PREDICTOR_HISTORY       ",Thistory_t,_param->_nb_predictor,_param->_nb_inst_update);
70  ALLOC2_SC_SIGNAL(out_UPDATE_PREDICTOR_DIRECTION     ,"out_UPDATE_PREDICTOR_DIRECTION     ",Tcontrol_t,_param->_nb_predictor,_param->_nb_inst_update);
71  ALLOC2_SC_SIGNAL(out_UPDATE_PREDICTOR_MISS          ,"out_UPDATE_PREDICTOR_MISS          ",Tcontrol_t,_param->_nb_predictor,_param->_nb_inst_update);
72
73  /********************************************************
74   * Instanciation
75   ********************************************************/
76 
77  msg(_("<%s> : Instanciation of _Meta_Predictor_Glue.\n"),name.c_str());
78
79  (*(_Meta_Predictor_Glue->in_CLOCK))        (*(in_CLOCK));
80  (*(_Meta_Predictor_Glue->in_NRESET))       (*(in_NRESET));
81
82  INSTANCE1_SC_SIGNAL(_Meta_Predictor_Glue, in_PREDICT_VAL                    ,_param->_nb_inst_predict);
83  INSTANCE1_SC_SIGNAL(_Meta_Predictor_Glue,out_PREDICT_ACK                    ,_param->_nb_inst_predict);
84  INSTANCE1_SC_SIGNAL(_Meta_Predictor_Glue,out_PREDICT_HISTORY                ,_param->_nb_inst_predict);
85  INSTANCE1_SC_SIGNAL(_Meta_Predictor_Glue,out_PREDICT_DIRECTION              ,_param->_nb_inst_predict);
86
87  INSTANCE2_SC_SIGNAL(_Meta_Predictor_Glue,out_PREDICT_PREDICTOR_VAL          ,_param->_nb_predictor,_param->_nb_inst_predict);
88  INSTANCE2_SC_SIGNAL(_Meta_Predictor_Glue, in_PREDICT_PREDICTOR_ACK          ,_param->_nb_predictor,_param->_nb_inst_predict);
89  INSTANCE2_SC_SIGNAL(_Meta_Predictor_Glue, in_PREDICT_PREDICTOR_HISTORY      ,_param->_nb_predictor,_param->_nb_inst_predict);
90  INSTANCE2_SC_SIGNAL(_Meta_Predictor_Glue, in_PREDICT_PREDICTOR_DIRECTION    ,_param->_nb_predictor,_param->_nb_inst_predict);
91 
92  for (uint32_t i=0; i<_param->_nb_predictor; ++i)
93    if (_param->_predictor_update_on_prediction [i])
94      {
95  INSTANCE1_SC_SIGNAL(_Meta_Predictor_Glue,out_PREDICT_PREDICTOR_DIRECTION_VAL[i],_param->_nb_inst_predict);
96  INSTANCE1_SC_SIGNAL(_Meta_Predictor_Glue,out_PREDICT_PREDICTOR_DIRECTION    [i],_param->_nb_inst_predict);
97      }
98
99  INSTANCE1_SC_SIGNAL(_Meta_Predictor_Glue, in_UPDATE_VAL                     ,_param->_nb_inst_update);
100  INSTANCE1_SC_SIGNAL(_Meta_Predictor_Glue,out_UPDATE_ACK                     ,_param->_nb_inst_update);
101  INSTANCE1_SC_SIGNAL(_Meta_Predictor_Glue, in_UPDATE_HISTORY                 ,_param->_nb_inst_update);
102  INSTANCE1_SC_SIGNAL(_Meta_Predictor_Glue, in_UPDATE_DIRECTION               ,_param->_nb_inst_update);
103
104  INSTANCE2_SC_SIGNAL(_Meta_Predictor_Glue,out_UPDATE_PREDICTOR_VAL           ,_param->_nb_predictor,_param->_nb_inst_update);
105  INSTANCE2_SC_SIGNAL(_Meta_Predictor_Glue, in_UPDATE_PREDICTOR_ACK           ,_param->_nb_predictor,_param->_nb_inst_update);
106  INSTANCE2_SC_SIGNAL(_Meta_Predictor_Glue,out_UPDATE_PREDICTOR_HISTORY       ,_param->_nb_predictor,_param->_nb_inst_update);
107  INSTANCE2_SC_SIGNAL(_Meta_Predictor_Glue,out_UPDATE_PREDICTOR_DIRECTION     ,_param->_nb_predictor,_param->_nb_inst_update);
108  for (uint32_t i=0; i<_param->_nb_predictor; ++i)
109    if (_param->_predictor_update_on_prediction [i])
110  INSTANCE1_SC_SIGNAL(_Meta_Predictor_Glue,out_UPDATE_PREDICTOR_MISS [i]                            ,_param->_nb_inst_update);
111
112  msg(_("<%s> : Start Simulation ............\n"),name.c_str());
113   
114  Time * _time = new Time();
115
116  /********************************************************
117   * Simulation - Begin
118   ********************************************************/
119
120  // Initialisation
121
122  const uint32_t seed = 0;
123//const uint32_t seed = static_cast<uint32_t>(time(NULL));
124
125  srand(seed);
126
127  SC_START(0);
128  LABEL("Initialisation");
129
130  LABEL("Reset");
131  in_NRESET->write(0);
132  SC_START(5);
133  in_NRESET->write(1); 
134
135  LABEL("Loop of Test");
136
137  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
138    {
139      LABEL("Iteration %d",iteration);
140
141      SC_START(1);
142    }
143
144  /********************************************************
145   * Simulation - End
146   ********************************************************/
147
148  TEST_OK ("End of Simulation");
149  delete _time;
150
151  msg(_("<%s> : ............ Stop Simulation\n"),name.c_str());
152
153  delete in_CLOCK;
154  delete in_NRESET;
155
156  DELETE1_SC_SIGNAL( in_PREDICT_VAL                    ,_param->_nb_inst_predict);
157  DELETE1_SC_SIGNAL(out_PREDICT_ACK                    ,_param->_nb_inst_predict);
158  DELETE1_SC_SIGNAL(out_PREDICT_HISTORY                ,_param->_nb_inst_predict);
159  DELETE1_SC_SIGNAL(out_PREDICT_DIRECTION              ,_param->_nb_inst_predict);
160
161  DELETE2_SC_SIGNAL(out_PREDICT_PREDICTOR_VAL          ,_param->_nb_predictor,_param->_nb_inst_predict);
162  DELETE2_SC_SIGNAL( in_PREDICT_PREDICTOR_ACK          ,_param->_nb_predictor,_param->_nb_inst_predict);
163  DELETE2_SC_SIGNAL( in_PREDICT_PREDICTOR_HISTORY      ,_param->_nb_predictor,_param->_nb_inst_predict);
164  DELETE2_SC_SIGNAL( in_PREDICT_PREDICTOR_DIRECTION    ,_param->_nb_predictor,_param->_nb_inst_predict);
165  DELETE2_SC_SIGNAL(out_PREDICT_PREDICTOR_DIRECTION_VAL,_param->_nb_predictor,_param->_nb_inst_predict);
166  DELETE2_SC_SIGNAL(out_PREDICT_PREDICTOR_DIRECTION    ,_param->_nb_predictor,_param->_nb_inst_predict);
167
168  DELETE1_SC_SIGNAL( in_UPDATE_VAL                     ,_param->_nb_inst_update);
169  DELETE1_SC_SIGNAL(out_UPDATE_ACK                     ,_param->_nb_inst_update);
170  DELETE1_SC_SIGNAL( in_UPDATE_HISTORY                 ,_param->_nb_inst_update);
171  DELETE1_SC_SIGNAL( in_UPDATE_DIRECTION               ,_param->_nb_inst_update);
172
173  DELETE2_SC_SIGNAL(out_UPDATE_PREDICTOR_VAL           ,_param->_nb_predictor,_param->_nb_inst_update);
174  DELETE2_SC_SIGNAL( in_UPDATE_PREDICTOR_ACK           ,_param->_nb_predictor,_param->_nb_inst_update);
175  DELETE2_SC_SIGNAL(out_UPDATE_PREDICTOR_HISTORY       ,_param->_nb_predictor,_param->_nb_inst_update);
176  DELETE2_SC_SIGNAL(out_UPDATE_PREDICTOR_DIRECTION     ,_param->_nb_predictor,_param->_nb_inst_update);
177  DELETE2_SC_SIGNAL(out_UPDATE_PREDICTOR_MISS          ,_param->_nb_predictor,_param->_nb_inst_update);
178    }
179#endif
180
181  delete _Meta_Predictor_Glue;
182#ifdef STATISTICS
183  delete _parameters_statistics;
184#endif
185}
Note: See TracBrowser for help on using the repository browser.