[110] | 1 | /* |
---|
| 2 | * $Id: test.cpp 112 2009-03-18 22:36:26Z 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 | |
---|
| 12 | void 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 | |
---|
[111] | 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); |
---|
[112] | 66 | ALLOC1_SC_SIGNAL( in_UPDATE_HISTORY_VAL ," in_UPDATE_HISTORY_VAL ",Tcontrol_t,_param->_nb_inst_update); |
---|
[111] | 67 | ALLOC1_SC_SIGNAL( in_UPDATE_DIRECTION ," in_UPDATE_DIRECTION ",Tcontrol_t,_param->_nb_inst_update); |
---|
| 68 | ALLOC2_SC_SIGNAL(out_UPDATE_PREDICTOR_VAL ,"out_UPDATE_PREDICTOR_VAL ",Tcontrol_t,_param->_nb_predictor,_param->_nb_inst_update); |
---|
| 69 | ALLOC2_SC_SIGNAL( in_UPDATE_PREDICTOR_ACK ," in_UPDATE_PREDICTOR_ACK ",Tcontrol_t,_param->_nb_predictor,_param->_nb_inst_update); |
---|
| 70 | ALLOC2_SC_SIGNAL(out_UPDATE_PREDICTOR_HISTORY ,"out_UPDATE_PREDICTOR_HISTORY ",Thistory_t,_param->_nb_predictor,_param->_nb_inst_update); |
---|
[112] | 71 | ALLOC2_SC_SIGNAL(out_UPDATE_PREDICTOR_HISTORY_VAL ,"out_UPDATE_PREDICTOR_HISTORY_VAL ",Tcontrol_t,_param->_nb_predictor,_param->_nb_inst_update); |
---|
[111] | 72 | ALLOC2_SC_SIGNAL(out_UPDATE_PREDICTOR_DIRECTION ,"out_UPDATE_PREDICTOR_DIRECTION ",Tcontrol_t,_param->_nb_predictor,_param->_nb_inst_update); |
---|
| 73 | ALLOC2_SC_SIGNAL(out_UPDATE_PREDICTOR_MISS ,"out_UPDATE_PREDICTOR_MISS ",Tcontrol_t,_param->_nb_predictor,_param->_nb_inst_update); |
---|
| 74 | |
---|
[110] | 75 | /******************************************************** |
---|
| 76 | * Instanciation |
---|
| 77 | ********************************************************/ |
---|
| 78 | |
---|
| 79 | msg(_("<%s> : Instanciation of _Meta_Predictor_Glue.\n"),name.c_str()); |
---|
| 80 | |
---|
| 81 | (*(_Meta_Predictor_Glue->in_CLOCK)) (*(in_CLOCK)); |
---|
| 82 | (*(_Meta_Predictor_Glue->in_NRESET)) (*(in_NRESET)); |
---|
| 83 | |
---|
[111] | 84 | INSTANCE1_SC_SIGNAL(_Meta_Predictor_Glue, in_PREDICT_VAL ,_param->_nb_inst_predict); |
---|
| 85 | INSTANCE1_SC_SIGNAL(_Meta_Predictor_Glue,out_PREDICT_ACK ,_param->_nb_inst_predict); |
---|
| 86 | INSTANCE1_SC_SIGNAL(_Meta_Predictor_Glue,out_PREDICT_HISTORY ,_param->_nb_inst_predict); |
---|
| 87 | INSTANCE1_SC_SIGNAL(_Meta_Predictor_Glue,out_PREDICT_DIRECTION ,_param->_nb_inst_predict); |
---|
[110] | 88 | |
---|
[111] | 89 | INSTANCE2_SC_SIGNAL(_Meta_Predictor_Glue,out_PREDICT_PREDICTOR_VAL ,_param->_nb_predictor,_param->_nb_inst_predict); |
---|
| 90 | INSTANCE2_SC_SIGNAL(_Meta_Predictor_Glue, in_PREDICT_PREDICTOR_ACK ,_param->_nb_predictor,_param->_nb_inst_predict); |
---|
| 91 | INSTANCE2_SC_SIGNAL(_Meta_Predictor_Glue, in_PREDICT_PREDICTOR_HISTORY ,_param->_nb_predictor,_param->_nb_inst_predict); |
---|
| 92 | INSTANCE2_SC_SIGNAL(_Meta_Predictor_Glue, in_PREDICT_PREDICTOR_DIRECTION ,_param->_nb_predictor,_param->_nb_inst_predict); |
---|
| 93 | |
---|
| 94 | for (uint32_t i=0; i<_param->_nb_predictor; ++i) |
---|
| 95 | if (_param->_predictor_update_on_prediction [i]) |
---|
| 96 | { |
---|
| 97 | INSTANCE1_SC_SIGNAL(_Meta_Predictor_Glue,out_PREDICT_PREDICTOR_DIRECTION_VAL[i],_param->_nb_inst_predict); |
---|
| 98 | INSTANCE1_SC_SIGNAL(_Meta_Predictor_Glue,out_PREDICT_PREDICTOR_DIRECTION [i],_param->_nb_inst_predict); |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | INSTANCE1_SC_SIGNAL(_Meta_Predictor_Glue, in_UPDATE_VAL ,_param->_nb_inst_update); |
---|
| 102 | INSTANCE1_SC_SIGNAL(_Meta_Predictor_Glue,out_UPDATE_ACK ,_param->_nb_inst_update); |
---|
| 103 | INSTANCE1_SC_SIGNAL(_Meta_Predictor_Glue, in_UPDATE_HISTORY ,_param->_nb_inst_update); |
---|
[112] | 104 | INSTANCE1_SC_SIGNAL(_Meta_Predictor_Glue, in_UPDATE_HISTORY_VAL ,_param->_nb_inst_update); |
---|
[111] | 105 | INSTANCE1_SC_SIGNAL(_Meta_Predictor_Glue, in_UPDATE_DIRECTION ,_param->_nb_inst_update); |
---|
| 106 | |
---|
| 107 | INSTANCE2_SC_SIGNAL(_Meta_Predictor_Glue,out_UPDATE_PREDICTOR_VAL ,_param->_nb_predictor,_param->_nb_inst_update); |
---|
| 108 | INSTANCE2_SC_SIGNAL(_Meta_Predictor_Glue, in_UPDATE_PREDICTOR_ACK ,_param->_nb_predictor,_param->_nb_inst_update); |
---|
| 109 | INSTANCE2_SC_SIGNAL(_Meta_Predictor_Glue,out_UPDATE_PREDICTOR_HISTORY ,_param->_nb_predictor,_param->_nb_inst_update); |
---|
[112] | 110 | INSTANCE2_SC_SIGNAL(_Meta_Predictor_Glue,out_UPDATE_PREDICTOR_HISTORY_VAL ,_param->_nb_predictor,_param->_nb_inst_update); |
---|
[111] | 111 | INSTANCE2_SC_SIGNAL(_Meta_Predictor_Glue,out_UPDATE_PREDICTOR_DIRECTION ,_param->_nb_predictor,_param->_nb_inst_update); |
---|
| 112 | for (uint32_t i=0; i<_param->_nb_predictor; ++i) |
---|
| 113 | if (_param->_predictor_update_on_prediction [i]) |
---|
| 114 | INSTANCE1_SC_SIGNAL(_Meta_Predictor_Glue,out_UPDATE_PREDICTOR_MISS [i] ,_param->_nb_inst_update); |
---|
| 115 | |
---|
[110] | 116 | msg(_("<%s> : Start Simulation ............\n"),name.c_str()); |
---|
| 117 | |
---|
| 118 | Time * _time = new Time(); |
---|
| 119 | |
---|
| 120 | /******************************************************** |
---|
| 121 | * Simulation - Begin |
---|
| 122 | ********************************************************/ |
---|
| 123 | |
---|
| 124 | // Initialisation |
---|
| 125 | |
---|
| 126 | const uint32_t seed = 0; |
---|
| 127 | //const uint32_t seed = static_cast<uint32_t>(time(NULL)); |
---|
| 128 | |
---|
| 129 | srand(seed); |
---|
| 130 | |
---|
| 131 | SC_START(0); |
---|
| 132 | LABEL("Initialisation"); |
---|
| 133 | |
---|
| 134 | LABEL("Reset"); |
---|
| 135 | in_NRESET->write(0); |
---|
| 136 | SC_START(5); |
---|
| 137 | in_NRESET->write(1); |
---|
| 138 | |
---|
| 139 | LABEL("Loop of Test"); |
---|
| 140 | |
---|
| 141 | for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++) |
---|
| 142 | { |
---|
| 143 | LABEL("Iteration %d",iteration); |
---|
| 144 | |
---|
| 145 | SC_START(1); |
---|
| 146 | } |
---|
| 147 | |
---|
| 148 | /******************************************************** |
---|
| 149 | * Simulation - End |
---|
| 150 | ********************************************************/ |
---|
| 151 | |
---|
| 152 | TEST_OK ("End of Simulation"); |
---|
| 153 | delete _time; |
---|
| 154 | |
---|
| 155 | msg(_("<%s> : ............ Stop Simulation\n"),name.c_str()); |
---|
| 156 | |
---|
| 157 | delete in_CLOCK; |
---|
| 158 | delete in_NRESET; |
---|
[111] | 159 | |
---|
| 160 | DELETE1_SC_SIGNAL( in_PREDICT_VAL ,_param->_nb_inst_predict); |
---|
| 161 | DELETE1_SC_SIGNAL(out_PREDICT_ACK ,_param->_nb_inst_predict); |
---|
| 162 | DELETE1_SC_SIGNAL(out_PREDICT_HISTORY ,_param->_nb_inst_predict); |
---|
| 163 | DELETE1_SC_SIGNAL(out_PREDICT_DIRECTION ,_param->_nb_inst_predict); |
---|
| 164 | |
---|
| 165 | DELETE2_SC_SIGNAL(out_PREDICT_PREDICTOR_VAL ,_param->_nb_predictor,_param->_nb_inst_predict); |
---|
| 166 | DELETE2_SC_SIGNAL( in_PREDICT_PREDICTOR_ACK ,_param->_nb_predictor,_param->_nb_inst_predict); |
---|
| 167 | DELETE2_SC_SIGNAL( in_PREDICT_PREDICTOR_HISTORY ,_param->_nb_predictor,_param->_nb_inst_predict); |
---|
| 168 | DELETE2_SC_SIGNAL( in_PREDICT_PREDICTOR_DIRECTION ,_param->_nb_predictor,_param->_nb_inst_predict); |
---|
| 169 | DELETE2_SC_SIGNAL(out_PREDICT_PREDICTOR_DIRECTION_VAL,_param->_nb_predictor,_param->_nb_inst_predict); |
---|
| 170 | DELETE2_SC_SIGNAL(out_PREDICT_PREDICTOR_DIRECTION ,_param->_nb_predictor,_param->_nb_inst_predict); |
---|
| 171 | |
---|
| 172 | DELETE1_SC_SIGNAL( in_UPDATE_VAL ,_param->_nb_inst_update); |
---|
| 173 | DELETE1_SC_SIGNAL(out_UPDATE_ACK ,_param->_nb_inst_update); |
---|
| 174 | DELETE1_SC_SIGNAL( in_UPDATE_HISTORY ,_param->_nb_inst_update); |
---|
[112] | 175 | DELETE1_SC_SIGNAL( in_UPDATE_HISTORY_VAL ,_param->_nb_inst_update); |
---|
[111] | 176 | DELETE1_SC_SIGNAL( in_UPDATE_DIRECTION ,_param->_nb_inst_update); |
---|
| 177 | |
---|
| 178 | DELETE2_SC_SIGNAL(out_UPDATE_PREDICTOR_VAL ,_param->_nb_predictor,_param->_nb_inst_update); |
---|
| 179 | DELETE2_SC_SIGNAL( in_UPDATE_PREDICTOR_ACK ,_param->_nb_predictor,_param->_nb_inst_update); |
---|
| 180 | DELETE2_SC_SIGNAL(out_UPDATE_PREDICTOR_HISTORY ,_param->_nb_predictor,_param->_nb_inst_update); |
---|
| 181 | DELETE2_SC_SIGNAL(out_UPDATE_PREDICTOR_DIRECTION ,_param->_nb_predictor,_param->_nb_inst_update); |
---|
| 182 | DELETE2_SC_SIGNAL(out_UPDATE_PREDICTOR_MISS ,_param->_nb_predictor,_param->_nb_inst_update); |
---|
[110] | 183 | } |
---|
| 184 | #endif |
---|
| 185 | |
---|
| 186 | delete _Meta_Predictor_Glue; |
---|
| 187 | #ifdef STATISTICS |
---|
| 188 | delete _parameters_statistics; |
---|
| 189 | #endif |
---|
| 190 | } |
---|