source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Stage_1_Ifetch/Predictor/Meta_Predictor/Two_Level_Branch_Predictor/src/Two_Level_Branch_Predictor_allocation.cpp @ 2

Last change on this file since 2 was 2, checked in by kane, 17 years ago

Import Morpheo

File size: 13.3 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id$
4 *
5 * [ Description ]
6 *
7 */
8
9#include "Behavioural/Stage_1_Ifetch/Predictor/Meta_Predictor/Two_Level_Branch_Predictor/include/Two_Level_Branch_Predictor.h"
10
11namespace morpheo                    {
12namespace behavioural {
13namespace stage_1_ifetch {
14namespace predictor {
15namespace meta_predictor {
16namespace two_level_branch_predictor {
17
18  void Two_Level_Branch_Predictor::allocation (void)
19  {
20    string rename;
21
22    log_printf(FUNC,Two_Level_Branch_Predictor,"allocation","Begin");
23
24     in_CLOCK  = new SC_CLOCK           ("in_CLOCK");
25
26     in_PREDICT_VAL                 = new SC_IN (Tcontrol_t)     * [_param._nb_prediction     ];
27    out_PREDICT_ACK                 = new SC_OUT(Tcontrol_t)     * [_param._nb_prediction     ];
28     in_PREDICT_ADDRESS             = new SC_IN (Taddress_t)     * [_param._nb_prediction     ];
29    if (_param._have_bht)
30    out_PREDICT_BHT_HISTORY         = new SC_OUT(Tbht_history_t) * [_param._nb_prediction     ];
31    if (_param._have_pht)
32    out_PREDICT_PHT_HISTORY         = new SC_OUT(Tpht_history_t) * [_param._nb_prediction     ];
33    if (_param._have_bht)
34      {
35    signal_PREDICT_BHT_ACK          = new SC_SIGNAL(Tcontrol_t)     * [_param._nb_prediction];
36    signal_PREDICT_BHT_ADDRESS      = new SC_SIGNAL(Taddress_t)     * [_param._nb_prediction];
37    signal_PREDICT_BHT_HISTORY      = new SC_SIGNAL(Tbht_history_t) * [_param._nb_prediction];
38      }
39    if (_param._have_pht)
40      {
41    signal_PREDICT_PHT_ACK          = new SC_SIGNAL(Tcontrol_t)     * [_param._nb_prediction];
42    signal_PREDICT_PHT_ADDRESS      = new SC_SIGNAL(Taddress_t)     * [_param._nb_prediction];
43      }
44
45    for (uint32_t i=0; i<_param._nb_prediction; i++)
46      {
47        rename = " in_PREDICT_VAL_"        +toString(i);
48         in_PREDICT_VAL                 [i] = new SC_IN (Tcontrol_t)     (rename.c_str());
49
50        rename = "out_PREDICT_ACK_"        +toString(i);
51        out_PREDICT_ACK                 [i] = new SC_OUT(Tcontrol_t)     (rename.c_str());
52
53        rename = " in_PREDICT_ADDRESS_"    +toString(i);
54         in_PREDICT_ADDRESS             [i] = new SC_IN (Taddress_t)     (rename.c_str());
55
56        if (_param._have_bht)
57          {
58        rename = "out_PREDICT_BHT_HISTORY_"+toString(i);
59        out_PREDICT_BHT_HISTORY         [i] = new SC_OUT(Tbht_history_t) (rename.c_str());
60          }
61
62        if (_param._have_pht)
63          {
64        rename = "out_PREDICT_PHT_HISTORY_"+toString(i);
65        out_PREDICT_PHT_HISTORY         [i] = new SC_OUT(Tpht_history_t) (rename.c_str());
66          }
67
68        if (_param._have_bht)
69          {
70        rename = "signal_PREDICT_BHT_ACK_"    +toString(i);
71        signal_PREDICT_BHT_ACK          [i] = new SC_SIGNAL(Tcontrol_t)     (rename.c_str());
72
73        rename = "signal_PREDICT_BHT_ADDRESS_"+toString(i);
74        signal_PREDICT_BHT_ADDRESS      [i] = new SC_SIGNAL(Taddress_t)     (rename.c_str());
75
76        rename = "signal_PREDICT_BHT_HISTORY_"+toString(i);
77        signal_PREDICT_BHT_HISTORY      [i] = new SC_SIGNAL(Tbht_history_t) (rename.c_str());
78          }
79
80        if (_param._have_pht)
81          {
82        rename = "signal_PREDICT_PHT_ACK_"    +toString(i);
83        signal_PREDICT_PHT_ACK          [i] = new SC_SIGNAL(Tcontrol_t)     (rename.c_str());
84
85        rename = "signal_PREDICT_PHT_ADDRESS_"+toString(i);
86        signal_PREDICT_PHT_ADDRESS      [i] = new SC_SIGNAL(Taddress_t)     (rename.c_str());
87          }
88      }
89
90     in_BRANCH_COMPLETE_VAL         = new SC_IN (Tcontrol_t)     * [_param._nb_branch_complete];
91    out_BRANCH_COMPLETE_ACK         = new SC_OUT(Tcontrol_t)     * [_param._nb_branch_complete];
92     in_BRANCH_COMPLETE_ADDRESS     = new SC_IN (Taddress_t)     * [_param._nb_branch_complete];
93    if (_param._have_bht)
94     in_BRANCH_COMPLETE_BHT_HISTORY = new SC_IN (Tbht_history_t) * [_param._nb_branch_complete];
95    if (_param._have_pht)
96     in_BRANCH_COMPLETE_PHT_HISTORY = new SC_IN (Tpht_history_t) * [_param._nb_branch_complete];
97     in_BRANCH_COMPLETE_HIT         = new SC_IN (Tcontrol_t)     * [_param._nb_branch_complete];
98    if (_param._have_bht)
99      {
100    signal_BRANCH_COMPLETE_BHT_ACK     = new SC_SIGNAL(Tcontrol_t) * [_param._nb_branch_complete];
101    signal_BRANCH_COMPLETE_BHT_ADDRESS = new SC_SIGNAL(Taddress_t) * [_param._nb_branch_complete]; 
102      }
103    if (_param._have_pht)
104      {
105    signal_BRANCH_COMPLETE_PHT_ACK     = new SC_SIGNAL(Tcontrol_t) * [_param._nb_branch_complete];
106    signal_BRANCH_COMPLETE_PHT_ADDRESS = new SC_SIGNAL(Taddress_t) * [_param._nb_branch_complete]; 
107      }
108
109    for (uint32_t i=0; i<_param._nb_branch_complete; i++)
110      {
111        rename = " in_BRANCH_COMPLETE_VAL_"        +toString(i);
112         in_BRANCH_COMPLETE_VAL         [i] = new SC_IN (Tcontrol_t)     (rename.c_str());
113
114        rename = "out_BRANCH_COMPLETE_ACK_"        +toString(i);
115        out_BRANCH_COMPLETE_ACK         [i] = new SC_OUT(Tcontrol_t)     (rename.c_str());
116
117        rename = " in_BRANCH_COMPLETE_ADDRESS_"    +toString(i);
118         in_BRANCH_COMPLETE_ADDRESS     [i] = new SC_IN (Taddress_t)     (rename.c_str());
119
120        if (_param._have_bht)
121          {
122        rename = " in_BRANCH_COMPLETE_BHT_HISTORY_"+toString(i);
123         in_BRANCH_COMPLETE_BHT_HISTORY [i] = new SC_IN (Tbht_history_t) (rename.c_str());
124          }
125        if (_param._have_bht)
126          {
127        rename = " in_BRANCH_COMPLETE_PHT_HISTORY_"+toString(i);
128         in_BRANCH_COMPLETE_PHT_HISTORY [i] = new SC_IN (Tpht_history_t) (rename.c_str());
129          }
130        rename = " in_BRANCH_COMPLETE_HIT_"        +toString(i);
131         in_BRANCH_COMPLETE_HIT         [i] = new SC_IN (Tcontrol_t)     (rename.c_str());
132        if (_param._have_bht)
133          {
134        rename = "signal_BRANCH_COMPLETE_BHT_ACK_"    +toString(i);
135        signal_BRANCH_COMPLETE_BHT_ACK     [i] = new SC_SIGNAL(Tcontrol_t) (rename.c_str());
136
137        rename = "signal_BRANCH_COMPLETE_BHT_ADDRESS_"+toString(i); 
138        signal_BRANCH_COMPLETE_BHT_ADDRESS [i] = new SC_SIGNAL(Taddress_t) (rename.c_str()); 
139          }
140        if (_param._have_pht)
141          {
142        rename = "signal_BRANCH_COMPLETE_PHT_ACK_"    +toString(i);
143        signal_BRANCH_COMPLETE_PHT_ACK     [i] = new SC_SIGNAL(Tcontrol_t) (rename.c_str());
144
145        rename = "signal_BRANCH_COMPLETE_PHT_ADDRESS_"+toString(i); 
146        signal_BRANCH_COMPLETE_PHT_ADDRESS [i] = new SC_SIGNAL(Taddress_t) (rename.c_str()); 
147          }
148      }
149
150    // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
151    string name_component;
152
153    // =====[ component_Branch_History_Table ]============================   
154    if (_param._have_bht)
155      {
156        name_component = _name+"_Branch_History_Table";
157       
158        component_Branch_History_Table = new morpheo::behavioural::stage_1_ifetch::predictor::meta_predictor::two_level_branch_predictor::branch_history_table ::Branch_History_Table (name_component.c_str()               ,
159#ifdef STATISTICS
160                                                                                                                                                                                       _param_statistics                    ,
161#endif
162                                                                                                                                                                                       *(_param._param_branch_history_table));
163       
164        // Instantiation
165        (*(component_Branch_History_Table->in_CLOCK))        (*(in_CLOCK));
166
167        for (uint32_t i=0; i<_param._nb_prediction; i++)
168          {
169            (*(component_Branch_History_Table-> in_PREDICT_VAL             [i]))    (*(    in_PREDICT_VAL          [i]));
170            (*(component_Branch_History_Table->out_PREDICT_ACK             [i]))    (*(signal_PREDICT_BHT_ACK      [i]));
171            (*(component_Branch_History_Table-> in_PREDICT_ADDRESS         [i]))    (*(signal_PREDICT_BHT_ADDRESS  [i]));
172            (*(component_Branch_History_Table->out_PREDICT_HISTORY         [i]))    (*(signal_PREDICT_BHT_HISTORY  [i]));
173          }
174       
175        for (uint32_t i=0; i<_param._nb_branch_complete; i++)
176          {
177            (*(component_Branch_History_Table-> in_BRANCH_COMPLETE_VAL     [i]))    (*(    in_BRANCH_COMPLETE_VAL         [i]));
178            (*(component_Branch_History_Table->out_BRANCH_COMPLETE_ACK     [i]))    (*(signal_BRANCH_COMPLETE_BHT_ACK     [i]));
179            (*(component_Branch_History_Table-> in_BRANCH_COMPLETE_ADDRESS [i]))    (*(signal_BRANCH_COMPLETE_BHT_ADDRESS [i]));
180            (*(component_Branch_History_Table-> in_BRANCH_COMPLETE_HISTORY [i]))    (*(    in_BRANCH_COMPLETE_BHT_HISTORY [i]));
181            (*(component_Branch_History_Table-> in_BRANCH_COMPLETE_HIT     [i]))    (*(    in_BRANCH_COMPLETE_HIT         [i]));
182          }
183      }
184
185    // =====[ component_Pattern_History_Table ]===========================   
186    if (_param._have_pht)
187      {
188        name_component = _name+"_Pattern_History_Table";
189       
190        component_Pattern_History_Table = new morpheo::behavioural::stage_1_ifetch::predictor::meta_predictor::two_level_branch_predictor::pattern_history_table::Pattern_History_Table (name_component.c_str()               ,
191#ifdef STATISTICS
192                                                                                                                                                                                         _param_statistics                    ,
193#endif
194                                                                                                                                                                                         *(_param._param_pattern_history_table));
195       
196        // Instantiation
197        (*(component_Pattern_History_Table->in_CLOCK))        (*(in_CLOCK));
198       
199        for (uint32_t i=0; i<_param._nb_prediction; i++)
200          {
201            (*(component_Pattern_History_Table-> in_PREDICT_VAL             [i]))    (*(    in_PREDICT_VAL          [i]));
202            (*(component_Pattern_History_Table->out_PREDICT_ACK             [i]))    (*(signal_PREDICT_PHT_ACK      [i]));
203            (*(component_Pattern_History_Table-> in_PREDICT_ADDRESS         [i]))    (*(signal_PREDICT_PHT_ADDRESS  [i]));
204            (*(component_Pattern_History_Table->out_PREDICT_HISTORY         [i]))    (*(   out_PREDICT_PHT_HISTORY  [i]));
205          }
206       
207        for (uint32_t i=0; i<_param._nb_branch_complete; i++)
208          {
209            (*(component_Pattern_History_Table-> in_BRANCH_COMPLETE_VAL     [i]))    (*(    in_BRANCH_COMPLETE_VAL         [i]));
210            (*(component_Pattern_History_Table->out_BRANCH_COMPLETE_ACK     [i]))    (*(signal_BRANCH_COMPLETE_PHT_ACK     [i]));
211            (*(component_Pattern_History_Table-> in_BRANCH_COMPLETE_ADDRESS [i]))    (*(signal_BRANCH_COMPLETE_PHT_ADDRESS [i]));
212            (*(component_Pattern_History_Table-> in_BRANCH_COMPLETE_HISTORY [i]))    (*(    in_BRANCH_COMPLETE_PHT_HISTORY [i]));
213            (*(component_Pattern_History_Table-> in_BRANCH_COMPLETE_HIT     [i]))    (*(    in_BRANCH_COMPLETE_HIT         [i]));
214          }
215      }
216
217    // =====[ component_Two_Level_Branch_Predictor_Glue ]===========================   
218    if (_param._have_pht)
219      {
220        name_component = _name+"_Two_Level_Branch_Predictor_Glue";
221       
222        component_Two_Level_Branch_Predictor_Glue = new morpheo::behavioural::stage_1_ifetch::predictor::meta_predictor::two_level_branch_predictor::two_level_branch_predictor_glue::Two_Level_Branch_Predictor_Glue (name_component.c_str()               ,
223#ifdef STATISTICS
224                                                                                                                                                                                                                       _param_statistics                    ,
225#endif
226                                                                                                                                                                                                                       *(_param._param_two_level_branch_predictor_glue));
227       
228        // Instantiation
229#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
230        (*(component_Two_Level_Branch_Predictor_Glue->in_CLOCK))        (*(in_CLOCK));
231#endif 
232        for (uint32_t i=0; i<_param._nb_prediction; i++)
233          {
234            if (_param._have_bht)
235              {
236            (*(component_Two_Level_Branch_Predictor_Glue-> in_PREDICT_BHT_ACK             [i])) (*(signal_PREDICT_BHT_ACK              [i]));
237            (*(component_Two_Level_Branch_Predictor_Glue->out_PREDICT_BHT_ADDRESS         [i])) (*(signal_PREDICT_BHT_ADDRESS          [i]));
238              }                                                                                                                                                                   
239            if (_param._have_pht)                                                                                                                         
240              {                                                                                                                                                                   
241            (*(component_Two_Level_Branch_Predictor_Glue-> in_PREDICT_PHT_ACK             [i])) (*(signal_PREDICT_PHT_ACK              [i]));
242            (*(component_Two_Level_Branch_Predictor_Glue->out_PREDICT_PHT_ADDRESS         [i])) (*(signal_PREDICT_PHT_ADDRESS          [i]));
243              }                                                                                                                                                                   
244            if (_param._have_bht and _param._have_pht)                                                                                   
245              {                                                                                                                                                                   
246            (*(component_Two_Level_Branch_Predictor_Glue-> in_PREDICT_BHT_HISTORY         [i])) (*(signal_PREDICT_BHT_HISTORY          [i]));
247              }                                                                                                                                                                   
248            (*(component_Two_Level_Branch_Predictor_Glue->out_PREDICT_ACK                 [i])) (*(   out_PREDICT_ACK                  [i]));
249            (*(component_Two_Level_Branch_Predictor_Glue-> in_PREDICT_ADDRESS             [i])) (*(    in_PREDICT_ADDRESS              [i]));
250          }
251       
252        for (uint32_t i=0; i<_param._nb_branch_complete; i++)
253          {
254            if (_param._have_bht)
255              {
256            (*(component_Two_Level_Branch_Predictor_Glue-> in_BRANCH_COMPLETE_BHT_ACK     [i])) (*(signal_BRANCH_COMPLETE_BHT_ACK      [i]));
257            (*(component_Two_Level_Branch_Predictor_Glue->out_BRANCH_COMPLETE_BHT_ADDRESS [i])) (*(signal_BRANCH_COMPLETE_BHT_ADDRESS  [i]));
258              }                                                                                                                                                   
259            if (_param._have_pht)                                                                                                         
260              {                                                                                                                                                   
261            (*(component_Two_Level_Branch_Predictor_Glue-> in_BRANCH_COMPLETE_PHT_ACK     [i])) (*(signal_BRANCH_COMPLETE_PHT_ACK      [i]));
262            (*(component_Two_Level_Branch_Predictor_Glue->out_BRANCH_COMPLETE_PHT_ADDRESS [i])) (*(signal_BRANCH_COMPLETE_PHT_ADDRESS  [i]));
263              }                                                                                                                                                   
264            if (_param._have_bht and _param._have_pht)                                                                           
265              {                                                                                                                                                   
266            (*(component_Two_Level_Branch_Predictor_Glue-> in_BRANCH_COMPLETE_BHT_HISTORY [i])) (*(    in_BRANCH_COMPLETE_BHT_HISTORY  [i]));
267              }                                                                                                                                                   
268            (*(component_Two_Level_Branch_Predictor_Glue->out_BRANCH_COMPLETE_ACK         [i])) (*(   out_BRANCH_COMPLETE_ACK          [i]));
269            (*(component_Two_Level_Branch_Predictor_Glue-> in_BRANCH_COMPLETE_ADDRESS     [i])) (*(    in_BRANCH_COMPLETE_ADDRESS      [i]));
270          }
271      }
272
273    log_printf(FUNC,Two_Level_Branch_Predictor,"allocation","End");
274  };
275
276}; // end namespace two_level_branch_predictor
277}; // end namespace meta_predictor
278}; // end namespace predictor
279}; // end namespace stage_1_ifetch
280}; // end namespace behavioural
281}; // end namespace morpheo             
282#endif
Note: See TracBrowser for help on using the repository browser.