source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Reexecute_unit/src/Reexecute_unit_transition.cpp @ 131

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

1) add constant method
2) test with systemc 2.2.0

  • Property svn:keywords set to Id
File size: 6.7 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id: Reexecute_unit_transition.cpp 131 2009-07-08 18:40:08Z rosiere $
4 *
5 * [ Description ]
6 *
7 */
8
9#include "Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Reexecute_unit/include/Reexecute_unit.h"
10
11namespace morpheo                    {
12namespace behavioural {
13namespace core {
14namespace multi_ooo_engine {
15namespace ooo_engine {
16namespace reexecute_unit {
17
18
19#undef  FUNCTION
20#define FUNCTION "Reexecute_unit::transition"
21  void Reexecute_unit::transition (void)
22  {
23    log_begin(Reexecute_unit,FUNCTION);
24    log_function(Reexecute_unit,FUNCTION,_name.c_str());
25
26    if (PORT_READ(in_NRESET) == 0)
27      {
28        _priority_execute_loop->reset();
29        _priority_queue_in    ->reset();
30
31        for (uint32_t i=0; i<_param->_nb_bank; i++)
32          _reexecute_queue [i].clear();
33      }
34    else
35      {
36        _priority_execute_loop->transition();
37        _priority_queue_in    ->transition();
38
39        // ===================================================================
40        // =====[ EXECUTE_LOOP / COMMIT ]=====================================
41        // ===================================================================
42        for (uint32_t i=0; i<_param->_nb_bank; ++i)
43          if (internal_QUEUE_PUSH [i])
44            {
45              entry_t * entry = new entry_t;
46              _reexecute_queue [i].push_back(entry);
47
48              uint32_t x = internal_QUEUE_NUM_EXECUTE_LOOP [i];
49              uint32_t y = internal_QUEUE_NUM_INST_EXECUTE [i];
50              uint32_t z = internal_QUEUE_NUM_INST_COMMIT  [i];
51
52              log_printf(TRACE,Reexecute_unit,FUNCTION,"  * EXECUTE_LOOP[%d][%d] - COMMIT[%d]",x,y,z);
53
54              entry->state        = STATE_SPR_ACCESS;
55              entry->context_id   = (_param->_have_port_context_id  )?PORT_READ(in_EXECUTE_LOOP_CONTEXT_ID   [x][y]):0;
56              entry->front_end_id = (_param->_have_port_front_end_id)?PORT_READ(in_EXECUTE_LOOP_FRONT_END_ID [x][y]):0;
57              entry->packet_id    = (_param->_have_port_rob_ptr     )?PORT_READ(in_EXECUTE_LOOP_PACKET_ID    [x][y]):0;
58              entry->address      = PORT_READ(in_EXECUTE_LOOP_ADDRESS [x][y]);
59              entry->data         = PORT_READ(in_EXECUTE_LOOP_DATA    [x][y]);
60              entry->num_reg_rd   = PORT_READ(in_COMMIT_NUM_REG_RD    [z]);
61              entry->spr_wen      = internal_QUEUE_INFO [i].spr_wen  ;
62              entry->reexecute    = internal_QUEUE_INFO [i].reexecute;
63              entry->type         = internal_QUEUE_INFO [i].type     ;
64              entry->operation    = internal_QUEUE_INFO [i].operation;
65              entry->write_rd     = internal_QUEUE_INFO [i].write_rd ;
66            }
67
68#ifdef STATISTICS
69        if (usage_is_set(_usage,USE_STATISTICS))
70          for (uint32_t i=0; i<_param->_nb_inst_commit; i++)
71            if (internal_COMMIT_VAL [i] and PORT_READ(in_COMMIT_ACK[i]))
72              (*_stat_nb_inst_commit) ++;
73#endif
74
75        // ===================================================================
76        // =====[ SPR ]=======================================================
77        // ===================================================================
78        for (uint32_t i=0; i<_param->_nb_inst_reexecute; i++)
79          if (internal_SPR_VAL [i] and PORT_READ(in_SPR_ACK [i]))
80            {
81#ifdef STATISTICS
82              if (usage_is_set(_usage,USE_STATISTICS))
83                (*_stat_nb_spr_access) ++;
84#endif
85              entry_t * entry = _reexecute_queue [i].front();
86
87              if (not entry->spr_wen)
88                {
89                  entry->data     =     PORT_READ(in_SPR_RDATA   [i]);
90//                entry->write_rd = not PORT_READ(in_SPR_INVALID [i]); // in all case write value
91                }
92
93              if (entry->reexecute)
94                entry->state = STATE_REEXECUTE;
95              else
96                entry->state = STATE_EMPTY;
97            }
98
99        // ===================================================================
100        // =====[ REEXECUTE ]=================================================
101        // ===================================================================
102        for (uint32_t i=0; i<_param->_nb_inst_reexecute; i++)
103          if (internal_REEXECUTE_VAL [i] and PORT_READ(in_REEXECUTE_ACK [i]))
104            // test source
105            if (not internal_REEXECUTE_ROB_ACK [i])
106              {
107#ifdef STATISTICS
108                if (usage_is_set(_usage,USE_STATISTICS))
109                  (*_stat_nb_inst_reexecute) ++;
110#endif
111
112                // invalid entry
113                _reexecute_queue [i].front()->state = STATE_EMPTY;             
114              }
115#ifdef DEBUG_TEST
116            else
117              {
118                if (not PORT_READ(in_REEXECUTE_ROB_VAL [i]))
119                  throw ERRORMORPHEO(FUNCTION,toString(_("in_REEXECUTE_ROB_VAL [%d] must be = 1.\n"),i));
120              }
121#endif
122       
123        // ===================================================================
124        // =====[ End cycle ]=================================================
125        // ===================================================================
126        for (uint32_t i=0; i<_param->_nb_bank; i++)
127          if (not _reexecute_queue [i].empty() and (_reexecute_queue [i].front()->state == STATE_EMPTY))
128            {
129              entry_t * entry = _reexecute_queue [i].front();
130              _reexecute_queue [i].pop_front();
131              delete entry;
132
133#ifdef STATISTICS
134              if (usage_is_set(_usage,USE_STATISTICS))
135                (*(_stat_bank_nb_inst [i])) += _reexecute_queue [i].size();
136#endif
137            }
138      }
139
140#if ((DEBUG >= DEBUG_TRACE) and DEBUG_Reexecute_unit)
141    log_printf(TRACE,Reexecute_unit,FUNCTION,"  * Dump Reexecute_queue");
142
143    for (uint32_t i=0; i<_param->_nb_bank; ++i)
144      {
145        uint32_t j=0;
146        for (std::list<entry_t *>::iterator it=_reexecute_queue[i].begin();
147             it!=_reexecute_queue[i].end();
148             ++it)
149          {
150            log_printf(TRACE,Reexecute_unit,FUNCTION,"  [%.4d][%.4d] %.4d %.4d %.4d, %.1d %.1d, %.4d %.4d, %.8x (%.2d %.4d) %.8x, %.1d %.5d, %s",
151                       i,
152                       j,
153                       (*it)->context_id    ,
154                       (*it)->front_end_id  ,
155                       (*it)->packet_id     ,
156                       (*it)->spr_wen       ,
157                       (*it)->reexecute     ,
158                       (*it)->type          ,
159                       (*it)->operation     ,
160                       (*it)->address       ,
161                      ((*it)->address >> _param->_shift_spr_num_group) & _param->_mask_spr_num_group,
162                      ((*it)->address                                ) & _param->_mask_spr_num_reg  ,
163                       (*it)->data          ,
164                       (*it)->write_rd      ,
165                       (*it)->num_reg_rd    ,
166                       toString((*it)->state).c_str());
167
168            ++j;
169          }
170      }
171//     // ~~~~~[ Register ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
172//   private   : std::list<entry_t *>          * _reexecute_queue                         ;//[nb_bank]
173  typedef struct 
174  {
175  } entry_t;
176
177#endif
178
179#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
180    end_cycle ();
181#endif
182
183    log_end(Reexecute_unit,FUNCTION);
184  };
185
186}; // end namespace reexecute_unit
187}; // end namespace ooo_engine
188}; // end namespace multi_ooo_engine
189}; // end namespace core
190
191}; // end namespace behavioural
192}; // end namespace morpheo             
193#endif
Note: See TracBrowser for help on using the repository browser.