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 @ 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: 5.2 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id: Meta_Predictor_Glue_genMealy_update.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/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 direction = PORT_READ(in_UPDATE_DIRECTION [i]);
33
34        switch (_param->_nb_predictor)
35          {
36          case 1 :
37            {
38              Thistory_t history_0       =  history;
39              Tcontrol_t direction_old_0 = (history_0>>_param->_predictor_history_shift_msb[0])&1;
40              PORT_WRITE(out_UPDATE_PREDICTOR_HISTORY   [0][i],history_0);
41              PORT_WRITE(out_UPDATE_PREDICTOR_DIRECTION [0][i],direction);
42              if (_param->_predictor_update_on_prediction [0])
43              PORT_WRITE(out_UPDATE_PREDICTOR_MISS      [0][i],direction xor direction_old_0);
44
45              break;
46            }
47          case 3 :
48            {
49              /*
50                dir_0 dir_1 dir_2 | good_dir  || next_dir_2
51                ------------------+-----------++-----------
52                  0     0     0   |     0     || no change
53                  1     0     0   |     0     ||         1 select pred_0 but miss
54                  0     1     0   |     0     ||         0 select pred_0 and hit
55                  1     1     0   |     0     || no change
56                  0     0     1   |     0     || no change
57                  1     0     1   |     0     ||         1 select pred_1 and hit
58                  0     1     1   |     0     ||         0 select pred_1 but miss
59                  1     1     1   |     0     || no change
60                  0     0     0   |     1     || no change
61                  1     0     0   |     1     ||         0 select pred_0 and hit
62                  0     1     0   |     1     ||         1 select pred_0 but miss
63                  1     1     0   |     1     || no change
64                  0     0     1   |     1     || no change
65                  1     0     1   |     1     ||         0 select pred_1 but miss
66                  0     1     1   |     1     ||         1 select pred_1 and hit
67                  1     1     1   |     1     || no change
68               
69                next_dir_2 = (good_dir and dir_1) or (not good_dir and dir_0)
70              */
71
72              Thistory_t history_0       = (history  >>_param->_predictor_history_shift    [0])&_param->_predictor_history_mask [0];
73              Thistory_t history_1       = (history  >>_param->_predictor_history_shift    [1])&_param->_predictor_history_mask [1];
74              Thistory_t history_2       = (history  >>_param->_predictor_history_shift    [2])&_param->_predictor_history_mask [2];
75              Tcontrol_t direction_old_0 = (history_0>>_param->_predictor_history_shift_msb[0])&1;
76              Tcontrol_t direction_old_1 = (history_1>>_param->_predictor_history_shift_msb[1])&1;
77              Tcontrol_t direction_old_2 = (history_2>>_param->_predictor_history_shift_msb[2])&1;
78              Tcontrol_t direction_new_2 = direction_old_2;
79
80              // Test if two predictor is different
81              if (direction_old_0 xor direction_old_1)
82                direction_new_2 = ((    direction and direction_old_1) or
83                                   (not direction and direction_old_0));
84
85              PORT_WRITE(out_UPDATE_PREDICTOR_DIRECTION [0][i],direction);
86              PORT_WRITE(out_UPDATE_PREDICTOR_DIRECTION [1][i],direction);
87              PORT_WRITE(out_UPDATE_PREDICTOR_DIRECTION [2][i],direction_new_2);
88
89              if (_param->_predictor_update_on_prediction [0])
90              PORT_WRITE(out_UPDATE_PREDICTOR_MISS      [0][i],direction       xor direction_old_0);
91              if (_param->_predictor_update_on_prediction [1])
92              PORT_WRITE(out_UPDATE_PREDICTOR_MISS      [1][i],direction       xor direction_old_1);
93              if (_param->_predictor_update_on_prediction [2])
94              PORT_WRITE(out_UPDATE_PREDICTOR_MISS      [2][i],direction_new_2 xor direction_old_2);
95
96              PORT_WRITE(out_UPDATE_PREDICTOR_HISTORY   [0][i],history_0);
97              PORT_WRITE(out_UPDATE_PREDICTOR_HISTORY   [1][i],history_1);
98              PORT_WRITE(out_UPDATE_PREDICTOR_HISTORY   [2][i],history_2);
99
100              break;
101            }
102          default :
103            { 
104              break;
105            }
106          }
107      }
108
109    log_end(Meta_Predictor_Glue,FUNCTION);
110  };
111
112}; // end namespace meta_predictor_glue
113}; // end namespace meta_predictor
114}; // end namespace direction
115}; // end namespace prediction_unit
116}; // end namespace front_end
117}; // end namespace multi_front_end
118}; // end namespace core
119
120}; // end namespace behavioural
121}; // end namespace morpheo             
122#endif
Note: See TracBrowser for help on using the repository browser.