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

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

Add :

  • Execute_loop (must be test systemC)
  • Prediction
    • Direction : predifined scheme
    • Branch Target Buffer
  • iFetch_unit
    • ifetch_queue
    • pc management
  • Decod_unit
    • coming soon : support for custom operation
  • Rename_unit
    • RAT
    • Free_list
    • Dependence RAW check
    • Load store unit pointer
  • New Environnement (hierarchy_memory will remove in a next version)


Modif :

  • Manage Custom Operation
  • All component in execute_loop to use the new statistics management

Not Finish :

  • Return Address Stack
  • Environnement
File size: 8.9 KB
Line 
1/*
2 * $Id$
3 *
4 * [ Description ]
5 *
6 * Test
7 */
8
9#include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/SelfTest/include/test.h"
10#include "Common/include/Test.h"
11#include "Common/include/BitManipulation.h"
12#include "Behavioural/include/Allocation.h"
13
14#define NB_ITERATION  1024
15#define CYCLE_MAX     (128*NB_ITERATION)
16
17#define LABEL(str...)                                                   \
18  {                                                                     \
19    msg (_("{%d} "),static_cast<uint32_t>(sc_simulation_time()));       \
20    msg (str);                                                          \
21    msg (_("\n"));                                                      \
22  } while(0)
23
24#define SC_START(cycle_offset)                                                       \
25  do                                                                                 \
26    {                                                                                \
27      /*cout << "SC_START (begin)" << endl;*/                                        \
28                                                                                     \
29      uint32_t cycle_current = static_cast<uint32_t>(sc_simulation_time());          \
30      if (cycle_offset != 0)                                                         \
31        {                                                                            \
32          cout << "##########[ cycle "<< cycle_current+cycle_offset << " ]" << endl; \
33        }                                                                            \
34                                                                                     \
35      if (cycle_current > CYCLE_MAX)                                                 \
36        {                                                                            \
37          TEST_KO("Maximal cycles Reached");                                         \
38        }                                                                            \
39                                                                                     \
40      sc_start(cycle_offset);                                                        \
41                                                                                     \
42      /*cout << "SC_START (end  )" << endl;*/                                        \
43    } while(0)
44
45void test (string name,
46           morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction::Parameters * _param)
47{
48  msg(_("<%s> : Simulation SystemC.\n"),name.c_str());
49
50#ifdef STATISTICS
51  morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5,50);
52#endif
53
54  Direction * _Direction = new Direction (name.c_str(),
55#ifdef STATISTICS
56                                             _parameters_statistics,
57#endif
58                                             _param);
59 
60#ifdef SYSTEMC
61  /*********************************************************************
62   * Déclarations des signaux
63   *********************************************************************/
64  string rename;
65
66  sc_clock              *  in_CLOCK  = new sc_clock ("clock", 1.0, 0.5);         
67  sc_signal<Tcontrol_t> *  in_NRESET = new sc_signal<Tcontrol_t> ("NRESET");
68
69  ALLOC1_SC_SIGNAL( in_PREDICT_VAL             ," in_PREDICT_VAL             ",Tcontrol_t,_param->_nb_inst_predict);
70  ALLOC1_SC_SIGNAL(out_PREDICT_ACK             ,"out_PREDICT_ACK             ",Tcontrol_t,_param->_nb_inst_predict);
71  ALLOC1_SC_SIGNAL( in_PREDICT_ADDRESS_SRC     ," in_PREDICT_ADDRESS_SRC     ",Taddress_t,_param->_nb_inst_predict);
72  ALLOC1_SC_SIGNAL( in_PREDICT_STATIC          ," in_PREDICT_STATIC          ",Tcontrol_t,_param->_nb_inst_predict);
73  ALLOC1_SC_SIGNAL( in_PREDICT_LAST_TAKE       ," in_PREDICT_LAST_TAKE       ",Tcontrol_t,_param->_nb_inst_predict);
74  ALLOC1_SC_SIGNAL(out_PREDICT_HISTORY         ,"out_PREDICT_HISTORY         ",Thistory_t,_param->_nb_inst_predict);
75  ALLOC1_SC_SIGNAL(out_PREDICT_DIRECTION       ,"out_PREDICT_DIRECTION       ",Tcontrol_t,_param->_nb_inst_predict);
76  ALLOC1_SC_SIGNAL( in_UPDATE_VAL              ," in_UPDATE_VAL              ",Tcontrol_t,_param->_nb_inst_update);
77  ALLOC1_SC_SIGNAL(out_UPDATE_ACK              ,"out_UPDATE_ACK              ",Tcontrol_t,_param->_nb_inst_update);
78  ALLOC1_SC_SIGNAL( in_UPDATE_ADDRESS          ," in_UPDATE_ADDRESS          ",Taddress_t,_param->_nb_inst_update);
79  ALLOC1_SC_SIGNAL( in_UPDATE_HISTORY          ," in_UPDATE_HISTORY          ",Thistory_t,_param->_nb_inst_update);
80  ALLOC1_SC_SIGNAL( in_UPDATE_DIRECTION        ," in_UPDATE_DIRECTION        ",Tcontrol_t,_param->_nb_inst_update);
81 
82  /********************************************************
83   * Instanciation
84   ********************************************************/
85 
86  msg(_("<%s> : Instanciation of _Direction.\n"),name.c_str());
87
88  (*(_Direction->in_CLOCK))        (*(in_CLOCK));
89  (*(_Direction->in_NRESET))       (*(in_NRESET));
90
91  INSTANCE1_SC_SIGNAL(_Direction, in_PREDICT_VAL             ,_param->_nb_inst_predict);
92  INSTANCE1_SC_SIGNAL(_Direction,out_PREDICT_ACK             ,_param->_nb_inst_predict);
93  INSTANCE1_SC_SIGNAL(_Direction, in_PREDICT_ADDRESS_SRC     ,_param->_nb_inst_predict);
94  INSTANCE1_SC_SIGNAL(_Direction, in_PREDICT_STATIC          ,_param->_nb_inst_predict);
95  INSTANCE1_SC_SIGNAL(_Direction, in_PREDICT_LAST_TAKE       ,_param->_nb_inst_predict);
96  if (_param->_have_port_history)
97  INSTANCE1_SC_SIGNAL(_Direction,out_PREDICT_HISTORY         ,_param->_nb_inst_predict);
98  INSTANCE1_SC_SIGNAL(_Direction,out_PREDICT_DIRECTION       ,_param->_nb_inst_predict);
99  INSTANCE1_SC_SIGNAL(_Direction, in_UPDATE_VAL              ,_param->_nb_inst_update);
100  INSTANCE1_SC_SIGNAL(_Direction,out_UPDATE_ACK              ,_param->_nb_inst_update);
101  INSTANCE1_SC_SIGNAL(_Direction, in_UPDATE_ADDRESS          ,_param->_nb_inst_update);
102  if (_param->_have_port_history)
103  INSTANCE1_SC_SIGNAL(_Direction, in_UPDATE_HISTORY          ,_param->_nb_inst_update);
104  INSTANCE1_SC_SIGNAL(_Direction, in_UPDATE_DIRECTION        ,_param->_nb_inst_update);
105
106  msg(_("<%s> : Start Simulation ............\n"),name.c_str());
107   
108  Time * _time = new Time();
109
110  /********************************************************
111   * Simulation - Begin
112   ********************************************************/
113
114  // Initialisation
115
116  const uint32_t seed = 0;
117//const uint32_t seed = static_cast<uint32_t>(time(NULL));
118
119  srand(seed);
120
121  SC_START(0);
122  LABEL("Initialisation");
123
124  LABEL("Reset");
125  in_NRESET->write(0);
126  SC_START(5);
127  in_NRESET->write(1); 
128
129  LABEL("Loop of Test");
130
131  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
132    {
133      LABEL("Iteration %d",iteration);
134
135      for (uint32_t i=0; i<_param->_nb_inst_predict; i++)
136        {
137          in_PREDICT_VAL                 [i]->write(rand()%2);
138          in_PREDICT_ADDRESS_SRC         [i]->write(range<Taddress_t>(rand(),_param->_size_address));
139          in_PREDICT_STATIC              [i]->write(rand()%2);
140          in_PREDICT_LAST_TAKE           [i]->write(rand()%2);
141        }
142
143      for (uint32_t i=0; i<_param->_nb_inst_update; i++)
144        {
145          in_UPDATE_VAL                  [i]->write(rand()%2);
146          in_UPDATE_ADDRESS              [i]->write(range<Taddress_t>(rand(),_param->_size_address));
147          in_UPDATE_HISTORY              [i]->write(range<Thistory_t>(rand(),_param->_size_history));
148          in_UPDATE_DIRECTION            [i]->write(rand()%2);
149        }
150
151      SC_START(0);
152
153      for (uint32_t i=0; i<_param->_nb_inst_predict; i++)
154        {
155          switch (_param->_predictor_scheme)
156            {
157            case PREDICTOR_NEVER_TAKE  :
158              {
159                TEST(Tcontrol_t,out_PREDICT_ACK                   [i]->read(), 1);
160                TEST(Tcontrol_t,out_PREDICT_DIRECTION             [i]->read(), 0);
161                break;
162              }
163            case PREDICTOR_ALWAYS_TAKE :
164              {
165                TEST(Tcontrol_t,out_PREDICT_ACK                   [i]->read(), 1);
166                TEST(Tcontrol_t,out_PREDICT_DIRECTION             [i]->read(), 1);
167                break;
168              }
169            case PREDICTOR_STATIC      :
170              {
171                TEST(Tcontrol_t,out_PREDICT_ACK                   [i]->read(), 1);
172                TEST(Tcontrol_t,out_PREDICT_DIRECTION             [i]->read(), in_PREDICT_STATIC               [i]->read());
173                break;
174              }
175            case PREDICTOR_LAST_TAKE   :
176              {
177                TEST(Tcontrol_t,out_PREDICT_ACK                   [i]->read(), 1);
178                TEST(Tcontrol_t,out_PREDICT_DIRECTION             [i]->read(), in_PREDICT_LAST_TAKE            [i]->read());
179                break;
180              }
181            case PREDICTOR_COUNTER     :
182            case PREDICTOR_LOCAL       :
183            case PREDICTOR_GLOBAL      :
184            case PREDICTOR_META        :
185            case PREDICTOR_CUSTOM      :
186              {
187                break;
188              }
189            default :
190              {
191                break;
192              }
193            }
194        }
195
196      for (uint32_t i=0; i<_param->_nb_inst_update; i++)
197        {
198
199
200          switch (_param->_predictor_scheme)
201            {
202            case PREDICTOR_COUNTER     :
203            case PREDICTOR_LOCAL       :
204            case PREDICTOR_GLOBAL      :
205            case PREDICTOR_META        :
206            case PREDICTOR_CUSTOM      :
207              {
208                break;
209              }
210            case PREDICTOR_NEVER_TAKE  :
211            case PREDICTOR_ALWAYS_TAKE :
212            case PREDICTOR_STATIC      :
213            case PREDICTOR_LAST_TAKE   :
214            default :
215              {
216                TEST(Tcontrol_t,out_UPDATE_ACK                 [i]->read(), 1);
217                break;
218              }
219            }
220        }
221
222      SC_START(1);
223
224    }
225
226  /********************************************************
227   * Simulation - End
228   ********************************************************/
229
230  TEST_OK ("End of Simulation");
231  delete _time;
232
233  msg(_("<%s> : ............ Stop Simulation\n"),name.c_str());
234
235  delete in_CLOCK;
236  delete in_NRESET;
237
238  delete []  in_PREDICT_VAL             ;
239  delete [] out_PREDICT_ACK             ;
240  delete []  in_PREDICT_ADDRESS_SRC     ;
241  delete []  in_PREDICT_STATIC          ;
242  delete []  in_PREDICT_LAST_TAKE       ;
243  delete [] out_PREDICT_HISTORY         ;
244  delete [] out_PREDICT_DIRECTION       ;
245  delete []  in_UPDATE_VAL              ;
246  delete [] out_UPDATE_ACK              ;
247  delete []  in_UPDATE_ADDRESS          ;
248  delete []  in_UPDATE_HISTORY          ;
249  delete []  in_UPDATE_DIRECTION        ;
250
251#endif
252
253  delete _Direction;
254#ifdef STATISTICS
255  delete _parameters_statistics;
256#endif
257}
Note: See TracBrowser for help on using the repository browser.