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

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

1) Ajout d'un "printer" XML pour la configuration de paramètres

2) Fin du composant "Two_Level_Branch_Predictor"

validation * systemc

  • vhdl
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      }
38    if (_param._have_pht)
39      {
40    signal_PREDICT_PHT_ACK          = new SC_SIGNAL(Tcontrol_t)     * [_param._nb_prediction];
41    signal_PREDICT_PHT_ADDRESS      = new SC_SIGNAL(Taddress_t)     * [_param._nb_prediction];
42      }
43
44    for (uint32_t i=0; i<_param._nb_prediction; i++)
45      {
46        rename = "in_PREDICT_VAL_"         +toString(i);
47         in_PREDICT_VAL                 [i] = new SC_IN (Tcontrol_t)     (rename.c_str());
48
49        rename = "out_PREDICT_ACK_"        +toString(i);
50        out_PREDICT_ACK                 [i] = new SC_OUT(Tcontrol_t)     (rename.c_str());
51
52        rename = "in_PREDICT_ADDRESS_"     +toString(i);
53         in_PREDICT_ADDRESS             [i] = new SC_IN (Taddress_t)     (rename.c_str());
54
55        if (_param._have_bht)
56          {
57        rename = "out_PREDICT_BHT_HISTORY_"+toString(i);
58        out_PREDICT_BHT_HISTORY         [i] = new SC_OUT(Tbht_history_t) (rename.c_str());
59          }
60
61        if (_param._have_pht)
62          {
63        rename = "out_PREDICT_PHT_HISTORY_"+toString(i);
64        out_PREDICT_PHT_HISTORY         [i] = new SC_OUT(Tpht_history_t) (rename.c_str());
65          }
66
67        if (_param._have_bht)
68          {
69        rename = "signal_PREDICT_BHT_ACK_"    +toString(i);
70        signal_PREDICT_BHT_ACK          [i] = new SC_SIGNAL(Tcontrol_t)     (rename.c_str());
71
72        rename = "signal_PREDICT_BHT_ADDRESS_"+toString(i);
73        signal_PREDICT_BHT_ADDRESS      [i] = new SC_SIGNAL(Taddress_t)     (rename.c_str());
74          }
75
76        if (_param._have_pht)
77          {
78        rename = "signal_PREDICT_PHT_ACK_"    +toString(i);
79        signal_PREDICT_PHT_ACK          [i] = new SC_SIGNAL(Tcontrol_t)     (rename.c_str());
80
81        rename = "signal_PREDICT_PHT_ADDRESS_"+toString(i);
82        signal_PREDICT_PHT_ADDRESS      [i] = new SC_SIGNAL(Taddress_t)     (rename.c_str());
83          }
84      }
85
86     in_BRANCH_COMPLETE_VAL         = new SC_IN (Tcontrol_t)     * [_param._nb_branch_complete];
87    out_BRANCH_COMPLETE_ACK         = new SC_OUT(Tcontrol_t)     * [_param._nb_branch_complete];
88     in_BRANCH_COMPLETE_ADDRESS     = new SC_IN (Taddress_t)     * [_param._nb_branch_complete];
89    if (_param._have_bht)
90     in_BRANCH_COMPLETE_BHT_HISTORY = new SC_IN (Tbht_history_t) * [_param._nb_branch_complete];
91    if (_param._have_pht)
92     in_BRANCH_COMPLETE_PHT_HISTORY = new SC_IN (Tpht_history_t) * [_param._nb_branch_complete];
93     in_BRANCH_COMPLETE_DIRECTION   = new SC_IN (Tcontrol_t)     * [_param._nb_branch_complete];
94    if (_param._have_bht)
95      {
96    signal_BRANCH_COMPLETE_BHT_ACK     = new SC_SIGNAL(Tcontrol_t) * [_param._nb_branch_complete];
97    signal_BRANCH_COMPLETE_BHT_ADDRESS = new SC_SIGNAL(Taddress_t) * [_param._nb_branch_complete]; 
98      }
99    if (_param._have_pht)
100      {
101    signal_BRANCH_COMPLETE_PHT_ACK     = new SC_SIGNAL(Tcontrol_t) * [_param._nb_branch_complete];
102    signal_BRANCH_COMPLETE_PHT_ADDRESS = new SC_SIGNAL(Taddress_t) * [_param._nb_branch_complete]; 
103      }
104
105    for (uint32_t i=0; i<_param._nb_branch_complete; i++)
106      {
107        rename = "in_BRANCH_COMPLETE_VAL_"         +toString(i);
108         in_BRANCH_COMPLETE_VAL         [i] = new SC_IN (Tcontrol_t)     (rename.c_str());
109
110        rename = "out_BRANCH_COMPLETE_ACK_"        +toString(i);
111        out_BRANCH_COMPLETE_ACK         [i] = new SC_OUT(Tcontrol_t)     (rename.c_str());
112
113        rename = "in_BRANCH_COMPLETE_ADDRESS_"     +toString(i);
114         in_BRANCH_COMPLETE_ADDRESS     [i] = new SC_IN (Taddress_t)     (rename.c_str());
115
116        if (_param._have_bht)
117          {
118        rename = "in_BRANCH_COMPLETE_BHT_HISTORY_"+toString(i);
119         in_BRANCH_COMPLETE_BHT_HISTORY [i] = new SC_IN (Tbht_history_t) (rename.c_str());
120          }
121        if (_param._have_pht)
122          {
123        rename = "in_BRANCH_COMPLETE_PHT_HISTORY_"+toString(i);
124         in_BRANCH_COMPLETE_PHT_HISTORY [i] = new SC_IN (Tpht_history_t) (rename.c_str());
125          }
126        rename = "in_BRANCH_COMPLETE_DIRECTION_"  +toString(i);
127         in_BRANCH_COMPLETE_DIRECTION   [i] = new SC_IN (Tcontrol_t)     (rename.c_str());
128        if (_param._have_bht)
129          {
130        rename = "signal_BRANCH_COMPLETE_BHT_ACK_"    +toString(i);
131        signal_BRANCH_COMPLETE_BHT_ACK     [i] = new SC_SIGNAL(Tcontrol_t) (rename.c_str());
132
133        rename = "signal_BRANCH_COMPLETE_BHT_ADDRESS_"+toString(i); 
134        signal_BRANCH_COMPLETE_BHT_ADDRESS [i] = new SC_SIGNAL(Taddress_t) (rename.c_str()); 
135          }
136        if (_param._have_pht)
137          {
138        rename = "signal_BRANCH_COMPLETE_PHT_ACK_"    +toString(i);
139        signal_BRANCH_COMPLETE_PHT_ACK     [i] = new SC_SIGNAL(Tcontrol_t) (rename.c_str());
140
141        rename = "signal_BRANCH_COMPLETE_PHT_ADDRESS_"+toString(i); 
142        signal_BRANCH_COMPLETE_PHT_ADDRESS [i] = new SC_SIGNAL(Taddress_t) (rename.c_str()); 
143          }
144      }
145
146    // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
147    string name_component;
148
149    // =====[ component_Branch_History_Table ]============================   
150    if (_param._have_bht)
151      {
152        name_component = _name+"_Branch_History_Table";
153
154        log_printf(INFO,Two_Level_Branch_Predictor,"allocation","Allocation : %s",name_component.c_str());
155       
156        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()               ,
157#ifdef STATISTICS
158                                                                                                                                                                                       _param_statistics                    ,
159#endif
160                                                                                                                                                                                       *(_param._param_branch_history_table));
161       
162        // Instantiation
163        (*(component_Branch_History_Table->in_CLOCK))        (*(in_CLOCK));
164
165        for (uint32_t i=0; i<_param._nb_prediction; i++)
166          {
167            (*(component_Branch_History_Table-> in_PREDICT_VAL             [i]))    (*(    in_PREDICT_VAL          [i]));
168            (*(component_Branch_History_Table->out_PREDICT_ACK             [i]))    (*(signal_PREDICT_BHT_ACK      [i]));
169            (*(component_Branch_History_Table-> in_PREDICT_ADDRESS         [i]))    (*(signal_PREDICT_BHT_ADDRESS  [i]));
170            (*(component_Branch_History_Table->out_PREDICT_HISTORY         [i]))    (*(   out_PREDICT_BHT_HISTORY  [i]));
171          }
172       
173        for (uint32_t i=0; i<_param._nb_branch_complete; i++)
174          {
175            (*(component_Branch_History_Table-> in_BRANCH_COMPLETE_VAL       [i]))    (*(    in_BRANCH_COMPLETE_VAL         [i]));
176            (*(component_Branch_History_Table->out_BRANCH_COMPLETE_ACK       [i]))    (*(signal_BRANCH_COMPLETE_BHT_ACK     [i]));
177            (*(component_Branch_History_Table-> in_BRANCH_COMPLETE_ADDRESS   [i]))    (*(signal_BRANCH_COMPLETE_BHT_ADDRESS [i]));
178            (*(component_Branch_History_Table-> in_BRANCH_COMPLETE_HISTORY   [i]))    (*(    in_BRANCH_COMPLETE_BHT_HISTORY [i]));
179            (*(component_Branch_History_Table-> in_BRANCH_COMPLETE_DIRECTION [i]))    (*(    in_BRANCH_COMPLETE_DIRECTION   [i]));
180          }
181      }
182
183    // =====[ component_Pattern_History_Table ]===========================   
184    if (_param._have_pht)
185      {
186        name_component = _name+"_Pattern_History_Table";
187       
188        log_printf(INFO,Two_Level_Branch_Predictor,"allocation","Allocation : %s",name_component.c_str());
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_DIRECTION [i]))    (*(    in_BRANCH_COMPLETE_DIRECTION   [i]));
214          }
215      }
216
217    // =====[ component_Two_Level_Branch_Predictor_Glue ]===========================   
218    name_component = _name+"_Two_Level_Branch_Predictor_Glue";
219   
220    log_printf(INFO,Two_Level_Branch_Predictor,"allocation","Allocation : %s",name_component.c_str());
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])) (*(   out_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    log_printf(FUNC,Two_Level_Branch_Predictor,"allocation","End");
273  };
274 
275}; // end namespace two_level_branch_predictor
276}; // end namespace meta_predictor
277}; // end namespace predictor
278}; // end namespace stage_1_ifetch
279}; // end namespace behavioural
280}; // end namespace morpheo             
281#endif
Note: See TracBrowser for help on using the repository browser.