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

Last change on this file since 137 was 137, checked in by rosiere, 14 years ago

Various modif (add test, and vhdl)

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