source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Stage_1_Ifetch/Predictor/Meta_Predictor/Meta_Predictor_Glue/src/Meta_Predictor_Glue.cpp @ 4

Last change on this file since 4 was 4, checked in by rosiere, 17 years ago
File size: 8.4 KB
Line 
1/*
2 * $Id$
3 *
4 * [ Description ]
5 *
6 */
7
8#include "Behavioural/Stage_1_Ifetch/Predictor/Meta_Predictor/Meta_Predictor_Glue/include/Meta_Predictor_Glue.h"
9
10namespace morpheo                    {
11namespace behavioural {
12namespace stage_1_ifetch {
13namespace predictor {
14namespace meta_predictor {
15namespace meta_predictor_glue {
16
17
18#ifdef SYSTEMC
19  Meta_Predictor_Glue::Meta_Predictor_Glue (sc_module_name name,
20#else
21  Meta_Predictor_Glue::Meta_Predictor_Glue (string name,
22#endif
23#ifdef STATISTICS
24                              morpheo::behavioural::Parameters_Statistics             param_statistics,
25#endif
26                              morpheo::behavioural::stage_1_ifetch::predictor::meta_predictor::meta_predictor_glue::Parameters param ):
27                              _name              (name)
28                              ,_param            (param)
29// #ifdef STATISTICS
30//                            ,_param_statistics (param_statistics)
31// #endif
32  {
33    log_printf(FUNC,Meta_Predictor_Glue,"Meta_Predictor_Glue","Begin");
34
35#ifdef STATISTICS
36    log_printf(INFO,Meta_Predictor_Glue,"Meta_Predictor_Glue","Allocation of statistics");
37
38    // Allocation of statistics
39    _stat = new Statistics (static_cast<string>(_name),
40                            param_statistics          ,
41                            param);
42#endif
43
44#ifdef VHDL_TESTBENCH
45    // Creation of a testbench
46    //  -> port
47    //  -> clock's signals
48    log_printf(INFO,Meta_Predictor_Glue,"Meta_Predictor_Glue","Creation of a testbench");
49    _vhdl_testbench = new Vhdl_Testbench (_name);
50    vhdl_testbench_port           ();
51    _vhdl_testbench->set_clock    ("in_CLOCK",false);
52#endif
53
54#ifdef VHDL
55    // generate the vhdl
56    log_printf(INFO,Meta_Predictor_Glue,"Meta_Predictor_Glue","VHDL's generation");
57    vhdl();
58#endif
59
60#ifdef SYSTEMC
61    log_printf(INFO,Meta_Predictor_Glue,"Meta_Predictor_Glue","Allocation");
62    allocation ();
63
64#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
65    log_printf(INFO,Meta_Predictor_Glue,"Meta_Predictor_Glue","method - transition");
66
67    SC_METHOD (transition);
68    dont_initialize ();
69    sensitive_pos << *(in_CLOCK);
70#endif
71
72    log_printf(INFO,Meta_Predictor_Glue,"Meta_Predictor_Glue","method - genMealy_predict_ack");
73    SC_METHOD (genMealy_predict_ack);
74    dont_initialize ();
75    for (uint32_t i=0; i<_param._nb_prediction; i++)
76      {
77        sensitive << *(in_PREDICT_PREDICTOR_2_ACK [i]);
78       
79        if (_param._have_meta_predictor)
80          {
81            sensitive << *(in_PREDICT_PREDICTOR_0_ACK [i])
82                      << *(in_PREDICT_PREDICTOR_1_ACK [i]);
83          }                               
84      }
85
86#ifdef SYSTEMCASS_SPECIFIC
87    // List dependency information
88    for (uint32_t i=0; i<_param._nb_prediction; i++)
89      {
90        (*(out_PREDICT_ACK [i])) (*(in_PREDICT_PREDICTOR_2_ACK [i]));
91       
92        if (_param._have_meta_predictor)
93          {
94        (*(out_PREDICT_ACK [i])) (*(in_PREDICT_PREDICTOR_0_ACK [i]));
95        (*(out_PREDICT_ACK [i])) (*(in_PREDICT_PREDICTOR_1_ACK [i]));
96          }                               
97      }
98#endif   
99
100    log_printf(INFO,Meta_Predictor_Glue,"Meta_Predictor_Glue","method - genMealy_predict_history");
101    SC_METHOD (genMealy_predict_history);
102    dont_initialize ();
103    for (uint32_t i=0; i<_param._nb_prediction; i++)
104      {
105        if (_param._predictor_2_have_bht)
106        sensitive << *(in_PREDICT_PREDICTOR_2_BHT_HISTORY [i]);
107        if (_param._predictor_2_have_pht)
108        sensitive << *(in_PREDICT_PREDICTOR_2_PHT_HISTORY [i]);
109
110        if (_param._have_meta_predictor)
111          {
112        if (_param._predictor_1_have_bht)
113        sensitive << *(in_PREDICT_PREDICTOR_1_BHT_HISTORY [i]);
114        if (_param._predictor_1_have_pht)
115        sensitive << *(in_PREDICT_PREDICTOR_1_PHT_HISTORY [i]);
116
117        if (_param._predictor_0_have_bht)
118        sensitive << *(in_PREDICT_PREDICTOR_0_BHT_HISTORY [i]);
119        if (_param._predictor_0_have_pht)
120        sensitive << *(in_PREDICT_PREDICTOR_0_PHT_HISTORY [i]);
121          }                               
122      }
123
124#ifdef SYSTEMCASS_SPECIFIC
125    // List dependency information
126    for (uint32_t i=0; i<_param._nb_prediction; i++)
127      {
128        if (_param._predictor_2_have_bht)
129        (*(out_PREDICT_HISTORY    [i])) (*(in_PREDICT_PREDICTOR_2_BHT_HISTORY [i]));
130        if (_param._predictor_2_have_pht)
131        (*(out_PREDICT_HISTORY    [i])) (*(in_PREDICT_PREDICTOR_2_PHT_HISTORY [i]));
132
133        if (_param._have_meta_predictor)
134          {
135        if (_param._predictor_1_have_bht)
136        (*(out_PREDICT_HISTORY    [i])) (*(in_PREDICT_PREDICTOR_1_BHT_HISTORY [i]));
137        if (_param._predictor_1_have_pht)
138        (*(out_PREDICT_HISTORY    [i])) (*(in_PREDICT_PREDICTOR_1_PHT_HISTORY [i]));
139
140        if (_param._predictor_0_have_bht)
141        (*(out_PREDICT_HISTORY    [i])) (*(in_PREDICT_PREDICTOR_0_BHT_HISTORY [i]));
142        if (_param._predictor_0_have_pht)
143        (*(out_PREDICT_HISTORY    [i])) (*(in_PREDICT_PREDICTOR_0_PHT_HISTORY [i]));
144          }                               
145
146        if (_param._predictor_2_have_bht)
147        (*(out_PREDICT_DIRECTION  [i])) (*(in_PREDICT_PREDICTOR_2_BHT_HISTORY [i]));
148        if (_param._predictor_2_have_pht)
149        (*(out_PREDICT_DIRECTION  [i])) (*(in_PREDICT_PREDICTOR_2_PHT_HISTORY [i]));
150
151        if (_param._have_meta_predictor)
152          {
153        if (_param._predictor_1_have_bht)
154        (*(out_PREDICT_DIRECTION  [i])) (*(in_PREDICT_PREDICTOR_1_BHT_HISTORY [i]));
155        if (_param._predictor_1_have_pht)
156        (*(out_PREDICT_DIRECTION  [i])) (*(in_PREDICT_PREDICTOR_1_PHT_HISTORY [i]));
157
158        if (_param._predictor_0_have_bht)
159        (*(out_PREDICT_DIRECTION  [i])) (*(in_PREDICT_PREDICTOR_0_BHT_HISTORY [i]));
160        if (_param._predictor_0_have_pht)
161        (*(out_PREDICT_DIRECTION  [i])) (*(in_PREDICT_PREDICTOR_0_PHT_HISTORY [i]));
162          }                               
163      }
164#endif   
165
166    log_printf(INFO,Meta_Predictor_Glue,"Meta_Predictor_Glue","method - genMealy_branch_complete_ack");
167    SC_METHOD (genMealy_branch_complete_ack);
168    dont_initialize ();
169    for (uint32_t i=0; i<_param._nb_branch_complete; i++)
170      {
171        sensitive << *(in_BRANCH_COMPLETE_PREDICTOR_2_ACK [i]);
172       
173        if (_param._have_meta_predictor)
174          {
175            sensitive << *(in_BRANCH_COMPLETE_PREDICTOR_0_ACK [i])
176                      << *(in_BRANCH_COMPLETE_PREDICTOR_1_ACK [i]);
177          }                               
178      }
179
180#ifdef SYSTEMCASS_SPECIFIC
181    // List dependency information
182    for (uint32_t i=0; i<_param._nb_branch_complete; i++)
183      {
184        (*(out_BRANCH_COMPLETE_ACK [i])) (*(in_BRANCH_COMPLETE_PREDICTOR_2_ACK [i]));
185       
186        if (_param._have_meta_predictor)
187          {
188        (*(out_BRANCH_COMPLETE_ACK [i])) (*(in_BRANCH_COMPLETE_PREDICTOR_0_ACK [i]));
189        (*(out_BRANCH_COMPLETE_ACK [i])) (*(in_BRANCH_COMPLETE_PREDICTOR_1_ACK [i]));
190          }                               
191      }
192#endif   
193
194    log_printf(INFO,Meta_Predictor_Glue,"Meta_Predictor_Glue","method - genMealy_branch_complete_history");
195    SC_METHOD (genMealy_branch_complete_history);
196    dont_initialize ();
197    for (uint32_t i=0; i<_param._nb_branch_complete; i++)
198      {
199        sensitive << *(in_BRANCH_COMPLETE_HISTORY [i]);
200      }
201
202#ifdef SYSTEMCASS_SPECIFIC
203    // List dependency information
204    for (uint32_t i=0; i<_param._nb_branch_complete; i++)
205      {
206        if (_param._predictor_2_have_bht)
207         (*(out_BRANCH_COMPLETE_PREDICTOR_2_BHT_HISTORY [i])) (*( in_BRANCH_COMPLETE_HISTORY    [i]));
208        if (_param._predictor_2_have_pht)
209         (*(out_BRANCH_COMPLETE_PREDICTOR_2_PHT_HISTORY [i])) (*( in_BRANCH_COMPLETE_HISTORY    [i]));
210               
211        if (_param._have_meta_predictor)
212          {
213            if (_param._predictor_1_have_bht)
214         (*(out_BRANCH_COMPLETE_PREDICTOR_1_BHT_HISTORY [i])) (*( in_BRANCH_COMPLETE_HISTORY    [i]));
215            if (_param._predictor_1_have_pht)
216         (*(out_BRANCH_COMPLETE_PREDICTOR_1_PHT_HISTORY [i])) (*( in_BRANCH_COMPLETE_HISTORY    [i]));
217                                                                                                           
218            if (_param._predictor_0_have_bht)
219         (*(out_BRANCH_COMPLETE_PREDICTOR_0_BHT_HISTORY [i])) (*( in_BRANCH_COMPLETE_HISTORY    [i]));
220            if (_param._predictor_0_have_pht)
221         (*(out_BRANCH_COMPLETE_PREDICTOR_0_PHT_HISTORY [i])) (*( in_BRANCH_COMPLETE_HISTORY    [i]));
222          }                               
223      }
224#endif   
225
226#endif
227    log_printf(FUNC,Meta_Predictor_Glue,"Meta_Predictor_Glue","End");
228  };
229 
230  Meta_Predictor_Glue::~Meta_Predictor_Glue (void)
231  {
232    log_printf(FUNC,Meta_Predictor_Glue,"~Meta_Predictor_Glue","Begin");
233
234#ifdef VHDL_TESTBENCH
235    log_printf(INFO,Meta_Predictor_Glue,"~Meta_Predictor_Glue","Generate Testbench");
236    // generate the test bench
237    _vhdl_testbench->generate_file();
238    delete _vhdl_testbench;
239#endif
240
241#ifdef STATISTICS
242    log_printf(INFO,Meta_Predictor_Glue,"~Meta_Predictor_Glue","Generate Statistics");
243    _stat->generate_file(statistics(0));
244   
245    delete _stat;
246#endif
247
248#ifdef SYSTEMC
249    log_printf(INFO,Meta_Predictor_Glue,"~Meta_Predictor_Glue","Dealocation");
250    deallocation ();
251#endif
252
253    log_printf(FUNC,Meta_Predictor_Glue,"~Meta_Predictor_Glue","End");
254  };
255
256}; // end namespace meta_predictor_glue
257}; // end namespace meta_predictor
258}; // end namespace predictor
259}; // end namespace stage_1_ifetch
260}; // end namespace behavioural
261}; // end namespace morpheo             
Note: See TracBrowser for help on using the repository browser.