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

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

1) Correct bug in link two signal
2) Fix error detected with valgrind
3) modif distexe script

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