source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Commit_unit/src/Commit_unit_genMealy_retire.cpp @ 122

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

Modif for performance :
1) Load Store Unit : store send request to valid exeception
2) Commit_unit : retire can bypass store
3) Commit_unit : add stat to manage store instruction
4) Load Store Unit and Load Store Pointer Manager : add store_queue_ptr_read
5) Fix lot of bug

  • Property svn:keywords set to Id
File size: 10.4 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id: Commit_unit_genMealy_retire.cpp 122 2009-06-03 08:15:51Z rosiere $
4 *
5 * [ Description ]
6 *
7 */
8
9#include "Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Commit_unit/include/Commit_unit.h"
10
11namespace morpheo                    {
12namespace behavioural {
13namespace core {
14namespace multi_ooo_engine {
15namespace ooo_engine {
16namespace commit_unit {
17
18
19#undef  FUNCTION
20#define FUNCTION "Commit_unit::genMealy_retire"
21  void Commit_unit::genMealy_retire (void)
22  {
23    log_begin(Commit_unit,FUNCTION);
24    log_function(Commit_unit,FUNCTION,_name.c_str());
25
26    Tcontrol_t retire_val          [_param->_nb_rename_unit][_param->_max_nb_inst_retire];
27    uint32_t   num_inst_retire     [_param->_nb_rename_unit];
28    bool       can_retire          [_param->_nb_rename_unit];
29
30    Tcontrol_t spr_write_val       [_param->_nb_front_end][_param->_max_nb_context];
31    Tcontrol_t spr_write_sr_f_val  [_param->_nb_front_end][_param->_max_nb_context];
32    Tcontrol_t spr_write_sr_f      [_param->_nb_front_end][_param->_max_nb_context];
33    Tcontrol_t spr_write_sr_cy_val [_param->_nb_front_end][_param->_max_nb_context];
34    Tcontrol_t spr_write_sr_cy     [_param->_nb_front_end][_param->_max_nb_context];
35    Tcontrol_t spr_write_sr_ov_val [_param->_nb_front_end][_param->_max_nb_context];
36    Tcontrol_t spr_write_sr_ov     [_param->_nb_front_end][_param->_max_nb_context];
37
38    // Initialisation
39    for (uint32_t i=0; i<_param->_nb_bank; i++)
40      internal_BANK_RETIRE_VAL  [i] = false;
41
42    for (uint32_t i=0; i<_param->_nb_rename_unit; i++)
43      {
44        num_inst_retire [i] = 0;
45        can_retire      [i] = true ;
46        for (uint32_t j=0; j<_param->_nb_inst_retire[i]; j++)
47          retire_val [i][j] = false;
48      }
49    for (uint32_t i=0; i<_param->_nb_front_end; ++i)
50      for (uint32_t j=0; j<_param->_nb_context[i]; ++j)
51        {
52          spr_write_val [i][j] = 0;
53          spr_write_sr_f_val  [i][j] = 0;
54          spr_write_sr_cy_val [i][j] = 0;
55          spr_write_sr_ov_val [i][j] = 0;
56
57        }
58
59    // Scan Top of each bank
60    internal_BANK_RETIRE_HEAD = reg_NUM_BANK_HEAD;
61    for (uint32_t i=0; i<_param->_nb_bank; i++)
62      {
63        uint32_t num_bank = (internal_BANK_RETIRE_HEAD+i)%_param->_nb_bank;
64
65        // Test if have instruction
66        if (not _rob[num_bank].empty())
67          {
68            // Scan all instruction in windows and test if instruction is speculative
69            entry_t  * entry = _rob [num_bank].front();
70            uint32_t   x     = entry->rename_unit_id;
71            uint32_t   y     = num_inst_retire [x];
72            bool       bypass= false;
73            // test if :
74            //  * can retire (all previous instruction is retired)
75            //  * all structure is ok (not busy)
76            if (can_retire [x] and // in-order
77                (y < _param->_nb_inst_retire [x]) and
78                PORT_READ(in_RETIRE_ACK [x][y])) // not busy
79              {
80                rob_state_t state        = entry->state;
81                Tcontext_t  front_end_id = entry->front_end_id;
82                Tcontext_t  context_id   = entry->context_id; 
83               
84                  if ((state == ROB_END_OK         ) or
85                      (state == ROB_END_KO         ) or
86                      (state == ROB_END_BRANCH_MISS) or
87                      (state == ROB_END_LOAD_MISS  ) or
88                      (state == ROB_END_MISS       )//  or
89//                    (state == ROB_END_EXCEPTION)
90                      )
91                    {
92                      Tcontrol_t         write_re       = entry->write_re;
93                      Tspecial_address_t num_reg_re_log = entry->num_reg_re_log;
94                     
95                      // if state is ok, when write flags in the SR regsiters
96                      bool spr_write_ack = true;
97                     
98                      // Write in SR the good flag
99                      if ((state == ROB_END_OK  ) and write_re)
100                        // ROB_END_BRANCH_MISS is a valid branch instruction but don't modify RE
101                        {
102                          spr_write_ack = PORT_READ(in_SPR_WRITE_ACK [front_end_id][context_id]);
103                         
104                          // retire_ack is set !!!
105                          spr_write_val       [front_end_id][context_id] = 1;
106                         
107                          Tspecial_data_t flags = entry->flags;
108                         
109                          switch (num_reg_re_log)
110                            {
111                            case SPR_LOGIC_SR_F     : 
112                              {
113                                spr_write_sr_f_val  [front_end_id][context_id] = 1;
114                                spr_write_sr_f      [front_end_id][context_id] = (flags & FLAG_F )!=0;
115                               
116                                break;
117                              }
118                            case SPR_LOGIC_SR_CY_OV :
119                              {
120                                spr_write_sr_cy_val [front_end_id][context_id] = 1;
121                                spr_write_sr_ov_val [front_end_id][context_id] = 1;     
122                                spr_write_sr_cy     [front_end_id][context_id] = (flags & FLAG_CY)!=0;
123                                spr_write_sr_ov     [front_end_id][context_id] = (flags & FLAG_OV)!=0;
124                               
125                                break;
126                              }
127                            default : 
128                              {
129#ifdef DEBUG_TEST
130                                throw ERRORMORPHEO(FUNCTION,_("Invalid num_reg_re_log.\n"));
131#endif
132                              }
133                            }
134                        }
135                     
136                      // find an instruction can be retire, and in order
137                     
138                      if (spr_write_ack)
139                        {
140                          retire_val [x][y] = 1;
141                          num_inst_retire [x] ++;
142                          internal_BANK_RETIRE_VAL [num_bank] = true;
143                        }
144                     
145                      internal_BANK_RETIRE_NUM_RENAME_UNIT [num_bank] = x;
146                      internal_BANK_RETIRE_NUM_INST        [num_bank] = y;
147                     
148                      if (_param->_have_port_front_end_id)
149                      PORT_WRITE(out_RETIRE_FRONT_END_ID          [x][y], front_end_id                );
150                      if (_param->_have_port_context_id)
151                      PORT_WRITE(out_RETIRE_CONTEXT_ID            [x][y], context_id                  );
152//                    PORT_WRITE(out_RETIRE_RENAME_UNIT_ID        [x][y], entry->rename_unit_id       );
153                      PORT_WRITE(out_RETIRE_USE_STORE_QUEUE       [x][y], entry->use_store_queue      );
154                      PORT_WRITE(out_RETIRE_USE_LOAD_QUEUE        [x][y], entry->use_load_queue       );
155                      PORT_WRITE(out_RETIRE_STORE_QUEUE_PTR_WRITE [x][y], entry->store_queue_ptr_write);
156                      if (_param->_have_port_load_queue_ptr)
157                      PORT_WRITE(out_RETIRE_LOAD_QUEUE_PTR_WRITE  [x][y], entry->load_queue_ptr_write );
158//                       PORT_WRITE(out_RETIRE_READ_RA               [x][y], entry->read_ra              );
159//                       PORT_WRITE(out_RETIRE_NUM_REG_RA_PHY        [x][y], entry->num_reg_ra_phy       );
160//                       PORT_WRITE(out_RETIRE_READ_RB               [x][y], entry->read_rb              );
161//                       PORT_WRITE(out_RETIRE_NUM_REG_RB_PHY        [x][y], entry->num_reg_rb_phy       );
162//                       PORT_WRITE(out_RETIRE_READ_RC               [x][y], entry->read_rc              );
163//                       PORT_WRITE(out_RETIRE_NUM_REG_RC_PHY        [x][y], entry->num_reg_rc_phy       );
164                      PORT_WRITE(out_RETIRE_WRITE_RD              [x][y], entry->write_rd             );
165                      PORT_WRITE(out_RETIRE_NUM_REG_RD_LOG        [x][y], entry->num_reg_rd_log       );
166                      PORT_WRITE(out_RETIRE_NUM_REG_RD_PHY_OLD    [x][y], entry->num_reg_rd_phy_old   );
167                      PORT_WRITE(out_RETIRE_NUM_REG_RD_PHY_NEW    [x][y], entry->num_reg_rd_phy_new   );
168                      PORT_WRITE(out_RETIRE_WRITE_RE              [x][y], write_re                    );
169                      PORT_WRITE(out_RETIRE_NUM_REG_RE_LOG        [x][y], num_reg_re_log              );
170                      PORT_WRITE(out_RETIRE_NUM_REG_RE_PHY_OLD    [x][y], entry->num_reg_re_phy_old   );
171                      PORT_WRITE(out_RETIRE_NUM_REG_RE_PHY_NEW    [x][y], entry->num_reg_re_phy_new   );
172
173                      // Event -> rob must be manage this event
174                      if ((state == ROB_END_BRANCH_MISS) or
175                          (state == ROB_END_LOAD_MISS))
176                        can_retire [x] = false;
177                    }
178
179                  bypass = ((state == ROB_END              ) or
180                            (state == ROB_STORE_OK         ) or
181                            (state == ROB_STORE_KO         ) or
182                            (state == ROB_STORE_OK_WAIT_END) or
183                            (state == ROB_STORE_KO_WAIT_END));
184                 
185                  uint32_t packet = ((entry->ptr << _param->_shift_num_slot) | num_bank);
186
187                  // if future event, don't update after this event
188                  if (reg_EVENT_STOP [front_end_id][context_id] and
189                      (reg_EVENT_PACKET [entry->front_end_id][entry->context_id]  == packet))
190                    bypass = false;
191              }
192
193            // Retire "in-order"
194            can_retire [x]  &= (retire_val [x][y] or bypass);
195          }
196      }
197   
198    for (uint32_t i=0; i<_param->_nb_rename_unit; i++)
199      for (uint32_t j=0; j<_param->_nb_inst_retire[i]; j++)
200        PORT_WRITE(out_RETIRE_VAL [i][j],retire_val [i][j]);
201
202    for (uint32_t i=0; i<_param->_nb_front_end; ++i)
203      for (uint32_t j=0; j<_param->_nb_context[i]; ++j)
204        {
205          PORT_WRITE(out_SPR_WRITE_VAL       [i][j], spr_write_val       [i][j]);
206          PORT_WRITE(out_SPR_WRITE_SR_F_VAL  [i][j], spr_write_sr_f_val  [i][j]);
207          PORT_WRITE(out_SPR_WRITE_SR_F      [i][j], spr_write_sr_f      [i][j]);
208          PORT_WRITE(out_SPR_WRITE_SR_CY_VAL [i][j], spr_write_sr_cy_val [i][j]);
209          PORT_WRITE(out_SPR_WRITE_SR_CY     [i][j], spr_write_sr_cy     [i][j]);
210          PORT_WRITE(out_SPR_WRITE_SR_OV_VAL [i][j], spr_write_sr_ov_val [i][j]);
211          PORT_WRITE(out_SPR_WRITE_SR_OV     [i][j], spr_write_sr_ov     [i][j]);
212        }
213
214    log_end(Commit_unit,FUNCTION);
215  };
216
217}; // end namespace commit_unit
218}; // end namespace ooo_engine
219}; // end namespace multi_ooo_engine
220}; // end namespace core
221}; // end namespace behavioural
222}; // end namespace morpheo             
223#endif
Note: See TracBrowser for help on using the repository browser.