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

Last change on this file since 111 was 111, checked in by rosiere, 15 years ago

1) Decod_queue : multi implementation (one_fifo, multi_fifo)
2) Issue_queue : multi implementation (in_order, out_of_order)
3) Direction : Add Meta predictor
4) Context_State : re add Branch_complete, More priority to Load miss (is not speculative)
5) Return_Address_Stack : update reg_PREDICT pointer on decod miss prediction
6) UPT : Fix bug in multi event
7) Prediction_glue : in read_stack case, insert in UPT pc_next
8) Rename select : when rob have an event (need flush), read_r{a,b,c} and write_r{d,e} is set at 0

  • Property svn:keywords set to Id
File size: 4.1 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id: Two_Level_Branch_Predictor_genMealy_predict.cpp 111 2009-02-27 18:37:40Z 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/include/Two_Level_Branch_Predictor.h"
10
11namespace morpheo                    {
12namespace behavioural {
13namespace core {
14namespace multi_front_end {
15namespace front_end {
16namespace prediction_unit {
17namespace direction {
18namespace meta_predictor {
19namespace two_level_branch_predictor {
20
21
22#undef  FUNCTION
23#define FUNCTION "Two_Level_Branch_Predictor::genMealy_predict"
24  void Two_Level_Branch_Predictor::genMealy_predict (void)
25  {
26    log_begin(Two_Level_Branch_Predictor,FUNCTION);
27    log_function(Two_Level_Branch_Predictor,FUNCTION,_name.c_str());
28
29    // ===================================================================
30    // =====[ PREDICT ]===================================================
31    // ===================================================================
32
33    for (uint32_t i=0; i<_param->_nb_inst_predict; ++i)
34//       if (PORT_READ(in_PREDICT_VAL[i]))
35        {
36          log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * PREDICT [%d]",i);
37
38          Taddress_t address     = PORT_READ(in_PREDICT_ADDRESS   [i]);
39          Thistory_t history     = 0;
40          Tcontrol_t direction;
41
42          log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * address          : 0x%.8x",address);
43
44          Thistory_t pht_bht_history = 0;
45          if (_param->_have_bht)
46            {
47              Thistory_t bht_num_reg = address & _param->_bht_address_mask;
48              Thistory_t bht_history = reg_BHT [bht_num_reg];
49              pht_bht_history = bht_history;
50
51              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_history      : 0x%x",bht_history);
52              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_num_reg      : %d",bht_num_reg);
53
54              history   = (bht_history << _param->_bht_history_rshift)&_param->_bht_history_mask ;
55              direction = (bht_history >> (_param->_bht_size_shifter-1))&1;
56
57              if (_param->_update_on_prediction)
58              internal_PREDICT_BHT_NUM_REG [i] = bht_num_reg;
59            }
60
61          if (_param->_have_pht)
62            {
63              Thistory_t pht_num_bank= (address>>_param->_pht_address_bank_rshift)&_param->_pht_address_bank_mask;
64              Thistory_t pht_num_reg = (pht_bht_history xor ((address&_param->_pht_address_share_mask)<<_param->_pht_address_share_lshift));
65              Thistory_t pht_history = reg_PHT [pht_num_bank][pht_num_reg];
66             
67              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * bht_history      : 0x%x",pht_bht_history);
68              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_history      : 0x%x",pht_history);
69              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_num_reg      : %d",pht_num_reg);
70              log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * pht_num_bank     : %d",pht_num_bank);
71             
72              history  |= (pht_history << _param->_pht_history_rshift)&_param->_pht_history_mask;
73              direction = (pht_history >> (_param->_pht_size_counter-1))&1;
74
75              if (_param->_update_on_prediction)
76                {
77              internal_PREDICT_PHT_NUM_REG [i] = pht_num_reg;
78              internal_PREDICT_PHT_NUM_BANK[i] = pht_num_bank;
79                }
80            }
81
82          log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * direction        : %d",direction);
83          log_printf(TRACE,Two_Level_Branch_Predictor,FUNCTION,"  * history          : 0x%x",history);
84
85          PORT_WRITE(out_PREDICT_DIRECTION [i],direction);
86          PORT_WRITE(out_PREDICT_HISTORY   [i],history  );
87        }
88
89    log_end(Two_Level_Branch_Predictor,FUNCTION);
90  };
91
92}; // end namespace two_level_branch_predictor
93}; // end namespace meta_predictor
94}; // end namespace direction
95}; // end namespace prediction_unit
96}; // end namespace front_end
97}; // end namespace multi_front_end
98}; // end namespace core
99
100}; // end namespace behavioural
101}; // end namespace morpheo             
102#endif
Note: See TracBrowser for help on using the repository browser.