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

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

1) Fix bug (read unit, RAT -> write in R0, SPR desallocation ...)
2) Change VHDL Execute_queue -> use Generic/Queue?
3) Complete document on VHDL generation
4) Add soc test

  • Property svn:keywords set to Id
File size: 6.6 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id: Reexecute_unit_transition.cpp 98 2008-12-31 10:18: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              entry->state        = STATE_SPR_ACCESS;
53              entry->context_id   = (_param->_have_port_context_id  )?PORT_READ(in_EXECUTE_LOOP_CONTEXT_ID   [x][y]):0;
54              entry->front_end_id = (_param->_have_port_front_end_id)?PORT_READ(in_EXECUTE_LOOP_FRONT_END_ID [x][y]):0;
55              entry->packet_id    = (_param->_have_port_rob_ptr     )?PORT_READ(in_EXECUTE_LOOP_PACKET_ID    [x][y]):0;
56              entry->address      = PORT_READ(in_EXECUTE_LOOP_ADDRESS [x][y]);
57              entry->data         = PORT_READ(in_EXECUTE_LOOP_DATA    [x][y]);
58              entry->num_reg_rd   = PORT_READ(in_COMMIT_NUM_REG_RD    [z]);
59              entry->spr_wen      = internal_QUEUE_INFO [i].spr_wen  ;
60              entry->reexecute    = internal_QUEUE_INFO [i].reexecute;
61              entry->type         = internal_QUEUE_INFO [i].type     ;
62              entry->operation    = internal_QUEUE_INFO [i].operation;
63              entry->write_rd     = internal_QUEUE_INFO [i].write_rd ;
64            }
65
66#ifdef STATISTICS
67        if (usage_is_set(_usage,USE_STATISTICS))
68          for (uint32_t i=0; i<_param->_nb_inst_commit; i++)
69            if (internal_COMMIT_VAL [i] and PORT_READ(in_COMMIT_ACK[i]))
70              (*_stat_nb_inst_commit) ++;
71#endif
72
73        // ===================================================================
74        // =====[ SPR ]=======================================================
75        // ===================================================================
76        for (uint32_t i=0; i<_param->_nb_inst_reexecute; i++)
77          if (internal_SPR_VAL [i] and PORT_READ(in_SPR_ACK [i]))
78            {
79#ifdef STATISTICS
80              if (usage_is_set(_usage,USE_STATISTICS))
81                (*_stat_nb_spr_access) ++;
82#endif
83              entry_t * entry = _reexecute_queue [i].front();
84
85              if (not entry->spr_wen)
86                {
87                  entry->data     =     PORT_READ(in_SPR_RDATA   [i]);
88                  entry->write_rd = not PORT_READ(in_SPR_INVALID [i]);
89                }
90
91              if (entry->reexecute)
92                entry->state = STATE_REEXECUTE;
93              else
94                entry->state = STATE_EMPTY;
95            }
96
97        // ===================================================================
98        // =====[ REEXECUTE ]=================================================
99        // ===================================================================
100        for (uint32_t i=0; i<_param->_nb_inst_reexecute; i++)
101          if (internal_REEXECUTE_VAL [i] and PORT_READ(in_REEXECUTE_ACK [i]))
102            // test source
103            if (not internal_REEXECUTE_ROB_ACK [i])
104              {
105#ifdef STATISTICS
106                if (usage_is_set(_usage,USE_STATISTICS))
107                  (*_stat_nb_inst_reexecute) ++;
108#endif
109
110                // invalid entry
111                _reexecute_queue [i].front()->state = STATE_EMPTY;             
112              }
113#ifdef DEBUG_TEST
114            else
115              {
116                if (not PORT_READ(in_REEXECUTE_ROB_VAL [i]))
117                  throw ERRORMORPHEO(FUNCTION,toString(_("in_REEXECUTE_ROB_VAL [%d] must be = 1.\n"),i));
118              }
119#endif
120       
121        // ===================================================================
122        // =====[ End cycle ]=================================================
123        // ===================================================================
124        for (uint32_t i=0; i<_param->_nb_bank; i++)
125          if (not _reexecute_queue [i].empty() and (_reexecute_queue [i].front()->state == STATE_EMPTY))
126            {
127              entry_t * entry = _reexecute_queue [i].front();
128              _reexecute_queue [i].pop_front();
129              delete entry;
130
131#ifdef STATISTICS
132              if (usage_is_set(_usage,USE_STATISTICS))
133                (*(_stat_bank_nb_inst [i])) += _reexecute_queue [i].size();
134#endif
135            }
136      }
137
138#if ((DEBUG >= DEBUG_TRACE) and DEBUG_Reexecute_unit)
139    log_printf(TRACE,Reexecute_unit,FUNCTION,"  * Dump Reexecute_queue");
140
141    for (uint32_t i=0; i<_param->_nb_bank; ++i)
142      {
143        uint32_t j=0;
144        for (std::list<entry_t *>::iterator it=_reexecute_queue[i].begin();
145             it!=_reexecute_queue[i].end();
146             ++it)
147          {
148            log_printf(TRACE,Reexecute_unit,FUNCTION,"  [%.4d][%.4d] %.4d %.4d %.4d, %.1d %.1d, %.4d %.4d, %.8x (%.2d %.4d) %.8x, %.1d %.5d, %s",
149                       i,
150                       j,
151                       (*it)->context_id    ,
152                       (*it)->front_end_id  ,
153                       (*it)->packet_id     ,
154                       (*it)->spr_wen       ,
155                       (*it)->reexecute     ,
156                       (*it)->type          ,
157                       (*it)->operation     ,
158                       (*it)->address       ,
159                      ((*it)->address >> _param->_shift_spr_num_group) & _param->_mask_spr_num_group,
160                      ((*it)->address                                ) & _param->_mask_spr_num_reg  ,
161                       (*it)->data          ,
162                       (*it)->write_rd      ,
163                       (*it)->num_reg_rd    ,
164                       toString((*it)->state).c_str());
165
166            ++j;
167          }
168      }
169//     // ~~~~~[ Register ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   
170//   private   : std::list<entry_t *>          * _reexecute_queue                         ;//[nb_bank]
171  typedef struct 
172  {
173  } entry_t;
174
175#endif
176
177#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
178    end_cycle ();
179#endif
180
181    log_end(Reexecute_unit,FUNCTION);
182  };
183
184}; // end namespace reexecute_unit
185}; // end namespace ooo_engine
186}; // end namespace multi_ooo_engine
187}; // end namespace core
188
189}; // end namespace behavioural
190}; // end namespace morpheo             
191#endif
Note: See TracBrowser for help on using the repository browser.