Changeset 105 for trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_transition.cpp
- Timestamp:
- Feb 5, 2009, 12:18:31 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/src/Update_Prediction_Table_transition.cpp
r101 r105 50 50 reg_IS_ACCURATE [i] = true; 51 51 52 reg_EVENT_VAL [i] = false; 52 53 reg_EVENT_STATE [i] = EVENT_STATE_OK; 53 54 } … … 55 56 else 56 57 { 57 bool flush_UFPT [_param->_nb_context];58 bool flush_UFPT [_param->_nb_context]; 58 59 for (uint32_t i=0; i<_param->_nb_context; i++) 59 flush_UFPT [i] = false; 60 { 61 flush_UFPT [i] = false; 62 } 60 63 61 64 // =================================================================== … … 66 69 // * Update state -> new status is "empty" 67 70 // * Update pointer (bottom and accurate) 68 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * GARBAGE COLLECTOR ");71 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * GARBAGE COLLECTOR (BEGIN)"); 69 72 for (uint32_t i=0; i<_param->_nb_context; i++) 70 73 { … … 113 116 // if (bottom = reg_UPT_UPDATE [i]) 114 117 // reg_UPT_UPDATE [i] = reg_UPT_BOTTOM [i]; 115 if (end_ko) // free 118 119 if (reg_EVENT_VAL [i] and (reg_EVENT_UPT_PTR [i] == bottom)) 120 // if (end_ko) // free 116 121 { 122 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * END EVENT"); 123 124 reg_EVENT_VAL [i] = false; 117 125 reg_UPT_TOP [i] = reg_UPT_TOP_EVENT [i]; 118 126 reg_UPT_UPDATE [i] = reg_UPT_TOP_EVENT [i]; 119 127 120 128 if (reg_UPT_BOTTOM [i] != reg_UPT_TOP [i]) 121 129 reg_UPT_EMPTY [i] = false; … … 124 132 } 125 133 } 134 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * GARBAGE COLLECTOR (END)"); 126 135 127 136 // =================================================================== … … 218 227 else 219 228 { 220 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * EVENT [%d] <- EVENT_STATE_ FLUSH_UFPT (decod - miss - flush ufpt)",context);221 reg_EVENT_STATE [context] = EVENT_STATE_ FLUSH_UFPT;229 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * EVENT [%d] <- EVENT_STATE_MISS_FLUSH_UFPT (decod - miss - flush ufpt)",context); 230 reg_EVENT_STATE [context] = EVENT_STATE_MISS_FLUSH_UFPT; 222 231 } 223 232 … … 273 282 reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._address_ras = reg_UPDATE_FETCH_PREDICTION_TABLE [context][ufpt_ptr_read]._address_ras ; 274 283 reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._index_ras = reg_UPDATE_FETCH_PREDICTION_TABLE [context][ufpt_ptr_read]._index_ras ; 275 reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._ifetch_prediction = true ; // prediction from ifetch284 reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._ifetch_prediction = true ; // prediction from ifetch 276 285 277 286 // Update pointer … … 283 292 284 293 // All case !!! 285 286 294 #ifdef DEBUG_TEST 287 295 if (reg_UPDATE_PREDICTION_TABLE [context][upt_ptr_write]._state != UPDATE_PREDICTION_STATE_EMPTY) … … 352 360 353 361 if (reg_UPT_BOTTOM [context] == reg_UPT_TOP [context]) 354 reg_UPT_EMPTY [ i] = true;362 reg_UPT_EMPTY [context] = true; 355 363 356 364 #ifdef DEBUG_TEST … … 364 372 Taddress_t address_src = reg_UPDATE_PREDICTION_TABLE [context][depth]._address_src; 365 373 event_state_t event_state = reg_EVENT_STATE [context]; 366 bool previous_update_ras = (event_state == EVENT_STATE_FLUSH_UPT); 367 bool update_ras = (new_update != depth); 368 369 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * update_ras : %d",update_ras); 374 bool previous_update_ras = ((event_state == EVENT_STATE_MISS_FLUSH_UFPT_AND_UPT ) or 375 (event_state == EVENT_STATE_MISS_FLUSH_UPT ) or 376 (event_state == EVENT_STATE_EVENT_FLUSH_UFPT_AND_UPT) or 377 (event_state == EVENT_STATE_EVENT_FLUSH_UPT)); 378 // bool update_ras = (new_update != depth); 379 380 // log_printf(TRACE,Update_Prediction_Table,FUNCTION," * update_ras : %d",update_ras); 370 381 371 382 if (reg_UFPT_NB_NEED_UPDATE [context] > 0) 372 383 { 373 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * EVENT [%d] <- EVENT_STATE_ FLUSH_UFPT_AND_UPT (branch_complete - miss)",context);374 reg_EVENT_STATE [context] = EVENT_STATE_ FLUSH_UFPT_AND_UPT;384 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * EVENT [%d] <- EVENT_STATE_MISS_FLUSH_UFPT_AND_UPT (branch_complete - miss)",context); 385 reg_EVENT_STATE [context] = EVENT_STATE_MISS_FLUSH_UFPT_AND_UPT; 375 386 } 376 387 else 377 388 { 378 if (not previous_update_ras)389 // if (not previous_update_ras) 379 390 { 380 391 // have ras prediction ? 381 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * EVENT [%d] <- EVENT_STATE_ FLUSH_UPT (branch_complete - miss)",context);382 383 reg_EVENT_STATE [context] = EVENT_STATE_ FLUSH_UPT;392 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * EVENT [%d] <- EVENT_STATE_MISS_FLUSH_UPT (branch_complete - miss)",context); 393 394 reg_EVENT_STATE [context] = EVENT_STATE_MISS_FLUSH_UPT; 384 395 385 396 } … … 442 453 switch (reg_EVENT_STATE [context]) 443 454 { 444 case EVENT_STATE_ FLUSH_UFPT: reg_EVENT_STATE [context] = EVENT_STATE_UPDATE_CONTEXT; break;455 case EVENT_STATE_MISS_FLUSH_UFPT : reg_EVENT_STATE [context] = EVENT_STATE_UPDATE_CONTEXT; break; 445 456 // impossible to have an update on ufpt and reg_upt_update>reg_upt_top 446 case EVENT_STATE_FLUSH_UFPT_AND_UPT : reg_EVENT_STATE [context] = EVENT_STATE_FLUSH_UPT ; break; 457 case EVENT_STATE_MISS_FLUSH_UFPT_AND_UPT : reg_EVENT_STATE [context] = EVENT_STATE_MISS_FLUSH_UPT ; break; 458 case EVENT_STATE_EVENT_FLUSH_UFPT : reg_EVENT_STATE [context] = EVENT_STATE_OK ; break; 459 case EVENT_STATE_EVENT_FLUSH_UFPT_AND_UPT: reg_EVENT_STATE [context] = EVENT_STATE_EVENT_FLUSH_UPT; break; 447 460 default : break; 448 461 } … … 478 491 { 479 492 if ((reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_EVENT) and 480 (reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_KO ) )493 (reg_UPDATE_PREDICTION_TABLE [context][depth]._state != UPDATE_PREDICTION_STATE_KO ) ) 481 494 throw ERRORMORPHEO(FUNCTION,_("Update : invalid upt state.")); 482 495 } … … 507 520 508 521 reg_UPDATE_PREDICTION_TABLE [context][depth]._state = UPDATE_PREDICTION_STATE_END_KO; 522 523 reg_EVENT_VAL [context] = true; 524 reg_EVENT_UPT_PTR [context] = depth; 509 525 510 526 #ifdef STATISTICS … … 541 557 if (end_event) 542 558 { 543 reg_UPT_UPDATE [context] = reg_UPT_BOTTOM[context]; 544 reg_EVENT_STATE [context] = EVENT_STATE_UPDATE_CONTEXT; 559 // reg_UPT_UPDATE [context] = reg_UPT_BOTTOM[context]; 560 561 if (reg_EVENT_STATE [context] == EVENT_STATE_EVENT_FLUSH_UPT) 562 { 563 reg_EVENT_STATE [context] = EVENT_STATE_OK; 564 } 565 else 566 reg_EVENT_STATE [context] = EVENT_STATE_UPDATE_CONTEXT; 545 567 } 546 568 else … … 593 615 if (PORT_READ(in_EVENT_VAL [i]) and internal_EVENT_ACK [i]) 594 616 { 617 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * EVENT"); 618 595 619 //---------------------------------------------------------------- 596 620 // Cases … … 606 630 607 631 Tevent_type_t event_type = PORT_READ(in_EVENT_TYPE [i]); 608 // Tdepth_t depth = PORT_READ(in_EVENT_DEPTH [i]); 609 632 610 633 // Test if end of miss -> all previous branch is complete 611 634 // -> all next branch is finish 612 if (event_type == EVENT_TYPE_MISS_SPECULATION) 635 636 switch (event_type) 613 637 { 614 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * EVENT"); 615 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * type : EVENT_TYPE_MISS_SPECULATION"); 616 617 #ifdef DEBUG_TEST 618 if (reg_EVENT_STATE [i] != EVENT_STATE_WAIT_END_EVENT) 619 throw ERRORMORPHEO(FUNCTION,_("Event : invalid event state.")); 620 #endif 621 622 // Change state 623 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * EVENT [%d] <- EVENT_STATE_OK (event)",i); 624 625 reg_EVENT_STATE [i] = EVENT_STATE_OK; 626 reg_IS_ACCURATE [i] = true; 627 628 // Tdepth_t depth = reg_UPT_TOP [i]; 629 630 #ifdef DEBUG_TEST 631 // if (reg_UPDATE_PREDICTION_TABLE [i][depth]._state != UPDATE_PREDICTION_STATE_END_KO_WAIT_END) 632 // throw ERRORMORPHEO(FUNCTION,_("Event : invalid upt event state.")); 633 // if (reg_UPDATE_PREDICTION_TABLE [i][depth]._state != UPDATE_PREDICTION_STATE_END_KO) 634 // throw ERRORMORPHEO(FUNCTION,_("Event : invalid upt event state.")); 635 #endif 636 637 // log_printf(TRACE,Update_Prediction_Table,FUNCTION," * UPT [%d][%d].state <- UPDATE_PREDICTION_STATE_END_KO (update)",i,depth); 638 case EVENT_TYPE_BRANCH_MISS_SPECULATION : 639 { 640 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * type : EVENT_TYPE_BRANCH_MISS_SPECULATION"); 641 642 #ifdef DEBUG_TEST 643 if (reg_EVENT_STATE [i] != EVENT_STATE_WAIT_END_EVENT) 644 throw ERRORMORPHEO(FUNCTION,_("Event : invalid event state.")); 645 #endif 646 647 // Change state 648 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * EVENT [%d] <- EVENT_STATE_OK (event)",i); 649 650 reg_EVENT_STATE [i] = EVENT_STATE_OK; 651 reg_IS_ACCURATE [i] = true; 652 653 // Tdepth_t depth = reg_UPT_TOP [i]; 654 655 #ifdef DEBUG_TEST 656 // if (reg_UPDATE_PREDICTION_TABLE [i][depth]._state != UPDATE_PREDICTION_STATE_END_KO_WAIT_END) 657 // throw ERRORMORPHEO(FUNCTION,_("Event : invalid upt event state.")); 658 // if (reg_UPDATE_PREDICTION_TABLE [i][depth]._state != UPDATE_PREDICTION_STATE_END_KO) 659 // throw ERRORMORPHEO(FUNCTION,_("Event : invalid upt event state.")); 660 #endif 661 662 // log_printf(TRACE,Update_Prediction_Table,FUNCTION," * UPT [%d][%d].state <- UPDATE_PREDICTION_STATE_END_KO (update)",i,depth); 638 663 639 // reg_UPDATE_PREDICTION_TABLE [i][depth]._state = UPDATE_PREDICTION_STATE_END_KO; 640 664 // reg_UPDATE_PREDICTION_TABLE [i][depth]._state = UPDATE_PREDICTION_STATE_END_KO; 665 666 break; 667 } 668 case EVENT_TYPE_LOAD_MISS_SPECULATION : 669 case EVENT_TYPE_EXCEPTION : 670 { 671 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * type : EVENT_TYPE_LOAD_MISS_SPECULATION"); 672 673 // Have a miss !!! 674 // Flush UPFT 675 flush_UFPT [i] = true; 676 677 // Flush UPT 678 Tdepth_t depth = (_param->_have_port_depth)?PORT_READ(in_EVENT_DEPTH [i]):0; 679 uint32_t top = reg_UPT_TOP [i]; 680 uint32_t bottom = reg_UPT_BOTTOM [i]; 681 uint32_t new_update = ((top==0)?_param->_size_upt_queue[i]:top)-1; 682 uint32_t full = ((depth == top) and (top == bottom) and not reg_UPT_EMPTY [i]); 683 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * top : %d",top); 684 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * depth : %d",depth); 685 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * new_update : %d",new_update); 686 687 688 #ifdef DEBUG_TEST 689 if (reg_UPDATE_PREDICTION_TABLE [i][depth]._state != UPDATE_PREDICTION_STATE_WAIT_END) 690 throw ERRORMORPHEO(FUNCTION,_("Branch complete : invalid upt state.")); 691 #endif 692 693 // flush all slot after the event 694 for (uint32_t j=depth; 695 j!=top; 696 j=(j+1)%_param->_size_upt_queue[i]) 697 reg_UPDATE_PREDICTION_TABLE [i][j]._state = UPDATE_PREDICTION_STATE_EVENT; 698 699 // test full : 700 if (full) 701 reg_UPDATE_PREDICTION_TABLE [i][depth]._state = UPDATE_PREDICTION_STATE_EVENT; 702 703 // reg_UPT_BOTTOM [i]; 704 // TODO : special case : event is an exception on branch, also depth is not valid 705 reg_UPT_TOP [i] = depth; // depth is again valid 706 reg_UPT_TOP_EVENT [i] = top; 707 708 if (bottom == reg_UPT_TOP [i]) 709 reg_UPT_EMPTY [i] = true; 710 711 reg_EVENT_VAL [i] = true; 712 reg_EVENT_UPT_PTR [i] = depth; 713 event_state_t event_state = reg_EVENT_STATE [i]; 714 bool previous_update_ras = ((event_state == EVENT_STATE_MISS_FLUSH_UFPT_AND_UPT ) or 715 (event_state == EVENT_STATE_MISS_FLUSH_UPT ) or 716 (event_state == EVENT_STATE_EVENT_FLUSH_UFPT_AND_UPT) or 717 (event_state == EVENT_STATE_EVENT_FLUSH_UPT)); 718 bool update_ras = (top != depth) or full; 719 720 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * update_ras : %d",update_ras); 721 722 // new state : 723 // * test if ufpt is empty 724 // * ok : flush upft and upt 725 // * ko : test if have previous flush upt 726 // * ok : nothing 727 // * ko : flush upt 728 if (reg_UFPT_NB_NEED_UPDATE [i] > 0) 729 { 730 if (update_ras) 731 { 732 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * EVENT [%d] <- EVENT_STATE_EVENT_FLUSH_UFPT_AND_UPT (branch_complete - miss)",i); 733 reg_EVENT_STATE [i] = EVENT_STATE_EVENT_FLUSH_UFPT_AND_UPT; 734 } 735 else 736 { 737 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * EVENT [%d] <- EVENT_STATE_EVENT_FLUSH_UFPT (branch_complete - miss)",i); 738 reg_EVENT_STATE [i] = EVENT_STATE_EVENT_FLUSH_UFPT; 739 } 740 } 741 else 742 { 743 // if (not previous_update_ras) 744 if (update_ras) 745 { 746 // have ras prediction ? 747 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * EVENT [%d] <- EVENT_STATE_EVENT_FLUSH_UPT (branch_complete - miss)",i); 748 749 reg_EVENT_STATE [i] = EVENT_STATE_EVENT_FLUSH_UPT; 750 } 751 else 752 { 753 reg_EVENT_STATE [i] = EVENT_STATE_OK; 754 } 755 } 756 757 if (not previous_update_ras and update_ras) 758 { 759 reg_UPT_UPDATE [i] = new_update; 760 } 761 // else no update 762 763 reg_EVENT_DEPTH [i] = depth; 764 // reg_EVENT_ADDRESS_SRC [i] = address_src; // delay_slot is compute in I_State 765 // reg_EVENT_ADDRESS_DEST_VAL[i] = good_take; 766 // reg_EVENT_ADDRESS_DEST [i] = good_addr; 767 768 break; 769 } 770 default : 771 { 772 // nothing 773 break; 774 } 641 775 } 642 776 } … … 706 840 { 707 841 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * reg_IS_ACCURATE : %d",reg_IS_ACCURATE [i]); 842 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * reg_EVENT_VAL : %d" ,reg_EVENT_VAL [i]); 843 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * reg_EVENT_UPT_PTR : %d" ,reg_EVENT_UPT_PTR [i]); 708 844 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * reg_EVENT_STATE : %s" ,toString(reg_EVENT_STATE [i]).c_str()); 709 845 log_printf(TRACE,Update_Prediction_Table,FUNCTION," * reg_EVENT_DEPTH : %d" ,reg_EVENT_DEPTH [i]);
Note: See TracChangeset
for help on using the changeset viewer.