[78] | 1 | /* |
---|
| 2 | * $Id$ |
---|
| 3 | * |
---|
| 4 | * [ Description ] |
---|
| 5 | * |
---|
| 6 | * Test |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | #include "Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Rename_unit/Register_translation_unit/Register_translation_unit_Glue/SelfTest/include/test.h" |
---|
| 10 | #include "Common/include/Test.h" |
---|
| 11 | #include "Behavioural/include/Allocation.h" |
---|
| 12 | |
---|
| 13 | #define NB_ITERATION 256 |
---|
| 14 | #define CYCLE_MAX (128*NB_ITERATION) |
---|
| 15 | |
---|
| 16 | #define LABEL(str...) \ |
---|
| 17 | { \ |
---|
| 18 | msg (_("{%d} "),static_cast<uint32_t>(sc_simulation_time())); \ |
---|
| 19 | msg (str); \ |
---|
| 20 | msg (_("\n")); \ |
---|
| 21 | } while(0) |
---|
| 22 | |
---|
| 23 | #define SC_START(cycle_offset) \ |
---|
| 24 | do \ |
---|
| 25 | { \ |
---|
| 26 | /*cout << "SC_START (begin)" << endl;*/ \ |
---|
| 27 | \ |
---|
| 28 | uint32_t cycle_current = static_cast<uint32_t>(sc_simulation_time()); \ |
---|
| 29 | if (cycle_offset != 0) \ |
---|
| 30 | { \ |
---|
| 31 | cout << "##########[ cycle "<< cycle_current+cycle_offset << " ]" << endl; \ |
---|
| 32 | } \ |
---|
| 33 | \ |
---|
| 34 | if (cycle_current > CYCLE_MAX) \ |
---|
| 35 | { \ |
---|
| 36 | TEST_KO("Maximal cycles Reached"); \ |
---|
| 37 | } \ |
---|
| 38 | \ |
---|
| 39 | sc_start(cycle_offset); \ |
---|
| 40 | \ |
---|
| 41 | /*cout << "SC_START (end )" << endl;*/ \ |
---|
| 42 | } while(0) |
---|
| 43 | |
---|
| 44 | void test (string name, |
---|
| 45 | morpheo::behavioural::core::multi_ooo_engine::ooo_engine::rename_unit::register_translation_unit::register_translation_unit_glue::Parameters * _param) |
---|
| 46 | { |
---|
| 47 | msg(_("<%s> : Simulation SystemC.\n"),name.c_str()); |
---|
| 48 | |
---|
| 49 | #ifdef STATISTICS |
---|
| 50 | morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5,50); |
---|
| 51 | #endif |
---|
| 52 | |
---|
| 53 | Register_translation_unit_Glue * _Register_translation_unit_Glue = new Register_translation_unit_Glue (name.c_str(), |
---|
| 54 | #ifdef STATISTICS |
---|
| 55 | _parameters_statistics, |
---|
| 56 | #endif |
---|
| 57 | _param); |
---|
| 58 | |
---|
| 59 | #ifdef SYSTEMC |
---|
| 60 | /********************************************************************* |
---|
| 61 | * Déclarations des signaux |
---|
| 62 | *********************************************************************/ |
---|
| 63 | string rename; |
---|
| 64 | |
---|
| 65 | sc_clock * in_CLOCK = new sc_clock ("clock", 1.0, 0.5); |
---|
| 66 | sc_signal<Tcontrol_t> * in_NRESET = new sc_signal<Tcontrol_t> ("NRESET"); |
---|
| 67 | |
---|
| 68 | ALLOC1_SC_SIGNAL( in_INSERT_RENAME_VAL ," in_INSERT_RENAME_VAL ",Tcontrol_t,_param->_nb_inst_insert); |
---|
| 69 | ALLOC1_SC_SIGNAL(out_INSERT_RENAME_ACK ,"out_INSERT_RENAME_ACK ",Tcontrol_t,_param->_nb_inst_insert); |
---|
| 70 | ALLOC1_SC_SIGNAL(out_INSERT_INSERT_VAL ,"out_INSERT_INSERT_VAL ",Tcontrol_t,_param->_nb_inst_insert); |
---|
| 71 | ALLOC1_SC_SIGNAL( in_INSERT_INSERT_ACK ," in_INSERT_INSERT_ACK ",Tcontrol_t,_param->_nb_inst_insert); |
---|
| 72 | ALLOC1_SC_SIGNAL(out_INSERT_RAT_INSERT_VAL,"out_INSERT_RAT_INSERT_VAL",Tcontrol_t,_param->_nb_inst_insert); |
---|
| 73 | ALLOC1_SC_SIGNAL( in_INSERT_RAT_RENAME_ACK," in_INSERT_RAT_RENAME_ACK",Tcontrol_t,_param->_nb_inst_insert); |
---|
| 74 | ALLOC1_SC_SIGNAL( in_INSERT_RAT_INSERT_ACK," in_INSERT_RAT_INSERT_ACK",Tcontrol_t,_param->_nb_inst_insert); |
---|
| 75 | ALLOC1_SC_SIGNAL(out_INSERT_FREE_LIST_VAL ,"out_INSERT_FREE_LIST_VAL ",Tcontrol_t,_param->_nb_inst_insert); |
---|
| 76 | ALLOC1_SC_SIGNAL( in_INSERT_FREE_LIST_ACK ," in_INSERT_FREE_LIST_ACK ",Tcontrol_t,_param->_nb_inst_insert); |
---|
| 77 | ALLOC1_SC_SIGNAL(out_INSERT_STAT_LIST_VAL ,"out_INSERT_STAT_LIST_VAL ",Tcontrol_t,_param->_nb_inst_insert); |
---|
| 78 | ALLOC1_SC_SIGNAL( in_INSERT_STAT_LIST_ACK ," in_INSERT_STAT_LIST_ACK ",Tcontrol_t,_param->_nb_inst_insert); |
---|
| 79 | ALLOC1_SC_SIGNAL( in_RETIRE_VAL ," in_RETIRE_VAL ",Tcontrol_t,_param->_nb_inst_retire); |
---|
| 80 | ALLOC1_SC_SIGNAL(out_RETIRE_ACK ,"out_RETIRE_ACK ",Tcontrol_t,_param->_nb_inst_retire); |
---|
| 81 | ALLOC1_SC_SIGNAL(out_RETIRE_RAT_VAL ,"out_RETIRE_RAT_VAL ",Tcontrol_t,_param->_nb_inst_retire); |
---|
| 82 | ALLOC1_SC_SIGNAL( in_RETIRE_RAT_ACK ," in_RETIRE_RAT_ACK ",Tcontrol_t,_param->_nb_inst_retire); |
---|
| 83 | ALLOC1_SC_SIGNAL(out_RETIRE_STAT_LIST_VAL ,"out_RETIRE_STAT_LIST_VAL ",Tcontrol_t,_param->_nb_inst_retire); |
---|
| 84 | ALLOC1_SC_SIGNAL( in_RETIRE_STAT_LIST_ACK ," in_RETIRE_STAT_LIST_ACK ",Tcontrol_t,_param->_nb_inst_retire); |
---|
| 85 | |
---|
| 86 | /******************************************************** |
---|
| 87 | * Instanciation |
---|
| 88 | ********************************************************/ |
---|
| 89 | |
---|
| 90 | msg(_("<%s> : Instanciation of _Register_translation_unit_Glue.\n"),name.c_str()); |
---|
| 91 | |
---|
| 92 | (*(_Register_translation_unit_Glue->in_CLOCK)) (*(in_CLOCK)); |
---|
| 93 | (*(_Register_translation_unit_Glue->in_NRESET)) (*(in_NRESET)); |
---|
| 94 | |
---|
| 95 | INSTANCE1_SC_SIGNAL(_Register_translation_unit_Glue, in_INSERT_RENAME_VAL ,_param->_nb_inst_insert); |
---|
| 96 | INSTANCE1_SC_SIGNAL(_Register_translation_unit_Glue,out_INSERT_RENAME_ACK ,_param->_nb_inst_insert); |
---|
| 97 | INSTANCE1_SC_SIGNAL(_Register_translation_unit_Glue,out_INSERT_INSERT_VAL ,_param->_nb_inst_insert); |
---|
| 98 | INSTANCE1_SC_SIGNAL(_Register_translation_unit_Glue, in_INSERT_INSERT_ACK ,_param->_nb_inst_insert); |
---|
| 99 | INSTANCE1_SC_SIGNAL(_Register_translation_unit_Glue,out_INSERT_RAT_INSERT_VAL,_param->_nb_inst_insert); |
---|
| 100 | INSTANCE1_SC_SIGNAL(_Register_translation_unit_Glue, in_INSERT_RAT_RENAME_ACK,_param->_nb_inst_insert); |
---|
| 101 | INSTANCE1_SC_SIGNAL(_Register_translation_unit_Glue, in_INSERT_RAT_INSERT_ACK,_param->_nb_inst_insert); |
---|
| 102 | INSTANCE1_SC_SIGNAL(_Register_translation_unit_Glue,out_INSERT_FREE_LIST_VAL ,_param->_nb_inst_insert); |
---|
| 103 | INSTANCE1_SC_SIGNAL(_Register_translation_unit_Glue, in_INSERT_FREE_LIST_ACK ,_param->_nb_inst_insert); |
---|
| 104 | INSTANCE1_SC_SIGNAL(_Register_translation_unit_Glue,out_INSERT_STAT_LIST_VAL ,_param->_nb_inst_insert); |
---|
| 105 | INSTANCE1_SC_SIGNAL(_Register_translation_unit_Glue, in_INSERT_STAT_LIST_ACK ,_param->_nb_inst_insert); |
---|
| 106 | INSTANCE1_SC_SIGNAL(_Register_translation_unit_Glue, in_RETIRE_VAL ,_param->_nb_inst_retire); |
---|
| 107 | INSTANCE1_SC_SIGNAL(_Register_translation_unit_Glue,out_RETIRE_ACK ,_param->_nb_inst_retire); |
---|
| 108 | INSTANCE1_SC_SIGNAL(_Register_translation_unit_Glue,out_RETIRE_RAT_VAL ,_param->_nb_inst_retire); |
---|
| 109 | INSTANCE1_SC_SIGNAL(_Register_translation_unit_Glue, in_RETIRE_RAT_ACK ,_param->_nb_inst_retire); |
---|
| 110 | INSTANCE1_SC_SIGNAL(_Register_translation_unit_Glue,out_RETIRE_STAT_LIST_VAL ,_param->_nb_inst_retire); |
---|
| 111 | INSTANCE1_SC_SIGNAL(_Register_translation_unit_Glue, in_RETIRE_STAT_LIST_ACK ,_param->_nb_inst_retire); |
---|
| 112 | |
---|
| 113 | msg(_("<%s> : Start Simulation ............\n"),name.c_str()); |
---|
| 114 | |
---|
| 115 | Time * _time = new Time(); |
---|
| 116 | |
---|
| 117 | /******************************************************** |
---|
| 118 | * Simulation - Begin |
---|
| 119 | ********************************************************/ |
---|
| 120 | |
---|
| 121 | // Initialisation |
---|
| 122 | |
---|
| 123 | const uint32_t seed = 0; |
---|
| 124 | //const uint32_t seed = static_cast<uint32_t>(time(NULL)); |
---|
| 125 | |
---|
| 126 | srand(seed); |
---|
| 127 | |
---|
| 128 | SC_START(0); |
---|
| 129 | LABEL("Initialisation"); |
---|
| 130 | |
---|
| 131 | LABEL("Reset"); |
---|
| 132 | in_NRESET->write(0); |
---|
| 133 | SC_START(5); |
---|
| 134 | in_NRESET->write(1); |
---|
| 135 | |
---|
| 136 | LABEL("Loop of Test"); |
---|
| 137 | |
---|
| 138 | for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++) |
---|
| 139 | { |
---|
| 140 | LABEL("Iteration %d",iteration); |
---|
| 141 | |
---|
| 142 | for (uint32_t i=0; i<_param->_nb_inst_insert;i++) |
---|
| 143 | { |
---|
| 144 | in_INSERT_RENAME_VAL [i]->write(rand()%2); |
---|
| 145 | in_INSERT_INSERT_ACK [i]->write(rand()%2); |
---|
| 146 | in_INSERT_RAT_RENAME_ACK[i]->write(rand()%2); |
---|
| 147 | in_INSERT_RAT_INSERT_ACK[i]->write(rand()%2); |
---|
| 148 | in_INSERT_FREE_LIST_ACK [i]->write(rand()%2); |
---|
| 149 | in_INSERT_STAT_LIST_ACK [i]->write(rand()%2); |
---|
| 150 | } |
---|
| 151 | |
---|
| 152 | for (uint32_t i=0; i<_param->_nb_inst_retire;i++) |
---|
| 153 | { |
---|
| 154 | in_RETIRE_VAL [i]->write(rand()%2); |
---|
| 155 | in_RETIRE_RAT_ACK [i]->write(rand()%2); |
---|
| 156 | in_RETIRE_STAT_LIST_ACK [i]->write(rand()%2); |
---|
| 157 | } |
---|
| 158 | |
---|
| 159 | SC_START(0); |
---|
| 160 | |
---|
| 161 | for (uint32_t i=0; i<_param->_nb_inst_insert;i++) |
---|
| 162 | { |
---|
| 163 | TEST(Tcontrol_t,out_INSERT_RENAME_ACK [i]->read(),(in_INSERT_INSERT_ACK [i]->read() and |
---|
| 164 | in_INSERT_RAT_RENAME_ACK [i]->read() and |
---|
| 165 | in_INSERT_RAT_INSERT_ACK [i]->read() and |
---|
| 166 | in_INSERT_FREE_LIST_ACK [i]->read() and |
---|
| 167 | in_INSERT_STAT_LIST_ACK [i]->read() )); |
---|
| 168 | TEST(Tcontrol_t,out_INSERT_INSERT_VAL [i]->read(),(in_INSERT_RENAME_VAL [i]->read() and |
---|
| 169 | in_INSERT_RAT_RENAME_ACK [i]->read() and |
---|
| 170 | in_INSERT_RAT_INSERT_ACK [i]->read() and |
---|
| 171 | in_INSERT_FREE_LIST_ACK [i]->read() and |
---|
| 172 | in_INSERT_STAT_LIST_ACK [i]->read() )); |
---|
| 173 | TEST(Tcontrol_t,out_INSERT_RAT_INSERT_VAL [i]->read(),(in_INSERT_RENAME_VAL [i]->read() and |
---|
| 174 | in_INSERT_INSERT_ACK [i]->read() and |
---|
| 175 | in_INSERT_RAT_RENAME_ACK [i]->read() and |
---|
| 176 | in_INSERT_FREE_LIST_ACK [i]->read() and |
---|
| 177 | in_INSERT_STAT_LIST_ACK [i]->read() )); |
---|
| 178 | TEST(Tcontrol_t,out_INSERT_FREE_LIST_VAL [i]->read(),(in_INSERT_RENAME_VAL [i]->read() and |
---|
| 179 | in_INSERT_INSERT_ACK [i]->read() and |
---|
| 180 | in_INSERT_RAT_RENAME_ACK [i]->read() and |
---|
| 181 | in_INSERT_RAT_INSERT_ACK [i]->read() and |
---|
| 182 | in_INSERT_STAT_LIST_ACK [i]->read() )); |
---|
| 183 | TEST(Tcontrol_t,out_INSERT_STAT_LIST_VAL [i]->read(),(in_INSERT_RENAME_VAL [i]->read() and |
---|
| 184 | in_INSERT_INSERT_ACK [i]->read() and |
---|
| 185 | in_INSERT_RAT_RENAME_ACK [i]->read() and |
---|
| 186 | in_INSERT_RAT_INSERT_ACK [i]->read() and |
---|
| 187 | in_INSERT_FREE_LIST_ACK [i]->read() )); |
---|
| 188 | } |
---|
| 189 | |
---|
| 190 | for (uint32_t i=0; i<_param->_nb_inst_retire;i++) |
---|
| 191 | { |
---|
| 192 | TEST(Tcontrol_t,out_RETIRE_ACK [i]->read(),(in_RETIRE_RAT_ACK [i]->read() and |
---|
| 193 | in_RETIRE_STAT_LIST_ACK [i]->read())); |
---|
| 194 | TEST(Tcontrol_t,out_RETIRE_RAT_VAL [i]->read(),(in_RETIRE_VAL [i]->read() and |
---|
| 195 | in_RETIRE_STAT_LIST_ACK [i]->read())); |
---|
| 196 | TEST(Tcontrol_t,out_RETIRE_STAT_LIST_VAL [i]->read(),(in_RETIRE_VAL [i]->read() and |
---|
| 197 | in_RETIRE_RAT_ACK [i]->read())); |
---|
| 198 | } |
---|
| 199 | |
---|
| 200 | SC_START(1); |
---|
| 201 | } |
---|
| 202 | |
---|
| 203 | /******************************************************** |
---|
| 204 | * Simulation - End |
---|
| 205 | ********************************************************/ |
---|
| 206 | |
---|
| 207 | TEST_OK ("End of Simulation"); |
---|
| 208 | delete _time; |
---|
| 209 | |
---|
| 210 | msg(_("<%s> : ............ Stop Simulation\n"),name.c_str()); |
---|
| 211 | |
---|
| 212 | delete in_CLOCK; |
---|
| 213 | delete in_NRESET; |
---|
| 214 | |
---|
| 215 | delete [] in_INSERT_RENAME_VAL ; |
---|
| 216 | delete [] out_INSERT_RENAME_ACK ; |
---|
| 217 | delete [] out_INSERT_INSERT_VAL ; |
---|
| 218 | delete [] in_INSERT_INSERT_ACK ; |
---|
| 219 | delete [] out_INSERT_RAT_INSERT_VAL; |
---|
| 220 | delete [] in_INSERT_RAT_RENAME_ACK; |
---|
| 221 | delete [] in_INSERT_RAT_INSERT_ACK; |
---|
| 222 | delete [] out_INSERT_FREE_LIST_VAL ; |
---|
| 223 | delete [] in_INSERT_FREE_LIST_ACK ; |
---|
| 224 | delete [] out_INSERT_STAT_LIST_VAL ; |
---|
| 225 | delete [] in_INSERT_STAT_LIST_ACK ; |
---|
| 226 | delete [] in_RETIRE_VAL ; |
---|
| 227 | delete [] out_RETIRE_ACK ; |
---|
| 228 | delete [] out_RETIRE_RAT_VAL ; |
---|
| 229 | delete [] in_RETIRE_RAT_ACK ; |
---|
| 230 | delete [] out_RETIRE_STAT_LIST_VAL ; |
---|
| 231 | delete [] in_RETIRE_STAT_LIST_ACK ; |
---|
| 232 | |
---|
| 233 | #endif |
---|
| 234 | |
---|
| 235 | delete _Register_translation_unit_Glue; |
---|
| 236 | #ifdef STATISTICS |
---|
| 237 | delete _parameters_statistics; |
---|
| 238 | #endif |
---|
| 239 | } |
---|