source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Two_Level_Branch_Predictor/src/Two_Level_Branch_Predictor_allocation.cpp @ 45

Last change on this file since 45 was 45, checked in by rosiere, 17 years ago
  • Documentation : specification d'un cache de donnée non bloquant
  • Modification de l'aborescence
File size: 15.3 KB
RevLine 
[2]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    log_printf(FUNC,Two_Level_Branch_Predictor,"allocation","Begin");
21
[42]22    _component   = new Component ();
[2]23
[42]24    Entity * entity = _component->set_entity (_name                 
25                                             ,"Two_Level_Branch_Predictor"
26#ifdef POSITION
27                                             ,MIXTE
28#endif
29                                              );
30   
31    _interfaces = entity->set_interfaces();
32
33    // ~~~~~[ Interface : "" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
34    {
35      Interface * interface = _interfaces->set_interface(""
36#ifdef POSITION
37                                                         , IN 
38                                                         , SOUTH
39                                                         , "Generalist interface"
40#endif
41                                                         );
42     
43      in_CLOCK              = interface->set_signal_clk              ("clock" ,1);
44      in_NRESET             = interface->set_signal_in  <Tcontrol_t> ("nreset",1,RESET_VHDL_YES);
45    }
46   
47    // ~~~~~[ Interface : "predict" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
48
[2]49     in_PREDICT_VAL                 = new SC_IN (Tcontrol_t)     * [_param._nb_prediction     ];
50    out_PREDICT_ACK                 = new SC_OUT(Tcontrol_t)     * [_param._nb_prediction     ];
51     in_PREDICT_ADDRESS             = new SC_IN (Taddress_t)     * [_param._nb_prediction     ];
52    if (_param._have_bht)
53    out_PREDICT_BHT_HISTORY         = new SC_OUT(Tbht_history_t) * [_param._nb_prediction     ];
54    if (_param._have_pht)
55    out_PREDICT_PHT_HISTORY         = new SC_OUT(Tpht_history_t) * [_param._nb_prediction     ];
56
57    for (uint32_t i=0; i<_param._nb_prediction; i++)
58      {
[42]59        Interface_fifo * interface = _interfaces->set_interface("predict_"+toString(i)
60#ifdef POSITION
61                                                                , IN 
62                                                                , WEST
63                                                                , "Interface Predict"
64#endif
65                                                                );
[2]66
[42]67         in_PREDICT_VAL                 [i] = interface->set_signal_valack_in            ("val"    , VAL);
68        out_PREDICT_ACK                 [i] = interface->set_signal_valack_out           ("ack"    , ACK);
69         in_PREDICT_ADDRESS             [i] = interface->set_signal_in  <Taddress_t>     ("address", _param._size_address);
[2]70        if (_param._have_bht)
[42]71        out_PREDICT_BHT_HISTORY         [i] = interface->set_signal_out <Tbht_history_t> ("bht_history", _param._bht_size_shifter);
[2]72        if (_param._have_pht)
[42]73        out_PREDICT_PHT_HISTORY         [i] = interface->set_signal_out <Tpht_history_t> ("pht_history", _param._pht_size_counter);
74      }
[2]75
[42]76    // ~~~~~[ Interface : "branch_complete" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[2]77
78     in_BRANCH_COMPLETE_VAL         = new SC_IN (Tcontrol_t)     * [_param._nb_branch_complete];
79    out_BRANCH_COMPLETE_ACK         = new SC_OUT(Tcontrol_t)     * [_param._nb_branch_complete];
80     in_BRANCH_COMPLETE_ADDRESS     = new SC_IN (Taddress_t)     * [_param._nb_branch_complete];
81    if (_param._have_bht)
82     in_BRANCH_COMPLETE_BHT_HISTORY = new SC_IN (Tbht_history_t) * [_param._nb_branch_complete];
83    if (_param._have_pht)
84     in_BRANCH_COMPLETE_PHT_HISTORY = new SC_IN (Tpht_history_t) * [_param._nb_branch_complete];
[3]85     in_BRANCH_COMPLETE_DIRECTION   = new SC_IN (Tcontrol_t)     * [_param._nb_branch_complete];
[2]86
87    for (uint32_t i=0; i<_param._nb_branch_complete; i++)
88      {
[43]89        Interface_fifo * interface = _interfaces->set_interface("branch_complete_"+toString(i)
90#ifdef POSITION
91                                                                , IN 
92                                                                , EAST
93                                                                , "Interface branch complete"
94#endif
95                                                                );
96
97         in_BRANCH_COMPLETE_VAL         [i] = interface->set_signal_valack_in            ("val"        , VAL);             
98        out_BRANCH_COMPLETE_ACK         [i] = interface->set_signal_valack_out           ("ack"        , ACK);             
99         in_BRANCH_COMPLETE_ADDRESS     [i] = interface->set_signal_in  <Taddress_t    > ("address"    , _param._size_address);
[2]100        if (_param._have_bht)
[43]101         in_BRANCH_COMPLETE_BHT_HISTORY [i] = interface->set_signal_in  <Tbht_history_t> ("bht_history", _param._bht_size_shifter);
[3]102        if (_param._have_pht)
[43]103         in_BRANCH_COMPLETE_PHT_HISTORY [i] = interface->set_signal_in  <Tpht_history_t> ("pht_history", _param._pht_size_counter);
104         in_BRANCH_COMPLETE_DIRECTION   [i] = interface->set_signal_in  <Tcontrol_t    > ("direction"  , 1);
[2]105      }
106
107    // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
108    string name_component;
109
110    // =====[ component_Branch_History_Table ]============================   
111    if (_param._have_bht)
112      {
113        name_component = _name+"_Branch_History_Table";
114       
[42]115        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()
[2]116#ifdef STATISTICS
[42]117                                                                                                                                                                                       ,_param_statistics
[2]118#endif
[43]119                                                                                                                                                                                       ,*(_param._param_branch_history_table));
[2]120       
[42]121        _component->set_component (component_Branch_History_Table->_component
122#ifdef POSITION
123                                   , 75
124                                   , 25
125                                   , 10
126                                   , 10
127#endif
128                                   );
129      }
130   
131    // =====[ component_Pattern_History_Table ]===========================   
132    if (_param._have_pht)
133      {
134        name_component = _name+"_Pattern_History_Table";
135       
136        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()
137#ifdef STATISTICS
138                                                                                                                                                                                          ,_param_statistics
139#endif
[43]140                                                                                                                                                                                          ,*(_param._param_pattern_history_table));
[42]141       
142        _component->set_component (component_Pattern_History_Table->_component
143#ifdef POSITION
144                                   , 75
145                                   , 75
146                                   , 10
147                                   , 10
148#endif
149                                   );
150      }
[2]151
[42]152    // =====[ component_Two_Level_Branch_Predictor_Glue ]=================
153
154    name_component = _name+"_Two_Level_Branch_Predictor_Glue";
155
156    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()
157#ifdef STATISTICS
158                                                                                                                                                                                                                   ,_param_statistics
159#endif
[43]160                                                                                                                                                                                                                   ,*(_param._param_two_level_branch_predictor_glue));
[42]161   
[43]162    _component->set_component (component_Two_Level_Branch_Predictor_Glue->_component
[42]163#ifdef POSITION
164                               , 50
165                               , 75
166                               , 10
167                               , 10
168#endif
169                               );
170   
171    // ~~~~~[ Component - Instanciation ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[43]172
[42]173    // =====[ component_Branch_History_Table - Instanciation ]============
174    if (_param._have_bht)
175      {
176#ifdef POSITION
177        _component->interface_map (_name+"_Branch_History_Table","",
178                                   _name                        ,"");
179#endif
180       
181        _component->port_map(_name+"_Branch_History_Table", "in_CLOCK" , _name,"in_CLOCK" );
182        _component->port_map(_name+"_Branch_History_Table", "in_NRESET", _name,"in_NRESET");
183
[2]184        for (uint32_t i=0; i<_param._nb_prediction; i++)
185          {
[42]186#ifdef POSITION
187            _component->interface_map (_name+"_Branch_History_Table","predict_"+toString(i),
188                                       _name                        ,"predict_"+toString(i));
189#endif
190            _component->port_map(_name+"_Branch_History_Table", "in_PREDICT_"+toString(i)+"_VAL"    , _name                                   , "in_PREDICT_"+toString(i)+"_VAL"        );
191            _component->port_map(_name+"_Branch_History_Table","out_PREDICT_"+toString(i)+"_ACK"    , _name+"_Two_Level_Branch_Predictor_Glue", "in_PREDICT_"+toString(i)+"_BHT_ACK"    );
192            _component->port_map(_name+"_Branch_History_Table", "in_PREDICT_"+toString(i)+"_ADDRESS", _name+"_Two_Level_Branch_Predictor_Glue","out_PREDICT_"+toString(i)+"_BHT_ADDRESS");
193            _component->port_map(_name+"_Branch_History_Table","out_PREDICT_"+toString(i)+"_HISTORY", _name                                   ,"out_PREDICT_"+toString(i)+"_BHT_HISTORY");
[2]194          }
195       
196        for (uint32_t i=0; i<_param._nb_branch_complete; i++)
197          {
[42]198#ifdef POSITION
199            _component->interface_map (_name+"_Branch_History_Table","branch_complete_"+toString(i),
200                                       _name                        ,"branch_complete_"+toString(i));
201#endif
202            _component->port_map(_name+"_Branch_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_VAL"      , _name                                   , "in_BRANCH_COMPLETE_"+toString(i)+"_VAL"          );
203            _component->port_map(_name+"_Branch_History_Table","out_BRANCH_COMPLETE_"+toString(i)+"_ACK"      , _name+"_Two_Level_Branch_Predictor_Glue", "in_BRANCH_COMPLETE_"+toString(i)+"_BHT_ACK"      );
204            _component->port_map(_name+"_Branch_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS"  , _name+"_Two_Level_Branch_Predictor_Glue","out_BRANCH_COMPLETE_"+toString(i)+"_BHT_ADDRESS"  );
205            _component->port_map(_name+"_Branch_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_HISTORY"  , _name                                   , "in_BRANCH_COMPLETE_"+toString(i)+"_BHT_HISTORY"  );
206            _component->port_map(_name+"_Branch_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_DIRECTION", _name                                   , "in_BRANCH_COMPLETE_"+toString(i)+"_DIRECTION"    );
[2]207          }
208      }
[42]209   
210    // =====[ component_Pattern_History_Table - Instanciation ]===========
[2]211    if (_param._have_pht)
212      {
[42]213#ifdef POSITION
214        _component->interface_map (_name+"_Pattern_History_Table","",
215                                   _name                         ,"");
[2]216#endif
217       
[42]218        _component->port_map(_name+"_Pattern_History_Table", "in_CLOCK" , _name,"in_CLOCK" );
219        _component->port_map(_name+"_Pattern_History_Table", "in_NRESET", _name,"in_NRESET");
220
[2]221        for (uint32_t i=0; i<_param._nb_prediction; i++)
222          {
[42]223#ifdef POSITION
224            _component->interface_map (_name+"_Pattern_History_Table","predict_"+toString(i),
225                                       _name                         ,"predict_"+toString(i));
226#endif
227            _component->port_map(_name+"_Pattern_History_Table", "in_PREDICT_"+toString(i)+"_VAL"    , _name                                   , "in_PREDICT_"+toString(i)+"_VAL"        );
228            _component->port_map(_name+"_Pattern_History_Table","out_PREDICT_"+toString(i)+"_ACK"    , _name+"_Two_Level_Branch_Predictor_Glue", "in_PREDICT_"+toString(i)+"_PHT_ACK"    );
229            _component->port_map(_name+"_Pattern_History_Table", "in_PREDICT_"+toString(i)+"_ADDRESS", _name+"_Two_Level_Branch_Predictor_Glue","out_PREDICT_"+toString(i)+"_PHT_ADDRESS");
230            _component->port_map(_name+"_Pattern_History_Table","out_PREDICT_"+toString(i)+"_HISTORY", _name                                   ,"out_PREDICT_"+toString(i)+"_PHT_HISTORY");
[2]231          }
[43]232
[2]233        for (uint32_t i=0; i<_param._nb_branch_complete; i++)
234          {
[42]235#ifdef POSITION
236            _component->interface_map (_name+"_Pattern_History_Table","branch_complete_"+toString(i),
237                                       _name                        ,"branch_complete_"+toString(i));
238#endif
239            _component->port_map(_name+"_Pattern_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_VAL"      , _name                                   , "in_BRANCH_COMPLETE_"+toString(i)+"_VAL"          );
240            _component->port_map(_name+"_Pattern_History_Table","out_BRANCH_COMPLETE_"+toString(i)+"_ACK"      , _name+"_Two_Level_Branch_Predictor_Glue", "in_BRANCH_COMPLETE_"+toString(i)+"_PHT_ACK"      );
241            _component->port_map(_name+"_Pattern_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS"  , _name+"_Two_Level_Branch_Predictor_Glue","out_BRANCH_COMPLETE_"+toString(i)+"_PHT_ADDRESS"  );
242            _component->port_map(_name+"_Pattern_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_HISTORY"  , _name                                   , "in_BRANCH_COMPLETE_"+toString(i)+"_PHT_HISTORY"  );
243            _component->port_map(_name+"_Pattern_History_Table", "in_BRANCH_COMPLETE_"+toString(i)+"_DIRECTION", _name                                   , "in_BRANCH_COMPLETE_"+toString(i)+"_DIRECTION"    );
[2]244          }
245      }
246
[42]247    // =====[ component_Two_Level_Branch_Predictor_Glue - Instanciation ]=
248#ifdef POSITION
249        _component->interface_map (_name+"_Two_Level_Branch_Predictor_Glue","",
250                                   _name                                   ,"");
[2]251#endif
[42]252        _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_CLOCK" , _name,"in_CLOCK" );
253        _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_NRESET", _name,"in_NRESET");
254
255        for (uint32_t i=0; i<_param._nb_prediction; i++)
256          {
[3]257        if (_param._have_bht)
[2]258          {
[43]259        _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue",  "in_PREDICT_"+toString(i)+"_BHT_ACK"    , _name+"_Branch_History_Table" , "out_PREDICT_"+toString(i)+"_ACK"    );
260        _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "out_PREDICT_"+toString(i)+"_BHT_ADDRESS", _name+"_Branch_History_Table" ,  "in_PREDICT_"+toString(i)+"_ADDRESS");
[42]261          }
262        if (_param._have_pht)
263          {
[43]264        _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue",  "in_PREDICT_"+toString(i)+"_PHT_ACK"    , _name+"_Pattern_History_Table", "out_PREDICT_"+toString(i)+"_ACK"    );
265        _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "out_PREDICT_"+toString(i)+"_PHT_ADDRESS", _name+"_Pattern_History_Table",  "in_PREDICT_"+toString(i)+"_ADDRESS");
[42]266          }
267        if (_param._have_bht and _param._have_pht)
[44]268        _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_PREDICT_"+toString(i)+"_BHT_HISTORY" , _name+"_Branch_History_Table" ,"out_PREDICT_"+toString(i)+"_HISTORY");
[42]269        _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue","out_PREDICT_"+toString(i)+"_ACK"         , _name                         ,"out_PREDICT_"+toString(i)+"_ACK");
270        _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_PREDICT_"+toString(i)+"_ADDRESS"     , _name                         , "in_PREDICT_"+toString(i)+"_ADDRESS");
271          }
[3]272   
273    for (uint32_t i=0; i<_param._nb_branch_complete; i++)
274      {
275        if (_param._have_bht)
[2]276          {
[43]277        _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue",  "in_BRANCH_COMPLETE_"+toString(i)+"_BHT_ACK"    , _name+"_Branch_History_Table" , "out_BRANCH_COMPLETE_"+toString(i)+"_ACK"    );
278        _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "out_BRANCH_COMPLETE_"+toString(i)+"_BHT_ADDRESS", _name+"_Branch_History_Table" ,  "in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS");
[42]279          }
280        if (_param._have_pht)
281          {
[43]282        _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue",  "in_BRANCH_COMPLETE_"+toString(i)+"_PHT_ACK"    , _name+"_Pattern_History_Table", "out_BRANCH_COMPLETE_"+toString(i)+"_ACK"    );
283        _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "out_BRANCH_COMPLETE_"+toString(i)+"_PHT_ADDRESS", _name+"_Pattern_History_Table",  "in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS");
[42]284          }
285        if (_param._have_bht and _param._have_pht)
286        _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_BRANCH_COMPLETE_"+toString(i)+"_BHT_HISTORY" , _name                         , "in_BRANCH_COMPLETE_"+toString(i)+"_BHT_HISTORY");
287        _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue","out_BRANCH_COMPLETE_"+toString(i)+"_ACK"         , _name                         ,"out_BRANCH_COMPLETE_"+toString(i)+"_ACK");
288        _component->port_map(_name+"_Two_Level_Branch_Predictor_Glue", "in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS"     , _name                         , "in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS");
[2]289      }
[42]290#ifdef POSITION
291    _component->generate_file();
292#endif
293
[2]294    log_printf(FUNC,Two_Level_Branch_Predictor,"allocation","End");
295  };
[3]296 
[2]297}; // end namespace two_level_branch_predictor
298}; // end namespace meta_predictor
299}; // end namespace predictor
300}; // end namespace stage_1_ifetch
301}; // end namespace behavioural
302}; // end namespace morpheo             
303#endif
Note: See TracBrowser for help on using the repository browser.