[78] | 1 | /* |
---|
| 2 | * $Id: test.cpp 82 2008-05-01 16:48:45Z rosiere $ |
---|
| 3 | * |
---|
| 4 | * [ Description ] |
---|
| 5 | * |
---|
| 6 | * Test |
---|
| 7 | */ |
---|
| 8 | |
---|
[82] | 9 | #define NB_ITERATION 1 |
---|
| 10 | #define CYCLE_MAX (128*NB_ITERATION) |
---|
| 11 | |
---|
[78] | 12 | #include "Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Rename_unit/Register_translation_unit/Free_List_unit/SelfTest/include/test.h" |
---|
| 13 | #include "Common/include/Test.h" |
---|
| 14 | #include "Behavioural/include/Allocation.h" |
---|
| 15 | |
---|
| 16 | void test (string name, |
---|
| 17 | morpheo::behavioural::core::multi_ooo_engine::ooo_engine::rename_unit::register_translation_unit::free_list_unit::Parameters * _param) |
---|
| 18 | { |
---|
| 19 | msg(_("<%s> : Simulation SystemC.\n"),name.c_str()); |
---|
| 20 | |
---|
| 21 | #ifdef STATISTICS |
---|
| 22 | morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5,50); |
---|
| 23 | #endif |
---|
| 24 | |
---|
[82] | 25 | Free_List_unit * _Free_List_unit = new Free_List_unit |
---|
| 26 | (name.c_str(), |
---|
[78] | 27 | #ifdef STATISTICS |
---|
[82] | 28 | _parameters_statistics, |
---|
[78] | 29 | #endif |
---|
[82] | 30 | _param, |
---|
| 31 | USE_ALL); |
---|
[78] | 32 | |
---|
| 33 | #ifdef SYSTEMC |
---|
| 34 | /********************************************************************* |
---|
| 35 | * Déclarations des signaux |
---|
| 36 | *********************************************************************/ |
---|
| 37 | string rename; |
---|
| 38 | |
---|
| 39 | sc_clock * in_CLOCK = new sc_clock ("clock", 1.0, 0.5); |
---|
| 40 | sc_signal<Tcontrol_t> * in_NRESET = new sc_signal<Tcontrol_t> ("NRESET"); |
---|
| 41 | |
---|
| 42 | ALLOC1_SC_SIGNAL( in_POP_VAL ," in_POP_VAL ",Tcontrol_t ,_param->_nb_pop ); |
---|
| 43 | ALLOC1_SC_SIGNAL(out_POP_ACK ,"out_POP_ACK ",Tcontrol_t ,_param->_nb_pop ); |
---|
| 44 | ALLOC1_SC_SIGNAL( in_POP_GPR_VAL ," in_POP_GPR_VAL ",Tcontrol_t ,_param->_nb_pop ); |
---|
| 45 | ALLOC1_SC_SIGNAL(out_POP_GPR_NUM_REG ,"out_POP_GPR_NUM_REG ",Tgeneral_address_t,_param->_nb_pop ); |
---|
| 46 | ALLOC1_SC_SIGNAL( in_POP_SPR_VAL ," in_POP_SPR_VAL ",Tcontrol_t ,_param->_nb_pop ); |
---|
| 47 | ALLOC1_SC_SIGNAL(out_POP_SPR_NUM_REG ,"out_POP_SPR_NUM_REG ",Tspecial_address_t,_param->_nb_pop ); |
---|
| 48 | ALLOC1_SC_SIGNAL( in_PUSH_GPR_VAL ," in_PUSH_GPR_VAL ",Tcontrol_t ,_param->_nb_push); |
---|
| 49 | ALLOC1_SC_SIGNAL(out_PUSH_GPR_ACK ,"out_PUSH_GPR_ACK ",Tcontrol_t ,_param->_nb_push); |
---|
| 50 | ALLOC1_SC_SIGNAL( in_PUSH_GPR_NUM_REG," in_PUSH_GPR_NUM_REG",Tgeneral_address_t,_param->_nb_push); |
---|
| 51 | ALLOC1_SC_SIGNAL( in_PUSH_SPR_VAL ," in_PUSH_SPR_VAL ",Tcontrol_t ,_param->_nb_push); |
---|
| 52 | ALLOC1_SC_SIGNAL(out_PUSH_SPR_ACK ,"out_PUSH_SPR_ACK ",Tcontrol_t ,_param->_nb_push); |
---|
| 53 | ALLOC1_SC_SIGNAL( in_PUSH_SPR_NUM_REG," in_PUSH_SPR_NUM_REG",Tspecial_address_t,_param->_nb_push); |
---|
| 54 | |
---|
| 55 | /******************************************************** |
---|
| 56 | * Instanciation |
---|
| 57 | ********************************************************/ |
---|
| 58 | |
---|
| 59 | msg(_("<%s> : Instanciation of _Free_List_unit.\n"),name.c_str()); |
---|
| 60 | |
---|
| 61 | (*(_Free_List_unit->in_CLOCK)) (*(in_CLOCK)); |
---|
| 62 | (*(_Free_List_unit->in_NRESET)) (*(in_NRESET)); |
---|
| 63 | |
---|
| 64 | INSTANCE1_SC_SIGNAL(_Free_List_unit, in_POP_VAL ,_param->_nb_pop ); |
---|
| 65 | INSTANCE1_SC_SIGNAL(_Free_List_unit,out_POP_ACK ,_param->_nb_pop ); |
---|
| 66 | INSTANCE1_SC_SIGNAL(_Free_List_unit, in_POP_GPR_VAL ,_param->_nb_pop ); |
---|
| 67 | INSTANCE1_SC_SIGNAL(_Free_List_unit,out_POP_GPR_NUM_REG ,_param->_nb_pop ); |
---|
| 68 | INSTANCE1_SC_SIGNAL(_Free_List_unit, in_POP_SPR_VAL ,_param->_nb_pop ); |
---|
| 69 | INSTANCE1_SC_SIGNAL(_Free_List_unit,out_POP_SPR_NUM_REG ,_param->_nb_pop ); |
---|
| 70 | INSTANCE1_SC_SIGNAL(_Free_List_unit, in_PUSH_GPR_VAL ,_param->_nb_push); |
---|
| 71 | INSTANCE1_SC_SIGNAL(_Free_List_unit,out_PUSH_GPR_ACK ,_param->_nb_push); |
---|
| 72 | INSTANCE1_SC_SIGNAL(_Free_List_unit, in_PUSH_GPR_NUM_REG,_param->_nb_push); |
---|
| 73 | INSTANCE1_SC_SIGNAL(_Free_List_unit, in_PUSH_SPR_VAL ,_param->_nb_push); |
---|
| 74 | INSTANCE1_SC_SIGNAL(_Free_List_unit,out_PUSH_SPR_ACK ,_param->_nb_push); |
---|
| 75 | INSTANCE1_SC_SIGNAL(_Free_List_unit, in_PUSH_SPR_NUM_REG,_param->_nb_push); |
---|
| 76 | |
---|
| 77 | msg(_("<%s> : Start Simulation ............\n"),name.c_str()); |
---|
| 78 | |
---|
| 79 | Time * _time = new Time(); |
---|
| 80 | |
---|
| 81 | /******************************************************** |
---|
| 82 | * Simulation - Begin |
---|
| 83 | ********************************************************/ |
---|
| 84 | |
---|
| 85 | // Initialisation |
---|
| 86 | |
---|
| 87 | const uint32_t seed = 0; |
---|
| 88 | //const uint32_t seed = static_cast<uint32_t>(time(NULL)); |
---|
| 89 | |
---|
| 90 | srand(seed); |
---|
| 91 | |
---|
| 92 | const int32_t percent_transaction_pop = 75; |
---|
| 93 | const int32_t percent_transaction_push = 75; |
---|
| 94 | |
---|
| 95 | bool gpr_free [_param->_nb_general_register]; |
---|
| 96 | bool spr_free [_param->_nb_general_register]; |
---|
| 97 | |
---|
| 98 | for (uint32_t i=0; i<_param->_nb_general_register; i++) |
---|
| 99 | gpr_free [i] = false; |
---|
| 100 | for (uint32_t i=0; i<_param->_nb_special_register; i++) |
---|
| 101 | spr_free [i] = false; |
---|
| 102 | |
---|
| 103 | SC_START(0); |
---|
| 104 | LABEL("Initialisation"); |
---|
| 105 | |
---|
| 106 | LABEL("Reset"); |
---|
| 107 | in_NRESET->write(0); |
---|
| 108 | SC_START(5); |
---|
| 109 | in_NRESET->write(1); |
---|
| 110 | |
---|
| 111 | |
---|
| 112 | LABEL("After reset all free-list is empty"); |
---|
| 113 | |
---|
| 114 | // Test GPR |
---|
| 115 | for (uint32_t i=0; i<_param->_nb_pop; i++) |
---|
| 116 | { |
---|
| 117 | in_POP_GPR_VAL [i]->write(1); |
---|
| 118 | } |
---|
| 119 | SC_START(0); |
---|
| 120 | |
---|
| 121 | for (uint32_t i=0; i<_param->_nb_pop; i++) |
---|
| 122 | TEST(Tcontrol_t, out_POP_ACK[i]->read(), false); |
---|
| 123 | |
---|
| 124 | // Test SPR |
---|
| 125 | for (uint32_t i=0; i<_param->_nb_pop; i++) |
---|
| 126 | { |
---|
| 127 | in_POP_GPR_VAL [i]->write(0); |
---|
| 128 | in_POP_SPR_VAL [i]->write(1); |
---|
| 129 | } |
---|
| 130 | SC_START(0); |
---|
| 131 | |
---|
| 132 | for (uint32_t i=0; i<_param->_nb_pop; i++) |
---|
| 133 | TEST(Tcontrol_t, out_POP_ACK[i]->read(), false); |
---|
| 134 | |
---|
| 135 | // Reset val |
---|
| 136 | for (uint32_t i=0; i<_param->_nb_pop; i++) |
---|
| 137 | { |
---|
| 138 | in_POP_GPR_VAL [i]->write(0); |
---|
| 139 | in_POP_SPR_VAL [i]->write(0); |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | LABEL("Loop of Test"); |
---|
| 143 | |
---|
| 144 | for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++) |
---|
| 145 | { |
---|
| 146 | LABEL("Iteration %d",iteration); |
---|
| 147 | |
---|
| 148 | int32_t nb_request = 32; |
---|
| 149 | |
---|
| 150 | while (nb_request > 1) |
---|
| 151 | { |
---|
| 152 | for (uint32_t i=0; i<_param->_nb_push; i++) |
---|
| 153 | { |
---|
| 154 | Tgeneral_address_t gpr_reg = rand()%_param->_nb_general_register; |
---|
| 155 | in_PUSH_GPR_VAL [i]->write(not gpr_free[gpr_reg] and ((rand()%100)<percent_transaction_push)); |
---|
| 156 | in_PUSH_GPR_NUM_REG [i]->write(gpr_reg); |
---|
| 157 | |
---|
| 158 | Tspecial_address_t spr_reg = rand()%_param->_nb_special_register; |
---|
| 159 | in_PUSH_SPR_VAL [i]->write(not spr_free[spr_reg] and ((rand()%100)<percent_transaction_push)); |
---|
| 160 | in_PUSH_SPR_NUM_REG [i]->write(spr_reg); |
---|
| 161 | } |
---|
| 162 | |
---|
| 163 | for (uint32_t i=0; i<_param->_nb_pop; i++) |
---|
| 164 | { |
---|
| 165 | in_POP_VAL [i]->write((rand()%100)<percent_transaction_pop); |
---|
| 166 | in_POP_GPR_VAL [i]->write(rand()%2); |
---|
| 167 | in_POP_SPR_VAL [i]->write(rand()%2); |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | SC_START(0); |
---|
| 171 | |
---|
| 172 | for (uint32_t i=0; i<_param->_nb_pop; i++) |
---|
| 173 | if (in_POP_VAL [i]->read() and out_POP_ACK[i]->read()) |
---|
| 174 | { |
---|
| 175 | nb_request --; |
---|
| 176 | if (in_POP_GPR_VAL [i]->read()) |
---|
| 177 | { |
---|
| 178 | Tgeneral_address_t reg = out_POP_GPR_NUM_REG [i]->read(); |
---|
| 179 | |
---|
| 180 | TEST(bool, gpr_free[reg],true); |
---|
| 181 | |
---|
| 182 | Tgeneral_address_t bank = reg >> _param->_bank_gpr_size_slot; |
---|
| 183 | TEST(bool, (bank >= (i*_param->_nb_bank_by_pop)) and (bank < ((i+1)*_param->_nb_bank_by_pop)), true); |
---|
| 184 | |
---|
| 185 | gpr_free[reg] = false; |
---|
| 186 | } |
---|
| 187 | |
---|
| 188 | if (in_POP_SPR_VAL [i]->read()) |
---|
| 189 | { |
---|
| 190 | Tspecial_address_t reg = out_POP_SPR_NUM_REG [i]->read(); |
---|
| 191 | |
---|
| 192 | TEST(bool,spr_free[reg],true); |
---|
| 193 | |
---|
| 194 | Tspecial_address_t bank = reg >> _param->_bank_spr_size_slot; |
---|
| 195 | TEST(bool, (bank >= (i*_param->_nb_bank_by_pop)) and (bank < ((i+1)*_param->_nb_bank_by_pop)), true); |
---|
| 196 | |
---|
| 197 | spr_free[reg] = false; |
---|
| 198 | } |
---|
| 199 | } |
---|
| 200 | |
---|
| 201 | for (uint32_t i=0; i<_param->_nb_push; i++) |
---|
| 202 | { |
---|
| 203 | if (in_PUSH_GPR_VAL [i]->read() and out_PUSH_GPR_ACK [i]->read()) |
---|
| 204 | gpr_free[in_PUSH_GPR_NUM_REG [i]->read()] = true; |
---|
| 205 | if (in_PUSH_SPR_VAL [i]->read() and out_PUSH_SPR_ACK [i]->read()) |
---|
| 206 | spr_free[in_PUSH_SPR_NUM_REG [i]->read()] = true; |
---|
| 207 | } |
---|
| 208 | SC_START(1); |
---|
| 209 | } |
---|
| 210 | } |
---|
| 211 | |
---|
| 212 | /******************************************************** |
---|
| 213 | * Simulation - End |
---|
| 214 | ********************************************************/ |
---|
| 215 | |
---|
| 216 | TEST_OK ("End of Simulation"); |
---|
| 217 | delete _time; |
---|
| 218 | |
---|
| 219 | msg(_("<%s> : ............ Stop Simulation\n"),name.c_str()); |
---|
| 220 | |
---|
| 221 | delete in_CLOCK; |
---|
| 222 | delete in_NRESET; |
---|
| 223 | |
---|
| 224 | delete [] in_POP_VAL ; |
---|
| 225 | delete [] out_POP_ACK ; |
---|
| 226 | delete [] in_POP_GPR_VAL ; |
---|
| 227 | delete [] out_POP_GPR_NUM_REG ; |
---|
| 228 | delete [] in_POP_SPR_VAL ; |
---|
| 229 | delete [] out_POP_SPR_NUM_REG ; |
---|
| 230 | delete [] in_PUSH_GPR_VAL ; |
---|
| 231 | delete [] out_PUSH_GPR_ACK ; |
---|
| 232 | delete [] in_PUSH_GPR_NUM_REG; |
---|
| 233 | delete [] in_PUSH_SPR_VAL ; |
---|
| 234 | delete [] out_PUSH_SPR_ACK ; |
---|
| 235 | delete [] in_PUSH_SPR_NUM_REG; |
---|
| 236 | #endif |
---|
| 237 | |
---|
| 238 | delete _Free_List_unit; |
---|
| 239 | #ifdef STATISTICS |
---|
| 240 | delete _parameters_statistics; |
---|
| 241 | #endif |
---|
| 242 | } |
---|