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

Last change on this file since 5 was 5, checked in by rosiere, 17 years ago

Ajout du composant Meta_Predictor

File size: 4.2 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id$
4 *
5 * [ Description ]
6 *
7 */
8
9#include "Behavioural/Stage_1_Ifetch/Predictor/Meta_Predictor/Meta_Predictor_Glue/include/Meta_Predictor_Glue.h"
10
11namespace morpheo                    {
12namespace behavioural {
13namespace stage_1_ifetch {
14namespace predictor {
15namespace meta_predictor {
16namespace meta_predictor_glue {
17
18
19  void Meta_Predictor_Glue::genMealy_predict_history (void)
20  {
21    log_printf(FUNC,Meta_Predictor_Glue,"genMealy_predict_history","Begin");
22   
23    for (uint32_t i=0; i<_param._nb_prediction; i++)
24      {
25        Thistory_t     history = 0;
26        Tpht_history_t predictor_0_pht_history  =0, predictor_1_pht_history  =0, predictor_2_pht_history  =0;
27        Tbht_history_t predictor_0_bht_history  =0, predictor_1_bht_history  =0, predictor_2_bht_history  =0;
28        Tcontrol_t     predictor_0_pht_direction=0, predictor_1_pht_direction=0, predictor_2_pht_direction=0;
29        Tcontrol_t     predictor_0_bht_direction=0, predictor_1_bht_direction=0, predictor_2_bht_direction=0;
30        Tcontrol_t     predictor_0_direction,     predictor_1_direction,     predictor_2_direction;
31        Tcontrol_t     predictor_direction;
32
33        if (_param._predictor_2_have_pht)
34          {
35        predictor_2_pht_history   = PORT_READ(in_PREDICT_PREDICTOR_2_PHT_HISTORY [i]);
36        predictor_2_pht_direction = predictor_2_pht_history >> (_param._predictor_2_pht_size_counter-1);
37        history                  |= (predictor_2_pht_history << _param._shift_5);
38          }
39        if (_param._predictor_2_have_bht)
40          {
41        predictor_2_bht_history   = PORT_READ(in_PREDICT_PREDICTOR_2_BHT_HISTORY [i]);
42        predictor_2_bht_direction = predictor_2_bht_history >> (_param._predictor_2_bht_size_shifter-1);
43        history                  |= (predictor_2_bht_history << _param._shift_4);
44          }
45
46        predictor_2_direction = (_param._predictor_2_have_pht==true)?predictor_2_pht_direction:predictor_2_bht_direction;
47
48        if (_param._have_meta_predictor)
49          {
50        if (_param._predictor_1_have_pht)
51          {
52        predictor_1_pht_history   = PORT_READ(in_PREDICT_PREDICTOR_1_PHT_HISTORY [i]);
53        predictor_1_pht_direction = predictor_1_pht_history >> (_param._predictor_1_pht_size_counter-1);
54        history                  |= (predictor_1_pht_history << _param._shift_3);
55          }
56        if (_param._predictor_1_have_bht)
57          {
58        predictor_1_bht_history   = PORT_READ(in_PREDICT_PREDICTOR_1_BHT_HISTORY [i]);
59        predictor_1_bht_direction = predictor_1_bht_history >> (_param._predictor_1_bht_size_shifter-1);
60        history                  |= (predictor_1_bht_history << _param._shift_2) ;
61          }
62        if (_param._predictor_0_have_pht)
63          {
64        predictor_0_pht_history   = PORT_READ(in_PREDICT_PREDICTOR_0_PHT_HISTORY [i]);
65        predictor_0_pht_direction = predictor_0_pht_history >> (_param._predictor_0_pht_size_counter-1);
66        history                  |= (predictor_0_pht_history << _param._shift_1);
67          }
68        if (_param._predictor_0_have_bht)
69          {
70        predictor_0_bht_history   = PORT_READ(in_PREDICT_PREDICTOR_0_BHT_HISTORY [i]);
71        predictor_0_bht_direction = predictor_0_bht_history >> (_param._predictor_0_bht_size_shifter-1);
72        history                  |= (predictor_0_bht_history << _param._shift_0);
73          }
74
75        predictor_0_direction = (_param._predictor_0_have_pht==true)?predictor_0_pht_direction:predictor_0_bht_direction;
76        predictor_1_direction = (_param._predictor_1_have_pht==true)?predictor_1_pht_direction:predictor_1_bht_direction;
77
78        // Meta predictor : take direction of prediction_2 and select the good predictor.
79        predictor_direction   = (predictor_2_direction==0)?predictor_0_direction:predictor_1_direction;
80       
81        log_printf(TRACE,Meta_Predictor_Glue,"genMealy_predict_history","predict_direction = %d - predictor(_0 %d, _1 %d, _2 %d)",predictor_direction,predictor_0_direction,predictor_1_direction,predictor_2_direction);
82          }
83        else
84          {
85        predictor_direction   =  predictor_2_direction;
86        log_printf(TRACE,Meta_Predictor_Glue,"genMealy_predict_history","predict_direction = %d - predictor_2 %d",predictor_direction,predictor_2_direction);
87          }
88
89        PORT_WRITE(out_PREDICT_DIRECTION [i], predictor_direction);
90        PORT_WRITE(out_PREDICT_HISTORY   [i], history            );
91      }
92
93    log_printf(FUNC,Meta_Predictor_Glue,"genMealy_predict_history","End");
94  };
95
96}; // end namespace meta_predictor_glue
97}; // end namespace meta_predictor
98}; // end namespace predictor
99}; // end namespace stage_1_ifetch
100}; // end namespace behavioural
101}; // end namespace morpheo             
102#endif
Note: See TracBrowser for help on using the repository browser.