source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/src/Parameters.cpp @ 88

Last change on this file since 88 was 88, checked in by rosiere, 16 years ago

Almost complete design
with Test and test platform

  • Property svn:keywords set to Id
File size: 7.6 KB
Line 
1/*
2 * $Id: Parameters.cpp 88 2008-12-10 18:31:39Z rosiere $
3 *
4 * [ Description ]
5 *
6 */
7
8#include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/include/Parameters.h"
9#include "Common/include/Max.h"
10
11namespace morpheo {
12namespace behavioural {
13namespace core {
14namespace multi_front_end {
15namespace front_end {
16namespace prediction_unit {
17
18
19#undef  FUNCTION
20#define FUNCTION "Prediction_unit::Parameters"
21  Parameters::Parameters (uint32_t     nb_context                    ,
22                          uint32_t     nb_decod_unit                 ,
23                          uint32_t     size_address                  ,
24                          uint32_t *   nb_instruction                ,//[nb_context]
25                          uint32_t *   nb_inst_decod                 ,//[nb_decod_unit]
26                          uint32_t     nb_inst_branch_predict        ,
27                          uint32_t     nb_inst_branch_decod          ,
28                          uint32_t     nb_inst_branch_update         ,
29                          uint32_t     nb_inst_branch_complete       ,
30                          uint32_t     btb_size_queue                ,
31                          uint32_t     btb_associativity             ,
32                          uint32_t     btb_size_counter              ,
33                          Tvictim_t    btb_victim_scheme             ,
34                          Tpredictor_t dir_predictor_scheme          ,
35                          bool         dir_have_bht               [3],
36                          uint32_t     dir_bht_size_shifter       [3],
37                          uint32_t     dir_bht_nb_shifter         [3],
38                          bool         dir_have_pht               [3],
39                          uint32_t     dir_pht_size_counter       [3],
40                          uint32_t     dir_pht_nb_counter         [3],
41                          uint32_t     dir_pht_size_address_share [3],
42                          uint32_t *   ras_size_queue                ,//[nb_context]
43                          uint32_t *   upt_size_queue                ,//[nb_context]
44                          bool         is_toplevel
45                          )
46  {
47    log_printf(FUNC,Prediction_unit,FUNCTION,"Begin");
48   
49    _nb_context                 = nb_context                ;
50    _nb_decod_unit              = nb_decod_unit             ;
51    _size_address               = size_address              ;
52    _nb_instruction             = nb_instruction            ;
53    _nb_inst_decod              = nb_inst_decod             ;
54    _nb_inst_branch_predict     = nb_inst_branch_predict    ;
55    _nb_inst_branch_decod       = nb_inst_branch_decod      ;
56    _nb_inst_branch_update      = nb_inst_branch_update     ;
57    _nb_inst_branch_complete    = nb_inst_branch_complete   ;
58    _btb_size_queue             = btb_size_queue            ;
59    _btb_associativity          = btb_associativity         ;
60    _btb_size_counter           = btb_size_counter          ;
61    _btb_victim_scheme          = btb_victim_scheme         ;
62    _dir_predictor_scheme       = dir_predictor_scheme      ;
63    for (uint32_t i=0; i<3; i++)
64      {
65        _dir_have_bht               [i] = dir_have_bht               [i];
66        _dir_bht_size_shifter       [i] = dir_bht_size_shifter       [i];
67        _dir_bht_nb_shifter         [i] = dir_bht_nb_shifter         [i];
68        _dir_have_pht               [i] = dir_have_pht               [i];
69        _dir_pht_size_counter       [i] = dir_pht_size_counter       [i];
70        _dir_pht_nb_counter         [i] = dir_pht_nb_counter         [i];
71        _dir_pht_size_address_share [i] = dir_pht_size_address_share [i];
72      }
73    _ras_size_queue             = ras_size_queue            ;
74    _upt_size_queue             = upt_size_queue            ;
75   
76    _array_size_depth           = new uint32_t [_nb_context];
77    _size_ras_index             = new uint32_t [_nb_context];
78
79    for (uint32_t i=0; i<_nb_context; i++)
80      {
81        _array_size_depth [i] = log2(_upt_size_queue [i]);
82        _size_ras_index   [i] = log2(_ras_size_queue [i]);
83      }
84
85    _param_glue = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::prediction_unit_glue   ::Parameters
86      (_nb_context            ,
87       _nb_decod_unit         ,
88       _size_address          ,
89       _nb_instruction        ,
90       _array_size_depth      ,
91       _nb_inst_decod         ,
92       _nb_inst_branch_predict,
93       _nb_inst_branch_decod  ,
94       _nb_inst_branch_update );
95
96    _param_btb  = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::branch_target_buffer   ::Parameters
97      (_nb_context            ,
98       _nb_instruction        ,
99       _btb_size_queue        ,
100       _btb_associativity     ,
101       _size_address          ,
102       _btb_size_counter      ,
103       _nb_inst_branch_predict,
104       _nb_inst_branch_decod  ,
105       _nb_inst_branch_update ,
106       _btb_victim_scheme     );
107   
108    _param_dir  = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::direction              ::Parameters
109      (_dir_predictor_scheme      ,
110       _nb_inst_branch_predict    ,
111       _nb_inst_branch_update     ,
112       _size_address              ,
113       _dir_have_bht              ,
114       _dir_bht_size_shifter      ,
115       _dir_bht_nb_shifter        ,
116       _dir_have_pht              ,
117       _dir_pht_size_counter      ,
118       _dir_pht_nb_counter        ,
119       _dir_pht_size_address_share);
120
121    _size_history      = _param_dir->_size_history;
122    _have_port_history = (_size_history > 0);
123
124    _param_ras  = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::return_address_stack   ::Parameters
125      (_nb_context            ,
126       _ras_size_queue        ,
127       _size_address          ,
128       _nb_inst_branch_predict,
129       _nb_inst_branch_decod  ,
130       _nb_inst_branch_update );
131
132    _param_upt  = new morpheo::behavioural::core::multi_front_end::front_end::prediction_unit::update_prediction_table::Parameters
133      (_nb_context             ,
134       _upt_size_queue         ,
135       _size_address           ,
136       _nb_inst_branch_predict ,
137       _nb_inst_branch_decod   ,
138       _nb_inst_branch_complete,
139       _nb_inst_branch_update  ,
140       _size_history           ,
141       _size_ras_index         );
142
143
144    if (is_toplevel)
145      {
146        _size_context_id           = log2(_nb_context);
147        _size_depth                = max<uint32_t>(_array_size_depth,_nb_context);
148        _size_inst_ifetch_ptr      = log2(max<uint32_t>(_nb_instruction,_nb_context));
149        _size_instruction_address  = size_address;
150//      _size_nb_inst_decod        = ;
151//      _size_nb_inst_commit       = ;
152//      _size_ifetch_queue_ptr     = ;
153   
154        _have_port_context_id      = (_size_context_id > 0);
155        _have_port_depth           = (_size_depth  > 0);
156        _have_port_inst_ifetch_ptr = _size_inst_ifetch_ptr > 0;
157//      _have_port_ifetch_queue_ptr= _size_ifetch_queue_ptr > 0;
158
159        copy ();
160      }
161
162    test();
163    log_printf(FUNC,Prediction_unit,FUNCTION,"End");
164  };
165 
166// #undef  FUNCTION
167// #define FUNCTION "Prediction_unit::Parameters (copy)"
168//   Parameters::Parameters (Parameters & param)
169//   {
170//     log_printf(FUNC,Prediction_unit,FUNCTION,"Begin");
171//     test();
172//     log_printf(FUNC,Prediction_unit,FUNCTION,"End");
173//   };
174
175#undef  FUNCTION
176#define FUNCTION "Prediction_unit::~Parameters"
177  Parameters::~Parameters () 
178  {
179    log_printf(FUNC,Prediction_unit,FUNCTION,"Begin");
180 
181    delete _param_btb;
182    delete _param_dir;
183    delete _param_ras;
184    delete _param_upt;
185    delete _param_glue;
186
187    delete [] _array_size_depth;
188    delete [] _size_ras_index;
189
190    log_printf(FUNC,Prediction_unit,FUNCTION,"End");
191  };
192
193#undef  FUNCTION
194#define FUNCTION "Prediction_unit::copy"
195  void Parameters::copy (void) 
196  {
197    log_printf(FUNC,Prediction_unit,FUNCTION,"Begin");
198 
199    COPY(_param_btb );
200    COPY(_param_dir );
201    COPY(_param_ras );
202    COPY(_param_upt );
203    COPY(_param_glue);
204
205    log_printf(FUNC,Prediction_unit,FUNCTION,"End");
206  };
207
208}; // end namespace prediction_unit
209}; // end namespace front_end
210}; // end namespace multi_front_end
211}; // end namespace core
212
213}; // end namespace behavioural
214}; // end namespace morpheo             
Note: See TracBrowser for help on using the repository browser.