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

Last change on this file since 45 was 45, checked in by rosiere, 17 years ago
  • Documentation : specification d'un cache de donnée non bloquant
  • Modification de l'aborescence
File size: 27.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 "Common/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  sc_signal<Tcontrol_t>            * NRESET;
31
32    // Interface Predict
33  sc_signal<Tcontrol_t>           ** PREDICT_PREDICTOR_0_ACK                ;
34  sc_signal<Tcontrol_t>           ** PREDICT_PREDICTOR_1_ACK                ;
35  sc_signal<Tcontrol_t>           ** PREDICT_PREDICTOR_2_ACK                ;
36  sc_signal<Tcontrol_t>           ** PREDICT_ACK                            ;
37
38  sc_signal<Tbht_history_t>       ** PREDICT_PREDICTOR_0_BHT_HISTORY        ;
39  sc_signal<Tpht_history_t>       ** PREDICT_PREDICTOR_0_PHT_HISTORY        ;
40  sc_signal<Tbht_history_t>       ** PREDICT_PREDICTOR_1_BHT_HISTORY        ;
41  sc_signal<Tpht_history_t>       ** PREDICT_PREDICTOR_1_PHT_HISTORY        ;
42  sc_signal<Tbht_history_t>       ** PREDICT_PREDICTOR_2_BHT_HISTORY        ;
43  sc_signal<Tpht_history_t>       ** PREDICT_PREDICTOR_2_PHT_HISTORY        ;
44  sc_signal<Thistory_t>           ** PREDICT_HISTORY                        ;
45  sc_signal<Tcontrol_t>           ** PREDICT_DIRECTION                      ;
46
47    // Interface Branch_complete
48  sc_signal<Tcontrol_t>           ** BRANCH_COMPLETE_VAL                    ;
49  sc_signal<Tcontrol_t>           ** BRANCH_COMPLETE_PREDICTOR_2_VAL        ;
50
51  sc_signal<Tcontrol_t>           ** BRANCH_COMPLETE_PREDICTOR_0_ACK        ;
52  sc_signal<Tcontrol_t>           ** BRANCH_COMPLETE_PREDICTOR_1_ACK        ;
53  sc_signal<Tcontrol_t>           ** BRANCH_COMPLETE_PREDICTOR_2_ACK        ;
54  sc_signal<Tcontrol_t>           ** BRANCH_COMPLETE_ACK                    ;
55
56  sc_signal<Tbht_history_t>       ** BRANCH_COMPLETE_PREDICTOR_0_BHT_HISTORY;
57  sc_signal<Tpht_history_t>       ** BRANCH_COMPLETE_PREDICTOR_0_PHT_HISTORY;
58  sc_signal<Tbht_history_t>       ** BRANCH_COMPLETE_PREDICTOR_1_BHT_HISTORY;
59  sc_signal<Tpht_history_t>       ** BRANCH_COMPLETE_PREDICTOR_1_PHT_HISTORY;
60  sc_signal<Tbht_history_t>       ** BRANCH_COMPLETE_PREDICTOR_2_BHT_HISTORY;
61  sc_signal<Tpht_history_t>       ** BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY;
62  sc_signal<Thistory_t>           ** BRANCH_COMPLETE_HISTORY                ;
63  sc_signal<Tcontrol_t>           ** BRANCH_COMPLETE_DIRECTION              ;
64  sc_signal<Tcontrol_t>           ** BRANCH_COMPLETE_PREDICTOR_2_DIRECTION  ;
65  string rename;
66
67#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
68  CLOCK                             = new sc_clock ("clock", 1.0, 0.5);
69  NRESET                            = new sc_signal<Tcontrol_t> ("nreset");
70#endif 
71
72    // Interface Predict
73
74    PREDICT_PREDICTOR_0_ACK         = new sc_signal<Tcontrol_t>     * [_param._nb_prediction     ];
75    PREDICT_PREDICTOR_1_ACK         = new sc_signal<Tcontrol_t>     * [_param._nb_prediction     ];
76    PREDICT_PREDICTOR_2_ACK         = new sc_signal<Tcontrol_t>     * [_param._nb_prediction     ];
77    PREDICT_ACK                     = new sc_signal<Tcontrol_t>     * [_param._nb_prediction     ];
78    PREDICT_PREDICTOR_0_BHT_HISTORY = new sc_signal<Tbht_history_t> * [_param._nb_prediction     ];
79    PREDICT_PREDICTOR_0_PHT_HISTORY = new sc_signal<Tpht_history_t> * [_param._nb_prediction     ];
80    PREDICT_PREDICTOR_1_BHT_HISTORY = new sc_signal<Tbht_history_t> * [_param._nb_prediction     ];
81    PREDICT_PREDICTOR_1_PHT_HISTORY = new sc_signal<Tpht_history_t> * [_param._nb_prediction     ];
82    PREDICT_PREDICTOR_2_BHT_HISTORY = new sc_signal<Tbht_history_t> * [_param._nb_prediction     ];
83    PREDICT_PREDICTOR_2_PHT_HISTORY = new sc_signal<Tpht_history_t> * [_param._nb_prediction     ];
84    PREDICT_HISTORY                 = new sc_signal<Thistory_t>     * [_param._nb_prediction     ];
85    PREDICT_DIRECTION               = new sc_signal<Tcontrol_t>     * [_param._nb_prediction     ];
86
87    for (uint32_t i=0; i<_param._nb_prediction; i++)
88      {
89        rename = "PREDICT_PREDICTOR_0_ACK_"          +toString(i);
90        PREDICT_PREDICTOR_0_ACK                   [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
91        rename = "PREDICT_PREDICTOR_1_ACK_"          +toString(i);
92        PREDICT_PREDICTOR_1_ACK                   [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
93        rename = "PREDICT_PREDICTOR_2_ACK_"          +toString(i);
94        PREDICT_PREDICTOR_2_ACK                   [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
95        rename = "PREDICT_ACK_"                    +toString(i);
96        PREDICT_ACK                               [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
97        rename = "PREDICT_PREDICTOR_0_BHT_HISTORY_"+toString(i);
98        PREDICT_PREDICTOR_0_BHT_HISTORY           [i] = new sc_signal<Tbht_history_t> (rename.c_str());
99        rename = "PREDICT_PREDICTOR_0_PHT_HISTORY_"+toString(i);
100        PREDICT_PREDICTOR_0_PHT_HISTORY           [i] = new sc_signal<Tpht_history_t> (rename.c_str());
101        rename = "PREDICT_PREDICTOR_1_BHT_HISTORY_"+toString(i);
102        PREDICT_PREDICTOR_1_BHT_HISTORY           [i] = new sc_signal<Tbht_history_t> (rename.c_str());
103        rename = "PREDICT_PREDICTOR_1_PHT_HISTORY_"+toString(i);
104        PREDICT_PREDICTOR_1_PHT_HISTORY           [i] = new sc_signal<Tpht_history_t> (rename.c_str());
105        rename = "PREDICT_PREDICTOR_2_BHT_HISTORY_"+toString(i);
106        PREDICT_PREDICTOR_2_BHT_HISTORY           [i] = new sc_signal<Tbht_history_t> (rename.c_str());
107        rename = "PREDICT_PREDICTOR_2_PHT_HISTORY_"+toString(i);
108        PREDICT_PREDICTOR_2_PHT_HISTORY           [i] = new sc_signal<Tpht_history_t> (rename.c_str());
109        rename = "PREDICT_HISTORY_"                +toString(i);
110        PREDICT_HISTORY                           [i] = new sc_signal<Thistory_t>     (rename.c_str());
111        rename = "PREDICT_DIRECTION_"              +toString(i);
112        PREDICT_DIRECTION                         [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
113      }
114
115    // Interface Branch_complete
116    BRANCH_COMPLETE_VAL                     = new sc_signal<Tcontrol_t>     * [_param._nb_branch_complete     ];
117    BRANCH_COMPLETE_PREDICTOR_2_VAL         = new sc_signal<Tcontrol_t>     * [_param._nb_branch_complete     ];
118    BRANCH_COMPLETE_PREDICTOR_0_ACK         = new sc_signal<Tcontrol_t>     * [_param._nb_branch_complete     ];
119    BRANCH_COMPLETE_PREDICTOR_1_ACK         = new sc_signal<Tcontrol_t>     * [_param._nb_branch_complete     ];
120    BRANCH_COMPLETE_PREDICTOR_2_ACK         = new sc_signal<Tcontrol_t>     * [_param._nb_branch_complete     ];
121    BRANCH_COMPLETE_ACK                     = new sc_signal<Tcontrol_t>     * [_param._nb_branch_complete     ];
122    BRANCH_COMPLETE_PREDICTOR_0_BHT_HISTORY = new sc_signal<Tbht_history_t> * [_param._nb_branch_complete     ];
123    BRANCH_COMPLETE_PREDICTOR_0_PHT_HISTORY = new sc_signal<Tpht_history_t> * [_param._nb_branch_complete     ];
124    BRANCH_COMPLETE_PREDICTOR_1_BHT_HISTORY = new sc_signal<Tbht_history_t> * [_param._nb_branch_complete     ];
125    BRANCH_COMPLETE_PREDICTOR_1_PHT_HISTORY = new sc_signal<Tpht_history_t> * [_param._nb_branch_complete     ];
126    BRANCH_COMPLETE_PREDICTOR_2_BHT_HISTORY = new sc_signal<Tbht_history_t> * [_param._nb_branch_complete     ];
127    BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY = new sc_signal<Tpht_history_t> * [_param._nb_branch_complete     ];
128    BRANCH_COMPLETE_HISTORY                 = new sc_signal<Thistory_t>     * [_param._nb_branch_complete     ];
129    BRANCH_COMPLETE_DIRECTION               = new sc_signal<Tcontrol_t>     * [_param._nb_branch_complete     ];
130    BRANCH_COMPLETE_PREDICTOR_2_DIRECTION   = new sc_signal<Tcontrol_t>     * [_param._nb_branch_complete     ];
131
132    for (uint32_t i=0; i<_param._nb_branch_complete; i++)
133      {
134        rename = "BRANCH_COMPLETE_VAL_"                      +toString(i);
135        BRANCH_COMPLETE_VAL                               [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
136        rename = "BRANCH_COMPLETE_PREDICTOR_2_VAL_"          +toString(i);
137        BRANCH_COMPLETE_PREDICTOR_2_VAL                   [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
138        rename = "BRANCH_COMPLETE_PREDICTOR_0_ACK_"          +toString(i);
139        BRANCH_COMPLETE_PREDICTOR_0_ACK                   [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
140        rename = "BRANCH_COMPLETE_PREDICTOR_1_ACK_"          +toString(i);
141        BRANCH_COMPLETE_PREDICTOR_1_ACK                   [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
142        rename = "BRANCH_COMPLETE_PREDICTOR_2_ACK_"          +toString(i);
143        BRANCH_COMPLETE_PREDICTOR_2_ACK                   [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
144        rename = "BRANCH_COMPLETE_ACK_"                    +toString(i);
145        BRANCH_COMPLETE_ACK                               [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
146        rename = "BRANCH_COMPLETE_PREDICTOR_0_BHT_HISTORY_"+toString(i);
147        BRANCH_COMPLETE_PREDICTOR_0_BHT_HISTORY           [i] = new sc_signal<Tbht_history_t> (rename.c_str());
148        rename = "BRANCH_COMPLETE_PREDICTOR_0_PHT_HISTORY_"+toString(i);
149        BRANCH_COMPLETE_PREDICTOR_0_PHT_HISTORY           [i] = new sc_signal<Tpht_history_t> (rename.c_str());
150        rename = "BRANCH_COMPLETE_PREDICTOR_1_BHT_HISTORY_"+toString(i);
151        BRANCH_COMPLETE_PREDICTOR_1_BHT_HISTORY           [i] = new sc_signal<Tbht_history_t> (rename.c_str());
152        rename = "BRANCH_COMPLETE_PREDICTOR_1_PHT_HISTORY_"+toString(i);
153        BRANCH_COMPLETE_PREDICTOR_1_PHT_HISTORY           [i] = new sc_signal<Tpht_history_t> (rename.c_str());
154        rename = "BRANCH_COMPLETE_PREDICTOR_2_BHT_HISTORY_"+toString(i);
155        BRANCH_COMPLETE_PREDICTOR_2_BHT_HISTORY           [i] = new sc_signal<Tbht_history_t> (rename.c_str());
156        rename = "BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY_"+toString(i);
157        BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY           [i] = new sc_signal<Tpht_history_t> (rename.c_str());
158        rename = "BRANCH_COMPLETE_HISTORY_"                +toString(i);
159        BRANCH_COMPLETE_HISTORY                           [i] = new sc_signal<Thistory_t>     (rename.c_str());
160        rename = "BRANCH_COMPLETE_DIRECTION_"              +toString(i);
161        BRANCH_COMPLETE_DIRECTION                         [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
162        rename = "BRANCH_COMPLETE_PREDICTOR_2_DIRECTION_"  +toString(i);
163        BRANCH_COMPLETE_PREDICTOR_2_DIRECTION             [i] = new sc_signal<Tcontrol_t>     (rename.c_str());
164      }
165
166  /********************************************************
167   * Instanciation
168   ********************************************************/
169 
170  cout << "<" << name << "> Instanciation of _Meta_Predictor_Glue" << endl;
171 
172#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
173  (*(_Meta_Predictor_Glue->in_CLOCK))        (*(CLOCK));
174  (*(_Meta_Predictor_Glue->in_NRESET))        (*(NRESET));
175#endif
176
177    // Interface Predict
178    for (uint32_t i=0; i<_param._nb_prediction; i++)
179      {
180        if (_param._have_meta_predictor)
181          {
182        (*(_Meta_Predictor_Glue-> in_PREDICT_PREDICTOR_0_ACK                 [i])) (*(PREDICT_PREDICTOR_0_ACK                 [i]));
183        (*(_Meta_Predictor_Glue-> in_PREDICT_PREDICTOR_1_ACK                 [i])) (*(PREDICT_PREDICTOR_1_ACK                 [i]));
184          }                                                                                                                   
185        (*(_Meta_Predictor_Glue-> in_PREDICT_PREDICTOR_2_ACK                 [i])) (*(PREDICT_PREDICTOR_2_ACK                 [i]));
186        (*(_Meta_Predictor_Glue->out_PREDICT_ACK                             [i])) (*(PREDICT_ACK                             [i]));
187        if (_param._have_meta_predictor)
188          {                                                                                                                   
189        if (_param._predictor_0_have_bht)
190        (*(_Meta_Predictor_Glue-> in_PREDICT_PREDICTOR_0_BHT_HISTORY         [i])) (*(PREDICT_PREDICTOR_0_BHT_HISTORY         [i]));
191        if (_param._predictor_0_have_pht)
192        (*(_Meta_Predictor_Glue-> in_PREDICT_PREDICTOR_0_PHT_HISTORY         [i])) (*(PREDICT_PREDICTOR_0_PHT_HISTORY         [i]));
193        if (_param._predictor_1_have_bht)
194        (*(_Meta_Predictor_Glue-> in_PREDICT_PREDICTOR_1_BHT_HISTORY         [i])) (*(PREDICT_PREDICTOR_1_BHT_HISTORY         [i]));
195        if (_param._predictor_1_have_pht)
196        (*(_Meta_Predictor_Glue-> in_PREDICT_PREDICTOR_1_PHT_HISTORY         [i])) (*(PREDICT_PREDICTOR_1_PHT_HISTORY         [i]));
197          }                                                                                                                   
198        if (_param._predictor_2_have_bht)
199        (*(_Meta_Predictor_Glue-> in_PREDICT_PREDICTOR_2_BHT_HISTORY         [i])) (*(PREDICT_PREDICTOR_2_BHT_HISTORY         [i]));
200        if (_param._predictor_2_have_pht)
201        (*(_Meta_Predictor_Glue-> in_PREDICT_PREDICTOR_2_PHT_HISTORY         [i])) (*(PREDICT_PREDICTOR_2_PHT_HISTORY         [i]));
202        (*(_Meta_Predictor_Glue->out_PREDICT_HISTORY                         [i])) (*(PREDICT_HISTORY                         [i]));
203        (*(_Meta_Predictor_Glue->out_PREDICT_DIRECTION                       [i])) (*(PREDICT_DIRECTION                       [i]));
204      }
205
206    // Interface Branch_complete
207   
208    for (uint32_t i=0; i<_param._nb_branch_complete; i++)
209      {
210        if (_param._have_meta_predictor)
211          {
212        (*(_Meta_Predictor_Glue-> in_BRANCH_COMPLETE_VAL                     [i])) (*(BRANCH_COMPLETE_VAL                     [i]));
213        (*(_Meta_Predictor_Glue->out_BRANCH_COMPLETE_PREDICTOR_2_VAL         [i])) (*(BRANCH_COMPLETE_PREDICTOR_2_VAL         [i]));
214
215        (*(_Meta_Predictor_Glue-> in_BRANCH_COMPLETE_PREDICTOR_0_ACK         [i])) (*(BRANCH_COMPLETE_PREDICTOR_0_ACK         [i]));
216        (*(_Meta_Predictor_Glue-> in_BRANCH_COMPLETE_PREDICTOR_1_ACK         [i])) (*(BRANCH_COMPLETE_PREDICTOR_1_ACK         [i]));
217          }                                     
218        (*(_Meta_Predictor_Glue-> in_BRANCH_COMPLETE_PREDICTOR_2_ACK         [i])) (*(BRANCH_COMPLETE_PREDICTOR_2_ACK         [i]));
219        (*(_Meta_Predictor_Glue->out_BRANCH_COMPLETE_ACK                     [i])) (*(BRANCH_COMPLETE_ACK                     [i]));
220                                               
221        if (_param._have_meta_predictor)       
222          {                                     
223        if (_param._predictor_0_have_bht)
224        (*(_Meta_Predictor_Glue->out_BRANCH_COMPLETE_PREDICTOR_0_BHT_HISTORY [i])) (*(BRANCH_COMPLETE_PREDICTOR_0_BHT_HISTORY [i]));
225        if (_param._predictor_0_have_pht)
226        (*(_Meta_Predictor_Glue->out_BRANCH_COMPLETE_PREDICTOR_0_PHT_HISTORY [i])) (*(BRANCH_COMPLETE_PREDICTOR_0_PHT_HISTORY [i]));
227        if (_param._predictor_1_have_bht)
228        (*(_Meta_Predictor_Glue->out_BRANCH_COMPLETE_PREDICTOR_1_BHT_HISTORY [i])) (*(BRANCH_COMPLETE_PREDICTOR_1_BHT_HISTORY [i]));
229        if (_param._predictor_1_have_pht)
230        (*(_Meta_Predictor_Glue->out_BRANCH_COMPLETE_PREDICTOR_1_PHT_HISTORY [i])) (*(BRANCH_COMPLETE_PREDICTOR_1_PHT_HISTORY [i]));
231          }                                     
232        if (_param._predictor_2_have_bht)
233        (*(_Meta_Predictor_Glue->out_BRANCH_COMPLETE_PREDICTOR_2_BHT_HISTORY [i])) (*(BRANCH_COMPLETE_PREDICTOR_2_BHT_HISTORY [i]));
234        if (_param._predictor_2_have_pht)
235        (*(_Meta_Predictor_Glue->out_BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY [i])) (*(BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY [i]));
236        (*(_Meta_Predictor_Glue-> in_BRANCH_COMPLETE_HISTORY                 [i])) (*(BRANCH_COMPLETE_HISTORY                 [i]));
237        if (_param._have_meta_predictor)       
238          {
239        (*(_Meta_Predictor_Glue-> in_BRANCH_COMPLETE_DIRECTION               [i])) (*(BRANCH_COMPLETE_DIRECTION               [i]));
240        (*(_Meta_Predictor_Glue->out_BRANCH_COMPLETE_PREDICTOR_2_DIRECTION   [i])) (*(BRANCH_COMPLETE_PREDICTOR_2_DIRECTION   [i]));
241          }
242      }
243
244  /********************************************************
245   * Simulation - Begin
246   ********************************************************/
247
248  cout << "<" << name << "> Start Simulation ............" << endl;
249  // Initialisation
250
251  const uint32_t seed = 0;
252//const uint32_t seed = static_cast<uint32_t>(time(NULL));
253
254  srand(seed);
255
256  sc_start(0);
257  cout << "{"+toString(static_cast<uint32_t>(sc_simulation_time()))+"} Initialisation" << endl;
258
259  NRESET->write(0);
260  sc_start(5);
261  NRESET->write(1);
262  // No need initialisation
263
264  cout << "{"+toString(static_cast<uint32_t>(sc_simulation_time()))+"} Loop of Test" << endl;
265 
266  Tcontrol_t     predict_ack                             [_param._nb_prediction];
267  Thistory_t     predict_history                         [_param._nb_prediction];
268  Tcontrol_t     predict_direction                       [_param._nb_prediction];
269               
270  Tcontrol_t     branch_complete_predictor_2_val         [_param._nb_branch_complete];
271  Tcontrol_t     branch_complete_ack                     [_param._nb_branch_complete];
272  Tbht_history_t branch_complete_predictor_0_bht_history [_param._nb_branch_complete];
273  Tpht_history_t branch_complete_predictor_0_pht_history [_param._nb_branch_complete];
274  Tbht_history_t branch_complete_predictor_1_bht_history [_param._nb_branch_complete];
275  Tpht_history_t branch_complete_predictor_1_pht_history [_param._nb_branch_complete];
276  Tbht_history_t branch_complete_predictor_2_bht_history [_param._nb_branch_complete];
277  Tpht_history_t branch_complete_predictor_2_pht_history [_param._nb_branch_complete];
278  Tcontrol_t     branch_complete_predictor_2_direction   [_param._nb_branch_complete];
279
280  uint32_t shift_0 = 0;
281  uint32_t shift_1 = shift_0 + _param._predictor_0_bht_size_shifter;
282  uint32_t shift_2 = shift_1 + _param._predictor_0_pht_size_counter;
283  uint32_t shift_3 = shift_2 + _param._predictor_1_bht_size_shifter;
284  uint32_t shift_4 = shift_3 + _param._predictor_1_pht_size_counter;
285  uint32_t shift_5 = shift_4 + _param._predictor_2_bht_size_shifter;
286//uint32_t shift_6 = shift_5 + _param._predictor_2_pht_size_counter;
287
288  cout << "shift_0 : " << shift_0 << endl;
289  cout << "shift_1 : " << shift_1 << endl;
290  cout << "shift_2 : " << shift_2 << endl;
291  cout << "shift_3 : " << shift_3 << endl;
292  cout << "shift_4 : " << shift_4 << endl;
293  cout << "shift_5 : " << shift_5 << endl;
294
295  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
296    {
297
298      for (uint32_t i=0; i<_param._nb_prediction; i++)
299        {
300          Tcontrol_t     predictor_0_ack        , predictor_1_ack        , predictor_2_ack        ;
301          Tpht_history_t predictor_0_pht_history, predictor_1_pht_history, predictor_2_pht_history;
302          Tbht_history_t predictor_0_bht_history, predictor_1_bht_history, predictor_2_bht_history;
303
304          predictor_0_ack             = not _param._have_meta_predictor or ((rand()%2) != 0);
305          predictor_1_ack             = not _param._have_meta_predictor or ((rand()%2) != 0);
306          predictor_2_ack             =                                    ((rand()%2) != 0);
307          predict_ack             [i] = predictor_0_ack and predictor_1_ack and predictor_2_ack;
308
309          PREDICT_PREDICTOR_0_ACK [i] ->write (predictor_0_ack);
310          PREDICT_PREDICTOR_1_ACK [i] ->write (predictor_1_ack);
311          PREDICT_PREDICTOR_2_ACK [i] ->write (predictor_2_ack);
312                                     
313          predictor_0_bht_history     = rand() % (_param._predictor_0_bht_size_shifter+1);
314          predictor_0_pht_history     = rand() % (_param._predictor_0_pht_size_counter+1);
315          predictor_1_bht_history     = rand() % (_param._predictor_1_bht_size_shifter+1);
316          predictor_1_pht_history     = rand() % (_param._predictor_1_pht_size_counter+1);
317          predictor_2_bht_history     = rand() % (_param._predictor_2_bht_size_shifter+1);
318          predictor_2_pht_history     = rand() % (_param._predictor_2_pht_size_counter+1);
319                                     
320          predict_history         [i] = ( (predictor_0_bht_history << shift_0) |
321                                          (predictor_0_pht_history << shift_1) |
322                                          (predictor_1_bht_history << shift_2) |
323                                          (predictor_1_pht_history << shift_3) |
324                                          (predictor_2_bht_history << shift_4) |
325                                          (predictor_2_pht_history << shift_5) );
326         
327          cout << "{"+toString(static_cast<uint32_t>(sc_simulation_time()))+"} predict         [" << i << "]" << endl
328               << "       _2_ " << predictor_2_bht_history << " - " << predictor_2_pht_history << endl
329               << "     _/    " << endl
330               << "    | |-1- " << predictor_1_bht_history << " - " << predictor_1_pht_history << endl
331               << "  --| |    " << endl
332               << "    |_|-0- " << predictor_0_bht_history << " - " << predictor_0_pht_history << endl;
333
334
335          Tcontrol_t predict_direction_predictor_2;
336         
337          if (_param._predictor_2_have_pht)
338            predict_direction_predictor_2 = (predictor_2_pht_history & (1<<(_param._predictor_2_pht_size_counter-1))) != 0;
339          else
340            predict_direction_predictor_2 = (predictor_2_bht_history & (1<<(_param._predictor_2_bht_size_shifter-1))) != 0;
341
342          if (_param._have_meta_predictor == false)
343            predict_direction       [i] = predict_direction_predictor_2;
344          else
345            if (predict_direction_predictor_2 == false)
346              if (_param._predictor_0_have_pht)
347                predict_direction       [i] = (predictor_0_pht_history & (1<<(_param._predictor_0_pht_size_counter-1))) != 0;
348              else
349                predict_direction       [i] = (predictor_0_bht_history & (1<<(_param._predictor_0_bht_size_shifter-1))) != 0;
350            else
351              if (_param._predictor_1_have_pht)
352                predict_direction       [i] = (predictor_1_pht_history & (1<<(_param._predictor_1_pht_size_counter-1))) != 0;
353              else
354                predict_direction       [i] = (predictor_1_bht_history & (1<<(_param._predictor_1_bht_size_shifter-1))) != 0;
355
356          PREDICT_PREDICTOR_0_BHT_HISTORY [i]->write(predictor_0_bht_history);
357          PREDICT_PREDICTOR_0_PHT_HISTORY [i]->write(predictor_0_pht_history);
358          PREDICT_PREDICTOR_1_BHT_HISTORY [i]->write(predictor_1_bht_history);
359          PREDICT_PREDICTOR_1_PHT_HISTORY [i]->write(predictor_1_pht_history);
360          PREDICT_PREDICTOR_2_BHT_HISTORY [i]->write(predictor_2_bht_history);
361          PREDICT_PREDICTOR_2_PHT_HISTORY [i]->write(predictor_2_pht_history);
362        }
363
364      for (uint32_t i=0; i<_param._nb_branch_complete; i++)
365        {
366          Tcontrol_t     predictor_0_ack        , predictor_1_ack        , predictor_2_ack        ;
367
368          predictor_0_ack                             = not _param._have_meta_predictor or ((rand()%2) != 0);
369          predictor_1_ack                             = not _param._have_meta_predictor or ((rand()%2) != 0);
370          predictor_2_ack                             =                                    ((rand()%2) != 0);
371          branch_complete_ack                     [i] = predictor_0_ack and predictor_1_ack and predictor_2_ack;
372
373          BRANCH_COMPLETE_PREDICTOR_0_ACK         [i] ->write (predictor_0_ack);
374          BRANCH_COMPLETE_PREDICTOR_1_ACK         [i] ->write (predictor_1_ack);
375          BRANCH_COMPLETE_PREDICTOR_2_ACK         [i] ->write (predictor_2_ack);
376
377          branch_complete_predictor_0_bht_history [i] = rand() % (1<<_param._predictor_0_bht_size_shifter);
378          branch_complete_predictor_0_pht_history [i] = rand() % (1<<_param._predictor_0_pht_size_counter);
379          branch_complete_predictor_1_bht_history [i] = rand() % (1<<_param._predictor_1_bht_size_shifter);
380          branch_complete_predictor_1_pht_history [i] = rand() % (1<<_param._predictor_1_pht_size_counter);
381          branch_complete_predictor_2_bht_history [i] = rand() % (1<<_param._predictor_2_bht_size_shifter);
382          branch_complete_predictor_2_pht_history [i] = rand() % (1<<_param._predictor_2_pht_size_counter);
383               
384          Thistory_t history = ((branch_complete_predictor_0_bht_history [i] << shift_0) |
385                                (branch_complete_predictor_0_pht_history [i] << shift_1) |
386                                (branch_complete_predictor_1_bht_history [i] << shift_2) |
387                                (branch_complete_predictor_1_pht_history [i] << shift_3) |
388                                (branch_complete_predictor_2_bht_history [i] << shift_4) |
389                                (branch_complete_predictor_2_pht_history [i] << shift_5) );
390
391          BRANCH_COMPLETE_HISTORY                 [i]->write (history);
392
393          cout << "<test> [" << i << "] : " << endl
394             << hex
395             << " *   " << history << endl
396             << "   - " << branch_complete_predictor_0_bht_history [i] << endl
397             << "   - " << branch_complete_predictor_0_pht_history [i] << endl
398             << "   - " << branch_complete_predictor_1_bht_history [i] << endl
399             << "   - " << branch_complete_predictor_1_pht_history [i] << endl
400             << "   - " << branch_complete_predictor_2_bht_history [i] << endl
401             << "   - " << branch_complete_predictor_2_pht_history [i] << endl
402             << dec;
403
404          Tcontrol_t direction_0 = ((_param._predictor_0_have_pht)?(branch_complete_predictor_0_pht_history [i] >> (_param._predictor_0_pht_size_counter-1)):(branch_complete_predictor_0_bht_history [i] >> (_param._predictor_0_bht_size_shifter-1)))&1;
405          Tcontrol_t direction_1 = ((_param._predictor_1_have_pht)?(branch_complete_predictor_1_pht_history [i] >> (_param._predictor_1_pht_size_counter-1)):(branch_complete_predictor_1_bht_history [i] >> (_param._predictor_1_bht_size_shifter-1)))&1;
406          Tcontrol_t direction_2 = ((_param._predictor_2_have_pht)?(branch_complete_predictor_2_pht_history [i] >> (_param._predictor_2_pht_size_counter-1)):(branch_complete_predictor_2_bht_history [i] >> (_param._predictor_2_bht_size_shifter-1)))&1;
407
408          Tcontrol_t direction   = ((rand()%2) != 0);
409          Tcontrol_t val         = ((rand()%2) != 0);
410
411          cout << "{"+toString(static_cast<uint32_t>(sc_simulation_time()))+"} " << endl
412               << "  * val             : " << val << endl
413               << "  * direction_good  : " << direction << endl
414               << "    * direction_0   : " << direction_0 << endl
415               << "    * direction_1   : " << direction_1 << endl
416               << "    * direction_2   : " << direction_2 << endl;
417         
418          BRANCH_COMPLETE_VAL       [i] ->write (val);
419          BRANCH_COMPLETE_DIRECTION [i] ->write (direction);
420         
421          if (val == 0)
422            {
423              branch_complete_predictor_2_val [i] = val;
424            }
425          else
426            {
427              branch_complete_predictor_2_val [i] = (direction_0 xor direction_1);
428              if (direction_2 == 0)
429                if (direction_0 == direction)
430                  branch_complete_predictor_2_direction [i] = 0;
431                else
432                  branch_complete_predictor_2_direction [i] = 1;
433              else
434                if (direction_1 == direction)
435                  branch_complete_predictor_2_direction [i] = 1;
436                else
437                  branch_complete_predictor_2_direction [i] = 0;
438            }
439        }
440
441      sc_start(1);
442
443      for (uint32_t i=0; i<_param._nb_prediction; i++)
444        {
445          TEST(Tcontrol_t    , PREDICT_ACK                             [i]->read(), predict_ack                             [i]);
446          TEST(Tcontrol_t    , PREDICT_HISTORY                         [i]->read(), predict_history                         [i]);
447          TEST(Tcontrol_t    , PREDICT_DIRECTION                       [i]->read(), predict_direction                       [i]);
448        }
449
450      for (uint32_t i=0; i<_param._nb_branch_complete; i++)
451        {
452          TEST(Tcontrol_t    , BRANCH_COMPLETE_ACK                     [i]->read(), branch_complete_ack                     [i]);
453
454        if (_param._have_meta_predictor)       
455          {                                     
456          TEST(Tcontrol_t    , BRANCH_COMPLETE_PREDICTOR_2_VAL         [i]->read(), branch_complete_predictor_2_val         [i]);
457
458          if (branch_complete_predictor_2_val         [i])
459          TEST(Tcontrol_t    , BRANCH_COMPLETE_PREDICTOR_2_DIRECTION   [i]->read(), branch_complete_predictor_2_direction   [i]); 
460
461        if (_param._predictor_0_have_bht)
462          TEST(Tbht_history_t, BRANCH_COMPLETE_PREDICTOR_0_BHT_HISTORY [i]->read(), branch_complete_predictor_0_bht_history [i]);
463        if (_param._predictor_0_have_pht)
464          TEST(Tpht_history_t, BRANCH_COMPLETE_PREDICTOR_0_PHT_HISTORY [i]->read(), branch_complete_predictor_0_pht_history [i]);
465        if (_param._predictor_1_have_bht)
466          TEST(Tbht_history_t, BRANCH_COMPLETE_PREDICTOR_1_BHT_HISTORY [i]->read(), branch_complete_predictor_1_bht_history [i]);
467        if (_param._predictor_1_have_pht)
468          TEST(Tpht_history_t, BRANCH_COMPLETE_PREDICTOR_1_PHT_HISTORY [i]->read(), branch_complete_predictor_1_pht_history [i]);
469          }                                     
470        if (_param._predictor_2_have_bht)
471          TEST(Tbht_history_t, BRANCH_COMPLETE_PREDICTOR_2_BHT_HISTORY [i]->read(), branch_complete_predictor_2_bht_history [i]);
472        if (_param._predictor_2_have_pht)
473          TEST(Tpht_history_t, BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY [i]->read(), branch_complete_predictor_2_pht_history [i]);
474        }
475    }
476
477  /********************************************************
478   * Simulation - End
479   ********************************************************/
480
481  cout << "<" << name << "> ............ Stop Simulation" << endl;
482
483#endif
484
485  delete _Meta_Predictor_Glue;
486}
Note: See TracBrowser for help on using the repository browser.