[78] | 1 | #ifdef SYSTEMC |
---|
| 2 | /* |
---|
| 3 | * $Id: Return_Address_Stack_genMealy_predict.cpp 123 2009-06-08 20:43:30Z rosiere $ |
---|
| 4 | * |
---|
| 5 | * [ Description ] |
---|
| 6 | * |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | #include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Return_Address_Stack/include/Return_Address_Stack.h" |
---|
| 10 | |
---|
| 11 | namespace morpheo { |
---|
| 12 | namespace behavioural { |
---|
| 13 | namespace core { |
---|
| 14 | namespace multi_front_end { |
---|
| 15 | namespace front_end { |
---|
| 16 | namespace prediction_unit { |
---|
| 17 | namespace return_address_stack { |
---|
| 18 | |
---|
| 19 | |
---|
| 20 | #undef FUNCTION |
---|
| 21 | #define FUNCTION "Return_Address_Stack::genMealy_predict" |
---|
| 22 | void Return_Address_Stack::genMealy_predict (void) |
---|
| 23 | { |
---|
[100] | 24 | log_begin(Return_Address_Stack,FUNCTION); |
---|
| 25 | log_function(Return_Address_Stack,FUNCTION,_name.c_str()); |
---|
[78] | 26 | |
---|
[123] | 27 | if (PORT_READ(in_NRESET)) |
---|
[118] | 28 | { |
---|
[78] | 29 | #ifdef DEBUG_TEST |
---|
[100] | 30 | // just to test if have many transaction on a same context |
---|
[78] | 31 | bool context_valid [_param->_nb_context]; |
---|
| 32 | for (uint32_t i=0; i<_param->_nb_context; i++) |
---|
| 33 | context_valid [i] = true; |
---|
| 34 | #endif |
---|
| 35 | |
---|
| 36 | for (uint32_t i=0; i<_param->_nb_inst_predict; i++) |
---|
| 37 | { |
---|
[100] | 38 | // Read context number |
---|
[78] | 39 | Tcontext_t context = (_param->_have_port_context_id)?PORT_READ(in_PREDICT_CONTEXT_ID [i]):0; |
---|
[100] | 40 | |
---|
[78] | 41 | #ifdef DEBUG_TEST |
---|
| 42 | if (PORT_READ(in_PREDICT_VAL [i])) |
---|
| 43 | { |
---|
| 44 | if (context_valid[context] == false) |
---|
| 45 | ERRORMORPHEO(FUNCTION,"Can't have 2 transactions with the same context_id"); |
---|
| 46 | context_valid[context] = false; |
---|
| 47 | } |
---|
| 48 | #endif |
---|
[100] | 49 | |
---|
| 50 | // Get top |
---|
[78] | 51 | Tptr_t top = reg_PREDICT_TOP[context]; |
---|
| 52 | Tcontrol_t push = PORT_READ(in_PREDICT_PUSH [i]); |
---|
| 53 | |
---|
[100] | 54 | // Hit : |
---|
| 55 | // * if push : value is hit |
---|
| 56 | // * if pop : no empty |
---|
| 57 | internal_PREDICT_HIT [i] = (push or (reg_PREDICT_NB_ELT[context]>0)); |
---|
| 58 | |
---|
[78] | 59 | PORT_WRITE(out_PREDICT_HIT [i], internal_PREDICT_HIT [i]); |
---|
| 60 | |
---|
| 61 | // if pop : address_pop = stack [top] |
---|
[100] | 62 | // if push : stock [top+1] = address_push; also stack [top+1] is erase ! save the old value in the update table |
---|
[78] | 63 | if (push) |
---|
| 64 | top = (top+1)%_param->_size_queue[context]; |
---|
| 65 | |
---|
| 66 | PORT_WRITE(out_PREDICT_ADDRESS_POP [i], reg_stack[context][top]._address); |
---|
[118] | 67 | |
---|
[78] | 68 | PORT_WRITE(out_PREDICT_INDEX [i], top); |
---|
| 69 | } |
---|
[118] | 70 | } |
---|
[123] | 71 | else |
---|
| 72 | { |
---|
| 73 | // for (uint32_t i=0; i<_param->_nb_inst_predict; i++) |
---|
| 74 | // internal_PREDICT_HIT [i] = (push or (reg_PREDICT_NB_ELT[context]>0)); |
---|
[78] | 75 | |
---|
[123] | 76 | } |
---|
| 77 | |
---|
[100] | 78 | log_end(Return_Address_Stack,FUNCTION); |
---|
[78] | 79 | }; |
---|
| 80 | |
---|
| 81 | }; // end namespace return_address_stack |
---|
| 82 | }; // end namespace prediction_unit |
---|
| 83 | }; // end namespace front_end |
---|
| 84 | }; // end namespace multi_front_end |
---|
| 85 | }; // end namespace core |
---|
| 86 | }; // end namespace behavioural |
---|
| 87 | }; // end namespace morpheo |
---|
| 88 | #endif |
---|