1 | #ifdef SYSTEMC |
---|
2 | /* |
---|
3 | * $Id: Return_Address_Stack_genMealy_predict.cpp 81 2008-04-15 18:40:01Z 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 | { |
---|
24 | log_printf(FUNC,Return_Address_Stack,FUNCTION,"Begin"); |
---|
25 | |
---|
26 | #ifdef DEBUG_TEST |
---|
27 | bool context_valid [_param->_nb_context]; |
---|
28 | for (uint32_t i=0; i<_param->_nb_context; i++) |
---|
29 | context_valid [i] = true; |
---|
30 | #endif |
---|
31 | |
---|
32 | for (uint32_t i=0; i<_param->_nb_inst_predict; i++) |
---|
33 | { |
---|
34 | Tcontext_t context = (_param->_have_port_context_id)?PORT_READ(in_PREDICT_CONTEXT_ID [i]):0; |
---|
35 | |
---|
36 | #ifdef DEBUG_TEST |
---|
37 | if (PORT_READ(in_PREDICT_VAL [i])) |
---|
38 | { |
---|
39 | if (context_valid[context] == false) |
---|
40 | ERRORMORPHEO(FUNCTION,"Can't have 2 transactions with the same context_id"); |
---|
41 | context_valid[context] = false; |
---|
42 | } |
---|
43 | #endif |
---|
44 | |
---|
45 | Tptr_t top = reg_PREDICT_TOP[context]; |
---|
46 | Tcontrol_t push = PORT_READ(in_PREDICT_PUSH [i]); |
---|
47 | |
---|
48 | // if push : value is hit |
---|
49 | // if pop : val and not miss |
---|
50 | internal_PREDICT_HIT [i] = (push or (reg_stack[context][top]._val and not reg_stack[context][top]._miss and (reg_PREDICT_NB_ELT[context]>0))); |
---|
51 | PORT_WRITE(out_PREDICT_HIT [i], internal_PREDICT_HIT [i]); |
---|
52 | |
---|
53 | // if pop : address_pop = stack [top] |
---|
54 | // if push : stock [top+1] = address_push; also stock [top+1] is erase ! give the old value at the update table |
---|
55 | if (push) |
---|
56 | top = (top+1)%_param->_size_queue[context]; |
---|
57 | |
---|
58 | PORT_WRITE(out_PREDICT_ADDRESS_POP [i], reg_stack[context][top]._address); |
---|
59 | PORT_WRITE(out_PREDICT_INDEX [i], top); |
---|
60 | } |
---|
61 | |
---|
62 | log_printf(FUNC,Return_Address_Stack,FUNCTION,"End"); |
---|
63 | }; |
---|
64 | |
---|
65 | }; // end namespace return_address_stack |
---|
66 | }; // end namespace prediction_unit |
---|
67 | }; // end namespace front_end |
---|
68 | }; // end namespace multi_front_end |
---|
69 | }; // end namespace core |
---|
70 | }; // end namespace behavioural |
---|
71 | }; // end namespace morpheo |
---|
72 | #endif |
---|