source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Meta_Predictor_Glue/src/Meta_Predictor_Glue_genMealy_update.cpp @ 112

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

1) Stat_list : fix retire old and new register bug
2) Stat_list : remove read_counter and valid flag, because validation of destination is in retire step (not in commit step)
3) Model : add class Model (cf Morpheo.sim)
4) Allocation : alloc_interface_begin and alloc_interface_end to delete temporary array.
5) Script : add distexe.sh
6) Add Comparator, Multiplier, Divider. But this component are not implemented
7) Software : add Dhrystone

  • Property svn:keywords set to Id
File size: 5.6 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id: Meta_Predictor_Glue_genMealy_update.cpp 112 2009-03-18 22:36:26Z rosiere $
4 *
5 * [ Description ]
6 *
7 */
8
9#include "Behavioural/Core/Multi_Front_end/Front_end/Prediction_unit/Direction/Meta_Predictor/Meta_Predictor_Glue/include/Meta_Predictor_Glue.h"
10
11namespace morpheo                    {
12namespace behavioural {
13namespace core {
14namespace multi_front_end {
15namespace front_end {
16namespace prediction_unit {
17namespace direction {
18namespace meta_predictor {
19namespace meta_predictor_glue {
20
21
22#undef  FUNCTION
23#define FUNCTION "Meta_Predictor_Glue::genMealy_update"
24  void Meta_Predictor_Glue::genMealy_update (void)
25  {
26    log_begin(Meta_Predictor_Glue,FUNCTION);
27    log_function(Meta_Predictor_Glue,FUNCTION,_name.c_str());
28
29    for (uint32_t i=0; i<_param->_nb_inst_update; ++i)
30      {
31        Thistory_t history     = PORT_READ(in_UPDATE_HISTORY     [i]);
32        Tcontrol_t history_val = PORT_READ(in_UPDATE_HISTORY_VAL [i]);
33        Tcontrol_t direction   = PORT_READ(in_UPDATE_DIRECTION   [i]);
34
35        switch (_param->_nb_predictor)
36          {
37          case 1 :
38            {
39              Thistory_t history_0       =  history;
40              Tcontrol_t direction_old_0 = (history_0>>_param->_predictor_history_shift_msb[0])&1;
41              PORT_WRITE(out_UPDATE_PREDICTOR_HISTORY     [0][i],history_0);
42              PORT_WRITE(out_UPDATE_PREDICTOR_HISTORY_VAL [0][i],history_val);
43              PORT_WRITE(out_UPDATE_PREDICTOR_DIRECTION   [0][i],direction);
44              if (_param->_predictor_update_on_prediction [0])
45              PORT_WRITE(out_UPDATE_PREDICTOR_MISS        [0][i],direction xor direction_old_0);
46
47              break;
48            }
49          case 3 :
50            {
51              /*
52                dir_0 dir_1 dir_2 | good_dir  || next_dir_2
53                ------------------+-----------++-----------
54                  0     0     0   |     0     || no change
55                  1     0     0   |     0     ||         1 select pred_0 but miss
56                  0     1     0   |     0     ||         0 select pred_0 and hit
57                  1     1     0   |     0     || no change
58                  0     0     1   |     0     || no change
59                  1     0     1   |     0     ||         1 select pred_1 and hit
60                  0     1     1   |     0     ||         0 select pred_1 but miss
61                  1     1     1   |     0     || no change
62                  0     0     0   |     1     || no change
63                  1     0     0   |     1     ||         0 select pred_0 and hit
64                  0     1     0   |     1     ||         1 select pred_0 but miss
65                  1     1     0   |     1     || no change
66                  0     0     1   |     1     || no change
67                  1     0     1   |     1     ||         0 select pred_1 but miss
68                  0     1     1   |     1     ||         1 select pred_1 and hit
69                  1     1     1   |     1     || no change
70               
71                next_dir_2 = (good_dir and dir_1) or (not good_dir and dir_0)
72              */
73
74              Thistory_t history_0       = (history  >>_param->_predictor_history_shift    [0])&_param->_predictor_history_mask [0];
75              Thistory_t history_1       = (history  >>_param->_predictor_history_shift    [1])&_param->_predictor_history_mask [1];
76              Thistory_t history_2       = (history  >>_param->_predictor_history_shift    [2])&_param->_predictor_history_mask [2];
77              Tcontrol_t direction_old_0 = (history_0>>_param->_predictor_history_shift_msb[0])&1;
78              Tcontrol_t direction_old_1 = (history_1>>_param->_predictor_history_shift_msb[1])&1;
79              Tcontrol_t direction_old_2 = (history_2>>_param->_predictor_history_shift_msb[2])&1;
80              Tcontrol_t direction_new_2 = direction_old_2;
81
82              // Test if two predictor is different
83              if (direction_old_0 xor direction_old_1)
84                direction_new_2 = ((    direction and direction_old_1) or
85                                   (not direction and direction_old_0));
86
87              PORT_WRITE(out_UPDATE_PREDICTOR_DIRECTION   [0][i],direction);
88              PORT_WRITE(out_UPDATE_PREDICTOR_DIRECTION   [1][i],direction);
89              PORT_WRITE(out_UPDATE_PREDICTOR_DIRECTION   [2][i],direction_new_2);
90
91              if (_param->_predictor_update_on_prediction [0])
92              PORT_WRITE(out_UPDATE_PREDICTOR_MISS        [0][i],direction       xor direction_old_0);
93              if (_param->_predictor_update_on_prediction [1])
94              PORT_WRITE(out_UPDATE_PREDICTOR_MISS        [1][i],direction       xor direction_old_1);
95              if (_param->_predictor_update_on_prediction [2])
96              PORT_WRITE(out_UPDATE_PREDICTOR_MISS        [2][i],direction_new_2 xor direction_old_2);
97
98              PORT_WRITE(out_UPDATE_PREDICTOR_HISTORY     [0][i],history_0);
99              PORT_WRITE(out_UPDATE_PREDICTOR_HISTORY     [1][i],history_1);
100              PORT_WRITE(out_UPDATE_PREDICTOR_HISTORY     [2][i],history_2);
101
102              PORT_WRITE(out_UPDATE_PREDICTOR_HISTORY_VAL [0][i],history_val);
103              PORT_WRITE(out_UPDATE_PREDICTOR_HISTORY_VAL [1][i],history_val);
104              PORT_WRITE(out_UPDATE_PREDICTOR_HISTORY_VAL [2][i],history_val);
105
106              break;
107            }
108          default :
109            { 
110              break;
111            }
112          }
113      }
114
115    log_end(Meta_Predictor_Glue,FUNCTION);
116  };
117
118}; // end namespace meta_predictor_glue
119}; // end namespace meta_predictor
120}; // end namespace direction
121}; // end namespace prediction_unit
122}; // end namespace front_end
123}; // end namespace multi_front_end
124}; // end namespace core
125
126}; // end namespace behavioural
127}; // end namespace morpheo             
128#endif
Note: See TracBrowser for help on using the repository browser.