Changeset 101 for trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Ifetch_unit/SelfTest/src/test.cpp
- Timestamp:
- Jan 15, 2009, 6:19:08 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Ifetch_unit/SelfTest/src/test.cpp
r88 r101 250 250 LABEL("Iteration %d",iteration); 251 251 252 // PREDICT253 {254 in_PREDICT_ACK ->write((rand()%100)<percent_transaction_predict);252 // // PREDICT 253 // { 254 // in_PREDICT_ACK ->write((rand()%100)<percent_transaction_predict); 255 255 256 SC_START(0);257 258 Taddress_t addr = (out_PREDICT_PC_CURRENT_IS_DS_TAKE->read())?out_PREDICT_PC_PREVIOUS->read():out_PREDICT_PC_CURRENT->read();259 260 uint32_t begin = addr%_param->_nb_instruction;261 uint32_t end = ((begin<<1)>_param->_nb_instruction)?(_param->_nb_instruction-1):(begin<<1);262 Tcontrol_t take = (nb_packet_in%jump)==0;256 // SC_START(0); 257 258 // Taddress_t addr = (out_PREDICT_PC_CURRENT_IS_DS_TAKE->read())?out_PREDICT_PC_PREVIOUS->read():out_PREDICT_PC_CURRENT->read(); 259 260 // uint32_t begin = addr%_param->_nb_instruction; 261 // uint32_t end = ((begin<<1)>_param->_nb_instruction)?(_param->_nb_instruction-1):(begin<<1); 262 // Tcontrol_t take = (nb_packet_in%jump)==0; 263 263 264 if (take)265 addr += 0x100;266 else267 addr += end-begin+1;268 269 for (uint32_t i=0; i<_param->_nb_instruction; i++)270 in_PREDICT_INSTRUCTION_ENABLE [i] ->write((i>=begin) and (i<=end));271 in_PREDICT_PC_NEXT ->write(addr);272 in_PREDICT_PC_NEXT_IS_DS_TAKE ->write(take);273 in_PREDICT_INST_IFETCH_PTR ->write(0);274 in_PREDICT_BRANCH_STATE ->write(0);275 in_PREDICT_BRANCH_UPDATE_PREDICTION_ID->write(0);276 }277 278 // DECOD279 {280 uint32_t nb_decod = (rand()%_param->_nb_instruction);281 282 for (uint32_t i=0; i<_param->_nb_instruction; i++)283 in_DECOD_ACK [i]->write(i<=nb_decod);284 }285 286 // EVENT287 in_EVENT_VAL ->write((rand()%100)<percent_transaction_event );288 in_EVENT_ADDRESS ->write(0x77);289 in_EVENT_ADDRESS_NEXT ->write(0x171);290 Tcontrol_t is_ds_take = rand();291 in_EVENT_ADDRESS_NEXT_VAL->write(is_ds_take);292 in_EVENT_IS_DS_TAKE ->write(is_ds_take);293 294 // ICACHE_REQ295 in_ICACHE_REQ_ACK->write((rand()%100)<percent_transaction_icache_req);296 297 // ICACHE_RSP298 {299 Tcontrol_t val = false;300 if (not cache->empty())301 {302 slot_t<cache_req_t *> cache_rsp = cache->read();303 304 val = (cache_rsp._delay == 0);264 // if (take) 265 // addr += 0x100; 266 // else 267 // addr += end-begin+1; 268 269 // for (uint32_t i=0; i<_param->_nb_instruction; i++) 270 // in_PREDICT_INSTRUCTION_ENABLE [i] ->write((i>=begin) and (i<=end)); 271 // in_PREDICT_PC_NEXT ->write(addr); 272 // in_PREDICT_PC_NEXT_IS_DS_TAKE ->write(take); 273 // in_PREDICT_INST_IFETCH_PTR ->write(0); 274 // in_PREDICT_BRANCH_STATE ->write(0); 275 // in_PREDICT_BRANCH_UPDATE_PREDICTION_ID->write(0); 276 // } 277 278 // // DECOD 279 // { 280 // uint32_t nb_decod = (rand()%_param->_nb_instruction); 281 282 // for (uint32_t i=0; i<_param->_nb_instruction; i++) 283 // in_DECOD_ACK [i]->write(i<=nb_decod); 284 // } 285 286 // // EVENT 287 // in_EVENT_VAL ->write((rand()%100)<percent_transaction_event ); 288 // in_EVENT_ADDRESS ->write(0x77); 289 // in_EVENT_ADDRESS_NEXT ->write(0x171); 290 // Tcontrol_t is_ds_take = rand(); 291 // in_EVENT_ADDRESS_NEXT_VAL->write(is_ds_take); 292 // in_EVENT_IS_DS_TAKE ->write(is_ds_take); 293 294 // // ICACHE_REQ 295 // in_ICACHE_REQ_ACK->write((rand()%100)<percent_transaction_icache_req); 296 297 // // ICACHE_RSP 298 // { 299 // Tcontrol_t val = false; 300 // if (not cache->empty()) 301 // { 302 // slot_t<cache_req_t *> cache_rsp = cache->read(); 303 304 // val = (cache_rsp._delay == 0); 305 305 306 Tpacket_t packet = cache_rsp._data->packet ;307 Taddress_t address = cache_rsp._data->address;306 // Tpacket_t packet = cache_rsp._data->packet ; 307 // Taddress_t address = cache_rsp._data->address; 308 308 309 in_ICACHE_RSP_PACKET_ID ->write(packet);310 for (uint32_t i=0; i<_param->_nb_instruction; i++)311 in_ICACHE_RSP_INSTRUCTION [i]->write(address+i);312 in_ICACHE_RSP_ERROR ->write(0);313 }314 315 in_ICACHE_RSP_VAL->write(val);316 }317 318 //-------------------------------------------------319 SC_START(0);320 //-------------------------------------------------321 322 if (out_ICACHE_REQ_VAL->read() and in_ICACHE_REQ_ACK->read())323 {324 LABEL("ICACHE_REQ : Transaction accepted");325 326 Tpacket_t packet = (_param->_have_port_ifetch_queue_ptr)?out_ICACHE_REQ_PACKET_ID->read():0;327 Taddress_t address = out_ICACHE_REQ_ADDRESS->read();328 329 TEST(bool ,slot_use[packet], false);330 TEST(Taddress_t,address ,c_addr);331 332 slot_use[packet] = true;333 334 uint32_t delay;335 if ((rand()%100)<percent_hit)336 delay = 1;337 else338 delay = delay_miss_min + (rand()%(delay_miss_max-delay_miss_min+1));339 340 cache_req_t * cache_req = new cache_req_t(packet,address);341 cache->push(delay,cache_req);342 343 c_val = 0;344 nb_packet_in ++;345 }346 347 {348 bool find=false;349 350 Taddress_t addr=out_DECOD_ADDRESS->read();351 for (uint32_t i=0; i<_param->_nb_instruction; i++)352 if (out_DECOD_VAL[i]->read() and in_DECOD_ACK [i]->read())353 {354 Tinstruction_t inst = out_DECOD_INSTRUCTION[i]->read();355 LABEL("DECOD [%d] : Transaction accepted",i);356 LABEL(" address : 0x%x",addr);357 LABEL(" instruction : 0x%x",inst);358 359 find = true;360 TEST(Tinstruction_t,inst,addr+i);361 }362 363 if (find)364 {365 if (_param->_have_port_inst_ifetch_ptr)366 TEST(Tinst_ifetch_ptr_t, out_DECOD_INST_IFETCH_PTR ->read(), 0);367 TEST(Tbranch_state_t , out_DECOD_BRANCH_STATE ->read(), 0);368 if (_param->_have_port_depth)369 TEST(Tprediction_ptr_t , out_DECOD_BRANCH_UPDATE_PREDICTION_ID->read(), 0);370 TEST(Texception_t , out_DECOD_EXCEPTION ->read(), 0);371 }372 }309 // in_ICACHE_RSP_PACKET_ID ->write(packet); 310 // for (uint32_t i=0; i<_param->_nb_instruction; i++) 311 // in_ICACHE_RSP_INSTRUCTION [i]->write(address+i); 312 // in_ICACHE_RSP_ERROR ->write(0); 313 // } 314 315 // in_ICACHE_RSP_VAL->write(val); 316 // } 317 318 // //------------------------------------------------- 319 // SC_START(0); 320 // //------------------------------------------------- 321 322 // if (out_ICACHE_REQ_VAL->read() and in_ICACHE_REQ_ACK->read()) 323 // { 324 // LABEL("ICACHE_REQ : Transaction accepted"); 325 326 // Tpacket_t packet = (_param->_have_port_ifetch_queue_ptr)?out_ICACHE_REQ_PACKET_ID->read():0; 327 // Taddress_t address = out_ICACHE_REQ_ADDRESS->read(); 328 329 // TEST(bool ,slot_use[packet], false); 330 // TEST(Taddress_t,address ,c_addr); 331 332 // slot_use[packet] = true; 333 334 // uint32_t delay; 335 // if ((rand()%100)<percent_hit) 336 // delay = 1; 337 // else 338 // delay = delay_miss_min + (rand()%(delay_miss_max-delay_miss_min+1)); 339 340 // cache_req_t * cache_req = new cache_req_t(packet,address); 341 // cache->push(delay,cache_req); 342 343 // c_val = 0; 344 // nb_packet_in ++; 345 // } 346 347 // { 348 // bool find=false; 349 350 // Taddress_t addr=out_DECOD_ADDRESS->read(); 351 // for (uint32_t i=0; i<_param->_nb_instruction; i++) 352 // if (out_DECOD_VAL[i]->read() and in_DECOD_ACK [i]->read()) 353 // { 354 // Tinstruction_t inst = out_DECOD_INSTRUCTION[i]->read(); 355 // LABEL("DECOD [%d] : Transaction accepted",i); 356 // LABEL(" address : 0x%x",addr); 357 // LABEL(" instruction : 0x%x",inst); 358 359 // find = true; 360 // TEST(Tinstruction_t,inst,addr+i); 361 // } 362 363 // if (find) 364 // { 365 // if (_param->_have_port_inst_ifetch_ptr) 366 // TEST(Tinst_ifetch_ptr_t, out_DECOD_INST_IFETCH_PTR ->read(), 0); 367 // TEST(Tbranch_state_t , out_DECOD_BRANCH_STATE ->read(), 0); 368 // if (_param->_have_port_depth) 369 // TEST(Tprediction_ptr_t , out_DECOD_BRANCH_UPDATE_PREDICTION_ID->read(), 0); 370 // TEST(Texception_t , out_DECOD_EXCEPTION ->read(), 0); 371 // } 372 // } 373 373 374 if (in_ICACHE_RSP_VAL->read() and out_ICACHE_RSP_ACK->read())375 {376 LABEL("ICACHE_RSP : Transaction accepted");377 378 slot_use[cache->read()._data->packet] = false;379 380 cache->pop();381 }382 383 if (out_PREDICT_VAL->read() and in_PREDICT_ACK->read())384 {385 LABEL("PREDICT : Transaction accepted");386 387 if (c_val)388 TEST(Tgeneral_address_t,out_PREDICT_PC_PREVIOUS ->read(),c_addr );389 TEST(Tgeneral_address_t,out_PREDICT_PC_CURRENT ->read(),n_addr );390 TEST(Tcontrol_t ,out_PREDICT_PC_CURRENT_IS_DS_TAKE->read(),n_is_ds_take);391 392 nn_val = true;393 nn_addr = in_PREDICT_PC_NEXT ->read();394 nn_is_ds_take = in_PREDICT_PC_NEXT_IS_DS_TAKE->read();374 // if (in_ICACHE_RSP_VAL->read() and out_ICACHE_RSP_ACK->read()) 375 // { 376 // LABEL("ICACHE_RSP : Transaction accepted"); 377 378 // slot_use[cache->read()._data->packet] = false; 379 380 // cache->pop(); 381 // } 382 383 // if (out_PREDICT_VAL->read() and in_PREDICT_ACK->read()) 384 // { 385 // LABEL("PREDICT : Transaction accepted"); 386 387 // if (c_val) 388 // TEST(Tgeneral_address_t,out_PREDICT_PC_PREVIOUS ->read(),c_addr ); 389 // TEST(Tgeneral_address_t,out_PREDICT_PC_CURRENT ->read(),n_addr ); 390 // TEST(Tcontrol_t ,out_PREDICT_PC_CURRENT_IS_DS_TAKE->read(),n_is_ds_take); 391 392 // nn_val = true; 393 // nn_addr = in_PREDICT_PC_NEXT ->read(); 394 // nn_is_ds_take = in_PREDICT_PC_NEXT_IS_DS_TAKE->read(); 395 395 396 for (uint32_t i=0; i<_param->_nb_instruction; i++)397 n_enable [i] = in_PREDICT_INSTRUCTION_ENABLE [i]->read();398 }399 400 if (not c_val)401 {402 if (n_val and nn_val)403 {404 c_val = 1;405 c_addr = n_addr;406 c_is_ds_take = n_is_ds_take;407 408 for (uint32_t i=0; i<_param->_nb_instruction; i++)409 c_enable [i] = n_enable [i];396 // for (uint32_t i=0; i<_param->_nb_instruction; i++) 397 // n_enable [i] = in_PREDICT_INSTRUCTION_ENABLE [i]->read(); 398 // } 399 400 // if (not c_val) 401 // { 402 // if (n_val and nn_val) 403 // { 404 // c_val = 1; 405 // c_addr = n_addr; 406 // c_is_ds_take = n_is_ds_take; 407 408 // for (uint32_t i=0; i<_param->_nb_instruction; i++) 409 // c_enable [i] = n_enable [i]; 410 410 411 n_val = 1;412 n_addr = nn_addr;413 n_is_ds_take = nn_is_ds_take;411 // n_val = 1; 412 // n_addr = nn_addr; 413 // n_is_ds_take = nn_is_ds_take; 414 414 415 nn_val = 0;416 }417 }418 419 if (in_EVENT_VAL->read() and out_EVENT_ACK->read())420 {421 LABEL("EVENT : Transaction accepted");422 423 c_val = false;424 n_val = true;425 426 n_addr = in_EVENT_ADDRESS->read();427 n_is_ds_take = in_EVENT_IS_DS_TAKE->read();428 nn_val = in_EVENT_ADDRESS_NEXT_VAL->read();429 nn_addr = in_EVENT_ADDRESS_NEXT ->read();430 nn_is_ds_take = 0;431 432 n_enable [0] = 1;433 for (uint32_t i=1; i<_param->_nb_instruction; i++)434 n_enable [i] = 0;435 }415 // nn_val = 0; 416 // } 417 // } 418 419 // if (in_EVENT_VAL->read() and out_EVENT_ACK->read()) 420 // { 421 // LABEL("EVENT : Transaction accepted"); 422 423 // c_val = false; 424 // n_val = true; 425 426 // n_addr = in_EVENT_ADDRESS->read(); 427 // n_is_ds_take = in_EVENT_IS_DS_TAKE->read(); 428 // nn_val = in_EVENT_ADDRESS_NEXT_VAL->read(); 429 // nn_addr = in_EVENT_ADDRESS_NEXT ->read(); 430 // nn_is_ds_take = 0; 431 432 // n_enable [0] = 1; 433 // for (uint32_t i=1; i<_param->_nb_instruction; i++) 434 // n_enable [i] = 0; 435 // } 436 436 437 437 438 {439 string str_c_enable = "";440 string str_n_enable = "";441 442 for (uint32_t i=0; i<_param->_nb_instruction; i++)443 {444 str_c_enable += " " + toString(c_enable [i]);445 str_n_enable += " " + toString(n_enable [i]);446 }447 448 LABEL("-----------------------------------");449 LABEL(" * nb_packet_in : %d",nb_packet_in);450 LABEL(" * nb_packet_out : %d",nb_packet_out);451 LABEL(" * pc : %d %d %.8x %s",c_val ,c_is_ds_take , c_addr ,str_c_enable.c_str());452 if (nn_val)453 {454 LABEL(" * pc+4 : %d %d %.8x %s",n_val ,n_is_ds_take , n_addr ,str_n_enable.c_str());455 }456 else457 {458 LABEL(" * pc+4 : %d %d %.8x" ,n_val ,n_is_ds_take , n_addr );459 }460 LABEL(" * pc+8 : %d %d %.8x" ,nn_val ,nn_is_ds_take, nn_addr);461 LABEL("-----------------------------------");462 }463 464 SC_START(1);465 cache->transition();438 // { 439 // string str_c_enable = ""; 440 // string str_n_enable = ""; 441 442 // for (uint32_t i=0; i<_param->_nb_instruction; i++) 443 // { 444 // str_c_enable += " " + toString(c_enable [i]); 445 // str_n_enable += " " + toString(n_enable [i]); 446 // } 447 448 // LABEL("-----------------------------------"); 449 // LABEL(" * nb_packet_in : %d",nb_packet_in); 450 // LABEL(" * nb_packet_out : %d",nb_packet_out); 451 // LABEL(" * pc : %d %d %.8x %s",c_val ,c_is_ds_take , c_addr ,str_c_enable.c_str()); 452 // if (nn_val) 453 // { 454 // LABEL(" * pc+4 : %d %d %.8x %s",n_val ,n_is_ds_take , n_addr ,str_n_enable.c_str()); 455 // } 456 // else 457 // { 458 // LABEL(" * pc+4 : %d %d %.8x" ,n_val ,n_is_ds_take , n_addr ); 459 // } 460 // LABEL(" * pc+8 : %d %d %.8x" ,nn_val ,nn_is_ds_take, nn_addr); 461 // LABEL("-----------------------------------"); 462 // } 463 464 // SC_START(1); 465 // cache->transition(); 466 466 } 467 467
Note: See TracChangeset
for help on using the changeset viewer.