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

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

1) Add test and configuration
2) Fix Bug
3) Add log file in load store unit
4) Fix Bug in environment

  • Property svn:keywords set to Id
File size: 75.1 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id: Commit_unit_transition.cpp 124 2009-06-17 12:11:25Z rosiere $
4 *
5 * [ Description ]
6 *
7 */
8
9#include "Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Commit_unit/include/Commit_unit.h"
10#include "Behavioural/include/Simulation.h"
11
12namespace morpheo                    {
13namespace behavioural {
14namespace core {
15namespace multi_ooo_engine {
16namespace ooo_engine {
17namespace commit_unit {
18 
19#undef  FUNCTION
20#define FUNCTION "Commit_unit::transition"
21  void Commit_unit::transition (void)
22  {
23    log_begin(Commit_unit,FUNCTION);
24    log_function(Commit_unit,FUNCTION,_name.c_str());
25
26    if (PORT_READ(in_NRESET) == 0)
27      {
28        // Clear all bank
29        for (uint32_t i=0; i<_param->_nb_bank; ++i)
30          {
31            while(not _rob[i].empty())
32              {
33                delete _rob[i].front();
34                _rob[i].pop_front();
35              }
36            reg_BANK_PTR [i] = 0;
37          }
38
39        // Reset pointer
40        reg_NUM_BANK_HEAD = 0;
41        reg_NUM_BANK_TAIL = 0;
42        reg_NUM_PTR_TAIL  = 0;
43
44        // Reset counter
45        for (uint32_t i=0; i<_param->_nb_front_end; i++)
46          for (uint32_t j=0; j<_param->_nb_context [i]; j++)
47            {
48              _nb_cycle_idle            [i][j] = 0;
49
50              reg_NB_INST_COMMIT_ALL    [i][j] = 0;
51              reg_NB_INST_COMMIT_MEM    [i][j] = 0;
52                                       
53              reg_EVENT_STATE           [i][j] = COMMIT_EVENT_STATE_NO_EVENT;
54//            reg_EVENT_FLUSH           [i][j] = false;
55//            reg_EVENT_STOP            [i][j] = false;
56              reg_EVENT_NB_INST         [i][j] = 0;
57              reg_EVENT_LAST            [i][j] = false;
58
59              reg_EVENT_NEXT_STOP       [i][j] = false;
60
61//            reg_PC_PREVIOUS           [i][j] = (0x100-4)>>2;
62              reg_PC_CURRENT            [i][j] = (0x100  )>>2;
63              reg_PC_CURRENT_IS_DS      [i][j] = 0;
64              reg_PC_CURRENT_IS_DS_TAKE [i][j] = 0;
65              reg_PC_NEXT               [i][j] = (0x100+4)>>2;
66            }
67
68        // Reset priority algorithm
69        _priority_insert->reset();
70      }
71    else
72      {
73        // Increase number idle cycle
74        for (uint32_t i=0; i<_param->_nb_front_end; i++)
75          for (uint32_t j=0; j<_param->_nb_context [i]; j++)
76            _nb_cycle_idle [i][j] ++;
77
78        // Compute next priority
79        _priority_insert->transition();
80
81        // ===================================================================
82        // =====[ GARBAGE COLLECTOR ]=========================================
83        // ===================================================================
84        for (uint32_t i=0; i<_param->_nb_front_end; i++)
85          for (uint32_t j=0; j<_param->_nb_context [i]; j++)
86            {
87              // Test if can_restart : (can_restart is to signal at the state than the decod_queue is empty)
88              //   *     no previous can_restart (trap for one)
89              //   * and decod_queue is empty
90              //   * and have an event or have a futur event
91//               if (not reg_EVENT_CAN_RESTART [i][j] and
92//                    (PORT_READ(in_NB_INST_DECOD_ALL [i][j]) == 0) and
93//                    (reg_EVENT_STOP [i][j] or (reg_EVENT_STATE [i][j] != COMMIT_EVENT_STATE_NO_EVENT)))
94//                 reg_EVENT_CAN_RESTART [i][j] = true;
95
96              // Test event state
97              switch (reg_EVENT_STATE [i][j])
98                {
99                case COMMIT_EVENT_STATE_EVENT    : 
100                  {
101                    // Have an event, test if all composant have ack
102                    if (internal_RETIRE_EVENT_VAL [i][j] and in_RETIRE_EVENT_ACK [i][j])
103                      {
104                        // A minor optimisation : test if wait_decod is previously empty.
105//                         if (not reg_EVENT_CAN_RESTART [i][j])
106//                           reg_EVENT_STATE [i][j] = COMMIT_EVENT_STATE_WAIT_DECOD;
107//                         else
108                          reg_EVENT_STATE [i][j] = COMMIT_EVENT_STATE_WAIT_END; 
109                      }
110                   
111                    break;
112                  }
113//                 case COMMIT_EVENT_STATE_WAIT_DECOD :
114//                   {
115//                     // Wait flush of decod_queue.
116//                     // Test if can restart now
117//                     if (reg_EVENT_CAN_RESTART [i][j])
118//                       {
119//                         //reg_EVENT_FLUSH [i][j] = false;
120
121//                         // A minor optimisation : test if the last element is already retire
122//                         if (not reg_EVENT_LAST [i][j])
123//                           reg_EVENT_STATE [i][j] = COMMIT_EVENT_STATE_WAIT_END;
124//                         else
125//                           reg_EVENT_STATE [i][j] = COMMIT_EVENT_STATE_END;
126//                       }
127//                     break;
128//                   }
129
130//                 case COMMIT_EVENT_STATE_WAIT_END :
131//                   {
132//                     // Wait the flush of Re Order Buffer.
133//                     // Test if the last element is retire
134//                     if (reg_EVENT_LAST [i][j])
135//                       reg_EVENT_STATE [i][j] = COMMIT_EVENT_STATE_END ;
136                   
137//                     break;
138//                   }
139//                 case COMMIT_EVENT_STATE_END      :
140//                   {
141//                     // Just one cycle
142                   
143//                     // flush of re order buffer is finish
144//                     reg_EVENT_LAST  [i][j] = false;
145
146//                     if (not reg_EVENT_NEXT_STOP [i][j])
147//                       reg_EVENT_STATE [i][j] = COMMIT_EVENT_STATE_NO_EVENT;
148//                     else
149//                       {
150//                         reg_EVENT_NEXT_STOP [i][j] = false;
151//                         reg_EVENT_PACKET [i][j] = reg_EVENT_NEXT_PACKET [i][j];
152//                         reg_EVENT_STATE         [i][j] = COMMIT_EVENT_STATE_NOT_YET_EVENT;
153// //                      reg_EVENT_STOP          [i][j] = true;
154//                         reg_EVENT_LAST_NUM_BANK [i][j] = ((reg_NUM_BANK_TAIL==0)?_param->_nb_bank:reg_NUM_BANK_TAIL)-1;
155//                         reg_EVENT_LAST_NUM_PTR  [i][j] = reg_NUM_PTR_TAIL;
156//                       }
157
158//                     break;
159//                   }
160
161
162                case COMMIT_EVENT_STATE_WAIT_END : 
163                  {
164                    // Wait the flush of Re Order Buffer.
165                    // Test if the last element is retire
166                    if (reg_EVENT_LAST [i][j])
167                      {
168                        // flush of re order buffer is finish
169                        reg_EVENT_LAST  [i][j] = false;
170                       
171                        if (not reg_EVENT_NEXT_STOP [i][j])
172                          reg_EVENT_STATE [i][j] = COMMIT_EVENT_STATE_NO_EVENT;
173                        else
174                          {
175                            reg_EVENT_STATE         [i][j] = COMMIT_EVENT_STATE_NOT_YET_EVENT;
176
177                            reg_EVENT_NEXT_STOP     [i][j] = false;
178                            reg_EVENT_PACKET        [i][j] = reg_EVENT_NEXT_PACKET [i][j];
179                            reg_EVENT_NB_INST       [i][j] = reg_NB_INST_COMMIT_ALL [i][j];
180                          //reg_EVENT_STOP          [i][j] = true;
181                            reg_EVENT_LAST_NUM_BANK [i][j] = ((reg_NUM_BANK_TAIL==0)?_param->_nb_bank:reg_NUM_BANK_TAIL)-1;
182                            reg_EVENT_LAST_NUM_PTR  [i][j] = reg_NUM_PTR_TAIL;
183                          }
184                      }
185                    break;
186                  }
187
188                  //case COMMIT_EVENT_STATE_NO_EVENT :
189                  //case COMMIT_EVENT_STATE_NOT_YET_EVENT :
190                default : break;
191                }
192            }
193
194        // ===================================================================
195        // =====[ INSERT ]====================================================
196        // ===================================================================
197        {
198//           for (uint32_t i=0; i<_param->_nb_rename_unit; i++)
199//             for (uint32_t j=0; j<_param->_nb_inst_insert[i]; j++)
200//               log_printf(TRACE,Commit_unit,FUNCTION,"  * INSERT_VAL        [%d][%d] : %d",i,j,PORT_READ(in_INSERT_VAL [i][j]));
201             
202          // variable to count instruction insert
203          uint32_t nb_insert = 0;
204         
205          for (uint32_t i=0; i<_param->_nb_bank; i++)
206            {
207              // compute first bank number
208              uint32_t num_bank = (reg_NUM_BANK_TAIL+i)%_param->_nb_bank;
209             
210              if (internal_BANK_INSERT_VAL [num_bank])
211                {
212                  // get rename unit source and instruction.
213                  uint32_t x = internal_BANK_INSERT_NUM_RENAME_UNIT [num_bank];
214                  uint32_t y = internal_BANK_INSERT_NUM_INST        [num_bank];
215                 
216                  // Test if an instruction is valid
217                  // (all in_order insert combinatory is in rename_unit )
218                  if (PORT_READ(in_INSERT_VAL [x][y]))
219                    {
220                      log_printf(TRACE,Commit_unit,FUNCTION,"  * INSERT            [%d][%d]",x,y);
221                     
222                      // get information
223                      Tcontext_t   front_end_id = (_param->_have_port_front_end_id)?PORT_READ(in_INSERT_FRONT_END_ID [x][y]):0;
224                      Tcontext_t   context_id   = (_param->_have_port_context_id  )?PORT_READ(in_INSERT_CONTEXT_ID   [x][y]):0;
225                      Ttype_t      type         = PORT_READ(in_INSERT_TYPE         [x][y]);
226                      Toperation_t operation    = PORT_READ(in_INSERT_OPERATION    [x][y]);
227                      bool         is_store     = is_operation_memory_store(operation);
228                     
229                      Texception_t exception    = PORT_READ(in_INSERT_EXCEPTION    [x][y]);
230                      Tcontrol_t   no_execute   = PORT_READ(in_INSERT_NO_EXECUTE   [x][y]);
231                     
232                      log_printf(TRACE,Commit_unit,FUNCTION,"    * front_end_id   : %d",front_end_id);
233                      log_printf(TRACE,Commit_unit,FUNCTION,"    * context_id     : %d",context_id);
234                      log_printf(TRACE,Commit_unit,FUNCTION,"    * type           : %s",toString(type).c_str());
235                      log_printf(TRACE,Commit_unit,FUNCTION,"    * operation      : %d",operation );
236                      log_printf(TRACE,Commit_unit,FUNCTION,"    * exception      : %d",exception );
237                     
238                      // Create new entry and write information
239                      entry_t * entry = new entry_t;
240                      uint32_t  ptr   = reg_BANK_PTR [num_bank];
241
242                      entry->ptr                     = ptr;
243                      entry->front_end_id            = front_end_id;
244                      entry->context_id              = context_id  ;
245                      entry->rename_unit_id          = x;
246                      entry->depth                   = (_param->_have_port_depth)?PORT_READ(in_INSERT_DEPTH [x][y]):0;
247                      entry->type                    = type;
248                      entry->operation               = operation;
249                      entry->is_delay_slot           = PORT_READ(in_INSERT_IS_DELAY_SLOT         [x][y]);
250//                    entry->address                 = PORT_READ(in_INSERT_ADDRESS               [x][y]);
251                      entry->exception               = exception;
252                      entry->exception_use           = PORT_READ(in_INSERT_EXCEPTION_USE         [x][y]);
253                      entry->use_store_queue         = (type == TYPE_MEMORY) and (    is_store) and (not no_execute);
254                      entry->use_load_queue          = (type == TYPE_MEMORY) and (not is_store) and (not no_execute);
255                      entry->store_queue_ptr_write   = PORT_READ(in_INSERT_STORE_QUEUE_PTR_WRITE [x][y]);
256                      entry->load_queue_ptr_write    = (_param->_have_port_load_queue_ptr)?PORT_READ(in_INSERT_LOAD_QUEUE_PTR_WRITE [x][y]):0;
257#ifdef DEBUG       
258                      entry->read_ra                 = PORT_READ(in_INSERT_READ_RA               [x][y]);
259                      entry->num_reg_ra_log          = PORT_READ(in_INSERT_NUM_REG_RA_LOG        [x][y]);
260                      entry->num_reg_ra_phy          = PORT_READ(in_INSERT_NUM_REG_RA_PHY        [x][y]);
261                      entry->read_rb                 = PORT_READ(in_INSERT_READ_RB               [x][y]);
262                      entry->num_reg_rb_log          = PORT_READ(in_INSERT_NUM_REG_RB_LOG        [x][y]);
263                      entry->num_reg_rb_phy          = PORT_READ(in_INSERT_NUM_REG_RB_PHY        [x][y]);
264                      entry->read_rc                 = PORT_READ(in_INSERT_READ_RC               [x][y]);
265                      entry->num_reg_rc_log          = PORT_READ(in_INSERT_NUM_REG_RC_LOG        [x][y]);
266                      entry->num_reg_rc_phy          = PORT_READ(in_INSERT_NUM_REG_RC_PHY        [x][y]);
267#endif               
268                      entry->write_rd                = PORT_READ(in_INSERT_WRITE_RD              [x][y]);
269                      entry->num_reg_rd_log          = PORT_READ(in_INSERT_NUM_REG_RD_LOG        [x][y]);
270                      entry->num_reg_rd_phy_old      = PORT_READ(in_INSERT_NUM_REG_RD_PHY_OLD    [x][y]);
271                      entry->num_reg_rd_phy_new      = PORT_READ(in_INSERT_NUM_REG_RD_PHY_NEW    [x][y]);
272                      entry->write_re                = PORT_READ(in_INSERT_WRITE_RE              [x][y]);
273                      entry->num_reg_re_log          = PORT_READ(in_INSERT_NUM_REG_RE_LOG        [x][y]);
274                      entry->num_reg_re_phy_old      = PORT_READ(in_INSERT_NUM_REG_RE_PHY_OLD    [x][y]);
275                      entry->num_reg_re_phy_new      = PORT_READ(in_INSERT_NUM_REG_RE_PHY_NEW    [x][y]);
276                      entry->no_sequence             = type == TYPE_BRANCH;
277//                    entry->speculative             = true;
278#ifdef DEBUG       
279                      entry->address                 = PORT_READ(in_INSERT_ADDRESS               [x][y]);
280#endif               
281                      entry->address_next            = PORT_READ(in_INSERT_ADDRESS_NEXT          [x][y]);
282#ifdef DEBUG       
283                      entry->cycle_rob_in            = simulation_cycle();
284                      entry->cycle_commit            = simulation_cycle();
285#endif     
286           
287                      // Test if exception :
288                      //  * yes : no execute instruction, wait ROB Head
289                      //  * no  : test if no_execute (== instruction is flushed)
290                      //          else test type
291                      //            * BRANCH : l.j   -> branch is ended
292                      //                       other -> wait the execution end of branchment
293                      //            * MEMORY : store -> wait store is at head of ROB
294                      //                       other -> wait end of instruction
295                      //            * OTHER
296           
297                      {
298                        if (exception == EXCEPTION_NONE)
299                          {
300                            // no_execute : l.j, l.nop, l.rfe
301                           
302                            log_printf(TRACE,Commit_unit,FUNCTION,"    * no_execute     : %d",no_execute);
303                           
304                            switch (type)
305                              {
306                              case TYPE_BRANCH : {entry->state=(no_execute==1)?ROB_BRANCH_COMPLETE:ROB_BRANCH_WAIT_END  ; break;}
307                              case TYPE_MEMORY : {entry->state=(no_execute==1)?ROB_END_OK_SPECULATIVE:(entry->state=(is_store  ==1)?ROB_STORE_WAIT_END_OK:ROB_OTHER_WAIT_END); break;}
308                              default          : {entry->state=(no_execute==1)?ROB_END_OK_SPECULATIVE:ROB_OTHER_WAIT_END; break;}
309                              }
310                          }
311                        else
312                          {
313                            // Have an exception : wait head of ROB
314                            // in_INSERT_NO_EXECUTE [x][y] : l.sys, l.trap
315                           
316                            entry->state = ROB_END_EXCEPTION_WAIT_HEAD;
317                          }
318                      }
319
320#ifdef STATISTICS
321                      if (usage_is_set(_usage,USE_STATISTICS))
322                        (*_stat_nb_inst_insert [x]) ++;
323#endif
324                   
325                      // Push entry in rob
326                      _rob[num_bank].push_back(entry);
327                     
328                      // Update counter and pointer
329                      reg_NB_INST_COMMIT_ALL [front_end_id][context_id] ++;
330                      if (type == TYPE_MEMORY)
331                        reg_NB_INST_COMMIT_MEM [front_end_id][context_id] ++;
332                     
333
334                      // flush = present event or future event.
335                      //  * present event = don't can restart
336
337//                       bool flush = reg_EVENT_FLUSH [front_end_id][context_id];
338
339//                       bool flush = (((reg_EVENT_STATE [front_end_id][context_id] == COMMIT_EVENT_STATE_EVENT) or
340//                                      (reg_EVENT_STATE [front_end_id][context_id] == COMMIT_EVENT_STATE_WAIT_DECOD)) or
341//                                     (reg_EVENT_STOP [front_end_id][context_id]));
342                     
343                      // New instruction from decod_queue. Flush if :
344                      //     * future event (instruction don't need execute because they are a previous event (miss load/branch or exception))
345                      //     * or present_event
346                      //   * and not can_restart (previous empty decod queue), because between the event_stop (branch_complete) and the state event (miss in head), many cycle is occured.
347//                       bool flush = ((// present event
348//                                      ((reg_EVENT_STATE [front_end_id][context_id] == COMMIT_EVENT_STATE_EVENT) or
349//                                       (reg_EVENT_STATE [front_end_id][context_id] == COMMIT_EVENT_STATE_WAIT_DECOD)
350//                                       ) or
351//                                      futur event
352//                                      reg_EVENT_STOP [front_end_id][context_id])
353//                                     // can't restart
354//                                     and not reg_EVENT_CAN_RESTART[front_end_id][context_id]
355//                                     );
356
357//                       if (flush)
358//                         {
359//                           // A new invalid instruction is push in rob -> new last instruction
360//                           reg_EVENT_LAST          [front_end_id][context_id] = false;
361//                           reg_EVENT_LAST_NUM_BANK [front_end_id][context_id] = num_bank;
362//                           reg_EVENT_LAST_NUM_PTR  [front_end_id][context_id] = ptr;
363//                         }
364                     
365                      // Update pointer
366                      reg_NUM_PTR_TAIL  = ptr;
367                      reg_BANK_PTR [num_bank]  = (reg_BANK_PTR [num_bank]+1)%_param->_size_bank;
368                      nb_insert ++;
369                    }
370                }
371            }
372          // Update pointer
373          reg_NUM_BANK_TAIL = (reg_NUM_BANK_TAIL+nb_insert)%_param->_nb_bank;
374        }
375
376        // ===================================================================
377        // =====[ COMMIT ]====================================================
378        // ===================================================================
379
380#ifdef STATISTICS
381        if (usage_is_set(_usage,USE_STATISTICS))
382          (*_stat_nb_inst_commit_conflit_access) += internal_BANK_COMMIT_CONFLIT_ACCESS;
383#endif
384
385        // For each commit instruction ...
386        for (uint32_t i=0; i<_param->_nb_bank; i++)
387          for (uint32_t j=0; j<_param->_nb_bank_access_commit; j++)
388            // ... test if an instruction have finish this execution
389            if (internal_BANK_COMMIT_VAL [i][j])
390              {
391                // An instruction is executed -> Change state of this instruction
392
393                // Get information
394                uint32_t x = internal_BANK_COMMIT_NUM_INST [i][j];
395
396                // Test if instruction is valid and is enable
397                // (can be disable if this instruction is reexecute)
398                if (PORT_READ(in_COMMIT_VAL [x]) and PORT_READ(in_COMMIT_WEN [x]))
399                  {
400                    log_printf(TRACE,Commit_unit,FUNCTION,"  * COMMIT            [%d]",x);
401
402#ifdef STATISTICS
403                    if (usage_is_set(_usage,USE_STATISTICS))
404                      (*_stat_nb_inst_commit) ++;
405#endif
406
407                    log_printf(TRACE,Commit_unit,FUNCTION,"    * num_bank              : %d",i);
408
409                    // find the good entry !!!
410                    entry_t *       entry        = internal_BANK_COMMIT_ENTRY [i][j];
411
412                    log_printf(TRACE,Commit_unit,FUNCTION,"    * ptr                   : %d",entry->ptr);
413                                                 
414                  //Toperation_t    operation    = PORT_READ(in_COMMIT_OPERATION   [x]);
415                    Ttype_t         type         = entry->type;
416                    Tcontrol_t      no_sequence  = PORT_READ(in_COMMIT_NO_SEQUENCE [x]);
417
418#if 0
419                    if ((type == TYPE_MEMORY) and no_sequence)
420                      continue;
421#endif             
422
423                    Texception_t    exception    = PORT_READ(in_COMMIT_EXCEPTION   [x]);
424
425                    rob_state_t     state        = entry->state;
426                    Tcontext_t      front_end_id = entry->front_end_id;
427                    Tcontext_t      context_id   = entry->context_id;
428
429                    // change state : test exception_use
430                   
431                    bool have_exception        = false;
432                    bool have_miss_speculation = false;
433
434                    // Test if have an exception ...
435                    if (exception != EXCEPTION_NONE)
436                      {
437                        // Test if the instruction is a load and is a miss speculation
438                        // (load is commit, but they have an dependence with a previous store -> need restart pipeline)
439
440                        have_miss_speculation  = (exception == EXCEPTION_MEMORY_MISS_SPECULATION);
441
442                        //  * Test if the exception generated can be trap by this exception
443                        switch (entry->exception_use)
444                          {
445                            // Have overflow exception if bit overflow enable is set.
446                          case  EXCEPTION_USE_RANGE                    : {have_exception = ((exception == EXCEPTION_RANGE) and PORT_READ(in_SPR_READ_SR_OVE[front_end_id][context_id])); break;}
447                          case  EXCEPTION_USE_MEMORY_WITH_ALIGNMENT    : {have_exception = ((exception == EXCEPTION_BUS_ERROR) or
448                                                                                            (exception == EXCEPTION_DATA_TLB ) or
449                                                                                            (exception == EXCEPTION_DATA_PAGE) or
450                                                                                            (exception == EXCEPTION_ALIGNMENT)); break;};
451                          case  EXCEPTION_USE_MEMORY_WITHOUT_ALIGNMENT : {have_exception = ((exception == EXCEPTION_BUS_ERROR) or
452                                                                                            (exception == EXCEPTION_DATA_TLB ) or
453                                                                                            (exception == EXCEPTION_DATA_PAGE)); break;};
454                          case  EXCEPTION_USE_CUSTOM_0                 : {have_exception = (exception == EXCEPTION_CUSTOM_0); break;}; 
455                          case  EXCEPTION_USE_CUSTOM_1                 : {have_exception = (exception == EXCEPTION_CUSTOM_1); break;}; 
456                          case  EXCEPTION_USE_CUSTOM_2                 : {have_exception = (exception == EXCEPTION_CUSTOM_2); break;}; 
457                          case  EXCEPTION_USE_CUSTOM_3                 : {have_exception = (exception == EXCEPTION_CUSTOM_3); break;}; 
458                          case  EXCEPTION_USE_CUSTOM_4                 : {have_exception = (exception == EXCEPTION_CUSTOM_4); break;}; 
459                          case  EXCEPTION_USE_CUSTOM_5                 : {have_exception = (exception == EXCEPTION_CUSTOM_5); break;}; 
460                          case  EXCEPTION_USE_CUSTOM_6                 : {have_exception = (exception == EXCEPTION_CUSTOM_6); break;}; 
461                            // Case already manage (decod stage -> in insert in ROB)
462                          case  EXCEPTION_USE_TRAP                     : {have_exception = false; exception = EXCEPTION_NONE; break;};
463                          case  EXCEPTION_USE_NONE                     : {have_exception = false; exception = EXCEPTION_NONE; break;}; 
464                          case  EXCEPTION_USE_ILLEGAL_INSTRUCTION      : {have_exception = false; exception = EXCEPTION_NONE; break;};
465                          case  EXCEPTION_USE_SYSCALL                  : {have_exception = false; exception = EXCEPTION_NONE; break;};
466                          default :
467                            {
468                              throw ERRORMORPHEO(FUNCTION,_("Commit : invalid exception_use.\n"));
469                              break;
470                            }
471                          }
472                      }
473
474                    log_printf(TRACE,Commit_unit,FUNCTION,"    * have_exception        : %d",have_exception       ); 
475                    log_printf(TRACE,Commit_unit,FUNCTION,"    * have_miss_speculation : %d",have_miss_speculation);
476
477                   
478                    // Next state depends of previous state
479                    switch (state)
480                      {
481                        // Branch : if no exception, the branchement can be completed
482                      case ROB_BRANCH_WAIT_END : 
483                        {
484                          if (not have_exception)
485                            state = ROB_BRANCH_COMPLETE;
486                          else
487                            state = ROB_END_EXCEPTION_WAIT_HEAD;
488                          break;
489                        }
490                        // Previous event -> set state as execute
491                      case ROB_STORE_KO_WAIT_END :
492                      case ROB_EVENT_WAIT_END  : 
493                        {
494                          state = ROB_END_KO_SPECULATIVE; 
495                          break;
496                        }
497                        // No previous event - Load and other instruction
498                      case ROB_STORE_OK_WAIT_END :
499                      case ROB_OTHER_WAIT_END  : 
500                        {
501                          if (not have_exception)
502                            {
503                              if (not have_miss_speculation)
504                                state = ROB_END_OK_SPECULATIVE;
505                              else
506                                state = ROB_END_LOAD_MISS_SPECULATIVE; 
507                            }
508                          else
509                            state = ROB_END_EXCEPTION_WAIT_HEAD;
510                          break;
511                        }
512                      case ROB_STORE_WAIT_END_OK :
513                        {
514                          if (not have_exception)
515                            state = ROB_STORE_OK;
516                          else
517                            state = ROB_STORE_EVENT;
518                          break;
519                        }
520                      case ROB_STORE_WAIT_END_KO :
521                        {
522//                        if (not have_exception)
523                            state = ROB_STORE_KO;
524//                        else
525//                             state = ROB_END_EXCEPTION_WAIT_HEAD;
526                          break;
527                        }
528
529
530                      default :
531                        {
532                          throw ERRORMORPHEO(FUNCTION,toString(_("Commit [%d] : Bank [%d][%d], invalid state value (%s).\n"),x,i,j,toString(state).c_str()));
533                          break;
534                        }
535                      }
536
537                    // Commit an instruction ...
538                    // Test if have an event (miss_speculation or exception)
539
540                    if (have_exception or have_miss_speculation)
541                      {
542                        // Two case :
543                        // if no previous manage event -> generate an event
544                        // if    previous manage event -> next generate an event
545
546//                      bool flush = reg_EVENT_FLUSH [front_end_id][context_id];
547                        bool flush = ((reg_EVENT_STATE [front_end_id][context_id] == COMMIT_EVENT_STATE_EVENT) or
548//                                    (reg_EVENT_STATE [front_end_id][context_id] == COMMIT_EVENT_STATE_WAIT_DECOD) or
549                                      (reg_EVENT_STATE [front_end_id][context_id] == COMMIT_EVENT_STATE_WAIT_END)//  or
550//                                       (reg_EVENT_STATE [front_end_id][context_id] == COMMIT_EVENT_STATE_END)
551                                      );
552                       
553                        uint32_t packet = ((entry->ptr << _param->_shift_num_slot) | i);
554                        uint32_t _top   = ((_rob[ reg_NUM_BANK_HEAD].front()->ptr << _param->_shift_num_slot) | reg_NUM_BANK_HEAD);
555
556                        log_printf(TRACE,Commit_unit,FUNCTION,"    * flush                 : %d",flush); 
557                        log_printf(TRACE,Commit_unit,FUNCTION,"    * packet                : %d",packet);
558                           
559                        if (not flush)
560                          {
561                            bool     can    = true;
562                            // test have a previous event detected (event_stop = 1)
563                            // if yes, test if the actual event if "before (in order)" that the previous event
564                            if (reg_EVENT_STATE [front_end_id][context_id] == COMMIT_EVENT_STATE_NOT_YET_EVENT)
565                              {
566                                // Compare packet_id (by construction instruction is insert in order by increase packet_id)
567                               
568                                uint32_t _old = reg_EVENT_PACKET [front_end_id][context_id];
569                                uint32_t _new = packet;
570                                if (_old < _top) _old = _old+_param->_size_queue;
571                                if (_new < _top) _new = _new+_param->_size_queue;
572                                if (_new < _old) reg_EVENT_PACKET [front_end_id][context_id] = packet;
573                                else can = false;
574                              }
575                            else
576                              reg_EVENT_PACKET [front_end_id][context_id] = packet;
577                           
578                            if (can)
579                              {
580                                // have an error, stop issue instruction
581                                reg_EVENT_STATE         [front_end_id][context_id] = COMMIT_EVENT_STATE_NOT_YET_EVENT;
582
583                                reg_EVENT_NB_INST       [front_end_id][context_id] = reg_NB_INST_COMMIT_ALL [front_end_id][context_id];
584
585                              //reg_EVENT_STOP          [front_end_id][context_id] = true;
586                               
587                                reg_EVENT_LAST_NUM_BANK [front_end_id][context_id] = ((reg_NUM_BANK_TAIL==0)?_param->_nb_bank:reg_NUM_BANK_TAIL)-1;
588                                reg_EVENT_LAST_NUM_PTR  [front_end_id][context_id] = reg_NUM_PTR_TAIL;
589                              }
590                          }
591                        else
592                          {
593                            bool find = true;
594
595                            log_printf(TRACE,Commit_unit,FUNCTION,"    * reg_EVENT_NEXT_STOP   : %d",reg_EVENT_NEXT_STOP  [front_end_id][context_id]); 
596                            log_printf(TRACE,Commit_unit,FUNCTION,"    * reg_EVENT_NEXT_PACKET : %d",reg_EVENT_NEXT_PACKET[front_end_id][context_id]); 
597
598                            // already manage an event.
599                            if (reg_EVENT_NEXT_STOP [front_end_id][context_id])
600                              {
601                                // after last ?
602                                uint32_t _old = reg_EVENT_NEXT_PACKET [front_end_id][context_id];
603                                uint32_t _new = packet;
604
605                                log_printf(TRACE,Commit_unit,FUNCTION,"    * _top                  : %d",_top ); 
606                                log_printf(TRACE,Commit_unit,FUNCTION,"    * _old (before)         : %d",_old ); 
607                                log_printf(TRACE,Commit_unit,FUNCTION,"    * _new (before)         : %d",_new ); 
608
609                                if (_old < _top) _old = _old+_param->_size_queue;
610                                if (_new < _top) _new = _new+_param->_size_queue;
611                                if (_new > _old) reg_EVENT_NEXT_PACKET [front_end_id][context_id] = packet;
612                                else find = false;
613
614                                log_printf(TRACE,Commit_unit,FUNCTION,"    * _old (after)          : %d",_old ); 
615                                log_printf(TRACE,Commit_unit,FUNCTION,"    * _new (after)          : %d",_new ); 
616                              }
617                            else
618                              {
619                                // after last ?
620                                uint32_t _old = ((reg_EVENT_LAST_NUM_PTR [front_end_id][context_id] << _param->_shift_num_slot) | reg_EVENT_LAST_NUM_BANK [front_end_id][context_id]);
621                                uint32_t _new = packet;
622
623                                log_printf(TRACE,Commit_unit,FUNCTION,"    * _top                  : %d",_top ); 
624                                log_printf(TRACE,Commit_unit,FUNCTION,"    * _old (before)         : %d",_old ); 
625                                log_printf(TRACE,Commit_unit,FUNCTION,"    * _new (before)         : %d",_new ); 
626
627                                if (_old < _top) _old = _old+_param->_size_queue;
628                                if (_new < _top) _new = _new+_param->_size_queue;
629                                if (_new > _old) reg_EVENT_NEXT_PACKET [front_end_id][context_id] = packet;
630                                else find = false;
631
632                                log_printf(TRACE,Commit_unit,FUNCTION,"    * _old (after)          : %d",_old ); 
633                                log_printf(TRACE,Commit_unit,FUNCTION,"    * _new (after)          : %d",_new ); 
634                              }
635
636                            log_printf(TRACE,Commit_unit,FUNCTION,"    * find                  : %d",find); 
637
638                            if (find)
639                            reg_EVENT_NEXT_STOP [front_end_id][context_id] = true; // in all case : need stop
640                          }
641                      }
642
643                    // Update Re Order Buffer
644                    entry->state        = state;
645                    entry->exception    = exception;
646                    entry->flags        = PORT_READ(in_COMMIT_FLAGS       [x]);
647                    entry->no_sequence  = no_sequence;
648                    // jalr, jr : address_dest is in register
649                    if ((       type      == TYPE_BRANCH) and
650                        (entry->operation == OPERATION_BRANCH_L_JALR) and
651                        (entry->read_rb))
652                    entry->address_next = PORT_READ(in_COMMIT_ADDRESS     [x]);
653
654#ifdef DEBUG
655                    entry->load_data               = PORT_READ(in_COMMIT_ADDRESS [x]);
656                    entry->cycle_commit            = simulation_cycle();
657#endif
658                  }
659              }
660
661        // ===================================================================
662        // =====[ RETIRE ]====================================================
663        // ===================================================================
664        for (uint32_t i=0; i<_param->_nb_bank; i++)
665          {
666            // Compute bank number
667            uint32_t num_bank = (internal_BANK_RETIRE_HEAD+i)%_param->_nb_bank;
668           
669            // Test if have an request
670            if (internal_BANK_RETIRE_VAL [num_bank])
671              {
672                // Take num instruction
673                uint32_t x = internal_BANK_RETIRE_NUM_RENAME_UNIT [num_bank];
674                uint32_t y = internal_BANK_RETIRE_NUM_INST        [num_bank];
675               
676                log_printf(TRACE,Commit_unit,FUNCTION,"  * RETIRE            [%d][%d]",x,y);
677                log_printf(TRACE,Commit_unit,FUNCTION,"    * num_bank     : %d",num_bank     );
678               
679#ifdef DEBUG_TEST
680                if (not PORT_READ(in_RETIRE_ACK [x][y]))
681                  throw ERRORMORPHEO(FUNCTION,_("Retire : retire_ack must be set.\n"));
682#endif
683
684
685#ifdef STATISTICS
686            if (usage_is_set(_usage,USE_STATISTICS))
687              (*_stat_nb_inst_retire [x]) ++;
688               
689#endif
690               
691                // Read information
692                entry_t *   entry        =  _rob [num_bank].front();
693
694                entry->state_old = entry->state;
695                entry->state     = ROB_END;
696              }
697          }
698
699        for (uint32_t i=0; i<_param->_nb_bank; i++)
700          {
701            // Compute bank number
702            bool      can_continue = false;
703            uint32_t  num_bank = reg_NUM_BANK_HEAD;
704           
705            if (not _rob [num_bank].empty ())
706              {
707                entry_t * entry = _rob [num_bank].front();
708               
709                if (entry->state == ROB_END)
710                  {
711                    log_printf(TRACE,Commit_unit,FUNCTION,"  * RETIRE_ROB [%d]",num_bank);
712           
713                    can_continue = true;
714
715                    Tcontext_t  front_end_id = entry->front_end_id;
716                    Tcontext_t  context_id   = entry->context_id  ;
717                    uint32_t    num_thread   = _param->_translate_num_context_to_num_thread [front_end_id][context_id];
718                    rob_state_t state        = entry->state_old;
719                    Ttype_t     type         = entry->type        ;
720                    bool        retire_ok    = false;
721                    uint32_t    packet_id    = ((entry->ptr << _param->_shift_num_slot) | num_bank);
722                   
723                    log_printf(TRACE,Commit_unit,FUNCTION,"    * front_end_id : %d",front_end_id );
724                    log_printf(TRACE,Commit_unit,FUNCTION,"    * context_id   : %d",context_id   );
725                    log_printf(TRACE,Commit_unit,FUNCTION,"    * rob_ptr      : %d",packet_id    );
726                    log_printf(TRACE,Commit_unit,FUNCTION,"    * num_thread   : %d",num_thread   );
727                    log_printf(TRACE,Commit_unit,FUNCTION,"    * type         : %s",toString(type).c_str());
728                    log_printf(TRACE,Commit_unit,FUNCTION,"    * state        : %s",toString(state).c_str());
729                   
730                    // Test if the instruction is valid
731                    // (BRANCH_MISS = instruction branch is valid, but have make an invalid prediction)
732                    // (LOAD_MISS   = instruction load   is valid, but have make an invalid result)
733                    if ((state == ROB_END_OK         ) or
734//                      (state == ROB_END_KO         ) or
735                        (state == ROB_END_BRANCH_MISS) or
736                        (state == ROB_END_LOAD_MISS  )//  or
737//                      (state == ROB_END_MISS       ) or
738//                      (state == ROB_END_EXCEPTION  )
739                        )
740                      {
741                        log_printf(TRACE,Commit_unit,FUNCTION,"    * retire_ok");
742                   
743                        retire_ok = true;
744                   
745                        // Update PC information
746//                      reg_PC_PREVIOUS           [front_end_id][context_id] = reg_PC_CURRENT [front_end_id][context_id];
747                        reg_PC_CURRENT            [front_end_id][context_id] = reg_PC_NEXT    [front_end_id][context_id];
748                        reg_PC_CURRENT_IS_DS      [front_end_id][context_id] = type == TYPE_BRANCH;
749                        reg_PC_CURRENT_IS_DS_TAKE [front_end_id][context_id] = entry->no_sequence;
750                        reg_PC_NEXT               [front_end_id][context_id] = (entry->no_sequence)?(entry->address_next):(reg_PC_CURRENT [front_end_id][context_id]+1);
751                      }
752                   
753                    // Test if have an event
754                    if ((state == ROB_END_BRANCH_MISS) or
755                        (state == ROB_END_LOAD_MISS))
756                      {
757                          reg_EVENT_STATE         [front_end_id][context_id] = COMMIT_EVENT_STATE_EVENT;
758//                        reg_EVENT_STOP          [front_end_id][context_id] = false; // instruction flow can continue
759                          reg_EVENT_LAST          [front_end_id][context_id] = false;
760                          // it the head !
761                          reg_EVENT_PACKET        [front_end_id][context_id] = packet_id;
762                   
763//                           // If event is an load_miss, many instruction can be inserted.
764//                           // -> new last instruction
765//                           if (state == ROB_END_LOAD_MISS)
766//                             {
767// //                             reg_EVENT_CAN_RESTART   [front_end_id][context_id] = false;
768                           
769//                             reg_EVENT_LAST_NUM_BANK [front_end_id][context_id] = ((reg_NUM_BANK_TAIL==0)?_param->_nb_bank:reg_NUM_BANK_TAIL)-1;
770//                             reg_EVENT_LAST_NUM_PTR  [front_end_id][context_id] = reg_NUM_PTR_TAIL;
771//                             }
772                        }
773                   
774                    // Test if this instruction is the last instruction of an event
775                    //   * need event
776                    //   * packet id = last packet id
777//                     for (uint32_t x=0; x<_param->_nb_front_end; x++)
778//                       for (uint32_t y=0; y<_param->_nb_context [x]; y++)
779//                         if (((reg_EVENT_STATE         [x][y] != COMMIT_EVENT_STATE_NO_EVENT     ) and
780//                              (reg_EVENT_STATE         [x][y] != COMMIT_EVENT_STATE_NOT_YET_EVENT)) and
781//                             (reg_EVENT_LAST_NUM_BANK [x][y] == num_bank            ) and
782//                             (reg_EVENT_LAST_NUM_PTR  [x][y] == entry->ptr          ))
783//                           reg_EVENT_LAST [x][y] = true;
784
785
786                    if (reg_EVENT_NB_INST [front_end_id][context_id] > 0)
787                      {
788                        reg_EVENT_NB_INST [front_end_id][context_id] --;
789                        if (reg_EVENT_NB_INST [front_end_id][context_id] == 0)
790                          reg_EVENT_LAST [front_end_id][context_id] = true;
791                      }
792
793                    // Update nb_inst
794                    reg_NB_INST_COMMIT_ALL [front_end_id][context_id] --;
795                    if (type == TYPE_MEMORY)
796                    reg_NB_INST_COMMIT_MEM [front_end_id][context_id] --;
797                   
798                    // Update pointer
799                    reg_NUM_BANK_HEAD = (num_bank+1)%_param->_nb_bank;
800                   
801                    // Reset watch dog timer because have transaction on retire interface
802                    _nb_cycle_idle [front_end_id][context_id] = 0;
803                   
804                    // Increase stop condition
805                    if (retire_ok)
806                      _simulation_nb_instruction_commited [num_thread] ++;
807
808#ifdef STATISTICS
809                    if (usage_is_set(_usage,USE_STATISTICS))
810                      {
811                        if (retire_ok)
812                          {
813                            (*_stat_nb_inst_retire_ok [num_thread]) ++;
814                            (*_stat_nb_inst_type      [type]      ) ++;
815                          }
816                        else
817                          (*_stat_nb_inst_retire_ko [num_thread]) ++;
818                      }
819#endif
820
821#if defined(DEBUG) and defined(DEBUG_Commit_unit) and (DEBUG_Commit_unit == true)
822                    {
823                      // log file
824                      instruction_log_file [num_thread] 
825                        << "[" << simulation_cycle() << "] "
826                        << std::hex
827                        << (entry->address<<2) << " (" << (entry->address) << ") "
828                        << std::dec
829                        << "[" << entry->cycle_rob_in << ", " << entry->cycle_commit << "] "
830                        << "{" << ((retire_ok)?"OK":"KO") << "} ";
831                     
832                      if ((type == TYPE_MEMORY) and  is_operation_memory_load(entry->operation))
833                        instruction_log_file [num_thread] << std::hex << entry->load_data << std::dec;
834                     
835                      instruction_log_file [num_thread] << std::endl;
836                    }
837#endif     
838
839                    // Remove entry
840                    delete entry;
841                    _rob [num_bank].pop_front();
842                  }
843              }
844           
845            if (not can_continue)
846              break; // stop scan
847          }
848
849        // ===================================================================
850        // =====[ REEXECUTE ]=================================================
851        // ===================================================================
852        // Test if have an reexecute instruction (an store in head of rob)
853        for (uint32_t i=0; i<_param->_nb_inst_reexecute; ++i)
854          if (internal_REEXECUTE_VAL [i] and PORT_READ(in_REEXECUTE_ACK [i]))
855            {
856              log_printf(TRACE,Commit_unit,FUNCTION,"  * REEXECUTE         [%d]",i);
857             
858              uint32_t num_bank = internal_REEXECUTE_NUM_BANK [i];
859             
860              entry_t    * entry = _rob [num_bank].front();
861              rob_state_t  state = entry->state;
862             
863              // Change state
864              switch (state)
865                {
866                case ROB_STORE_OK    : {state = ROB_STORE_OK_WAIT_END; break; }
867                case ROB_STORE_KO    : {state = ROB_STORE_KO_WAIT_END; break; }
868                case ROB_STORE_EVENT : {state = ROB_EVENT_WAIT_END; break; }
869                default : {throw ERRORMORPHEO(FUNCTION,_("Reexecute : invalid state value.\n"));}
870                }
871             
872              entry->state = state;
873            }
874       
875        // ===================================================================
876        // =====[ BRANCH_COMPLETE ]===========================================
877        // ===================================================================
878        for (uint32_t i=0; i<_param->_nb_inst_branch_complete; i++)
879          // Test if the prediction_unit have accept the branch complete transaction
880          if (internal_BRANCH_COMPLETE_VAL [i] and PORT_READ(in_BRANCH_COMPLETE_ACK [i]))
881            {
882              log_printf(TRACE,Commit_unit,FUNCTION,"  * BRANCH_COMPLETE   [%d]",i);
883
884              // Read information
885              uint32_t num_bank = internal_BRANCH_COMPLETE_NUM_BANK [i];
886             
887              entry_t   * entry = _rob [num_bank].front();
888
889#ifdef DEBUG_TEST
890              rob_state_t  state = entry->state;
891              if (state != ROB_BRANCH_COMPLETE)
892                throw ERRORMORPHEO(FUNCTION,_("Branch_complete : Invalid state value.\n"));
893#endif
894              Tcontrol_t miss = PORT_READ(in_BRANCH_COMPLETE_MISS_PREDICTION [i]);
895
896              log_printf(TRACE,Commit_unit,FUNCTION,"    * miss_prediction : %d",miss);
897             
898              entry->state = (miss)?ROB_END_BRANCH_MISS_SPECULATIVE:ROB_END_OK_SPECULATIVE;
899
900//            bool flush = reg_EVENT_FLUSH [entry->front_end_id][entry->context_id];
901
902              // Branch_complete can be execute if
903              //   * no present event
904              //   * futur event and most not speculative that the event
905
906              // Also, test if in this cycle, they have not an most recently event !!!
907              if (miss)
908                {
909                  bool     can    = true;
910                  uint32_t packet = ((entry->ptr << _param->_shift_num_slot) | num_bank);
911                     
912                  // test if this packet is before previous event
913                  if (reg_EVENT_STATE [entry->front_end_id][entry->context_id] == COMMIT_EVENT_STATE_NOT_YET_EVENT)
914                    {
915                      uint32_t _top = ((_rob[ reg_NUM_BANK_HEAD].front()->ptr << _param->_shift_num_slot) | reg_NUM_BANK_HEAD);
916                      uint32_t _old = reg_EVENT_PACKET [entry->front_end_id][entry->context_id];
917                      uint32_t _new = packet;
918                      if (_old < _top) _old = _old+_param->_size_queue;
919                      if (_new < _top) _new = _new+_param->_size_queue;
920                      if (_new < _old) reg_EVENT_PACKET [entry->front_end_id][entry->context_id] = packet;
921                      else can = false;
922                    }
923                  else
924                    reg_EVENT_PACKET [entry->front_end_id][entry->context_id] = packet;
925
926                  if (can)
927                    {
928                      // In all case, stop instruction flow
929                      reg_EVENT_STATE         [entry->front_end_id][entry->context_id] = COMMIT_EVENT_STATE_NOT_YET_EVENT;
930                      reg_EVENT_NB_INST       [entry->front_end_id][entry->context_id] = reg_NB_INST_COMMIT_ALL [entry->front_end_id][entry->context_id];
931                               
932//                    reg_EVENT_STOP          [entry->front_end_id][entry->context_id] = true;
933
934//                    reg_EVENT_CAN_RESTART   [entry->front_end_id][entry->context_id] = false;
935
936                      reg_EVENT_LAST_NUM_BANK [entry->front_end_id][entry->context_id] = ((reg_NUM_BANK_TAIL==0)?_param->_nb_bank:reg_NUM_BANK_TAIL)-1;
937                      reg_EVENT_LAST_NUM_PTR  [entry->front_end_id][entry->context_id] = reg_NUM_PTR_TAIL;
938                    }
939                }
940            }
941
942        // ===================================================================
943        // =====[ UPDATE ]====================================================
944        // ===================================================================
945        // Update when exception or load_miss
946        if (internal_UPDATE_VAL and PORT_READ(in_UPDATE_ACK))
947          {
948            log_printf(TRACE,Commit_unit,FUNCTION,"  * UPDATE");
949
950            // Change state
951            entry_t * entry = _rob [internal_UPDATE_NUM_BANK].front();
952
953            switch (entry->state)
954              {
955//               case ROB_END_EXCEPTION_UPDATE :
956//                 {
957//                   entry->state = ROB_END_KO;
958//                   throw ERRORMORPHEO(FUNCTION,_("Moore : exception is not yet supported (Coming Soon).\n"));
959//                   break;
960//                 }
961              case ROB_END_LOAD_MISS_UPDATE :
962                {
963                  log_printf(TRACE,Commit_unit,FUNCTION,"    * ROB_END_LOAD_MISS_UPDATE");
964
965                  entry->state = ROB_END_LOAD_MISS;
966                  break;
967                }
968              default :
969                {
970                  throw ERRORMORPHEO(FUNCTION,_("Update : invalid state.\n"));
971                  break;
972                }
973              }
974          }
975
976        // ===================================================================
977        // =====[ EVENT ]=====================================================
978        // ===================================================================
979//         for (uint32_t i=0; i < _param->_nb_front_end; ++i)
980//           for (uint32_t j=0; j < _param->_nb_context[i]; ++j)
981//             if (PORT_READ(in_EVENT_VAL [i][j]) and internal_EVENT_ACK [i][j])
982//               {
983//                 log_printf(TRACE,Commit_unit,FUNCTION,"  * EVENT [%d][%d]",i,j);
984
985//                 reg_PC_CURRENT            [i][j] = PORT_READ(in_EVENT_ADDRESS      [i][j]);
986//                 reg_PC_CURRENT_IS_DS      [i][j] = PORT_READ(in_EVENT_IS_DS_TAKE   [i][j]); // ??
987//                 reg_PC_CURRENT_IS_DS_TAKE [i][j] = PORT_READ(in_EVENT_IS_DS_TAKE   [i][j]);
988//                 reg_PC_NEXT               [i][j] = PORT_READ(in_EVENT_ADDRESS_NEXT [i][j]);
989//                 // PORT_READ(in_EVENT_ADDRESS_NEXT_VAL [i][j]);
990//               }
991
992        // ===================================================================
993        // =====[ DEPTH - HEAD ]==============================================
994        // ===================================================================
995
996        {
997          bool     can_continue   [_param->_nb_front_end][_param->_max_nb_context];
998          uint32_t event_nb_inst  [_param->_nb_front_end][_param->_max_nb_context];
999          bool     is_speculative [_param->_nb_front_end][_param->_max_nb_context];
1000          for (uint32_t i=0; i<_param->_nb_front_end; i++)
1001            for (uint32_t j=0; j<_param->_nb_context [i]; j++)
1002              {
1003                event_nb_inst [i][j] = 0;
1004                is_speculative[i][j] = false;
1005                can_continue  [i][j] = (((reg_EVENT_NB_INST [i][j] == 0) or
1006                                         (    event_nb_inst [i][j] < reg_EVENT_NB_INST [i][j])) and
1007                                        not reg_EVENT_LAST [i][j]);
1008              }
1009
1010          // Read all instruction of all top bank
1011          for (uint32_t i=0; i<_param->_nb_bank; i++)
1012            {
1013              uint32_t num_bank = (reg_NUM_BANK_HEAD+i)%_param->_nb_bank;
1014             
1015              // Test if have an instruction
1016              if (not _rob[num_bank].empty())
1017                {
1018                  // Scan all instruction in windows and test if instruction is speculative
1019                  entry_t    * entry        = _rob [num_bank].front();
1020
1021                  uint32_t     num_packet   = ((entry->ptr << _param->_shift_num_slot) | num_bank);
1022                  Tcontext_t   front_end_id = entry->front_end_id;
1023                  Tcontext_t   context_id   = entry->context_id  ;
1024
1025                  log_printf(TRACE,Commit_unit,FUNCTION,"  * HEAD              [%d] - %d",num_bank,num_packet);
1026                  log_printf(TRACE,Commit_unit,FUNCTION,"    * front_end_id    : %d",front_end_id);
1027                  log_printf(TRACE,Commit_unit,FUNCTION,"    * context_id      : %d",context_id);
1028                  log_printf(TRACE,Commit_unit,FUNCTION,"    * EVENT_LAST      : %d",reg_EVENT_LAST    [front_end_id][context_id]);
1029                  log_printf(TRACE,Commit_unit,FUNCTION,"    * EVENT_NB_INST   : %d",reg_EVENT_NB_INST [front_end_id][context_id]);
1030                  log_printf(TRACE,Commit_unit,FUNCTION,"    * event_nb_inst   : %d",    event_nb_inst [front_end_id][context_id]);
1031                 
1032                  // scan while last event instruction is not retire
1033                  if (can_continue  [front_end_id][context_id])
1034                    {
1035                      // Read information
1036                      rob_state_t  state        = entry->state;
1037                      Tdepth_t     depth        = entry->depth;
1038                     
1039                      Tdepth_t     depth_min    = (_param->_have_port_depth)?PORT_READ(in_DEPTH_MIN[front_end_id][context_id]):0;
1040                      Tdepth_t     depth_max    = (_param->_have_port_depth)?PORT_READ(in_DEPTH_MAX[front_end_id][context_id]):0;
1041                      Tcontrol_t   depth_full   = PORT_READ(in_DEPTH_FULL [front_end_id][context_id]);
1042                     
1043                      // is a valid instruction ?
1044                      // If DEPTH_CURRENT :
1045                      // equal at     DEPTH_MIN            -> not speculative
1046                      // not include ]DEPTH_MIN:DEPTH_MAX] -> previous branch miss
1047                      //     include ]DEPTH_MIN:DEPTH_MAX] -> speculative
1048                     
1049                      // All case
1050                      // ....... min ...X... max ....... OK
1051                      // ....... min ....... max ...X... KO
1052                      // ...X... min ....... max ....... KO
1053                      // ....... max ....... min ...X... OK
1054                      // ...X... max ....... min ....... OK
1055                      // ....... max ...X... min ....... KO
1056                     
1057                      bool         flush         = ((reg_EVENT_STATE [front_end_id][context_id] == COMMIT_EVENT_STATE_EVENT) or
1058//                                                  (reg_EVENT_STATE [front_end_id][context_id] == COMMIT_EVENT_STATE_WAIT_DECOD) or
1059                                                    (reg_EVENT_STATE [front_end_id][context_id] == COMMIT_EVENT_STATE_WAIT_END));
1060                      bool         speculative   = is_speculative [front_end_id][context_id];
1061
1062//                       bool         speculative   = entry->speculative and not (depth == depth_min);
1063//                       Tcontrol_t   is_valid      = ((not speculative or
1064//                                                      (speculative and (depth_full or // all is valid
1065//                                                                        ((depth_min <= depth_max)? // test if depth is overflow
1066//                                                                         ((depth >= depth_min) and (depth <=depth_max)):
1067//                                                                         ((depth >= depth_min) or  (depth <=depth_max))))))
1068//                                                     and not flush); // no event
1069
1070                      Tcontrol_t   is_valid      = not flush;
1071
1072
1073                      //Tcontrol_t   is_valid      = ((depth == depth_min) and not flush);
1074                     
1075                     
1076                      log_printf(TRACE,Commit_unit,FUNCTION,"    * is_valid        : %d ((depth == depth_min) and not flush)",is_valid);
1077                      log_printf(TRACE,Commit_unit,FUNCTION,"    * depth           : %d",depth    );
1078                      log_printf(TRACE,Commit_unit,FUNCTION,"    * depth_min       : %d",depth_min);
1079                      log_printf(TRACE,Commit_unit,FUNCTION,"    * depth_max       : %d",depth_max);
1080                      log_printf(TRACE,Commit_unit,FUNCTION,"    * depth_full      : %d",depth_full);
1081                      log_printf(TRACE,Commit_unit,FUNCTION,"    * speculative     : %d",speculative);
1082                      log_printf(TRACE,Commit_unit,FUNCTION,"    * flush           : %d",flush);
1083                      log_printf(TRACE,Commit_unit,FUNCTION,"    * state (before)  : %s",toString(state).c_str());
1084
1085//                       //------------------------------------------------------
1086//                       // Event ?
1087//                       //------------------------------------------------------
1088
1089//                       if ((reg_EVENT_STATE  [front_end_id][context_id] == COMMIT_EVENT_STATE_NOT_YET_EVENT) and
1090//                           (reg_EVENT_PACKET [front_end_id][context_id] == num_packet))
1091//                         {
1092//                           switch (state)
1093//                             {
1094//                             case ROB_END_BRANCH_MISS_SPECULATIVE : {state = ROB_END_BRANCH_MISS        ; break;}
1095//                             case ROB_END_LOAD_MISS_SPECULATIVE   : {state = ROB_END_LOAD_MISS_UPDATE   ; break;}
1096//                             case ROB_END_BRANCH_MISS             :
1097//                             case ROB_END_LOAD_MISS               :
1098//                             case ROB_END                         :
1099//                               {break;}
1100//                             default :
1101//                               {
1102//                                 throw ERRORMORPHEO(FUNCTION,toString(_("Head [%d] : invalid state (%s)"),num_packet,toString(state).c_str()));
1103//                                 break;
1104//                               }
1105//                             }
1106//                         }
1107                   
1108                      //------------------------------------------------------
1109                      // test if instruction is miss speculative
1110                      //------------------------------------------------------
1111                      if (not is_valid)
1112                        {
1113                          // Change state
1114                          switch (state)
1115                            {
1116                            case ROB_BRANCH_WAIT_END             : {state = ROB_EVENT_WAIT_END; break;}
1117                            case ROB_BRANCH_COMPLETE             : {state = ROB_END_MISS      ; break;}
1118                            case ROB_END_BRANCH_MISS             :
1119                            case ROB_END_BRANCH_MISS_SPECULATIVE : {state = ROB_END_MISS      ; break;}
1120                            case ROB_END_LOAD_MISS               :
1121                            case ROB_END_LOAD_MISS_UPDATE        :
1122                            case ROB_END_LOAD_MISS_SPECULATIVE   : {state = ROB_END_MISS      ; break;}
1123                            case ROB_STORE_OK                    : {state = ROB_STORE_KO      ; break;}
1124                            case ROB_STORE_WAIT_END_OK           : {state = ROB_STORE_WAIT_END_KO; break;}
1125                            case ROB_STORE_OK_WAIT_END           : {state = ROB_STORE_KO_WAIT_END; break;}
1126                            case ROB_OTHER_WAIT_END              : {state = ROB_EVENT_WAIT_END; break;}
1127                            case ROB_END_OK                      :
1128                            case ROB_END_OK_SPECULATIVE          : {state = ROB_END_MISS      ; break;}
1129                            case ROB_END_KO                      :
1130                            case ROB_END_KO_SPECULATIVE          : {state = ROB_END_MISS      ; break;}
1131                            case ROB_END_EXCEPTION_UPDATE        :
1132                            case ROB_END_EXCEPTION               :
1133                            case ROB_END_EXCEPTION_WAIT_HEAD     : {state = ROB_END_MISS      ; break;}
1134                             
1135                              // don't change state -> wait
1136                            case ROB_STORE_WAIT_END_KO           : {break;}
1137                            case ROB_STORE_KO                    : {break;}
1138                            case ROB_STORE_KO_WAIT_END           : {break;}
1139                            case ROB_STORE_EVENT                 : {break;}
1140                            case ROB_EVENT_WAIT_END              : {break;}
1141                            case ROB_END_MISS                    : {break;}
1142                            case ROB_END                         : {break;}
1143                             
1144                              // can't have miss speculation -> invalid state
1145                            default                              : 
1146                              {
1147                                throw ERRORMORPHEO(FUNCTION,toString(_("Miss Speculation : Invalide state : %s.\n"),toString(state).c_str()));
1148                                break;
1149                              }
1150                            }
1151                        }
1152
1153                      //------------------------------------------------------
1154                      // test if instruction is branch not finish
1155                      //------------------------------------------------------
1156                      switch (state)
1157                        {
1158                        case ROB_BRANCH_WAIT_END :
1159                        case ROB_BRANCH_COMPLETE :
1160                          {
1161                            is_speculative [front_end_id][context_id] = true;
1162                            break;
1163                          }
1164                        default : break;
1165                        }
1166                     
1167                      //------------------------------------------------------
1168                      // test if instruction is not speculative
1169                      //------------------------------------------------------
1170//                       entry->speculative = speculative;
1171//                    if (entry->depth == depth_min)
1172                      // test if instruction is speculative (depth != depth_min)
1173                      if (not speculative)
1174                        {
1175                          switch (state)
1176                            {
1177                            case ROB_END_OK_SPECULATIVE          : {state = ROB_END_OK                 ; break;}
1178                            case ROB_END_KO_SPECULATIVE          : {state = ROB_END_KO                 ; break;}
1179                            case ROB_END_BRANCH_MISS_SPECULATIVE : {state = ROB_END_BRANCH_MISS        ; break;}
1180                            case ROB_END_LOAD_MISS_SPECULATIVE   : {state = ROB_END_LOAD_MISS_UPDATE   ; break;}
1181                            default : {break;} // else, no change
1182                            }
1183                        }
1184                   
1185                      //------------------------------------------------------
1186                      // test if instruction wait head and is the top of rob
1187                      //------------------------------------------------------
1188                      // TODO : retire OOO
1189                      if (i == 0)
1190                        {
1191                          switch (state)
1192                            {
1193//                             case ROB_STORE_WAIT_HEAD_OK      : {state = ROB_STORE_HEAD_OK;        break;}
1194                            case ROB_END_EXCEPTION_WAIT_HEAD : {state = ROB_END_EXCEPTION_UPDATE; break;}
1195                            default : {break;} // else, no change
1196                            }
1197                        }
1198                   
1199                      // Write new state
1200                      entry->state = state;
1201
1202                      log_printf(TRACE,Commit_unit,FUNCTION,"    * state (after )  : %s",toString(state).c_str());
1203                     
1204//                    log_printf(TRACE,Commit_unit,FUNCTION,"  * Stop Scan !!!");
1205                         
1206                      event_nb_inst [front_end_id][context_id] ++;
1207
1208                      // stop if :
1209                      //  * begin event
1210                      //  * end event
1211                      if (((reg_EVENT_STATE [front_end_id][context_id] == COMMIT_EVENT_STATE_NOT_YET_EVENT) and
1212                           (reg_EVENT_PACKET[front_end_id][context_id] == num_packet)) or
1213                          ((reg_EVENT_NB_INST [front_end_id][context_id] > 0) and
1214                           (    event_nb_inst [front_end_id][context_id] >= reg_EVENT_NB_INST [front_end_id][context_id])))
1215                        can_continue [front_end_id][context_id] = false;
1216                    }
1217                }
1218            }
1219        }
1220
1221
1222
1223#ifdef STATISTICS
1224    if (usage_is_set(_usage,USE_STATISTICS))
1225      {
1226        for (uint32_t i=0; i<_param->_nb_bank; i++)
1227          *(_stat_bank_nb_inst [i]) += _rob[i].size();
1228
1229        for (uint32_t i=0; i<_param->_nb_front_end; i++)
1230          for (uint32_t j=0; j<_param->_nb_context [i]; j++)
1231            {
1232              uint32_t num_thread = _param->_translate_num_context_to_num_thread [i][j];
1233             
1234              switch (reg_EVENT_STATE [i][j])
1235                {
1236                case COMMIT_EVENT_STATE_NO_EVENT      : (*_stat_nb_cycle_state_no_event      [num_thread])++; break;
1237                case COMMIT_EVENT_STATE_NOT_YET_EVENT : (*_stat_nb_cycle_state_not_yet_event [num_thread])++; break;
1238                case COMMIT_EVENT_STATE_EVENT         : (*_stat_nb_cycle_state_event         [num_thread])++; break;
1239                case COMMIT_EVENT_STATE_WAIT_END      : (*_stat_nb_cycle_state_wait_end      [num_thread])++; break;
1240                }
1241            }
1242      }
1243#endif
1244      }
1245
1246    // ===================================================================
1247    // =====[ OTHER ]=====================================================
1248    // ===================================================================
1249
1250#if (DEBUG >= DEBUG_TRACE) and (DEBUG_Commit_unit == true)
1251    {
1252      log_printf(TRACE,Commit_unit,FUNCTION,"  * Dump ROB (Re-Order-Buffer)");
1253      log_printf(TRACE,Commit_unit,FUNCTION,"    * num_bank_head : %d",reg_NUM_BANK_HEAD);
1254      log_printf(TRACE,Commit_unit,FUNCTION,"    * num_bank_tail : %d",reg_NUM_BANK_TAIL);
1255      log_printf(TRACE,Commit_unit,FUNCTION,"    * num_ptr_tail  : %d",reg_NUM_PTR_TAIL );
1256     
1257      for (uint32_t i=0; i<_param->_nb_front_end; i++)
1258        for (uint32_t j=0; j<_param->_nb_context [i]; j++)
1259          {
1260            log_printf(TRACE,Commit_unit,FUNCTION,"    * [%d][%d] - %d",i,j,_param->_translate_num_context_to_num_thread [i][j]);
1261            log_printf(TRACE,Commit_unit,FUNCTION,"      * EVENT_STATE       : %s - %s",toString(reg_EVENT_STATE [i][j]).c_str(),toString(commit_event_state_to_event_state(reg_EVENT_STATE [i][j])).c_str());
1262//          log_printf(TRACE,Commit_unit,FUNCTION,"      * EVENT_FLUSH       : %d",reg_EVENT_FLUSH [i][j]);
1263//          log_printf(TRACE,Commit_unit,FUNCTION,"      * EVENT_STOP        : %d",reg_EVENT_STOP  [i][j]);
1264//          log_printf(TRACE,Commit_unit,FUNCTION,"      * EVENT             : %d (bank %d, ptr %d)",((reg_EVENT_NUM_PTR [i][j] << _param->_shift_num_slot) | reg_EVENT_NUM_BANK [i][j]), reg_EVENT_NUM_BANK [i][j],reg_EVENT_NUM_PTR [i][j]);
1265//          log_printf(TRACE,Commit_unit,FUNCTION,"      * EVENT_CAN_RESTART : %d",reg_EVENT_CAN_RESTART [i][j]);
1266            log_printf(TRACE,Commit_unit,FUNCTION,"      * EVENT_LAST        : %d - packet %d - ptr %d (bank %d, ptr %d)",reg_EVENT_LAST [i][j],reg_EVENT_PACKET[i][j],((reg_EVENT_LAST_NUM_PTR [i][j] << _param->_shift_num_slot) | reg_EVENT_LAST_NUM_BANK [i][j]), reg_EVENT_LAST_NUM_BANK [i][j],reg_EVENT_LAST_NUM_PTR [i][j]);
1267            log_printf(TRACE,Commit_unit,FUNCTION,"      * EVENT_NEXT        : stop : %d - packet : %d",reg_EVENT_NEXT_STOP  [i][j],reg_EVENT_NEXT_PACKET[i][j]);
1268            log_printf(TRACE,Commit_unit,FUNCTION,"      * NB_INST_ALL       : all : %d - mem : %d - event : %d",reg_NB_INST_COMMIT_ALL[i][j], reg_NB_INST_COMMIT_MEM[i][j],reg_EVENT_NB_INST[i][j]);
1269            log_printf(TRACE,Commit_unit,FUNCTION,"      * PC                : %.8x (%.8x) - %d %d - %.8x (%.8x)",reg_PC_CURRENT [i][j],reg_PC_CURRENT [i][j]<<2, reg_PC_CURRENT_IS_DS [i][j], reg_PC_CURRENT_IS_DS_TAKE [i][j],reg_PC_NEXT [i][j],reg_PC_NEXT [i][j]<<2);
1270          }
1271
1272      std::list<entry_t*>::iterator iter [_param->_nb_bank];
1273      for (uint32_t i=0; i<_param->_nb_bank; i++)
1274        {
1275          uint32_t num_bank = (reg_NUM_BANK_HEAD+i)%_param->_nb_bank;
1276//           log_printf(TRACE,Commit_unit,FUNCTION,"      * Bank [%d] size : %d, ptr : %d",num_bank,(int)_rob[num_bank].size(), reg_BANK_PTR [i]);
1277
1278          iter [num_bank] = _rob[num_bank].begin();
1279        }
1280
1281      bool     all_empty   = false;
1282      uint32_t nb_write_rd = 0;
1283      uint32_t nb_write_re = 0;
1284
1285      while (not all_empty)
1286        {
1287          all_empty = true;
1288         
1289          for (uint32_t i=0; i<_param->_nb_bank; i++)
1290            {
1291              uint32_t num_bank = (reg_NUM_BANK_HEAD+i)%_param->_nb_bank;
1292     
1293              std::list<entry_t*>::iterator it = iter[num_bank];       
1294              if (it != _rob[num_bank].end())
1295                {
1296                  all_empty = false;
1297
1298                  nb_write_rd += ((*it)->write_rd)?1:0;
1299                  nb_write_re += ((*it)->write_re)?1:0;
1300
1301                  log_printf(TRACE,Commit_unit,FUNCTION,"        [%.4d][%.4d] %.4d %.4d %.4d %.4d, %.3d %.3d, %.1d, %.1d %.4d, %.1d %.4d, %s",
1302                             num_bank                       ,
1303                             (*it)->ptr                     ,
1304                             (*it)->front_end_id            ,
1305                             (*it)->context_id              ,
1306                             (*it)->rename_unit_id          ,
1307                             (*it)->depth                   ,
1308                             (*it)->type                    ,
1309                             (*it)->operation               ,
1310                             (*it)->is_delay_slot           ,
1311                             (*it)->use_store_queue         ,
1312                             (*it)->store_queue_ptr_write   ,
1313                             (*it)->use_load_queue          ,
1314                             (*it)->load_queue_ptr_write    ,
1315                             toString((*it)->state).c_str() );
1316                  log_printf(TRACE,Commit_unit,FUNCTION,"              (%.4d) %.1d %.2d %.6d, %.1d %.2d %.6d, %.1d %.1d %.6d, %.1d %.2d %.6d %.6d, %.1d %.1d %.6d %.6d ",
1317                             (((*it)->ptr << _param->_shift_num_slot) | num_bank),
1318                             (*it)->read_ra                 ,
1319                             (*it)->num_reg_ra_log          ,
1320                             (*it)->num_reg_ra_phy          ,
1321                             (*it)->read_rb                 ,
1322                             (*it)->num_reg_rb_log          ,
1323                             (*it)->num_reg_rb_phy          ,
1324                             (*it)->read_rc                 ,
1325                             (*it)->num_reg_rc_log          ,
1326                             (*it)->num_reg_rc_phy          ,
1327                             (*it)->write_rd                ,
1328                             (*it)->num_reg_rd_log          ,
1329                             (*it)->num_reg_rd_phy_old      ,
1330                             (*it)->num_reg_rd_phy_new      ,
1331                             (*it)->write_re                ,
1332                             (*it)->num_reg_re_log          ,
1333                             (*it)->num_reg_re_phy_old      ,
1334                             (*it)->num_reg_re_phy_new      );
1335                 
1336                  log_printf(TRACE,Commit_unit,FUNCTION,"                     %.2d %.2d %.1d %.1d - %.8x (%.8x) %.8x (%.8x)",
1337                             (*it)->exception_use ,
1338                             (*it)->exception     ,
1339                             (*it)->flags         ,
1340                             (*it)->no_sequence   ,
1341//                              (*it)->speculative   ,
1342                             (*it)->address       ,
1343                             (*it)->address<<2    ,
1344                             (*it)->address_next  ,
1345                             (*it)->address_next<<2
1346                             );
1347                 
1348                  iter [num_bank] ++;
1349                }
1350            }
1351        }
1352
1353      log_printf(TRACE,Commit_unit,FUNCTION,"    * nb_write_rd   : %d",nb_write_rd);
1354      log_printf(TRACE,Commit_unit,FUNCTION,"    * nb_write_re   : %d",nb_write_re);
1355    }
1356#endif
1357
1358#ifdef DEBUG_TEST
1359    {
1360      uint32_t x=reg_NUM_BANK_HEAD;
1361      if (not _rob[x].empty())
1362        {
1363          entry_t * entry = _rob [x].front();
1364
1365          if (false
1366//            or (entry->state == ROB_EMPTY                      )
1367//            or (entry->state == ROB_BRANCH_WAIT_END            )
1368//            or (entry->state == ROB_BRANCH_COMPLETE            )
1369//            or (entry->state == ROB_STORE_WAIT_HEAD_OK         )
1370//          //or (entry->state == ROB_STORE_WAIT_HEAD_KO         )
1371//            or (entry->state == ROB_STORE_HEAD_OK              )
1372//            or (entry->state == ROB_STORE_HEAD_KO              )
1373//            or (entry->state == ROB_OTHER_WAIT_END             )
1374//            or (entry->state == ROB_EVENT_WAIT_END             )
1375//            or (entry->state == ROB_END_OK_SPECULATIVE         )
1376              or (entry->state == ROB_END_OK                     )
1377//            or (entry->state == ROB_END_KO_SPECULATIVE         )
1378//            or (entry->state == ROB_END_KO                     )
1379//            or (entry->state == ROB_END_BRANCH_MISS_SPECULATIVE)
1380              or (entry->state == ROB_END_BRANCH_MISS            )
1381//            or (entry->state == ROB_END_LOAD_MISS_SPECULATIVE  )
1382//            or (entry->state == ROB_END_LOAD_MISS_UPDATE       )
1383              or (entry->state == ROB_END_LOAD_MISS              )
1384//            or (entry->state == ROB_END_MISS                   )
1385//            or (entry->state == ROB_END_EXCEPTION_WAIT_HEAD    )
1386//            or (entry->state == ROB_END_EXCEPTION_UPDATE       )
1387//            or (entry->state == ROB_END_EXCEPTION              )
1388              )
1389          if (entry->address != reg_PC_CURRENT[entry->front_end_id][entry->context_id])
1390            throw ERRORMORPHEO(FUNCTION,toString(_("Rob top address (0x%x) is different of reg_PC_CURRENT[%d][%d] (0x%x).\n"),
1391                                                 entry->address,
1392                                                 entry->front_end_id,
1393                                                 entry->context_id,
1394                                                 reg_PC_CURRENT[entry->front_end_id][entry->context_id]));
1395        }
1396    }
1397    {
1398      uint32_t NB_INST [_param->_nb_front_end][_param->_max_nb_context];
1399      for (uint32_t i=0; i<_param->_nb_front_end; i++)
1400        for (uint32_t j=0; j<_param->_nb_context [i]; j++)
1401          NB_INST [i][j] = 0; //reg_EVENT_NB_INST [i][j];
1402
1403      for (uint32_t i=0; i<_param->_nb_bank; ++i)
1404        for (std::list<entry_t*>::iterator it=_rob[i].begin();
1405             it!=_rob [i].end();
1406             ++it)
1407          NB_INST [(*it)->front_end_id][(*it)->context_id] ++;
1408
1409      for (uint32_t i=0; i<_param->_nb_front_end; i++)
1410        for (uint32_t j=0; j<_param->_nb_context [i]; j++)
1411          if (NB_INST [i][j] != reg_NB_INST_COMMIT_ALL [i][j])
1412            throw ERRORMORPHEO(FUNCTION,toString(_("Context [%d][%d] have not the good nb_inst (%d in rob, %d in register).\n"),i,j,NB_INST[i][j], reg_NB_INST_COMMIT_ALL [i][j]));
1413    }
1414#endif
1415
1416#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
1417    end_cycle ();
1418#endif
1419
1420    // Stop Condition
1421    for (uint32_t i=0; i<_param->_nb_front_end; i++)
1422      for (uint32_t j=0; j<_param->_nb_context [i]; j++)
1423        if (_nb_cycle_idle [i][j] >= debug_idle_cycle)
1424          throw ERRORMORPHEO(FUNCTION,toString(_("Thread [%d] is idle since %.0f cycles.\n"),_param->_translate_num_context_to_num_thread[i][j],_nb_cycle_idle [i][j]));
1425
1426    log_end(Commit_unit,FUNCTION);
1427  };
1428
1429}; // end namespace commit_unit
1430}; // end namespace ooo_engine
1431}; // end namespace multi_ooo_engine
1432}; // end namespace core
1433
1434}; // end namespace behavioural
1435}; // end namespace morpheo             
1436#endif
Note: See TracBrowser for help on using the repository browser.