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

Last change on this file since 15 was 15, checked in by rosiere, 17 years ago

Interface normalisé
Début du banc de registres multi niveaux

File size: 13.5 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     in_NRESET = new SC_IN (Tcontrol_t) ("in_NRESET");
26
27     in_PREDICT_VAL                 = new SC_IN (Tcontrol_t)     * [_param._nb_prediction     ];
28    out_PREDICT_ACK                 = new SC_OUT(Tcontrol_t)     * [_param._nb_prediction     ];
29     in_PREDICT_ADDRESS             = new SC_IN (Taddress_t)     * [_param._nb_prediction     ];
30    if (_param._have_bht)
31    out_PREDICT_BHT_HISTORY         = new SC_OUT(Tbht_history_t) * [_param._nb_prediction     ];
32    if (_param._have_pht)
33    out_PREDICT_PHT_HISTORY         = new SC_OUT(Tpht_history_t) * [_param._nb_prediction     ];
34    if (_param._have_bht)
35      {
36    signal_PREDICT_BHT_ACK          = new SC_SIGNAL(Tcontrol_t)     * [_param._nb_prediction];
37    signal_PREDICT_BHT_ADDRESS      = new SC_SIGNAL(Taddress_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
77        if (_param._have_pht)
78          {
79        rename = "signal_PREDICT_PHT_ACK_"    +toString(i);
80        signal_PREDICT_PHT_ACK          [i] = new SC_SIGNAL(Tcontrol_t)     (rename.c_str());
81
82        rename = "signal_PREDICT_PHT_ADDRESS_"+toString(i);
83        signal_PREDICT_PHT_ADDRESS      [i] = new SC_SIGNAL(Taddress_t)     (rename.c_str());
84          }
85      }
86
87     in_BRANCH_COMPLETE_VAL         = new SC_IN (Tcontrol_t)     * [_param._nb_branch_complete];
88    out_BRANCH_COMPLETE_ACK         = new SC_OUT(Tcontrol_t)     * [_param._nb_branch_complete];
89     in_BRANCH_COMPLETE_ADDRESS     = new SC_IN (Taddress_t)     * [_param._nb_branch_complete];
90    if (_param._have_bht)
91     in_BRANCH_COMPLETE_BHT_HISTORY = new SC_IN (Tbht_history_t) * [_param._nb_branch_complete];
92    if (_param._have_pht)
93     in_BRANCH_COMPLETE_PHT_HISTORY = new SC_IN (Tpht_history_t) * [_param._nb_branch_complete];
94     in_BRANCH_COMPLETE_DIRECTION   = new SC_IN (Tcontrol_t)     * [_param._nb_branch_complete];
95    if (_param._have_bht)
96      {
97    signal_BRANCH_COMPLETE_BHT_ACK     = new SC_SIGNAL(Tcontrol_t) * [_param._nb_branch_complete];
98    signal_BRANCH_COMPLETE_BHT_ADDRESS = new SC_SIGNAL(Taddress_t) * [_param._nb_branch_complete]; 
99      }
100    if (_param._have_pht)
101      {
102    signal_BRANCH_COMPLETE_PHT_ACK     = new SC_SIGNAL(Tcontrol_t) * [_param._nb_branch_complete];
103    signal_BRANCH_COMPLETE_PHT_ADDRESS = new SC_SIGNAL(Taddress_t) * [_param._nb_branch_complete]; 
104      }
105
106    for (uint32_t i=0; i<_param._nb_branch_complete; i++)
107      {
108        rename = "in_BRANCH_COMPLETE_VAL_"         +toString(i);
109         in_BRANCH_COMPLETE_VAL         [i] = new SC_IN (Tcontrol_t)     (rename.c_str());
110
111        rename = "out_BRANCH_COMPLETE_ACK_"        +toString(i);
112        out_BRANCH_COMPLETE_ACK         [i] = new SC_OUT(Tcontrol_t)     (rename.c_str());
113
114        rename = "in_BRANCH_COMPLETE_ADDRESS_"     +toString(i);
115         in_BRANCH_COMPLETE_ADDRESS     [i] = new SC_IN (Taddress_t)     (rename.c_str());
116
117        if (_param._have_bht)
118          {
119        rename = "in_BRANCH_COMPLETE_BHT_HISTORY_"+toString(i);
120         in_BRANCH_COMPLETE_BHT_HISTORY [i] = new SC_IN (Tbht_history_t) (rename.c_str());
121          }
122        if (_param._have_pht)
123          {
124        rename = "in_BRANCH_COMPLETE_PHT_HISTORY_"+toString(i);
125         in_BRANCH_COMPLETE_PHT_HISTORY [i] = new SC_IN (Tpht_history_t) (rename.c_str());
126          }
127        rename = "in_BRANCH_COMPLETE_DIRECTION_"  +toString(i);
128         in_BRANCH_COMPLETE_DIRECTION   [i] = new SC_IN (Tcontrol_t)     (rename.c_str());
129        if (_param._have_bht)
130          {
131        rename = "signal_BRANCH_COMPLETE_BHT_ACK_"    +toString(i);
132        signal_BRANCH_COMPLETE_BHT_ACK     [i] = new SC_SIGNAL(Tcontrol_t) (rename.c_str());
133
134        rename = "signal_BRANCH_COMPLETE_BHT_ADDRESS_"+toString(i); 
135        signal_BRANCH_COMPLETE_BHT_ADDRESS [i] = new SC_SIGNAL(Taddress_t) (rename.c_str()); 
136          }
137        if (_param._have_pht)
138          {
139        rename = "signal_BRANCH_COMPLETE_PHT_ACK_"    +toString(i);
140        signal_BRANCH_COMPLETE_PHT_ACK     [i] = new SC_SIGNAL(Tcontrol_t) (rename.c_str());
141
142        rename = "signal_BRANCH_COMPLETE_PHT_ADDRESS_"+toString(i); 
143        signal_BRANCH_COMPLETE_PHT_ADDRESS [i] = new SC_SIGNAL(Taddress_t) (rename.c_str()); 
144          }
145      }
146
147    // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
148    string name_component;
149
150    // =====[ component_Branch_History_Table ]============================   
151    if (_param._have_bht)
152      {
153        name_component = _name+"_Branch_History_Table";
154
155        log_printf(INFO,Two_Level_Branch_Predictor,"allocation","Allocation : %s",name_component.c_str());
156       
157        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()               ,
158#ifdef STATISTICS
159                                                                                                                                                                                       _param_statistics                    ,
160#endif
161                                                                                                                                                                                       *(_param._param_branch_history_table));
162       
163        // Instantiation
164        (*(component_Branch_History_Table->in_CLOCK ))        (*(in_CLOCK ));
165        (*(component_Branch_History_Table->in_NRESET))        (*(in_NRESET));
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]))    (*(   out_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_DIRECTION [i]))    (*(    in_BRANCH_COMPLETE_DIRECTION   [i]));
182          }
183      }
184
185    // =====[ component_Pattern_History_Table ]===========================   
186    if (_param._have_pht)
187      {
188        name_component = _name+"_Pattern_History_Table";
189       
190        log_printf(INFO,Two_Level_Branch_Predictor,"allocation","Allocation : %s",name_component.c_str());
191       
192        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()               ,
193#ifdef STATISTICS
194                                                                                                                                                                                         _param_statistics                    ,
195#endif
196                                                                                                                                                                                         *(_param._param_pattern_history_table));
197       
198        // Instantiation
199        (*(component_Pattern_History_Table->in_CLOCK))        (*(in_CLOCK));
200        (*(component_Pattern_History_Table->in_NRESET))       (*(in_NRESET));
201       
202        for (uint32_t i=0; i<_param._nb_prediction; i++)
203          {
204            (*(component_Pattern_History_Table-> in_PREDICT_VAL             [i]))    (*(    in_PREDICT_VAL          [i]));
205            (*(component_Pattern_History_Table->out_PREDICT_ACK             [i]))    (*(signal_PREDICT_PHT_ACK      [i]));
206            (*(component_Pattern_History_Table-> in_PREDICT_ADDRESS         [i]))    (*(signal_PREDICT_PHT_ADDRESS  [i]));
207            (*(component_Pattern_History_Table->out_PREDICT_HISTORY         [i]))    (*(   out_PREDICT_PHT_HISTORY  [i]));
208          }
209       
210        for (uint32_t i=0; i<_param._nb_branch_complete; i++)
211          {
212            (*(component_Pattern_History_Table-> in_BRANCH_COMPLETE_VAL       [i]))    (*(    in_BRANCH_COMPLETE_VAL         [i]));
213            (*(component_Pattern_History_Table->out_BRANCH_COMPLETE_ACK       [i]))    (*(signal_BRANCH_COMPLETE_PHT_ACK     [i]));
214            (*(component_Pattern_History_Table-> in_BRANCH_COMPLETE_ADDRESS   [i]))    (*(signal_BRANCH_COMPLETE_PHT_ADDRESS [i]));
215            (*(component_Pattern_History_Table-> in_BRANCH_COMPLETE_HISTORY   [i]))    (*(    in_BRANCH_COMPLETE_PHT_HISTORY [i]));
216            (*(component_Pattern_History_Table-> in_BRANCH_COMPLETE_DIRECTION [i]))    (*(    in_BRANCH_COMPLETE_DIRECTION   [i]));
217          }
218      }
219
220    // =====[ component_Two_Level_Branch_Predictor_Glue ]===========================   
221    name_component = _name+"_Two_Level_Branch_Predictor_Glue";
222   
223    log_printf(INFO,Two_Level_Branch_Predictor,"allocation","Allocation : %s",name_component.c_str());
224   
225    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()               ,
226#ifdef STATISTICS
227                                                                                                                                                                                                                   _param_statistics                    ,
228#endif
229                                                                                                                                                                                                                   *(_param._param_two_level_branch_predictor_glue));
230   
231    // Instantiation
232#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
233    (*(component_Two_Level_Branch_Predictor_Glue->in_CLOCK))        (*(in_CLOCK));
234#endif 
235    for (uint32_t i=0; i<_param._nb_prediction; i++)
236      {
237        if (_param._have_bht)
238          {
239            (*(component_Two_Level_Branch_Predictor_Glue-> in_PREDICT_BHT_ACK             [i])) (*(signal_PREDICT_BHT_ACK              [i]));
240            (*(component_Two_Level_Branch_Predictor_Glue->out_PREDICT_BHT_ADDRESS         [i])) (*(signal_PREDICT_BHT_ADDRESS          [i]));
241          }                                                                                                                                                                       
242        if (_param._have_pht)                                                                                                                     
243          {                                                                                                                                                                       
244            (*(component_Two_Level_Branch_Predictor_Glue-> in_PREDICT_PHT_ACK             [i])) (*(signal_PREDICT_PHT_ACK              [i]));
245            (*(component_Two_Level_Branch_Predictor_Glue->out_PREDICT_PHT_ADDRESS         [i])) (*(signal_PREDICT_PHT_ADDRESS          [i]));
246          }                                                                                                                                                                       
247        if (_param._have_bht and _param._have_pht)                                                                                       
248          {                                                                                                                                                                       
249            (*(component_Two_Level_Branch_Predictor_Glue-> in_PREDICT_BHT_HISTORY         [i])) (*(   out_PREDICT_BHT_HISTORY          [i]));
250          }                                                                                                                                                                       
251        (*(component_Two_Level_Branch_Predictor_Glue->out_PREDICT_ACK                 [i])) (*(   out_PREDICT_ACK                  [i]));
252        (*(component_Two_Level_Branch_Predictor_Glue-> in_PREDICT_ADDRESS             [i])) (*(    in_PREDICT_ADDRESS              [i]));
253      }
254   
255    for (uint32_t i=0; i<_param._nb_branch_complete; i++)
256      {
257        if (_param._have_bht)
258          {
259            (*(component_Two_Level_Branch_Predictor_Glue-> in_BRANCH_COMPLETE_BHT_ACK     [i])) (*(signal_BRANCH_COMPLETE_BHT_ACK      [i]));
260            (*(component_Two_Level_Branch_Predictor_Glue->out_BRANCH_COMPLETE_BHT_ADDRESS [i])) (*(signal_BRANCH_COMPLETE_BHT_ADDRESS  [i]));
261          }                                                                                                                                                       
262        if (_param._have_pht)                                                                                                     
263          {                                                                                                                                                       
264            (*(component_Two_Level_Branch_Predictor_Glue-> in_BRANCH_COMPLETE_PHT_ACK     [i])) (*(signal_BRANCH_COMPLETE_PHT_ACK      [i]));
265            (*(component_Two_Level_Branch_Predictor_Glue->out_BRANCH_COMPLETE_PHT_ADDRESS [i])) (*(signal_BRANCH_COMPLETE_PHT_ADDRESS  [i]));
266          }                                                                                                                                                       
267        if (_param._have_bht and _param._have_pht)                                                                               
268          {                                                                                                                                                       
269            (*(component_Two_Level_Branch_Predictor_Glue-> in_BRANCH_COMPLETE_BHT_HISTORY [i])) (*(    in_BRANCH_COMPLETE_BHT_HISTORY  [i]));
270          }                                                                                                                                                       
271        (*(component_Two_Level_Branch_Predictor_Glue->out_BRANCH_COMPLETE_ACK         [i])) (*(   out_BRANCH_COMPLETE_ACK          [i]));
272        (*(component_Two_Level_Branch_Predictor_Glue-> in_BRANCH_COMPLETE_ADDRESS     [i])) (*(    in_BRANCH_COMPLETE_ADDRESS      [i]));
273      }
274 
275    log_printf(FUNC,Two_Level_Branch_Predictor,"allocation","End");
276  };
277 
278}; // end namespace two_level_branch_predictor
279}; // end namespace meta_predictor
280}; // end namespace predictor
281}; // end namespace stage_1_ifetch
282}; // end namespace behavioural
283}; // end namespace morpheo             
284#endif
Note: See TracBrowser for help on using the repository browser.