source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Stage_1_Ifetch/Predictor/Meta_Predictor/Meta_Predictor_Glue/SelfTest/src/test.cpp @ 4

Last change on this file since 4 was 4, checked in by rosiere, 17 years ago
File size: 22.5 KB
Line 
1/*
2 * $Id$
3 *
4 * [ Description ]
5 *
6 * Test
7 */
8
9#define NB_ITERATION 1024
10
11#include "Behavioural/Stage_1_Ifetch/Predictor/Meta_Predictor/Meta_Predictor_Glue/SelfTest/include/test.h"
12#include "Include/Test.h"
13
14void test (string name,
15           morpheo::behavioural::stage_1_ifetch::predictor::meta_predictor::meta_predictor_glue::Parameters _param)
16{
17  cout << "<" << name << "> : Simulation SystemC" << endl;
18
19  Meta_Predictor_Glue * _Meta_Predictor_Glue = new Meta_Predictor_Glue (name.c_str(),
20#ifdef STATISTICS
21                                                                        morpheo::behavioural::Parameters_Statistics(5,50),
22#endif
23                                                                        _param);
24 
25#ifdef SYSTEMC
26  /*********************************************************************
27   * Déclarations des signaux
28   *********************************************************************/
29  sc_clock                         * CLOCK;
30
31    // Interface Predict
32  sc_signal<Tcontrol_t>           ** PREDICT_PREDICTOR_0_ACK                ;
33  sc_signal<Tcontrol_t>           ** PREDICT_PREDICTOR_1_ACK                ;
34  sc_signal<Tcontrol_t>           ** PREDICT_PREDICTOR_2_ACK                ;
35  sc_signal<Tcontrol_t>           ** PREDICT_ACK                            ;
36
37  sc_signal<Tbht_history_t>       ** PREDICT_PREDICTOR_0_BHT_HISTORY        ;
38  sc_signal<Tpht_history_t>       ** PREDICT_PREDICTOR_0_PHT_HISTORY        ;
39  sc_signal<Tbht_history_t>       ** PREDICT_PREDICTOR_1_BHT_HISTORY        ;
40  sc_signal<Tpht_history_t>       ** PREDICT_PREDICTOR_1_PHT_HISTORY        ;
41  sc_signal<Tbht_history_t>       ** PREDICT_PREDICTOR_2_BHT_HISTORY        ;
42  sc_signal<Tpht_history_t>       ** PREDICT_PREDICTOR_2_PHT_HISTORY        ;
43  sc_signal<Thistory_t>           ** PREDICT_HISTORY                        ;
44  sc_signal<Tcontrol_t>           ** PREDICT_DIRECTION                      ;
45
46    // Interface Branch_complete
47  sc_signal<Tcontrol_t>           ** BRANCH_COMPLETE_PREDICTOR_0_ACK        ;
48  sc_signal<Tcontrol_t>           ** BRANCH_COMPLETE_PREDICTOR_1_ACK        ;
49  sc_signal<Tcontrol_t>           ** BRANCH_COMPLETE_PREDICTOR_2_ACK        ;
50  sc_signal<Tcontrol_t>           ** BRANCH_COMPLETE_ACK                    ;
51
52  sc_signal<Tbht_history_t>       ** BRANCH_COMPLETE_PREDICTOR_0_BHT_HISTORY;
53  sc_signal<Tpht_history_t>       ** BRANCH_COMPLETE_PREDICTOR_0_PHT_HISTORY;
54  sc_signal<Tbht_history_t>       ** BRANCH_COMPLETE_PREDICTOR_1_BHT_HISTORY;
55  sc_signal<Tpht_history_t>       ** BRANCH_COMPLETE_PREDICTOR_1_PHT_HISTORY;
56  sc_signal<Tbht_history_t>       ** BRANCH_COMPLETE_PREDICTOR_2_BHT_HISTORY;
57  sc_signal<Tpht_history_t>       ** BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY;
58  sc_signal<Thistory_t>           ** BRANCH_COMPLETE_HISTORY                ;
59
60  string rename;
61
62#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
63  CLOCK                                  = new sc_clock ("clock", 1.0, 0.5);
64#endif 
65
66    // Interface Predict
67
68    PREDICT_PREDICTOR_0_ACK         = new sc_signal<Tcontrol_t>     * [_param._nb_prediction     ];
69    PREDICT_PREDICTOR_1_ACK         = new sc_signal<Tcontrol_t>     * [_param._nb_prediction     ];
70    PREDICT_PREDICTOR_2_ACK         = new sc_signal<Tcontrol_t>     * [_param._nb_prediction     ];
71    PREDICT_ACK                     = new sc_signal<Tcontrol_t>     * [_param._nb_prediction     ];
72    PREDICT_PREDICTOR_0_BHT_HISTORY = new sc_signal<Tbht_history_t> * [_param._nb_prediction     ];
73    PREDICT_PREDICTOR_0_PHT_HISTORY = new sc_signal<Tpht_history_t> * [_param._nb_prediction     ];
74    PREDICT_PREDICTOR_1_BHT_HISTORY = new sc_signal<Tbht_history_t> * [_param._nb_prediction     ];
75    PREDICT_PREDICTOR_1_PHT_HISTORY = new sc_signal<Tpht_history_t> * [_param._nb_prediction     ];
76    PREDICT_PREDICTOR_2_BHT_HISTORY = new sc_signal<Tbht_history_t> * [_param._nb_prediction     ];
77    PREDICT_PREDICTOR_2_PHT_HISTORY = new sc_signal<Tpht_history_t> * [_param._nb_prediction     ];
78    PREDICT_HISTORY                 = new sc_signal<Thistory_t>     * [_param._nb_prediction     ];
79    PREDICT_DIRECTION               = new sc_signal<Tcontrol_t>     * [_param._nb_prediction     ];
80
81    for (uint32_t i=0; i<_param._nb_prediction; i++)
82      {
83        rename = "PREDICT_PREDICTOR_0_ACK_"          +toString(i);
84        PREDICT_PREDICTOR_0_ACK                   [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
85        rename = "PREDICT_PREDICTOR_1_ACK_"          +toString(i);
86        PREDICT_PREDICTOR_1_ACK                   [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
87        rename = "PREDICT_PREDICTOR_2_ACK_"          +toString(i);
88        PREDICT_PREDICTOR_2_ACK                   [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
89        rename = "PREDICT_ACK_"                    +toString(i);
90        PREDICT_ACK                               [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
91        rename = "PREDICT_PREDICTOR_0_BHT_HISTORY_"+toString(i);
92        PREDICT_PREDICTOR_0_BHT_HISTORY           [i] = new sc_signal<Tbht_history_t> (rename.c_str());
93        rename = "PREDICT_PREDICTOR_0_PHT_HISTORY_"+toString(i);
94        PREDICT_PREDICTOR_0_PHT_HISTORY           [i] = new sc_signal<Tpht_history_t> (rename.c_str());
95        rename = "PREDICT_PREDICTOR_1_BHT_HISTORY_"+toString(i);
96        PREDICT_PREDICTOR_1_BHT_HISTORY           [i] = new sc_signal<Tbht_history_t> (rename.c_str());
97        rename = "PREDICT_PREDICTOR_1_PHT_HISTORY_"+toString(i);
98        PREDICT_PREDICTOR_1_PHT_HISTORY           [i] = new sc_signal<Tpht_history_t> (rename.c_str());
99        rename = "PREDICT_PREDICTOR_2_BHT_HISTORY_"+toString(i);
100        PREDICT_PREDICTOR_2_BHT_HISTORY           [i] = new sc_signal<Tbht_history_t> (rename.c_str());
101        rename = "PREDICT_PREDICTOR_2_PHT_HISTORY_"+toString(i);
102        PREDICT_PREDICTOR_2_PHT_HISTORY           [i] = new sc_signal<Tpht_history_t> (rename.c_str());
103        rename = "PREDICT_HISTORY_"                +toString(i);
104        PREDICT_HISTORY                           [i] = new sc_signal<Thistory_t>     (rename.c_str());
105        rename = "PREDICT_DIRECTION_"              +toString(i);
106        PREDICT_DIRECTION                         [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
107      }
108
109    // Interface Branch_complete
110   
111    BRANCH_COMPLETE_PREDICTOR_0_ACK         = new sc_signal<Tcontrol_t>     * [_param._nb_branch_complete     ];
112    BRANCH_COMPLETE_PREDICTOR_1_ACK         = new sc_signal<Tcontrol_t>     * [_param._nb_branch_complete     ];
113    BRANCH_COMPLETE_PREDICTOR_2_ACK         = new sc_signal<Tcontrol_t>     * [_param._nb_branch_complete     ];
114    BRANCH_COMPLETE_ACK                     = new sc_signal<Tcontrol_t>     * [_param._nb_branch_complete     ];
115    BRANCH_COMPLETE_PREDICTOR_0_BHT_HISTORY = new sc_signal<Tbht_history_t> * [_param._nb_branch_complete     ];
116    BRANCH_COMPLETE_PREDICTOR_0_PHT_HISTORY = new sc_signal<Tpht_history_t> * [_param._nb_branch_complete     ];
117    BRANCH_COMPLETE_PREDICTOR_1_BHT_HISTORY = new sc_signal<Tbht_history_t> * [_param._nb_branch_complete     ];
118    BRANCH_COMPLETE_PREDICTOR_1_PHT_HISTORY = new sc_signal<Tpht_history_t> * [_param._nb_branch_complete     ];
119    BRANCH_COMPLETE_PREDICTOR_2_BHT_HISTORY = new sc_signal<Tbht_history_t> * [_param._nb_branch_complete     ];
120    BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY = new sc_signal<Tpht_history_t> * [_param._nb_branch_complete     ];
121    BRANCH_COMPLETE_HISTORY                 = new sc_signal<Thistory_t>     * [_param._nb_branch_complete     ];
122
123    for (uint32_t i=0; i<_param._nb_branch_complete; i++)
124      {
125        rename = "BRANCH_COMPLETE_PREDICTOR_0_ACK_"          +toString(i);
126        BRANCH_COMPLETE_PREDICTOR_0_ACK                   [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
127        rename = "BRANCH_COMPLETE_PREDICTOR_1_ACK_"          +toString(i);
128        BRANCH_COMPLETE_PREDICTOR_1_ACK                   [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
129        rename = "BRANCH_COMPLETE_PREDICTOR_2_ACK_"          +toString(i);
130        BRANCH_COMPLETE_PREDICTOR_2_ACK                   [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
131        rename = "BRANCH_COMPLETE_ACK_"                    +toString(i);
132        BRANCH_COMPLETE_ACK                               [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
133        rename = "BRANCH_COMPLETE_PREDICTOR_0_BHT_HISTORY_"+toString(i);
134        BRANCH_COMPLETE_PREDICTOR_0_BHT_HISTORY           [i] = new sc_signal<Tbht_history_t> (rename.c_str());
135        rename = "BRANCH_COMPLETE_PREDICTOR_0_PHT_HISTORY_"+toString(i);
136        BRANCH_COMPLETE_PREDICTOR_0_PHT_HISTORY           [i] = new sc_signal<Tpht_history_t> (rename.c_str());
137        rename = "BRANCH_COMPLETE_PREDICTOR_1_BHT_HISTORY_"+toString(i);
138        BRANCH_COMPLETE_PREDICTOR_1_BHT_HISTORY           [i] = new sc_signal<Tbht_history_t> (rename.c_str());
139        rename = "BRANCH_COMPLETE_PREDICTOR_1_PHT_HISTORY_"+toString(i);
140        BRANCH_COMPLETE_PREDICTOR_1_PHT_HISTORY           [i] = new sc_signal<Tpht_history_t> (rename.c_str());
141        rename = "BRANCH_COMPLETE_PREDICTOR_2_BHT_HISTORY_"+toString(i);
142        BRANCH_COMPLETE_PREDICTOR_2_BHT_HISTORY           [i] = new sc_signal<Tbht_history_t> (rename.c_str());
143        rename = "BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY_"+toString(i);
144        BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY           [i] = new sc_signal<Tpht_history_t> (rename.c_str());
145        rename = "BRANCH_COMPLETE_HISTORY_"                +toString(i);
146        BRANCH_COMPLETE_HISTORY                           [i] = new sc_signal<Thistory_t>     (rename.c_str());
147      }
148
149  /********************************************************
150   * Instanciation
151   ********************************************************/
152 
153  cout << "<" << name << "> Instanciation of _Meta_Predictor_Glue" << endl;
154 
155#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
156  (*(_Meta_Predictor_Glue->in_CLOCK))        (*(CLOCK));
157#endif
158
159    // Interface Predict
160    for (uint32_t i=0; i<_param._nb_prediction; i++)
161      {
162        if (_param._have_meta_predictor)
163          {
164        (*(_Meta_Predictor_Glue-> in_PREDICT_PREDICTOR_0_ACK                 [i])) (*(PREDICT_PREDICTOR_0_ACK                 [i]));
165        (*(_Meta_Predictor_Glue-> in_PREDICT_PREDICTOR_1_ACK                 [i])) (*(PREDICT_PREDICTOR_1_ACK                 [i]));
166          }                                                                                                                   
167        (*(_Meta_Predictor_Glue-> in_PREDICT_PREDICTOR_2_ACK                 [i])) (*(PREDICT_PREDICTOR_2_ACK                 [i]));
168        (*(_Meta_Predictor_Glue->out_PREDICT_ACK                             [i])) (*(PREDICT_ACK                             [i]));
169        if (_param._have_meta_predictor)
170          {                                                                                                                   
171        if (_param._predictor_0_have_bht)
172        (*(_Meta_Predictor_Glue-> in_PREDICT_PREDICTOR_0_BHT_HISTORY         [i])) (*(PREDICT_PREDICTOR_0_BHT_HISTORY         [i]));
173        if (_param._predictor_0_have_pht)
174        (*(_Meta_Predictor_Glue-> in_PREDICT_PREDICTOR_0_PHT_HISTORY         [i])) (*(PREDICT_PREDICTOR_0_PHT_HISTORY         [i]));
175        if (_param._predictor_1_have_bht)
176        (*(_Meta_Predictor_Glue-> in_PREDICT_PREDICTOR_1_BHT_HISTORY         [i])) (*(PREDICT_PREDICTOR_1_BHT_HISTORY         [i]));
177        if (_param._predictor_1_have_pht)
178        (*(_Meta_Predictor_Glue-> in_PREDICT_PREDICTOR_1_PHT_HISTORY         [i])) (*(PREDICT_PREDICTOR_1_PHT_HISTORY         [i]));
179          }                                                                                                                   
180        if (_param._predictor_2_have_bht)
181        (*(_Meta_Predictor_Glue-> in_PREDICT_PREDICTOR_2_BHT_HISTORY         [i])) (*(PREDICT_PREDICTOR_2_BHT_HISTORY         [i]));
182        if (_param._predictor_2_have_pht)
183        (*(_Meta_Predictor_Glue-> in_PREDICT_PREDICTOR_2_PHT_HISTORY         [i])) (*(PREDICT_PREDICTOR_2_PHT_HISTORY         [i]));
184        (*(_Meta_Predictor_Glue->out_PREDICT_HISTORY                         [i])) (*(PREDICT_HISTORY                         [i]));
185        (*(_Meta_Predictor_Glue->out_PREDICT_DIRECTION                       [i])) (*(PREDICT_DIRECTION                       [i]));
186      }
187
188    // Interface Branch_complete
189   
190    for (uint32_t i=0; i<_param._nb_branch_complete; i++)
191      {
192        if (_param._have_meta_predictor)
193          {
194        (*(_Meta_Predictor_Glue-> in_BRANCH_COMPLETE_PREDICTOR_0_ACK         [i])) (*(BRANCH_COMPLETE_PREDICTOR_0_ACK         [i]));
195        (*(_Meta_Predictor_Glue-> in_BRANCH_COMPLETE_PREDICTOR_1_ACK         [i])) (*(BRANCH_COMPLETE_PREDICTOR_1_ACK         [i]));
196          }                                     
197        (*(_Meta_Predictor_Glue-> in_BRANCH_COMPLETE_PREDICTOR_2_ACK         [i])) (*(BRANCH_COMPLETE_PREDICTOR_2_ACK         [i]));
198        (*(_Meta_Predictor_Glue->out_BRANCH_COMPLETE_ACK                     [i])) (*(BRANCH_COMPLETE_ACK                     [i]));
199                                               
200        if (_param._have_meta_predictor)       
201          {                                     
202        if (_param._predictor_0_have_bht)
203        (*(_Meta_Predictor_Glue->out_BRANCH_COMPLETE_PREDICTOR_0_BHT_HISTORY [i])) (*(BRANCH_COMPLETE_PREDICTOR_0_BHT_HISTORY [i]));
204        if (_param._predictor_0_have_pht)
205        (*(_Meta_Predictor_Glue->out_BRANCH_COMPLETE_PREDICTOR_0_PHT_HISTORY [i])) (*(BRANCH_COMPLETE_PREDICTOR_0_PHT_HISTORY [i]));
206        if (_param._predictor_1_have_bht)
207        (*(_Meta_Predictor_Glue->out_BRANCH_COMPLETE_PREDICTOR_1_BHT_HISTORY [i])) (*(BRANCH_COMPLETE_PREDICTOR_1_BHT_HISTORY [i]));
208        if (_param._predictor_1_have_pht)
209        (*(_Meta_Predictor_Glue->out_BRANCH_COMPLETE_PREDICTOR_1_PHT_HISTORY [i])) (*(BRANCH_COMPLETE_PREDICTOR_1_PHT_HISTORY [i]));
210          }                                     
211        if (_param._predictor_2_have_bht)
212        (*(_Meta_Predictor_Glue->out_BRANCH_COMPLETE_PREDICTOR_2_BHT_HISTORY [i])) (*(BRANCH_COMPLETE_PREDICTOR_2_BHT_HISTORY [i]));
213        if (_param._predictor_2_have_pht)
214        (*(_Meta_Predictor_Glue->out_BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY [i])) (*(BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY [i]));
215        (*(_Meta_Predictor_Glue-> in_BRANCH_COMPLETE_HISTORY                 [i])) (*(BRANCH_COMPLETE_HISTORY                 [i]));
216      }
217
218  /********************************************************
219   * Simulation - Begin
220   ********************************************************/
221
222  cout << "<" << name << "> Start Simulation ............" << endl;
223  // Initialisation
224
225  const uint32_t seed = 0;
226//const uint32_t seed = static_cast<uint32_t>(time(NULL));
227
228  srand(seed);
229
230  sc_start(0);
231  _Meta_Predictor_Glue->vhdl_testbench_label("Initialisation");
232  cout << "{"+toString(static_cast<uint32_t>(sc_simulation_time()))+"} Initialisation" << endl;
233 
234  // No need initialisation
235
236  _Meta_Predictor_Glue->vhdl_testbench_label("Loop of Test");
237  cout << "{"+toString(static_cast<uint32_t>(sc_simulation_time()))+"} Loop of Test" << endl;
238 
239  Tcontrol_t     predict_ack                             [_param._nb_prediction];
240  Thistory_t     predict_history                         [_param._nb_prediction];
241  Tcontrol_t     predict_direction                       [_param._nb_prediction];
242               
243  Tcontrol_t     branch_complete_ack                     [_param._nb_branch_complete];
244  Tbht_history_t branch_complete_predictor_0_bht_history [_param._nb_branch_complete];
245  Tpht_history_t branch_complete_predictor_0_pht_history [_param._nb_branch_complete];
246  Tbht_history_t branch_complete_predictor_1_bht_history [_param._nb_branch_complete];
247  Tpht_history_t branch_complete_predictor_1_pht_history [_param._nb_branch_complete];
248  Tbht_history_t branch_complete_predictor_2_bht_history [_param._nb_branch_complete];
249  Tpht_history_t branch_complete_predictor_2_pht_history [_param._nb_branch_complete];
250
251  uint32_t shift_0 = 0;
252  uint32_t shift_1 = shift_0 + _param._predictor_0_bht_size_shifter;
253  uint32_t shift_2 = shift_1 + _param._predictor_0_pht_size_counter;
254  uint32_t shift_3 = shift_2 + _param._predictor_1_bht_size_shifter;
255  uint32_t shift_4 = shift_3 + _param._predictor_1_pht_size_counter;
256  uint32_t shift_5 = shift_4 + _param._predictor_2_bht_size_shifter;
257//uint32_t shift_5 = shift_5 + _param._predictor_2_pht_size_counter;
258
259  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
260    {
261      _Meta_Predictor_Glue->vhdl_testbench_label("Iteration "+toString(iteration));
262
263      for (uint32_t i=0; i<_param._nb_prediction; i++)
264        {
265          Tcontrol_t     predictor_0_ack        , predictor_1_ack        , predictor_2_ack        ;
266          Tpht_history_t predictor_0_pht_history, predictor_1_pht_history, predictor_2_pht_history;
267          Tbht_history_t predictor_0_bht_history, predictor_1_bht_history, predictor_2_bht_history;
268
269          predictor_0_ack             = not _param._have_meta_predictor or ((rand()%2) != 0);
270          predictor_1_ack             = not _param._have_meta_predictor or ((rand()%2) != 0);
271          predictor_2_ack             =                                    ((rand()%2) != 0);
272          predict_ack             [i] = predictor_0_ack and predictor_1_ack and predictor_2_ack;
273
274          PREDICT_PREDICTOR_0_ACK [i] ->write (predictor_0_ack);
275          PREDICT_PREDICTOR_1_ACK [i] ->write (predictor_1_ack);
276          PREDICT_PREDICTOR_2_ACK [i] ->write (predictor_2_ack);
277                                     
278          predictor_0_bht_history     = rand() % (_param._predictor_0_bht_size_shifter+1);
279          predictor_0_pht_history     = rand() % (_param._predictor_0_pht_size_counter+1);
280          predictor_1_bht_history     = rand() % (_param._predictor_1_bht_size_shifter+1);
281          predictor_1_pht_history     = rand() % (_param._predictor_1_pht_size_counter+1);
282          predictor_2_bht_history     = rand() % (_param._predictor_2_bht_size_shifter+1);
283          predictor_2_pht_history     = rand() % (_param._predictor_2_pht_size_counter+1);
284                                     
285          predict_history         [i] = ( (predictor_0_bht_history << shift_0) |
286                                          (predictor_0_pht_history << shift_1) |
287                                          (predictor_1_bht_history << shift_2) |
288                                          (predictor_1_pht_history << shift_3) |
289                                          (predictor_2_bht_history << shift_4) |
290                                          (predictor_2_pht_history << shift_5) );
291         
292          cout << "{"+toString(static_cast<uint32_t>(sc_simulation_time()))+"} predict         [" << i << "]" << endl
293               << "       _2_ " << predictor_2_bht_history << " - " << predictor_2_pht_history << endl
294               << "     _/    " << endl
295               << "    | |-1- " << predictor_1_bht_history << " - " << predictor_1_pht_history << endl
296               << "  --| |    " << endl
297               << "    |_|-0- " << predictor_0_bht_history << " - " << predictor_0_pht_history << endl;
298
299
300          Tcontrol_t predict_direction_predictor_2;
301         
302          if (_param._predictor_2_have_pht)
303            predict_direction_predictor_2 = (predictor_2_pht_history & (1<<(_param._predictor_2_pht_size_counter-1))) != 0;
304          else
305            predict_direction_predictor_2 = (predictor_2_bht_history & (1<<(_param._predictor_2_bht_size_shifter-1))) != 0;
306
307          if (_param._have_meta_predictor == false)
308            predict_direction       [i] = predict_direction_predictor_2;
309          else
310            if (predict_direction_predictor_2 == false)
311              if (_param._predictor_0_have_pht)
312                predict_direction       [i] = (predictor_0_pht_history & (1<<(_param._predictor_0_pht_size_counter-1))) != 0;
313              else
314                predict_direction       [i] = (predictor_0_bht_history & (1<<(_param._predictor_0_bht_size_shifter-1))) != 0;
315            else
316              if (_param._predictor_1_have_pht)
317                predict_direction       [i] = (predictor_1_pht_history & (1<<(_param._predictor_1_pht_size_counter-1))) != 0;
318              else
319                predict_direction       [i] = (predictor_1_bht_history & (1<<(_param._predictor_1_bht_size_shifter-1))) != 0;
320
321          PREDICT_PREDICTOR_0_BHT_HISTORY [i]->write(predictor_0_bht_history);
322          PREDICT_PREDICTOR_0_PHT_HISTORY [i]->write(predictor_0_pht_history);
323          PREDICT_PREDICTOR_1_BHT_HISTORY [i]->write(predictor_1_bht_history);
324          PREDICT_PREDICTOR_1_PHT_HISTORY [i]->write(predictor_1_pht_history);
325          PREDICT_PREDICTOR_2_BHT_HISTORY [i]->write(predictor_2_bht_history);
326          PREDICT_PREDICTOR_2_PHT_HISTORY [i]->write(predictor_2_pht_history);
327        }
328
329      for (uint32_t i=0; i<_param._nb_branch_complete; i++)
330        {
331          Tcontrol_t     predictor_0_ack        , predictor_1_ack        , predictor_2_ack        ;
332
333          predictor_0_ack                             = not _param._have_meta_predictor or ((rand()%2) != 0);
334          predictor_1_ack                             = not _param._have_meta_predictor or ((rand()%2) != 0);
335          predictor_2_ack                             =                                    ((rand()%2) != 0);
336          branch_complete_ack                     [i] = predictor_0_ack and predictor_1_ack and predictor_2_ack;
337
338          BRANCH_COMPLETE_PREDICTOR_0_ACK         [i] ->write (predictor_0_ack);
339          BRANCH_COMPLETE_PREDICTOR_1_ACK         [i] ->write (predictor_1_ack);
340          BRANCH_COMPLETE_PREDICTOR_2_ACK         [i] ->write (predictor_2_ack);
341
342          branch_complete_predictor_0_bht_history [i] = rand() % (_param._predictor_0_bht_size_shifter+1);
343          branch_complete_predictor_0_pht_history [i] = rand() % (_param._predictor_0_pht_size_counter+1);
344          branch_complete_predictor_1_bht_history [i] = rand() % (_param._predictor_1_bht_size_shifter+1);
345          branch_complete_predictor_1_pht_history [i] = rand() % (_param._predictor_1_pht_size_counter+1);
346          branch_complete_predictor_2_bht_history [i] = rand() % (_param._predictor_2_bht_size_shifter+1);
347          branch_complete_predictor_2_pht_history [i] = rand() % (_param._predictor_2_pht_size_counter+1);
348               
349          BRANCH_COMPLETE_HISTORY                 [i]->write((branch_complete_predictor_0_bht_history [i] << shift_0) |
350                                                             (branch_complete_predictor_0_pht_history [i] << shift_1) |
351                                                             (branch_complete_predictor_1_bht_history [i] << shift_2) |
352                                                             (branch_complete_predictor_1_pht_history [i] << shift_3) |
353                                                             (branch_complete_predictor_2_bht_history [i] << shift_4) |
354                                                             (branch_complete_predictor_2_pht_history [i] << shift_5) );
355        }
356
357      sc_start(1);
358
359      for (uint32_t i=0; i<_param._nb_prediction; i++)
360        {
361          TEST(Tcontrol_t    , PREDICT_ACK                             [i]->read(), predict_ack                             [i]);
362          TEST(Tcontrol_t    , PREDICT_HISTORY                         [i]->read(), predict_history                         [i]);
363          TEST(Tcontrol_t    , PREDICT_DIRECTION                       [i]->read(), predict_direction                       [i]);
364        }
365
366      for (uint32_t i=0; i<_param._nb_branch_complete; i++)
367        {
368          TEST(Tcontrol_t    , BRANCH_COMPLETE_ACK                     [i]->read(), branch_complete_ack                     [i]);
369
370        if (_param._have_meta_predictor)       
371          {                                     
372        if (_param._predictor_0_have_bht)
373          TEST(Tbht_history_t, BRANCH_COMPLETE_PREDICTOR_0_BHT_HISTORY [i]->read(), branch_complete_predictor_0_bht_history [i]);
374        if (_param._predictor_0_have_pht)
375          TEST(Tpht_history_t, BRANCH_COMPLETE_PREDICTOR_0_PHT_HISTORY [i]->read(), branch_complete_predictor_0_pht_history [i]);
376        if (_param._predictor_1_have_bht)
377          TEST(Tbht_history_t, BRANCH_COMPLETE_PREDICTOR_1_BHT_HISTORY [i]->read(), branch_complete_predictor_1_bht_history [i]);
378        if (_param._predictor_1_have_pht)
379          TEST(Tpht_history_t, BRANCH_COMPLETE_PREDICTOR_1_PHT_HISTORY [i]->read(), branch_complete_predictor_1_pht_history [i]);
380          }                                     
381        if (_param._predictor_2_have_bht)
382          TEST(Tbht_history_t, BRANCH_COMPLETE_PREDICTOR_2_BHT_HISTORY [i]->read(), branch_complete_predictor_2_bht_history [i]);
383        if (_param._predictor_2_have_pht)
384          TEST(Tpht_history_t, BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY [i]->read(), branch_complete_predictor_2_pht_history [i]);
385        }
386    }
387
388  /********************************************************
389   * Simulation - End
390   ********************************************************/
391
392  cout << "<" << name << "> ............ Stop Simulation" << endl;
393
394#endif
395
396  delete _Meta_Predictor_Glue;
397}
Note: See TracBrowser for help on using the repository browser.