[78] | 1 | /* |
---|
| 2 | * $Id: test.cpp 87 2008-05-15 19:23:42Z rosiere $ |
---|
| 3 | * |
---|
| 4 | * [ Description ] |
---|
| 5 | * |
---|
| 6 | * Test |
---|
| 7 | */ |
---|
| 8 | |
---|
[82] | 9 | #define NB_ITERATION 1 |
---|
| 10 | #define CYCLE_MAX (2048*NB_ITERATION) |
---|
| 11 | |
---|
[78] | 12 | #include "Behavioural/Core/Multi_Front_end/Front_end/Decod_unit/Decod/SelfTest/include/test.h" |
---|
[87] | 13 | #include "Behavioural/Core/Multi_Front_end/Front_end/Decod_unit/Decod/SelfTest/include/Decod_request.h" |
---|
[78] | 14 | #include <list> |
---|
| 15 | #include "Common/include/Test.h" |
---|
| 16 | #include "Behavioural/include/Allocation.h" |
---|
| 17 | |
---|
| 18 | void test (string name, |
---|
| 19 | morpheo::behavioural::core::multi_front_end::front_end::decod_unit::decod::Parameters * _param) |
---|
| 20 | { |
---|
| 21 | msg(_("<%s> : Simulation SystemC.\n"),name.c_str()); |
---|
| 22 | |
---|
| 23 | #ifdef STATISTICS |
---|
| 24 | morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5,50); |
---|
| 25 | #endif |
---|
| 26 | |
---|
[82] | 27 | Decod * _Decod = new Decod |
---|
| 28 | (name.c_str(), |
---|
[78] | 29 | #ifdef STATISTICS |
---|
[82] | 30 | _parameters_statistics, |
---|
[78] | 31 | #endif |
---|
[82] | 32 | _param, |
---|
| 33 | USE_ALL); |
---|
[78] | 34 | |
---|
| 35 | #ifdef SYSTEMC |
---|
| 36 | /********************************************************************* |
---|
| 37 | * Déclarations des signaux |
---|
| 38 | *********************************************************************/ |
---|
| 39 | string rename; |
---|
| 40 | |
---|
| 41 | sc_clock * in_CLOCK = new sc_clock ("clock", 1.0, 0.5); |
---|
| 42 | sc_signal<Tcontrol_t> * in_NRESET = new sc_signal<Tcontrol_t> ("NRESET"); |
---|
| 43 | |
---|
| 44 | ALLOC2_SC_SIGNAL( in_IFETCH_VAL ," in_IFETCH_VAL ",Tcontrol_t ,_param->_nb_context,_param->_nb_inst_fetch[alloc_signal_it1]); |
---|
| 45 | ALLOC2_SC_SIGNAL(out_IFETCH_ACK ,"out_IFETCH_ACK ",Tcontrol_t ,_param->_nb_context,_param->_nb_inst_fetch[alloc_signal_it1]); |
---|
| 46 | ALLOC2_SC_SIGNAL( in_IFETCH_INSTRUCTION ," in_IFETCH_INSTRUCTION ",Tinstruction_t ,_param->_nb_context,_param->_nb_inst_fetch[alloc_signal_it1]); |
---|
| 47 | ALLOC1_SC_SIGNAL( in_IFETCH_CONTEXT_ID ," in_IFETCH_CONTEXT_ID ",Tcontext_t ,_param->_nb_context); |
---|
| 48 | ALLOC1_SC_SIGNAL( in_IFETCH_ADDRESS ," in_IFETCH_ADDRESS ",Tgeneral_address_t ,_param->_nb_context); |
---|
| 49 | // ALLOC1_SC_SIGNAL( in_IFETCH_ADDRESS_NEXT ," in_IFETCH_ADDRESS_NEXT ",Tgeneral_address_t ,_param->_nb_context); |
---|
| 50 | ALLOC1_SC_SIGNAL( in_IFETCH_INST_IFETCH_PTR ," in_IFETCH_INST_IFETCH_PTR ",Tinst_ifetch_ptr_t ,_param->_nb_context); |
---|
| 51 | ALLOC1_SC_SIGNAL( in_IFETCH_BRANCH_STATE ," in_IFETCH_BRANCH_STATE ",Tbranch_state_t ,_param->_nb_context); |
---|
| 52 | ALLOC1_SC_SIGNAL( in_IFETCH_BRANCH_UPDATE_PREDICTION_ID ," in_IFETCH_BRANCH_UPDATE_PREDICTION_ID ",Tprediction_ptr_t ,_param->_nb_context); |
---|
| 53 | ALLOC1_SC_SIGNAL(out_DECOD_VAL ,"out_DECOD_VAL ",Tcontrol_t ,_param->_nb_inst_decod); |
---|
| 54 | ALLOC1_SC_SIGNAL( in_DECOD_ACK ," in_DECOD_ACK ",Tcontrol_t ,_param->_nb_inst_decod); |
---|
| 55 | ALLOC1_SC_SIGNAL(out_DECOD_CONTEXT_ID ,"out_DECOD_CONTEXT_ID ",Tcontext_t ,_param->_nb_inst_decod); |
---|
| 56 | ALLOC1_SC_SIGNAL(out_DECOD_DEPTH ,"out_DECOD_DEPTH ",Tdepth_t ,_param->_nb_inst_decod); |
---|
| 57 | ALLOC1_SC_SIGNAL(out_DECOD_TYPE ,"out_DECOD_TYPE ",Ttype_t ,_param->_nb_inst_decod); |
---|
| 58 | ALLOC1_SC_SIGNAL(out_DECOD_OPERATION ,"out_DECOD_OPERATION ",Toperation_t ,_param->_nb_inst_decod); |
---|
| 59 | ALLOC1_SC_SIGNAL(out_DECOD_IS_DELAY_SLOT ,"out_DECOD_IS_DELAY_SLOT ",Tcontrol_t ,_param->_nb_inst_decod); |
---|
| 60 | ALLOC1_SC_SIGNAL(out_DECOD_ADDRESS ,"out_DECOD_ADDRESS ",Tgeneral_data_t ,_param->_nb_inst_decod); |
---|
| 61 | ALLOC1_SC_SIGNAL(out_DECOD_HAS_IMMEDIAT ,"out_DECOD_HAS_IMMEDIAT ",Tcontrol_t ,_param->_nb_inst_decod); |
---|
| 62 | ALLOC1_SC_SIGNAL(out_DECOD_IMMEDIAT ,"out_DECOD_IMMEDIAT ",Tgeneral_data_t ,_param->_nb_inst_decod); |
---|
| 63 | ALLOC1_SC_SIGNAL(out_DECOD_READ_RA ,"out_DECOD_READ_RA ",Tcontrol_t ,_param->_nb_inst_decod); |
---|
| 64 | ALLOC1_SC_SIGNAL(out_DECOD_NUM_REG_RA ,"out_DECOD_NUM_REG_RA ",Tgeneral_address_t ,_param->_nb_inst_decod); |
---|
| 65 | ALLOC1_SC_SIGNAL(out_DECOD_READ_RB ,"out_DECOD_READ_RB ",Tcontrol_t ,_param->_nb_inst_decod); |
---|
| 66 | ALLOC1_SC_SIGNAL(out_DECOD_NUM_REG_RB ,"out_DECOD_NUM_REG_RB ",Tgeneral_address_t ,_param->_nb_inst_decod); |
---|
| 67 | ALLOC1_SC_SIGNAL(out_DECOD_READ_RC ,"out_DECOD_READ_RC ",Tcontrol_t ,_param->_nb_inst_decod); |
---|
| 68 | ALLOC1_SC_SIGNAL(out_DECOD_NUM_REG_RC ,"out_DECOD_NUM_REG_RC ",Tspecial_address_t ,_param->_nb_inst_decod); |
---|
| 69 | ALLOC1_SC_SIGNAL(out_DECOD_WRITE_RD ,"out_DECOD_WRITE_RD ",Tcontrol_t ,_param->_nb_inst_decod); |
---|
| 70 | ALLOC1_SC_SIGNAL(out_DECOD_NUM_REG_RD ,"out_DECOD_NUM_REG_RD ",Tgeneral_address_t ,_param->_nb_inst_decod); |
---|
| 71 | ALLOC1_SC_SIGNAL(out_DECOD_WRITE_RE ,"out_DECOD_WRITE_RE ",Tcontrol_t ,_param->_nb_inst_decod); |
---|
| 72 | ALLOC1_SC_SIGNAL(out_DECOD_NUM_REG_RE ,"out_DECOD_NUM_REG_RE ",Tspecial_address_t ,_param->_nb_inst_decod); |
---|
| 73 | ALLOC1_SC_SIGNAL(out_DECOD_EXCEPTION_USE ,"out_DECOD_EXCEPTION_USE ",Texception_t ,_param->_nb_inst_decod); |
---|
| 74 | ALLOC1_SC_SIGNAL(out_PREDICT_VAL ,"out_PREDICT_VAL ",Tcontrol_t ,_param->_nb_inst_decod); |
---|
| 75 | ALLOC1_SC_SIGNAL( in_PREDICT_ACK ," in_PREDICT_ACK ",Tcontrol_t ,_param->_nb_inst_decod); |
---|
| 76 | ALLOC1_SC_SIGNAL(out_PREDICT_CONTEXT_ID ,"out_PREDICT_CONTEXT_ID ",Tcontext_t ,_param->_nb_inst_decod); |
---|
| 77 | ALLOC1_SC_SIGNAL(out_PREDICT_MATCH_INST_IFETCH_PTR ,"out_PREDICT_MATCH_INST_IFETCH_PTR ",Tcontrol_t ,_param->_nb_inst_decod); |
---|
| 78 | ALLOC1_SC_SIGNAL(out_PREDICT_BRANCH_STATE ,"out_PREDICT_BRANCH_STATE ",Tbranch_state_t ,_param->_nb_inst_decod); |
---|
| 79 | ALLOC1_SC_SIGNAL(out_PREDICT_BRANCH_UPDATE_PREDICTION_ID,"out_PREDICT_BRANCH_UPDATE_PREDICTION_ID",Tprediction_ptr_t ,_param->_nb_inst_decod); |
---|
| 80 | ALLOC1_SC_SIGNAL(out_PREDICT_BRANCH_CONDITION ,"out_PREDICT_BRANCH_CONDITION ",Tbranch_condition_t,_param->_nb_inst_decod); |
---|
| 81 | // ALLOC1_SC_SIGNAL(out_PREDICT_BRANCH_STACK_WRITE ,"out_PREDICT_BRANCH_STACK_WRITE ",Tcontrol_t ,_param->_nb_inst_decod); |
---|
| 82 | ALLOC1_SC_SIGNAL(out_PREDICT_BRANCH_DIRECTION ,"out_PREDICT_BRANCH_DIRECTION ",Tcontrol_t ,_param->_nb_inst_decod); |
---|
| 83 | ALLOC1_SC_SIGNAL(out_PREDICT_ADDRESS_SRC ,"out_PREDICT_ADDRESS_SRC ",Tgeneral_data_t ,_param->_nb_inst_decod); |
---|
| 84 | ALLOC1_SC_SIGNAL(out_PREDICT_ADDRESS_DEST ,"out_PREDICT_ADDRESS_DEST ",Tgeneral_data_t ,_param->_nb_inst_decod); |
---|
| 85 | // ALLOC1_SC_SIGNAL( in_PREDICT_CAN_CONTINUE ," in_PREDICT_CAN_CONTINUE ",Tcontrol_t ,_param->_nb_inst_decod); |
---|
| 86 | ALLOC1_SC_SIGNAL( in_CONTEXT_DECOD_ENABLE ," in_CONTEXT_DECOD_ENABLE ",Tcontrol_t ,_param->_nb_context); |
---|
| 87 | ALLOC1_SC_SIGNAL( in_CONTEXT_DEPTH ," in_CONTEXT_DEPTH ",Tdepth_t ,_param->_nb_context); |
---|
| 88 | ALLOC_SC_SIGNAL (out_CONTEXT_EVENT_VAL ,"out_CONTEXT_EVENT_VAL ",Tcontrol_t ); |
---|
| 89 | ALLOC_SC_SIGNAL ( in_CONTEXT_EVENT_ACK ," in_CONTEXT_EVENT_ACK ",Tcontrol_t ); |
---|
| 90 | ALLOC_SC_SIGNAL (out_CONTEXT_EVENT_CONTEXT_ID ,"out_CONTEXT_EVENT_CONTEXT_ID ",Tcontext_t ); |
---|
| 91 | ALLOC_SC_SIGNAL (out_CONTEXT_EVENT_TYPE ,"out_CONTEXT_EVENT_TYPE ",Tevent_type_t ); |
---|
| 92 | ALLOC_SC_SIGNAL (out_CONTEXT_EVENT_IS_DELAY_SLOT ,"out_CONTEXT_EVENT_IS_DELAY_SLOT ",Tcontrol_t ); |
---|
| 93 | ALLOC_SC_SIGNAL (out_CONTEXT_EVENT_ADDRESS ,"out_CONTEXT_EVENT_ADDRESS ",Tgeneral_data_t ); |
---|
| 94 | ALLOC_SC_SIGNAL (out_CONTEXT_EVENT_ADDRESS_EPCR ,"out_CONTEXT_EVENT_ADDRESS_EPCR ",Tgeneral_data_t ); |
---|
| 95 | |
---|
| 96 | /******************************************************** |
---|
| 97 | * Instanciation |
---|
| 98 | ********************************************************/ |
---|
| 99 | |
---|
| 100 | msg(_("<%s> : Instanciation of _Decod.\n"),name.c_str()); |
---|
| 101 | |
---|
| 102 | (*(_Decod->in_CLOCK)) (*(in_CLOCK)); |
---|
| 103 | (*(_Decod->in_NRESET)) (*(in_NRESET)); |
---|
| 104 | |
---|
| 105 | INSTANCE2_SC_SIGNAL(_Decod, in_IFETCH_VAL ,_param->_nb_context,_param->_nb_inst_fetch[alloc_signal_it1]); |
---|
| 106 | INSTANCE2_SC_SIGNAL(_Decod,out_IFETCH_ACK ,_param->_nb_context,_param->_nb_inst_fetch[alloc_signal_it1]); |
---|
| 107 | INSTANCE2_SC_SIGNAL(_Decod, in_IFETCH_INSTRUCTION ,_param->_nb_context,_param->_nb_inst_fetch[alloc_signal_it1]); |
---|
| 108 | if (_param->_have_port_context_id) |
---|
| 109 | INSTANCE1_SC_SIGNAL(_Decod, in_IFETCH_CONTEXT_ID ,_param->_nb_context); |
---|
| 110 | INSTANCE1_SC_SIGNAL(_Decod, in_IFETCH_ADDRESS ,_param->_nb_context); |
---|
| 111 | // INSTANCE1_SC_SIGNAL(_Decod, in_IFETCH_ADDRESS_NEXT ,_param->_nb_context); |
---|
| 112 | if (_param->_have_port_inst_ifetch_ptr) |
---|
| 113 | INSTANCE1_SC_SIGNAL(_Decod, in_IFETCH_INST_IFETCH_PTR ,_param->_nb_context); |
---|
| 114 | INSTANCE1_SC_SIGNAL(_Decod, in_IFETCH_BRANCH_STATE ,_param->_nb_context); |
---|
| 115 | if (_param->_have_port_branch_update_prediction_id) |
---|
| 116 | INSTANCE1_SC_SIGNAL(_Decod, in_IFETCH_BRANCH_UPDATE_PREDICTION_ID ,_param->_nb_context); |
---|
| 117 | INSTANCE1_SC_SIGNAL(_Decod,out_DECOD_VAL ,_param->_nb_inst_decod); |
---|
| 118 | INSTANCE1_SC_SIGNAL(_Decod, in_DECOD_ACK ,_param->_nb_inst_decod); |
---|
| 119 | if (_param->_have_port_context_id) |
---|
| 120 | INSTANCE1_SC_SIGNAL(_Decod,out_DECOD_CONTEXT_ID ,_param->_nb_inst_decod); |
---|
| 121 | if (_param->_have_port_depth) |
---|
| 122 | INSTANCE1_SC_SIGNAL(_Decod,out_DECOD_DEPTH ,_param->_nb_inst_decod); |
---|
| 123 | INSTANCE1_SC_SIGNAL(_Decod,out_DECOD_TYPE ,_param->_nb_inst_decod); |
---|
| 124 | INSTANCE1_SC_SIGNAL(_Decod,out_DECOD_OPERATION ,_param->_nb_inst_decod); |
---|
| 125 | INSTANCE1_SC_SIGNAL(_Decod,out_DECOD_IS_DELAY_SLOT ,_param->_nb_inst_decod); |
---|
| 126 | INSTANCE1_SC_SIGNAL(_Decod,out_DECOD_ADDRESS ,_param->_nb_inst_decod); |
---|
| 127 | INSTANCE1_SC_SIGNAL(_Decod,out_DECOD_HAS_IMMEDIAT ,_param->_nb_inst_decod); |
---|
| 128 | INSTANCE1_SC_SIGNAL(_Decod,out_DECOD_IMMEDIAT ,_param->_nb_inst_decod); |
---|
| 129 | INSTANCE1_SC_SIGNAL(_Decod,out_DECOD_READ_RA ,_param->_nb_inst_decod); |
---|
| 130 | INSTANCE1_SC_SIGNAL(_Decod,out_DECOD_NUM_REG_RA ,_param->_nb_inst_decod); |
---|
| 131 | INSTANCE1_SC_SIGNAL(_Decod,out_DECOD_READ_RB ,_param->_nb_inst_decod); |
---|
| 132 | INSTANCE1_SC_SIGNAL(_Decod,out_DECOD_NUM_REG_RB ,_param->_nb_inst_decod); |
---|
| 133 | INSTANCE1_SC_SIGNAL(_Decod,out_DECOD_READ_RC ,_param->_nb_inst_decod); |
---|
| 134 | INSTANCE1_SC_SIGNAL(_Decod,out_DECOD_NUM_REG_RC ,_param->_nb_inst_decod); |
---|
| 135 | INSTANCE1_SC_SIGNAL(_Decod,out_DECOD_WRITE_RD ,_param->_nb_inst_decod); |
---|
| 136 | INSTANCE1_SC_SIGNAL(_Decod,out_DECOD_NUM_REG_RD ,_param->_nb_inst_decod); |
---|
| 137 | INSTANCE1_SC_SIGNAL(_Decod,out_DECOD_WRITE_RE ,_param->_nb_inst_decod); |
---|
| 138 | INSTANCE1_SC_SIGNAL(_Decod,out_DECOD_NUM_REG_RE ,_param->_nb_inst_decod); |
---|
| 139 | INSTANCE1_SC_SIGNAL(_Decod,out_DECOD_EXCEPTION_USE ,_param->_nb_inst_decod); |
---|
| 140 | INSTANCE1_SC_SIGNAL(_Decod,out_PREDICT_VAL ,_param->_nb_inst_decod); |
---|
| 141 | INSTANCE1_SC_SIGNAL(_Decod, in_PREDICT_ACK ,_param->_nb_inst_decod); |
---|
| 142 | if (_param->_have_port_context_id) |
---|
| 143 | INSTANCE1_SC_SIGNAL(_Decod,out_PREDICT_CONTEXT_ID ,_param->_nb_inst_decod); |
---|
| 144 | INSTANCE1_SC_SIGNAL(_Decod,out_PREDICT_MATCH_INST_IFETCH_PTR ,_param->_nb_inst_decod); |
---|
| 145 | INSTANCE1_SC_SIGNAL(_Decod,out_PREDICT_BRANCH_STATE ,_param->_nb_inst_decod); |
---|
| 146 | if (_param->_have_port_branch_update_prediction_id) |
---|
| 147 | INSTANCE1_SC_SIGNAL(_Decod,out_PREDICT_BRANCH_UPDATE_PREDICTION_ID,_param->_nb_inst_decod); |
---|
| 148 | INSTANCE1_SC_SIGNAL(_Decod,out_PREDICT_BRANCH_CONDITION ,_param->_nb_inst_decod); |
---|
| 149 | // INSTANCE1_SC_SIGNAL(_Decod,out_PREDICT_BRANCH_STACK_WRITE ,_param->_nb_inst_decod); |
---|
| 150 | INSTANCE1_SC_SIGNAL(_Decod,out_PREDICT_BRANCH_DIRECTION ,_param->_nb_inst_decod); |
---|
| 151 | INSTANCE1_SC_SIGNAL(_Decod,out_PREDICT_ADDRESS_SRC ,_param->_nb_inst_decod); |
---|
| 152 | INSTANCE1_SC_SIGNAL(_Decod,out_PREDICT_ADDRESS_DEST ,_param->_nb_inst_decod); |
---|
| 153 | // INSTANCE1_SC_SIGNAL(_Decod, in_PREDICT_CAN_CONTINUE ,_param->_nb_inst_decod); |
---|
| 154 | INSTANCE1_SC_SIGNAL(_Decod, in_CONTEXT_DECOD_ENABLE ,_param->_nb_context); |
---|
| 155 | if (_param->_have_port_depth) |
---|
| 156 | INSTANCE1_SC_SIGNAL(_Decod, in_CONTEXT_DEPTH ,_param->_nb_context); |
---|
| 157 | INSTANCE_SC_SIGNAL (_Decod,out_CONTEXT_EVENT_VAL ); |
---|
| 158 | INSTANCE_SC_SIGNAL (_Decod, in_CONTEXT_EVENT_ACK ); |
---|
| 159 | if (_param->_have_port_context_id) |
---|
| 160 | INSTANCE_SC_SIGNAL (_Decod,out_CONTEXT_EVENT_CONTEXT_ID ); |
---|
| 161 | INSTANCE_SC_SIGNAL (_Decod,out_CONTEXT_EVENT_TYPE ); |
---|
| 162 | INSTANCE_SC_SIGNAL (_Decod,out_CONTEXT_EVENT_IS_DELAY_SLOT ); |
---|
| 163 | INSTANCE_SC_SIGNAL (_Decod,out_CONTEXT_EVENT_ADDRESS ); |
---|
| 164 | INSTANCE_SC_SIGNAL (_Decod,out_CONTEXT_EVENT_ADDRESS_EPCR ); |
---|
| 165 | |
---|
| 166 | msg(_("<%s> : Start Simulation ............\n"),name.c_str()); |
---|
| 167 | |
---|
| 168 | Time * _time = new Time(); |
---|
| 169 | |
---|
| 170 | /******************************************************** |
---|
| 171 | * Simulation - Begin |
---|
| 172 | ********************************************************/ |
---|
| 173 | |
---|
| 174 | // Initialisation |
---|
| 175 | |
---|
| 176 | const uint32_t seed = 0; |
---|
| 177 | //const uint32_t seed = static_cast<uint32_t>(time(NULL)); |
---|
| 178 | |
---|
| 179 | const int32_t percent_transaction_ifetch = 75; |
---|
| 180 | const int32_t percent_transaction_decod = 75; |
---|
| 181 | const int32_t percent_transaction_predict = 75; |
---|
| 182 | const int32_t percent_transaction_event = 75; |
---|
| 183 | |
---|
| 184 | srand(seed); |
---|
| 185 | |
---|
| 186 | SC_START(0); |
---|
| 187 | LABEL("Initialisation"); |
---|
| 188 | |
---|
| 189 | LABEL("Reset"); |
---|
| 190 | in_NRESET->write(0); |
---|
| 191 | SC_START(5); |
---|
| 192 | in_NRESET->write(1); |
---|
| 193 | |
---|
| 194 | LABEL("Loop of Test"); |
---|
| 195 | |
---|
| 196 | for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++) |
---|
| 197 | { |
---|
| 198 | LABEL("Iteration %d",iteration); |
---|
| 199 | |
---|
[87] | 200 | Decod_request request [_param->_nb_context]; |
---|
[78] | 201 | |
---|
[87] | 202 | uint32_t nb_request = 0; |
---|
[78] | 203 | |
---|
| 204 | uint32_t delay_slot_previous [_param->_nb_context]; |
---|
| 205 | uint32_t delay_slot_current [_param->_nb_context]; |
---|
| 206 | uint32_t delay_slot_next [_param->_nb_context]; |
---|
| 207 | |
---|
| 208 | for (uint32_t i=0; i<_param->_nb_context; i++) |
---|
| 209 | { |
---|
[87] | 210 | nb_request += request[i].size(); |
---|
[78] | 211 | delay_slot_current [i] = false; |
---|
| 212 | delay_slot_next [i] = false; |
---|
| 213 | } |
---|
| 214 | |
---|
| 215 | while (nb_request > 0) |
---|
| 216 | { |
---|
| 217 | for (uint32_t i=0; i<_param->_nb_context; i++) |
---|
| 218 | { |
---|
| 219 | delay_slot_previous [i] = false; |
---|
| 220 | |
---|
| 221 | in_CONTEXT_DECOD_ENABLE [i]->write((rand()%100)<percent_transaction_decod); |
---|
| 222 | |
---|
| 223 | for (uint32_t j=0; j<_param->_nb_inst_fetch[i]; j++) |
---|
| 224 | in_IFETCH_VAL [i][j]->write(0); |
---|
| 225 | |
---|
| 226 | if ((rand()%100)<percent_transaction_ifetch) |
---|
| 227 | { |
---|
[87] | 228 | list<entry_t>::iterator it = request[i].begin(); |
---|
| 229 | |
---|
[78] | 230 | if (it!=request [i].end()) |
---|
| 231 | { |
---|
[86] | 232 | uint32_t lsb = it->_address%_param->_nb_inst_fetch[i]; |
---|
[78] | 233 | |
---|
[86] | 234 | in_IFETCH_ADDRESS [i]->write(it->_address-lsb); |
---|
[78] | 235 | in_IFETCH_BRANCH_STATE [i]->write(BRANCH_STATE_NONE); |
---|
| 236 | if (_param->_have_port_inst_ifetch_ptr) |
---|
| 237 | in_IFETCH_INST_IFETCH_PTR [i]->write(0); |
---|
| 238 | |
---|
| 239 | // Alignement |
---|
| 240 | for (uint32_t j=lsb; j<_param->_nb_inst_fetch[i]; j++) |
---|
| 241 | { |
---|
| 242 | in_IFETCH_VAL [i][j]->write(1); |
---|
| 243 | in_IFETCH_INSTRUCTION [i][j]->write(it->_instruction); |
---|
| 244 | // in_IFETCH_ADDRESS_NEXT [i]->write(it->_address_next); |
---|
| 245 | if (it->_type == TYPE_BRANCH) |
---|
| 246 | in_IFETCH_BRANCH_STATE [i]->write(it->_branch_state); |
---|
| 247 | in_IFETCH_BRANCH_UPDATE_PREDICTION_ID [i]->write(it->_branch_update_prediction_id); |
---|
| 248 | |
---|
| 249 | if ((it->_is_delay_slot) or |
---|
| 250 | ((++it)==request [i].end())) |
---|
| 251 | break; |
---|
| 252 | } |
---|
| 253 | } |
---|
| 254 | } |
---|
| 255 | } |
---|
| 256 | |
---|
| 257 | { |
---|
| 258 | bool previous_ack = true; |
---|
| 259 | |
---|
| 260 | for (uint32_t i=0; i<_param->_nb_inst_decod; i++) |
---|
| 261 | { |
---|
| 262 | bool ack = previous_ack and ((rand()%100)<percent_transaction_decod); |
---|
| 263 | in_DECOD_ACK [i]->write(ack); |
---|
| 264 | |
---|
| 265 | previous_ack = ack; |
---|
| 266 | |
---|
| 267 | in_PREDICT_ACK [i]->write((rand()%100)<percent_transaction_predict); |
---|
| 268 | // in_PREDICT_CAN_CONTINUE [i]->write(0); |
---|
| 269 | } |
---|
| 270 | } |
---|
| 271 | |
---|
| 272 | in_CONTEXT_EVENT_ACK->write((rand()%100)<percent_transaction_event); |
---|
| 273 | |
---|
| 274 | SC_START(0); |
---|
| 275 | |
---|
| 276 | |
---|
| 277 | uint32_t nb_inst_ifetch = 0; |
---|
| 278 | for (uint32_t i=0; i<_param->_nb_context; i++) |
---|
| 279 | for (uint32_t j=0; j<_param->_nb_inst_fetch[i]; j++) |
---|
| 280 | if (in_IFETCH_VAL[i][j]->read() and out_IFETCH_ACK[i][j]->read()) |
---|
| 281 | { |
---|
| 282 | LABEL("IFETCH [%d][%d] : transaction",i,j); |
---|
| 283 | nb_inst_ifetch ++; |
---|
| 284 | } |
---|
| 285 | |
---|
| 286 | uint32_t nb_inst_decod = 0; |
---|
| 287 | uint32_t find_event = false; |
---|
| 288 | |
---|
| 289 | for (uint32_t i=0; i<_param->_nb_inst_decod; i++) |
---|
| 290 | if (out_DECOD_VAL[i]->read() and in_DECOD_ACK[i]->read()) |
---|
| 291 | { |
---|
| 292 | Tcontext_t context = (_param->_have_port_context_id)?out_DECOD_CONTEXT_ID[i]->read():0; |
---|
| 293 | |
---|
| 294 | LABEL("DECOD [%d] : transaction",i ); |
---|
| 295 | LABEL(" * context : %d",context); |
---|
[86] | 296 | LABEL(" * instruction : 0x%x",request [context].front()._instruction); |
---|
[78] | 297 | |
---|
| 298 | if (_param->_have_port_depth) |
---|
| 299 | TEST(Tdepth_t , out_DECOD_DEPTH [i]->read(), request [context].front()._depth ); |
---|
| 300 | TEST(Ttype_t , out_DECOD_TYPE [i]->read(), request [context].front()._type ); |
---|
| 301 | TEST(Toperation_t , out_DECOD_OPERATION [i]->read(), request [context].front()._operation ); |
---|
| 302 | TEST(Tcontrol_t , out_DECOD_IS_DELAY_SLOT [i]->read(), request [context].front()._is_delay_slot); |
---|
| 303 | TEST(Tcontrol_t , delay_slot_current [context] , request [context].front()._is_delay_slot); |
---|
| 304 | TEST(Tgeneral_data_t , out_DECOD_ADDRESS [i]->read(), request [context].front()._address ); |
---|
| 305 | TEST(Tcontrol_t , out_DECOD_HAS_IMMEDIAT [i]->read(), request [context].front()._has_immediat ); |
---|
| 306 | if (request [context].front()._has_immediat) |
---|
| 307 | TEST(Tgeneral_data_t , out_DECOD_IMMEDIAT [i]->read(), request [context].front()._immediat ); |
---|
| 308 | TEST(Tcontrol_t , out_DECOD_READ_RA [i]->read(), request [context].front()._read_ra ); |
---|
| 309 | if (request [context].front()._read_ra) |
---|
| 310 | TEST(Tgeneral_address_t, out_DECOD_NUM_REG_RA [i]->read(), request [context].front()._num_reg_ra ); |
---|
| 311 | TEST(Tcontrol_t , out_DECOD_READ_RB [i]->read(), request [context].front()._read_rb ); |
---|
| 312 | if (request [context].front()._read_rb) |
---|
| 313 | TEST(Tgeneral_address_t, out_DECOD_NUM_REG_RB [i]->read(), request [context].front()._num_reg_rb ); |
---|
| 314 | TEST(Tcontrol_t , out_DECOD_READ_RC [i]->read(), request [context].front()._read_rc ); |
---|
| 315 | if (request [context].front()._read_rc) |
---|
| 316 | TEST(Tspecial_address_t, out_DECOD_NUM_REG_RC [i]->read(), request [context].front()._num_reg_rc ); |
---|
| 317 | TEST(Tcontrol_t , out_DECOD_WRITE_RD [i]->read(), request [context].front()._write_rd ); |
---|
| 318 | if (request [context].front()._write_rd) |
---|
| 319 | TEST(Tgeneral_address_t, out_DECOD_NUM_REG_RD [i]->read(), request [context].front()._num_reg_rd ); |
---|
| 320 | TEST(Tcontrol_t , out_DECOD_WRITE_RE [i]->read(), request [context].front()._write_re ); |
---|
| 321 | if (request [context].front()._write_re) |
---|
| 322 | TEST(Tspecial_address_t, out_DECOD_NUM_REG_RE [i]->read(), request [context].front()._num_reg_re ); |
---|
| 323 | TEST(Texception_t , out_DECOD_EXCEPTION_USE [i]->read(), request [context].front()._exception_use); |
---|
| 324 | |
---|
| 325 | if (request [context].front()._type == TYPE_BRANCH) |
---|
| 326 | { |
---|
| 327 | delay_slot_next [context] = true; |
---|
| 328 | |
---|
| 329 | TEST(Tcontrol_t, out_PREDICT_VAL[i]->read(), true); |
---|
| 330 | TEST(Tcontrol_t, in_PREDICT_ACK[i]->read(), true); |
---|
| 331 | |
---|
| 332 | LABEL("PREDICT [%d] : transaction",i ); |
---|
| 333 | |
---|
| 334 | if (_param->_have_port_context_id) |
---|
| 335 | TEST(Tcontext_t , out_PREDICT_CONTEXT_ID [i]->read(), context); |
---|
[86] | 336 | TEST(Tcontrol_t , out_PREDICT_MATCH_INST_IFETCH_PTR [i]->read(),((request [context].front()._address)%_param->_nb_inst_fetch[context]) == 0); |
---|
[78] | 337 | TEST(Tbranch_state_t , out_PREDICT_BRANCH_STATE [i]->read(), request [context].front()._branch_state ); |
---|
| 338 | if (_param->_have_port_branch_update_prediction_id) |
---|
| 339 | TEST(Tprediction_ptr_t , out_PREDICT_BRANCH_UPDATE_PREDICTION_ID [i]->read(), request [context].front()._branch_update_prediction_id); |
---|
| 340 | TEST(Tbranch_condition_t, out_PREDICT_BRANCH_CONDITION [i]->read(), request [context].front()._branch_condition ); |
---|
| 341 | // TEST(Tcontrol_t , out_PREDICT_BRANCH_STACK_WRITE [i]->read(), request [context].front()._branch_stack_write ); |
---|
| 342 | TEST(Tcontrol_t , out_PREDICT_BRANCH_DIRECTION [i]->read(), request [context].front()._branch_direction ); |
---|
| 343 | TEST(Tgeneral_data_t , out_PREDICT_ADDRESS_SRC [i]->read(), request [context].front()._address ); |
---|
| 344 | TEST(Tgeneral_data_t , out_PREDICT_ADDRESS_DEST [i]->read(), request [context].front()._branch_address_dest ); |
---|
| 345 | } |
---|
| 346 | else |
---|
| 347 | { |
---|
| 348 | TEST(Tcontrol_t, out_PREDICT_VAL[i]->read(), false); |
---|
| 349 | } |
---|
| 350 | |
---|
| 351 | TEST(bool, find_event, false); // can continue decod after event |
---|
| 352 | if (request [context].front()._context_event_type != EVENT_TYPE_NONE) |
---|
| 353 | { |
---|
| 354 | find_event = true; |
---|
| 355 | |
---|
| 356 | LABEL("CONTEXT_EVENT : transaction"); |
---|
| 357 | |
---|
| 358 | if (_param->_have_port_context_id) |
---|
| 359 | TEST(Tcontext_t ,out_CONTEXT_EVENT_CONTEXT_ID ->read(), context); |
---|
| 360 | TEST(Tevent_type_t ,out_CONTEXT_EVENT_TYPE ->read(), request [context].front()._context_event_type); |
---|
| 361 | TEST(Tcontrol_t ,out_CONTEXT_EVENT_IS_DELAY_SLOT->read(), request [context].front()._is_delay_slot); |
---|
| 362 | TEST(Tgeneral_data_t,out_CONTEXT_EVENT_ADDRESS ->read(), request [context].front()._address ); |
---|
| 363 | TEST(Tgeneral_data_t,out_CONTEXT_EVENT_ADDRESS_EPCR ->read(), request [context].front()._address_next ); |
---|
| 364 | |
---|
| 365 | } |
---|
| 366 | |
---|
| 367 | TEST(bool, delay_slot_previous [context], false); // can't continue |
---|
| 368 | delay_slot_previous [context] = delay_slot_current [context]; |
---|
| 369 | delay_slot_current [context] = delay_slot_next [context]; |
---|
| 370 | delay_slot_next [context] = false; |
---|
| 371 | |
---|
| 372 | request [context].pop_front(); |
---|
| 373 | nb_inst_decod ++; |
---|
| 374 | nb_request --; |
---|
| 375 | } |
---|
| 376 | |
---|
| 377 | TEST(bool, (out_CONTEXT_EVENT_VAL->read() and in_CONTEXT_EVENT_ACK->read()), find_event); |
---|
| 378 | TEST(uint32_t, nb_inst_decod, nb_inst_ifetch); |
---|
| 379 | |
---|
| 380 | SC_START(1); |
---|
| 381 | } |
---|
| 382 | } |
---|
| 383 | |
---|
| 384 | /******************************************************** |
---|
| 385 | * Simulation - End |
---|
| 386 | ********************************************************/ |
---|
| 387 | |
---|
| 388 | TEST_OK ("End of Simulation"); |
---|
| 389 | delete _time; |
---|
| 390 | |
---|
| 391 | msg(_("<%s> : ............ Stop Simulation\n"),name.c_str()); |
---|
| 392 | |
---|
| 393 | delete in_CLOCK; |
---|
| 394 | delete in_NRESET; |
---|
| 395 | |
---|
| 396 | delete [] in_IFETCH_VAL ; |
---|
| 397 | delete [] out_IFETCH_ACK ; |
---|
| 398 | delete [] in_IFETCH_INSTRUCTION ; |
---|
| 399 | delete [] in_IFETCH_CONTEXT_ID ; |
---|
| 400 | delete [] in_IFETCH_ADDRESS ; |
---|
| 401 | // delete [] in_IFETCH_ADDRESS_NEXT ; |
---|
| 402 | delete [] in_IFETCH_INST_IFETCH_PTR ; |
---|
| 403 | delete [] in_IFETCH_BRANCH_STATE ; |
---|
| 404 | delete [] in_IFETCH_BRANCH_UPDATE_PREDICTION_ID ; |
---|
| 405 | |
---|
| 406 | delete [] out_DECOD_VAL ; |
---|
| 407 | delete [] in_DECOD_ACK ; |
---|
| 408 | delete [] out_DECOD_CONTEXT_ID ; |
---|
| 409 | delete [] out_DECOD_DEPTH ; |
---|
| 410 | delete [] out_DECOD_TYPE ; |
---|
| 411 | delete [] out_DECOD_OPERATION ; |
---|
| 412 | delete [] out_DECOD_IS_DELAY_SLOT ; |
---|
| 413 | delete [] out_DECOD_ADDRESS ; |
---|
| 414 | delete [] out_DECOD_HAS_IMMEDIAT ; |
---|
| 415 | delete [] out_DECOD_IMMEDIAT ; |
---|
| 416 | delete [] out_DECOD_READ_RA ; |
---|
| 417 | delete [] out_DECOD_NUM_REG_RA ; |
---|
| 418 | delete [] out_DECOD_READ_RB ; |
---|
| 419 | delete [] out_DECOD_NUM_REG_RB ; |
---|
| 420 | delete [] out_DECOD_READ_RC ; |
---|
| 421 | delete [] out_DECOD_NUM_REG_RC ; |
---|
| 422 | delete [] out_DECOD_WRITE_RD ; |
---|
| 423 | delete [] out_DECOD_NUM_REG_RD ; |
---|
| 424 | delete [] out_DECOD_WRITE_RE ; |
---|
| 425 | delete [] out_DECOD_NUM_REG_RE ; |
---|
| 426 | delete [] out_DECOD_EXCEPTION_USE ; |
---|
| 427 | |
---|
| 428 | delete [] out_PREDICT_VAL ; |
---|
| 429 | delete [] in_PREDICT_ACK ; |
---|
| 430 | delete [] out_PREDICT_CONTEXT_ID ; |
---|
| 431 | delete [] out_PREDICT_MATCH_INST_IFETCH_PTR ; |
---|
| 432 | delete [] out_PREDICT_BRANCH_STATE ; |
---|
| 433 | delete [] out_PREDICT_BRANCH_UPDATE_PREDICTION_ID; |
---|
| 434 | delete [] out_PREDICT_BRANCH_CONDITION ; |
---|
[87] | 435 | //delete [] out_PREDICT_BRANCH_STACK_WRITE ; |
---|
[78] | 436 | delete [] out_PREDICT_BRANCH_DIRECTION ; |
---|
| 437 | delete [] out_PREDICT_ADDRESS_SRC ; |
---|
| 438 | delete [] out_PREDICT_ADDRESS_DEST ; |
---|
[87] | 439 | //delete [] in_PREDICT_CAN_CONTINUE ; |
---|
[78] | 440 | |
---|
| 441 | delete [] in_CONTEXT_DECOD_ENABLE ; |
---|
| 442 | delete [] in_CONTEXT_DEPTH ; |
---|
| 443 | |
---|
| 444 | delete out_CONTEXT_EVENT_VAL ; |
---|
| 445 | delete in_CONTEXT_EVENT_ACK ; |
---|
| 446 | delete out_CONTEXT_EVENT_CONTEXT_ID ; |
---|
| 447 | delete out_CONTEXT_EVENT_TYPE ; |
---|
| 448 | delete out_CONTEXT_EVENT_IS_DELAY_SLOT ; |
---|
| 449 | delete out_CONTEXT_EVENT_ADDRESS ; |
---|
| 450 | delete out_CONTEXT_EVENT_ADDRESS_EPCR ; |
---|
| 451 | #endif |
---|
| 452 | |
---|
| 453 | delete _Decod; |
---|
| 454 | #ifdef STATISTICS |
---|
| 455 | delete _parameters_statistics; |
---|
| 456 | #endif |
---|
| 457 | } |
---|