source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Rename_unit/Register_translation_unit/Free_List_unit/src/Free_List_unit_transition.cpp

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

Various modif (add test, and vhdl)

  • Property svn:keywords set to Id
File size: 7.4 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id: Free_List_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/Rename_unit/Register_translation_unit/Free_List_unit/include/Free_List_unit.h"
10
11namespace morpheo                    {
12namespace behavioural {
13namespace core {
14namespace multi_ooo_engine {
15namespace ooo_engine {
16namespace rename_unit {
17namespace register_translation_unit {
18namespace free_list_unit {
19
20
21#undef  FUNCTION
22#define FUNCTION "Free_List_unit::transition"
23  void Free_List_unit::transition (void)
24  {
25    log_begin(Free_List_unit,FUNCTION);
26    log_function(Free_List_unit,FUNCTION,_name.c_str());
27
28    if (PORT_READ(in_NRESET) == 0)
29      {
30        _priority_gpr->reset();
31        _priority_spr->reset();
32
33        for (uint32_t i=0; i<_param->_nb_bank; i++)
34          {
35            _gpr_list[i].clear();
36            _spr_list[i].clear();
37          }
38      }
39    else
40      {
41        _priority_gpr->transition();
42        _priority_spr->transition();
43
44        // ==================================================
45        // =====[ POP ]======================================
46        // ==================================================
47        for (uint32_t i=0; i<_param->_nb_pop; i++)
48          if (PORT_READ(in_POP_VAL[i]) and internal_POP_ACK [i])
49            {
50              log_printf(TRACE,Free_List_unit,FUNCTION,"  * POP [%d]",i);
51
52#ifdef STATISTICS
53              if (usage_is_set(_usage,USE_STATISTICS))
54                (*_stat_nb_inst_pop) ++;
55#endif
56
57              if (PORT_READ(in_POP_GPR_VAL [i]))
58                {
59#ifdef STATISTICS
60                  if (usage_is_set(_usage,USE_STATISTICS))
61                    (*_stat_nb_inst_pop_gpr) ++;
62#endif
63                  _gpr_list [internal_POP_GPR_BANK[i]].pop_front();
64                }
65         
66              if (PORT_READ(in_POP_SPR_VAL [i]))
67                {
68#ifdef STATISTICS
69                  if (usage_is_set(_usage,USE_STATISTICS))
70                    (*_stat_nb_inst_pop_spr) ++;
71#endif
72                  _spr_list [internal_POP_SPR_BANK[i]].pop_front();
73                }
74            }
75
76        // ==================================================
77        // =====[ PUSH_GPR ]=================================
78        // ==================================================
79        for (uint32_t i=0; i<_param->_nb_push; i++)
80          if (PORT_READ(in_PUSH_GPR_VAL[i]) and internal_PUSH_GPR_ACK [i])
81            {
82              log_printf(TRACE,Free_List_unit,FUNCTION,"  * PUSH_GPR[%d]",i);
83              log_printf(TRACE,Free_List_unit,FUNCTION,"    * bank    : %d",internal_PUSH_GPR_BANK[i]);
84              log_printf(TRACE,Free_List_unit,FUNCTION,"    * num_reg : %d",PORT_READ(in_PUSH_GPR_NUM_REG [i]));
85
86#ifdef STATISTICS
87              if (usage_is_set(_usage,USE_STATISTICS))
88                (*_stat_nb_inst_push_gpr) ++;
89#endif
90
91              _gpr_list [internal_PUSH_GPR_BANK[i]].push_back(PORT_READ(in_PUSH_GPR_NUM_REG [i]));
92            }
93        // ==================================================
94        // =====[ PUSH_SPR ]=================================
95        // ==================================================
96        for (uint32_t i=0; i<_param->_nb_push; i++)
97          if (PORT_READ(in_PUSH_SPR_VAL[i]) and internal_PUSH_SPR_ACK [i])
98            {
99              log_printf(TRACE,Free_List_unit,FUNCTION,"  * PUSH_SPR[%d]",i);
100              log_printf(TRACE,Free_List_unit,FUNCTION,"    * bank    : %d",internal_PUSH_SPR_BANK[i]);
101              log_printf(TRACE,Free_List_unit,FUNCTION,"    * num_reg : %d",PORT_READ(in_PUSH_SPR_NUM_REG [i]));
102
103#ifdef STATISTICS
104              if (usage_is_set(_usage,USE_STATISTICS))
105                (*_stat_nb_inst_push_spr) ++;
106#endif
107
108              _spr_list [internal_PUSH_SPR_BANK[i]].push_back(PORT_READ(in_PUSH_SPR_NUM_REG [i]));
109            }
110
111#ifdef STATISTICS
112        if (usage_is_set(_usage,USE_STATISTICS))
113          for (uint32_t i=0; i<_param->_nb_bank; ++i)
114            {
115             
116              (*(_stat_bank_gpr_nb_elt [i])) += _gpr_list[i].size();
117              (*(_stat_bank_spr_nb_elt [i])) += _spr_list[i].size();
118            }
119#endif
120
121#if (DEBUG >= DEBUG_TRACE) and (DEBUG_Free_List_unit == true)
122        if (0)
123        {
124          uint32_t limit = 4;
125     
126          log_printf(TRACE,Free_List_unit,FUNCTION,"  * Dump Free List");
127          for (uint32_t i=0; i<_param->_nb_bank; ++i)
128            {
129              log_printf(TRACE,Free_List_unit,FUNCTION,"    * GPR [%d] - NB_ELT : %d",i,_gpr_list[i].size());
130
131              uint32_t j=0;
132              for (std::list<Tgeneral_address_t>::iterator it=_gpr_list[i].begin();
133                   it!=_gpr_list[i].end();
134                   )
135                {
136                  std::string str = "";
137             
138                  for (uint32_t x=0; x<limit; x++)
139                    {
140                      if (it==_gpr_list[i].end())
141                        break;
142                      else
143                        str+=toString("GPR[%.4d][%.4d] : %.5d | ",i,j,*it);
144                      ++it;
145                      ++j;
146                    }
147                  log_printf(TRACE,Register_Address_Translation_unit,FUNCTION,"      * %s",str.c_str());
148                }
149            }
150
151          for (uint32_t i=0; i<_param->_nb_bank; ++i)
152            {
153              log_printf(TRACE,Free_List_unit,FUNCTION,"    * SPR [%d] - NB_ELT : %d",i,_spr_list[i].size());
154
155              uint32_t j=0;
156              for (std::list<Tspecial_address_t>::iterator it=_spr_list[i].begin();
157                   it!=_spr_list[i].end();
158                   )
159                {
160                  std::string str = "";
161
162                  for (uint32_t x=0; x<limit; x++)
163                    {
164                      if (it==_spr_list[i].end())
165                        break;
166                      else
167                        str+=toString("SPR[%.4d][%.4d] : %.5d | ",i,j,*it);
168                      ++it;
169                      ++j;
170                    }
171                  log_printf(TRACE,Register_Address_Translation_unit,FUNCTION,"      * %s",str.c_str());
172                }
173            }
174        }
175#endif
176
177#ifdef DEBUG_TEST
178        if (0)
179          for (uint32_t i=0; i<_param->_nb_bank; ++i)
180            {
181            for (std::list<Tgeneral_address_t>::iterator it1=_gpr_list[i].begin();
182                 it1!=_gpr_list[i].end();
183                 ++it1
184                 )
185              {
186                std::list<Tgeneral_address_t>::iterator it2 = it1;
187
188                it2 ++;
189                while (it2 != _gpr_list[i].end())
190                  {
191                    if (*it1 == *it2)
192                      throw ERRORMORPHEO (FUNCTION,toString(_("In free list, Same GPR (%d)"),*it1));
193                    it2 ++;
194                  }
195              }
196
197            for (std::list<Tspecial_address_t>::iterator it1=_spr_list[i].begin();
198                 it1!=_spr_list[i].end();
199                 ++it1
200                 )
201              {
202                std::list<Tspecial_address_t>::iterator it2 = it1;
203
204                it2 ++;
205                while (it2 != _spr_list[i].end())
206                  {
207                    if (*it1 == *it2)
208                      throw ERRORMORPHEO (FUNCTION,toString(_("In free list, Same SPR (%d)"),*it1));
209                    it2 ++;
210                  }
211              }
212          }
213#endif
214
215      }
216
217#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
218    end_cycle ();
219#endif
220
221    log_end(Free_List_unit,FUNCTION);
222  };
223
224}; // end namespace free_list_unit
225}; // end namespace register_translation_unit
226}; // end namespace rename_unit
227}; // end namespace ooo_engine
228}; // end namespace multi_ooo_engine
229}; // end namespace core
230
231}; // end namespace behavioural
232}; // end namespace morpheo             
233#endif
Note: See TracBrowser for help on using the repository browser.