1 | #ifndef morpheo_behavioural_core_multi_front_end_front_end_prediction_unit_update_prediction_table_Update_Prediction_Table_h |
---|
2 | #define morpheo_behavioural_core_multi_front_end_front_end_prediction_unit_update_prediction_table_Update_Prediction_Table_h |
---|
3 | |
---|
4 | /* |
---|
5 | * $Id: Update_Prediction_Table.h 94 2008-12-15 11:04:03Z rosiere $ |
---|
6 | * |
---|
7 | * [ Description ] |
---|
8 | * |
---|
9 | */ |
---|
10 | |
---|
11 | #ifdef SYSTEMC |
---|
12 | #include "systemc.h" |
---|
13 | #endif |
---|
14 | |
---|
15 | #include <iostream> |
---|
16 | #include "Common/include/ToString.h" |
---|
17 | #include "Common/include/Debug.h" |
---|
18 | |
---|
19 | #include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/include/Types.h" |
---|
20 | #include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Update_Prediction_Table/include/Parameters.h" |
---|
21 | #ifdef STATISTICS |
---|
22 | #include "Behavioural/include/Stat.h" |
---|
23 | #endif |
---|
24 | #include "Behavioural/include/Component.h" |
---|
25 | #ifdef VHDL |
---|
26 | #include "Behavioural/include/Vhdl.h" |
---|
27 | #endif |
---|
28 | #include "Behavioural/include/Usage.h" |
---|
29 | |
---|
30 | namespace morpheo { |
---|
31 | namespace behavioural { |
---|
32 | |
---|
33 | namespace core { |
---|
34 | namespace multi_front_end { |
---|
35 | namespace front_end { |
---|
36 | namespace prediction_unit { |
---|
37 | namespace update_prediction_table { |
---|
38 | |
---|
39 | |
---|
40 | class Update_Prediction_Table |
---|
41 | #if SYSTEMC |
---|
42 | : public sc_module |
---|
43 | #endif |
---|
44 | { |
---|
45 | // -----[ fields ]---------------------------------------------------- |
---|
46 | // Parameters |
---|
47 | protected : const std::string _name; |
---|
48 | protected : const Parameters * _param; |
---|
49 | private : const Tusage_t _usage; |
---|
50 | |
---|
51 | #ifdef STATISTICS |
---|
52 | public : Stat * _stat; |
---|
53 | |
---|
54 | private : counter_t ** _stat_nb_branch_hit ; //[nb_context] |
---|
55 | private : counter_t ** _stat_nb_branch_miss ; //[nb_context] |
---|
56 | private : counter_t ** _stat_nb_branch_unused ; //[nb_context] |
---|
57 | private : counter_t ** _stat_queue_nb_cycle_empty; //[nb_context] |
---|
58 | private : counter_t ** _stat_queue_nb_cycle_full ; //[nb_context] |
---|
59 | private : counter_t ** _stat_queue_nb_elt ; //[nb_context] |
---|
60 | |
---|
61 | #endif |
---|
62 | |
---|
63 | public : Component * _component; |
---|
64 | private : Interfaces * _interfaces; |
---|
65 | |
---|
66 | #ifdef SYSTEMC |
---|
67 | // ~~~~~[ Interface ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
68 | // ~~~~~[ Interface : "" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
69 | public : SC_CLOCK * in_CLOCK ; |
---|
70 | public : SC_IN (Tcontrol_t) * in_NRESET ; |
---|
71 | |
---|
72 | // ~~~~~[ Interface : "predict" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
73 | public : SC_IN (Tcontrol_t ) ** in_PREDICT_VAL ; //[nb_inst_predict] |
---|
74 | public : SC_OUT(Tcontrol_t ) ** out_PREDICT_ACK ; //[nb_inst_predict] |
---|
75 | public : SC_IN (Tcontext_t ) ** in_PREDICT_CONTEXT_ID ; //[nb_inst_predict] |
---|
76 | public : SC_IN (Taddress_t ) ** in_PREDICT_BTB_ADDRESS_SRC ; //[nb_inst_predict] |
---|
77 | public : SC_IN (Taddress_t ) ** in_PREDICT_BTB_ADDRESS_DEST ; //[nb_inst_predict] |
---|
78 | public : SC_IN (Tbranch_condition_t) ** in_PREDICT_BTB_CONDITION ; //[nb_inst_predict] |
---|
79 | public : SC_IN (Tcontrol_t ) ** in_PREDICT_BTB_LAST_TAKE ; //[nb_inst_predict] |
---|
80 | public : SC_IN (Tcontrol_t ) ** in_PREDICT_BTB_IS_ACCURATE ; //[nb_inst_predict] |
---|
81 | public : SC_IN (Thistory_t ) ** in_PREDICT_DIR_HISTORY ; //[nb_inst_predict] |
---|
82 | public : SC_IN (Taddress_t ) ** in_PREDICT_RAS_ADDRESS ; //[nb_inst_predict] |
---|
83 | public : SC_IN (Tptr_t ) ** in_PREDICT_RAS_INDEX ; //[nb_inst_predict] |
---|
84 | public : SC_OUT(Tprediction_ptr_t ) ** out_PREDICT_UPDATE_PREDICTION_ID ; //[nb_inst_predict] |
---|
85 | |
---|
86 | // ~~~~~[ Interface : "decod" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
87 | public : SC_IN (Tcontrol_t ) ** in_DECOD_VAL ; //[nb_inst_decod] |
---|
88 | public : SC_OUT(Tcontrol_t ) ** out_DECOD_ACK ; //[nb_inst_decod] |
---|
89 | public : SC_IN (Tcontext_t ) ** in_DECOD_CONTEXT_ID ; //[nb_inst_decod] |
---|
90 | public : SC_IN (Taddress_t ) ** in_DECOD_BTB_ADDRESS_SRC ; //[nb_inst_decod] |
---|
91 | public : SC_IN (Taddress_t ) ** in_DECOD_BTB_ADDRESS_DEST ; //[nb_inst_decod] |
---|
92 | public : SC_IN (Tbranch_condition_t) ** in_DECOD_BTB_CONDITION ; //[nb_inst_decod] |
---|
93 | public : SC_IN (Tcontrol_t ) ** in_DECOD_BTB_LAST_TAKE ; //[nb_inst_decod] |
---|
94 | //public : SC_IN (Thistory_t ) ** in_DECOD_DIR_HISTORY ; //[nb_inst_decod] // if ifetch prediction is miss -> miss btb -> make a static state |
---|
95 | public : SC_IN (Taddress_t ) ** in_DECOD_RAS_ADDRESS ; //[nb_inst_decod] |
---|
96 | public : SC_IN (Tptr_t ) ** in_DECOD_RAS_INDEX ; //[nb_inst_decod] |
---|
97 | public : SC_IN (Tcontrol_t ) ** in_DECOD_MISS_IFETCH ; //[nb_inst_decod] |
---|
98 | public : SC_IN (Tcontrol_t ) ** in_DECOD_MISS_DECOD ; //[nb_inst_decod] |
---|
99 | public : SC_IN (Tprediction_ptr_t ) ** in_DECOD_UPDATE_PREDICTION_ID ; //[nb_inst_decod] |
---|
100 | //public : SC_OUT(Tdepth_t ) ** out_DECOD_DEPTH ; //[nb_inst_decod] |
---|
101 | public : SC_IN (Tcontrol_t ) ** in_DECOD_IS_ACCURATE ; //[nb_inst_decod] |
---|
102 | |
---|
103 | // ~~~~~[ Interface : "branch_complete" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
104 | public : SC_IN (Tcontrol_t ) ** in_BRANCH_COMPLETE_VAL ; //[nb_inst_branch_complete] |
---|
105 | public : SC_OUT(Tcontrol_t ) ** out_BRANCH_COMPLETE_ACK ; //[nb_inst_branch_complete] |
---|
106 | public : SC_IN (Tcontext_t ) ** in_BRANCH_COMPLETE_CONTEXT_ID ; //[nb_inst_branch_complete] |
---|
107 | public : SC_IN (Tdepth_t ) ** in_BRANCH_COMPLETE_DEPTH ; //[nb_inst_branch_complete] |
---|
108 | public : SC_IN (Taddress_t ) ** in_BRANCH_COMPLETE_ADDRESS ; //[nb_inst_branch_complete] |
---|
109 | public : SC_IN (Tcontrol_t ) ** in_BRANCH_COMPLETE_FLAG ; //[nb_inst_branch_complete] |
---|
110 | public : SC_OUT(Tcontrol_t ) ** out_BRANCH_COMPLETE_MISS_PREDICTION; //[nb_inst_branch_complete] |
---|
111 | public : SC_OUT(Tcontrol_t ) ** out_BRANCH_COMPLETE_TAKE ; //[nb_inst_branch_complete] |
---|
112 | public : SC_OUT(Taddress_t ) ** out_BRANCH_COMPLETE_ADDRESS_SRC ; //[nb_inst_branch_complete] |
---|
113 | public : SC_OUT(Taddress_t ) ** out_BRANCH_COMPLETE_ADDRESS_DEST ; //[nb_inst_branch_complete] |
---|
114 | |
---|
115 | // ~~~~~[ Interface : "branch_event" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
116 | public : SC_OUT(Tcontrol_t ) ** out_BRANCH_EVENT_VAL ; //[nb_context] |
---|
117 | public : SC_IN (Tcontrol_t ) ** in_BRANCH_EVENT_ACK ; //[nb_context] |
---|
118 | //public : SC_OUT(Tcontext_t ) ** out_BRANCH_EVENT_CONTEXT_ID ; //[nb_context] |
---|
119 | //public : SC_OUT(Tdepth_t ) ** out_BRANCH_EVENT_DEPTH ; //[nb_context] |
---|
120 | //public : SC_OUT(Tcontrol_t ) ** out_BRANCH_EVENT_MISS_PREDICTION ; //[nb_context] is always miss prediction |
---|
121 | public : SC_OUT(Taddress_t ) ** out_BRANCH_EVENT_ADDRESS_SRC ; //[nb_context] |
---|
122 | public : SC_OUT(Tcontrol_t ) ** out_BRANCH_EVENT_ADDRESS_DEST_VAL ; //[nb_context] |
---|
123 | public : SC_OUT(Taddress_t ) ** out_BRANCH_EVENT_ADDRESS_DEST ; //[nb_context] |
---|
124 | |
---|
125 | // ~~~~~[ Interface : "update" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
126 | public : SC_OUT(Tcontrol_t ) ** out_UPDATE_VAL ; //[nb_inst_update] |
---|
127 | public : SC_IN (Tcontrol_t ) ** in_UPDATE_ACK ; //[nb_inst_update] |
---|
128 | public : SC_OUT(Tcontext_t ) ** out_UPDATE_CONTEXT_ID ; //[nb_inst_update] |
---|
129 | public : SC_OUT(Tcontrol_t ) ** out_UPDATE_MISS_PREDICTION ; //[nb_inst_update] |
---|
130 | public : SC_OUT(Tcontrol_t ) ** out_UPDATE_DIRECTION_GOOD ; //[nb_inst_update] |
---|
131 | public : SC_OUT(Tcontrol_t ) ** out_UPDATE_BTB_VAL ; //[nb_inst_update] |
---|
132 | public : SC_OUT(Taddress_t ) ** out_UPDATE_BTB_ADDRESS_SRC ; //[nb_inst_update] |
---|
133 | public : SC_OUT(Taddress_t ) ** out_UPDATE_BTB_ADDRESS_DEST ; //[nb_inst_update] |
---|
134 | public : SC_OUT(Tbranch_condition_t) ** out_UPDATE_BTB_CONDITION ; //[nb_inst_update] |
---|
135 | public : SC_OUT(Tcontrol_t ) ** out_UPDATE_DIR_VAL ; //[nb_inst_update] |
---|
136 | public : SC_OUT(Thistory_t ) ** out_UPDATE_DIR_HISTORY ; //[nb_inst_update] |
---|
137 | public : SC_OUT(Tcontrol_t ) ** out_UPDATE_RAS_VAL ; //[nb_inst_update] |
---|
138 | public : SC_OUT(Tcontrol_t ) ** out_UPDATE_RAS_FLUSH ; //[nb_inst_update] |
---|
139 | public : SC_OUT(Tcontrol_t ) ** out_UPDATE_RAS_PUSH ; //[nb_inst_update] |
---|
140 | public : SC_OUT(Taddress_t ) ** out_UPDATE_RAS_ADDRESS ; //[nb_inst_update] |
---|
141 | public : SC_OUT(Tptr_t ) ** out_UPDATE_RAS_INDEX ; //[nb_inst_update] |
---|
142 | public : SC_OUT(Tcontrol_t ) ** out_UPDATE_RAS_PREDICTION_IFETCH ; //[nb_inst_update] |
---|
143 | |
---|
144 | // ~~~~~[ Interface : "event" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
145 | public : SC_IN (Tevent_state_t ) ** in_EVENT_STATE ; //[nb_context] |
---|
146 | public : SC_IN (Tevent_type_t ) ** in_EVENT_TYPE ; //[nb_context] |
---|
147 | public : SC_IN (Tdepth_t ) ** in_EVENT_DEPTH ; //[nb_context] |
---|
148 | |
---|
149 | // ~~~~~[ Interface : "depth" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
150 | public : SC_OUT(Tdepth_t ) ** out_DEPTH_CURRENT ; //[nb_context] |
---|
151 | public : SC_OUT(Tdepth_t ) ** out_DEPTH_MIN ; //[nb_context] |
---|
152 | public : SC_OUT(Tdepth_t ) ** out_DEPTH_MAX ; //[nb_context] |
---|
153 | // If DEPTH_CURRENT : |
---|
154 | // equal at DEPTH_MIN -> not speculative |
---|
155 | // not include ]DEPTH_MIN:DEPTH_MAX[ -> previous branch miss |
---|
156 | // include ]DEPTH_MIN:DEPTH_MAX[ -> speculative |
---|
157 | |
---|
158 | // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
159 | |
---|
160 | // ~~~~~[ Register ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
161 | private : uint32_t reg_UPDATE_PRIORITY ; |
---|
162 | |
---|
163 | private : ufpt_entry_t ** reg_UPDATE_FETCH_PREDICTION_TABLE ; //[nb_context][size_ufpt_queue] |
---|
164 | private : uint32_t * reg_UFPT_BOTTOM ; //[nb_context] |
---|
165 | private : uint32_t * reg_UFPT_TOP ; //[nb_context] |
---|
166 | private : uint32_t * reg_UFPT_UPDATE ; //[nb_context] |
---|
167 | private : uint32_t * reg_UFPT_NB_NEED_UPDATE ; //[nb_context] |
---|
168 | |
---|
169 | private : upt_entry_t ** reg_UPDATE_PREDICTION_TABLE ; //[nb_context][size_upt_queue] |
---|
170 | private : uint32_t * reg_UPT_BOTTOM ; //[nb_context] |
---|
171 | private : uint32_t * reg_UPT_TOP ; //[nb_context] |
---|
172 | private : uint32_t * reg_UPT_UPDATE ; //[nb_context] |
---|
173 | |
---|
174 | private : bool * reg_IS_ACCURATE ; //[nb_context] |
---|
175 | |
---|
176 | private : event_state_t * reg_EVENT_STATE ; //[nb_context] |
---|
177 | private : Taddress_t * reg_EVENT_ADDRESS_SRC ; //[nb_context] // Address branch |
---|
178 | private : Tcontrol_t * reg_EVENT_ADDRESS_DEST_VAL ; //[nb_context] // if miss ifetch, decod issue branch, dest must be reload |
---|
179 | private : Taddress_t * reg_EVENT_ADDRESS_DEST ; //[nb_context] // Address dest |
---|
180 | |
---|
181 | // ~~~~~[ Internal ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
182 | private : Tcontrol_t * internal_PREDICT_ACK ; //[nb_inst_predict] |
---|
183 | private : Tdepth_t * internal_PREDICT_UPDATE_PREDICTION_ID ; //[nb_inst_predict] |
---|
184 | private : Tcontrol_t * internal_DECOD_ACK ; //[nb_inst_decod] |
---|
185 | private : uint32_t * internal_DECOD_UPT_PTR_WRITE ; //[nb_inst_decod] |
---|
186 | private : Tcontrol_t * internal_BRANCH_COMPLETE_ACK ; //[nb_inst_branch_complete] |
---|
187 | private : Tcontrol_t * internal_BRANCH_COMPLETE_MISS_PREDICTION; //[nb_inst_branch_complete] |
---|
188 | private : Tcontrol_t * internal_BRANCH_COMPLETE_TAKE ; //[nb_inst_branch_complete] |
---|
189 | private : Taddress_t * internal_BRANCH_COMPLETE_ADDRESS_DEST ; //[nb_inst_branch_complete] |
---|
190 | private : Tcontrol_t * internal_BRANCH_EVENT_VAL ; //[nb_context] |
---|
191 | private : Tdepth_t * internal_BRANCH_EVENT_DEPTH ; //[nb_context] |
---|
192 | private : Tcontrol_t * internal_UPDATE_VAL ; //[nb_inst_update] |
---|
193 | private : Tcontrol_t * internal_UPDATE_VAL_WITHOUT_ACK ; //[nb_inst_update] |
---|
194 | private : Tcontext_t * internal_UPDATE_CONTEXT_ID ; //[nb_inst_update] |
---|
195 | private : bool * internal_UPDATE_FROM_UFPT ; //[nb_inst_update] |
---|
196 | private : Tdepth_t * internal_UPDATE_DEPTH ; //[nb_inst_update] |
---|
197 | private : bool * internal_UPDATE_RAS ; //[nb_inst_update] |
---|
198 | |
---|
199 | #endif |
---|
200 | |
---|
201 | // -----[ Methods ]--------------------------------------------------- |
---|
202 | |
---|
203 | #ifdef SYSTEMC |
---|
204 | SC_HAS_PROCESS (Update_Prediction_Table); |
---|
205 | #endif |
---|
206 | public : Update_Prediction_Table |
---|
207 | ( |
---|
208 | #ifdef SYSTEMC |
---|
209 | sc_module_name name, |
---|
210 | #else |
---|
211 | std::string name, |
---|
212 | #endif |
---|
213 | #ifdef STATISTICS |
---|
214 | morpheo::behavioural::Parameters_Statistics * param_statistics, |
---|
215 | #endif |
---|
216 | Parameters * param, |
---|
217 | morpheo::behavioural::Tusage_t usage |
---|
218 | ); |
---|
219 | public : ~Update_Prediction_Table (void); |
---|
220 | |
---|
221 | private : void allocation ( |
---|
222 | #ifdef STATISTICS |
---|
223 | morpheo::behavioural::Parameters_Statistics * param_statistics |
---|
224 | #else |
---|
225 | void |
---|
226 | #endif |
---|
227 | ); |
---|
228 | private : void deallocation (void); |
---|
229 | |
---|
230 | #ifdef SYSTEMC |
---|
231 | public : void transition (void); |
---|
232 | public : void genMoore (void); |
---|
233 | public : void genMealy_predict (void); |
---|
234 | public : void genMealy_decod (void); |
---|
235 | public : void genMealy_branch_complete (void); |
---|
236 | //public : void genMealy_update (void); |
---|
237 | #endif |
---|
238 | |
---|
239 | #if VHDL |
---|
240 | public : void vhdl (void); |
---|
241 | private : void vhdl_declaration (Vhdl * & vhdl); |
---|
242 | private : void vhdl_body (Vhdl * & vhdl); |
---|
243 | #endif |
---|
244 | |
---|
245 | #ifdef STATISTICS |
---|
246 | public : void statistics_allocation (morpheo::behavioural::Parameters_Statistics * param_statistics); |
---|
247 | public : void statistics_deallocation (void); |
---|
248 | #endif |
---|
249 | #if defined(STATISTICS) or defined(VHDL_TESTBENCH) |
---|
250 | private : void end_cycle (void); |
---|
251 | #endif |
---|
252 | }; |
---|
253 | |
---|
254 | }; // end namespace update_prediction_table |
---|
255 | }; // end namespace prediction_unit |
---|
256 | }; // end namespace front_end |
---|
257 | }; // end namespace multi_front_end |
---|
258 | }; // end namespace core |
---|
259 | |
---|
260 | }; // end namespace behavioural |
---|
261 | }; // end namespace morpheo |
---|
262 | |
---|
263 | #endif |
---|