source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/Pattern_History_Table/src/Pattern_History_Table_allocation.cpp @ 81

Last change on this file since 81 was 81, checked in by rosiere, 16 years ago
  • Finish Environment (and test)
  • Continue predictor_unit
  • Add external tools
  • svn keyword "Id" set
  • Property svn:keywords set to Id
File size: 8.3 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id: Pattern_History_Table_allocation.cpp 81 2008-04-15 18:40:01Z rosiere $
4 *
5 * [ Description ]
6 *
7 */
8
9#include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Two_Level_Branch_Predictor/Pattern_History_Table/include/Pattern_History_Table.h"
10
11namespace morpheo                    {
12namespace behavioural {
13namespace core {
14namespace multi_front_end {
15namespace front_end {
16namespace prediction_unit {
17namespace direction {
18
19namespace meta_predictor {
20namespace two_level_branch_predictor {
21namespace pattern_history_table {
22
23
24  void Pattern_History_Table::allocation (void)
25  {
26    log_printf(FUNC,Pattern_History_Table,"allocation","Begin");
27
28    _component   = new Component ();
29
30    Entity * entity = _component->set_entity (_name                 
31                                             ,"Pattern_History_Table"
32#ifdef POSITION
33                                             ,MIXTE               
34#endif
35                                              );
36   
37    _interfaces = entity->set_interfaces();
38
39    // ~~~~~[ Interface : "" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
40    {
41      Interface * interface = _interfaces->set_interface(""
42#ifdef POSITION
43                                                         , IN 
44                                                         , SOUTH
45                                                         , "Generalist interface"
46#endif
47                                                         );
48     
49      in_CLOCK              = interface->set_signal_clk              ("clock" ,1);
50      in_NRESET             = interface->set_signal_in  <Tcontrol_t> ("nreset",1,RESET_VHDL_YES);
51    }
52
53    // ~~~~~[ Interface : "predict" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
54     in_PREDICT_VAL     = new SC_IN (Tcontrol_t) * [_param._nb_prediction];
55    out_PREDICT_ACK     = new SC_OUT(Tcontrol_t) * [_param._nb_prediction];
56     in_PREDICT_ADDRESS = new SC_IN (Taddress_t) * [_param._nb_prediction];
57    out_PREDICT_HISTORY = new SC_OUT(Thistory_t) * [_param._nb_prediction];
58
59    for (uint32_t i=0; i<_param._nb_prediction; i++)
60      {
61        Interface_fifo * interface = _interfaces->set_interface("predict_"+toString(i)
62#ifdef POSITION
63                                                                , IN 
64                                                                , WEST
65                                                                , "Interface Predict"
66#endif
67                                                                );
68
69         in_PREDICT_VAL     [i] = interface->set_signal_valack_in        ("val"    , VAL);
70        out_PREDICT_ACK     [i] = interface->set_signal_valack_out       ("ack"    , ACK);
71         in_PREDICT_ADDRESS [i] = interface->set_signal_in  <Taddress_t> ("address", static_cast<uint32_t>(ceil(log2(_param._nb_counter))));
72        out_PREDICT_HISTORY [i] = interface->set_signal_out <Thistory_t> ("history", _param._size_counter);
73      }
74   
75    // ~~~~~[ Interface : "branch_complete" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
76
77        in_BRANCH_COMPLETE_VAL       = new SC_IN     (Tcontrol_t) * [_param._nb_branch_complete];
78       out_BRANCH_COMPLETE_ACK       = new SC_OUT    (Tcontrol_t) * [_param._nb_branch_complete];
79        in_BRANCH_COMPLETE_ADDRESS   = new SC_IN     (Taddress_t) * [_param._nb_branch_complete];
80        in_BRANCH_COMPLETE_HISTORY   = new SC_IN     (Thistory_t) * [_param._nb_branch_complete];
81        in_BRANCH_COMPLETE_DIRECTION = new SC_IN     (Tcontrol_t) * [_param._nb_branch_complete];
82
83    for (uint32_t i=0; i<_param._nb_branch_complete; i++)
84      {
85        Interface_fifo * interface = _interfaces->set_interface("branch_complete_"+toString(i)
86#ifdef POSITION
87                                                                , IN 
88                                                                , EAST
89                                                                , "Interface branch complete"
90#endif
91                                                                );
92
93         in_BRANCH_COMPLETE_VAL        [i] = interface->set_signal_valack_in        ("val"      , VAL);
94        out_BRANCH_COMPLETE_ACK        [i] = interface->set_signal_valack_out       ("ack"      , ACK);
95         in_BRANCH_COMPLETE_ADDRESS    [i] = interface->set_signal_in  <Taddress_t> ("address"  , static_cast<uint32_t>(ceil(log2(_param._nb_counter))));
96         in_BRANCH_COMPLETE_HISTORY    [i] = interface->set_signal_in  <Thistory_t> ("history"  , _param._size_counter);
97         in_BRANCH_COMPLETE_DIRECTION  [i] = interface->set_signal_in  <Tcontrol_t> ("direction", 1);
98      }
99
100    // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
101    string name_component;
102
103    // =====[ component_Counter ]=========================================   
104   
105    name_component = _name+"_Counter";
106
107    component_Counter = new morpheo::behavioural::generic::counter::Counter (name_component.c_str()
108#ifdef STATISTICS
109                                                                             ,_param_statistics
110#endif
111                                                                             ,*(_param._param_counter));
112
113    _component->set_component (component_Counter->_component
114#ifdef POSITION
115                               , 25
116                               , 25
117                               , 10
118                               , 10
119#endif
120                               );
121
122     // =====[ component_RegisterFile ]====================================   
123   
124    name_component = _name+"_RegisterFile";
125   
126    component_RegisterFile = new morpheo::behavioural::generic::registerfile::registerfile_monolithic::RegisterFile_Monolithic(name_component.c_str(),
127#ifdef STATISTICS
128                                                                                                                               _param_statistics            ,
129#endif
130                                                                                                                               *(_param._param_registerfile));
131
132    _component->set_component (component_RegisterFile->_component
133#ifdef POSITION
134                               , 75
135                               , 75
136                               , 10
137                               , 10
138#endif
139                               );
140     
141    // ~~~~~[ Component - Instanciation ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
142
143    // =====[ component_RegisterFile - Instanciation ]====================   
144
145#ifdef POSITION
146    _component->interface_map (_name+"_RegisterFile","",
147                               _name                ,"");
148#endif
149
150    _component->port_map(_name+"_RegisterFile", "in_CLOCK" , _name,"in_CLOCK" );
151    _component->port_map(_name+"_RegisterFile", "in_NRESET", _name,"in_NRESET");
152   
153    for (uint32_t i=0; i<_param._nb_prediction; i++)
154      {
155#ifdef POSITION
156        _component->interface_map (_name+"_RegisterFile","read_"   +toString(i),
157                                   _name                ,"predict_"+toString(i));
158#endif
159
160        _component->port_map(_name+"_RegisterFile", "in_READ_"+toString(i)+"_VAL"    , _name, "in_PREDICT_"+toString(i)+"_VAL"    );
161        _component->port_map(_name+"_RegisterFile","out_READ_"+toString(i)+"_ACK"    , _name,"out_PREDICT_"+toString(i)+"_ACK"    );
162        _component->port_map(_name+"_RegisterFile", "in_READ_"+toString(i)+"_ADDRESS", _name, "in_PREDICT_"+toString(i)+"_ADDRESS");
163        _component->port_map(_name+"_RegisterFile","out_READ_"+toString(i)+"_DATA"   , _name,"out_PREDICT_"+toString(i)+"_HISTORY");
164      }
165   
166    for (uint32_t i=0; i<_param._nb_branch_complete; i++)
167      {
168#ifdef POSITION
169        _component->interface_map (_name+"_RegisterFile","write_"  +toString(i),
170                                   _name+"_Counter"     ,"counter_"+toString(i));
171#endif
172
173        _component->port_map(_name+"_RegisterFile", "in_WRITE_"+toString(i)+"_VAL"    , _name           , "in_BRANCH_COMPLETE_"+toString(i)+"_VAL"    );
174        _component->port_map(_name+"_RegisterFile","out_WRITE_"+toString(i)+"_ACK"    , _name           ,"out_BRANCH_COMPLETE_"+toString(i)+"_ACK"    );
175        _component->port_map(_name+"_RegisterFile", "in_WRITE_"+toString(i)+"_ADDRESS", _name           , "in_BRANCH_COMPLETE_"+toString(i)+"_ADDRESS");
176        _component->port_map(_name+"_RegisterFile", "in_WRITE_"+toString(i)+"_DATA"   , _name+"_Counter","out_COUNTER_"        +toString(i)+"_DATA");
177      }
178
179    // =====[ component_Counter - Instanciation ]=========================   
180
181#if (defined(STATISTICS) || defined (VHDL_TESTBENCH))
182
183#ifdef POSITION
184    _component->interface_map (_name+"_Counter","",
185                               _name           ,"");
186#endif
187
188    _component->port_map(_name+"_Counter", "in_CLOCK" , _name,"in_CLOCK" );
189    _component->port_map(_name+"_Counter", "in_NRESET", _name,"in_NRESET");
190
191#endif
192
193    for (uint32_t i=0; i<_param._nb_branch_complete; i++)
194      {
195#ifdef POSITION
196        _component->interface_map (_name+"_Counter","counter_"+toString(i),
197                                   _name           ,"branch_complete_"+toString(i));
198
199#endif
200
201        _component->port_map(_name+"_Counter", "in_COUNTER_" +toString(i)+"_DATA"    , _name                , "in_BRANCH_COMPLETE_"+toString(i)+"_HISTORY");
202        _component->port_map(_name+"_Counter", "in_COUNTER_" +toString(i)+"_ADDSUB"  , _name                , "in_BRANCH_COMPLETE_"+toString(i)+"_DIRECTION");
203        _component->port_map(_name+"_Counter", "out_COUNTER_"+toString(i)+"_DATA"    , _name+"_RegisterFile", "in_WRITE_"+toString(i)+"_DATA");
204      }
205
206#ifdef POSITION
207    _component->generate_file();
208#endif
209
210    log_printf(FUNC,Pattern_History_Table,"allocation","End");
211  };
212
213}; // end namespace pattern_history_table
214}; // end namespace two_level_branch_predictor
215}; // end namespace meta_predictor
216
217}; // end namespace core
218}; // end namespace multi_front_end
219}; // end namespace front_end
220}; // end namespace prediction_unit
221}; // end namespace direction
222
223
224}; // end namespace behavioural
225}; // end namespace morpheo             
226#endif
Note: See TracBrowser for help on using the repository browser.