1 | #ifdef SYSTEMC |
---|
2 | /* |
---|
3 | * $Id: Meta_Predictor_Glue_genMealy_branch_complete_val.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/Direction/Meta_Predictor/Meta_Predictor_Glue/include/Meta_Predictor_Glue.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 direction { |
---|
18 | |
---|
19 | namespace meta_predictor { |
---|
20 | namespace meta_predictor_glue { |
---|
21 | |
---|
22 | void Meta_Predictor_Glue::genMealy_branch_complete_val (void) |
---|
23 | { |
---|
24 | log_printf(FUNC,Meta_Predictor_Glue,"genMealy_branch_complete_val","Begin"); |
---|
25 | |
---|
26 | for (uint32_t i=0; i<_param._nb_branch_complete; i++) |
---|
27 | { |
---|
28 | Tcontrol_t val = PORT_READ(in_BRANCH_COMPLETE_VAL [i]); |
---|
29 | Thistory_t history = PORT_READ(in_BRANCH_COMPLETE_HISTORY [i]); |
---|
30 | Tcontrol_t direction = PORT_READ(in_BRANCH_COMPLETE_DIRECTION [i]); |
---|
31 | |
---|
32 | Tcontrol_t predictor_0_direction = (history>>(_param._shift_2-1))&1; |
---|
33 | Tcontrol_t predictor_1_direction = (history>>(_param._shift_4-1))&1; |
---|
34 | // Tcontrol_t predictor_2_direction = (history>>(_param._shift_6-1))&1; |
---|
35 | |
---|
36 | // log_printf(TRACE,Meta_Predictor_Glue,"genMealy_branch_complete_val","direction_(predictor_0 %d, predictor_1 %d, predictor_2 %d, good %d)", predictor_0_direction, predictor_1_direction, predictor_2_direction, direction); |
---|
37 | log_printf(TRACE,Meta_Predictor_Glue,"genMealy_branch_complete_val","direction_(predictor_0 %d, predictor_1 %d, good %d)", predictor_0_direction, predictor_1_direction, direction); |
---|
38 | |
---|
39 | log_printf(TRACE,Meta_Predictor_Glue,"genMealy_branch_complete_val"," * direction_0 : %d >>(%d-1)",history,_param._shift_2); |
---|
40 | log_printf(TRACE,Meta_Predictor_Glue,"genMealy_branch_complete_val"," * direction_1 : %d >>(%d-1)",history,_param._shift_4); |
---|
41 | log_printf(TRACE,Meta_Predictor_Glue,"genMealy_branch_complete_val"," * direction_2 : %d >>(%d-1)",history,_param._shift_6); |
---|
42 | |
---|
43 | /* |
---|
44 | dir_0 dir_1 dir_2 | good_dir || next_dir_2 |
---|
45 | ------------------+-----------++----------- |
---|
46 | 0 0 0 | 0 || no change |
---|
47 | 1 0 0 | 0 || 1 select pred_0 but miss |
---|
48 | 0 1 0 | 0 || 0 select pred_0 and hit |
---|
49 | 1 1 0 | 0 || no change |
---|
50 | 0 0 1 | 0 || no change |
---|
51 | 1 0 1 | 0 || 1 select pred_1 and hit |
---|
52 | 0 1 1 | 0 || 0 select pred_1 but miss |
---|
53 | 1 1 1 | 0 || no change |
---|
54 | 0 0 0 | 1 || no change |
---|
55 | 1 0 0 | 1 || 0 select pred_0 and hit |
---|
56 | 0 1 0 | 1 || 1 select pred_0 but miss |
---|
57 | 1 1 0 | 1 || no change |
---|
58 | 0 0 1 | 1 || no change |
---|
59 | 1 0 1 | 1 || 0 select pred_1 but miss |
---|
60 | 0 1 1 | 1 || 1 select pred_1 and hit |
---|
61 | 1 1 1 | 1 || no change |
---|
62 | |
---|
63 | next_dir_2 = (good_dir and dir_1) or (not good_dir and dir_0) |
---|
64 | */ |
---|
65 | |
---|
66 | Tcontrol_t branch_complete_predictor_2_val = val and (predictor_0_direction xor predictor_1_direction); |
---|
67 | Tcontrol_t branch_complete_predictor_2_direction = ( (not direction and predictor_0_direction) or |
---|
68 | ( direction and predictor_1_direction) ); |
---|
69 | |
---|
70 | log_printf(TRACE,Meta_Predictor_Glue,"genMealy_branch_complete_val","branch_complete_predictor_2_( val %d, direction %d)",branch_complete_predictor_2_val, branch_complete_predictor_2_direction); |
---|
71 | |
---|
72 | // Modify meta_predictor if have a branch_complete and twice prediction have not predict the same way |
---|
73 | PORT_WRITE(out_BRANCH_COMPLETE_PREDICTOR_2_DIRECTION [i], branch_complete_predictor_2_direction); |
---|
74 | PORT_WRITE(out_BRANCH_COMPLETE_PREDICTOR_2_VAL [i], branch_complete_predictor_2_val ); |
---|
75 | } |
---|
76 | |
---|
77 | log_printf(FUNC,Meta_Predictor_Glue,"genMealy_branch_complete_val","End"); |
---|
78 | }; |
---|
79 | |
---|
80 | }; // end namespace meta_predictor_glue |
---|
81 | }; // end namespace meta_predictor |
---|
82 | |
---|
83 | }; // end namespace core |
---|
84 | }; // end namespace multi_front_end |
---|
85 | }; // end namespace front_end |
---|
86 | }; // end namespace prediction_unit |
---|
87 | }; // end namespace direction |
---|
88 | |
---|
89 | }; // end namespace behavioural |
---|
90 | }; // end namespace morpheo |
---|
91 | #endif |
---|