source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Decod_unit/Decod_queue/src/Decod_queue_function_one_fifo_transition.cpp @ 136

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

1) Add new algo in ifetch queue
2) Add Cancel bit
3) new config

  • Property svn:keywords set to Id
File size: 8.1 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id: Decod_queue_function_one_fifo_transition.cpp 136 2009-10-20 18:52:15Z rosiere $
4 *
5 * [ Description ]
6 *
7 */
8
9#include "Behavioural/Core/Multi_Front_end/Front_end/Decod_unit/Decod_queue/include/Decod_queue.h"
10
11namespace morpheo                    {
12namespace behavioural {
13namespace core {
14namespace multi_front_end {
15namespace front_end {
16namespace decod_unit {
17namespace decod_queue {
18
19
20#undef  FUNCTION
21#define FUNCTION "Decod_queue::function_one_fifo_transition"
22  void Decod_queue::function_one_fifo_transition (void)
23  {
24    log_begin(Decod_queue,FUNCTION);
25    log_function(Decod_queue,FUNCTION,_name.c_str());
26
27    if (PORT_READ(in_NRESET) == 0)
28      {
29        while (not reg_QUEUE->empty())
30          {
31            delete reg_QUEUE->front();
32            reg_QUEUE->pop_front();
33          }
34
35        for (uint32_t i=0; i<_param->_nb_context; i++)
36          {
37            reg_NB_INST       [i]=0;
38            reg_NB_INST_EVENT [i]=0;
39          }
40
41        reg_LAST_SLOT = 0;
42      }
43    else
44      {
45        //--------------------------------------------------------------------
46        //-----[ DECOD_IN ]---------------------------------------------------
47        //-------------------------------------------------------------------- 
48        {
49        decod_queue_entry_t * entry = NULL;
50
51#ifdef STATISTICS
52        uint32_t nb_decod_in = 0;
53#endif
54
55        for (uint32_t i=0; i<_param->_nb_inst_decod; i++)
56          {
57            if (PORT_READ(in_DECOD_IN_VAL [i]) and internal_DECOD_IN_ACK[i])
58              {
59                log_printf(TRACE,Decod_queue,FUNCTION,_("  * DECOD_IN  [%d]"),i);
60
61                if (entry == NULL)
62                 {
63                   // Once creation and insert in queue
64                   entry = new decod_queue_entry_t (_param->_nb_inst_decod);
65                   reg_QUEUE->push_back(entry);
66                 }
67
68#ifdef STATISTICS
69                nb_decod_in ++;
70#endif
71
72                Tcontext_t context = (_param->_have_port_context_id)?PORT_READ(in_DECOD_IN_CONTEXT_ID [i]):0;
73
74                log_printf(TRACE,Decod_queue,FUNCTION,_("    * context : %d"),context);
75
76                entry->_val           [i] = 1;
77                entry->_context_id    [i] = context;
78                entry->_depth         [i] = (_param->_have_port_depth)?PORT_READ(in_DECOD_IN_DEPTH [i]):0;
79                entry->_type          [i] = PORT_READ(in_DECOD_IN_TYPE          [i]);
80                entry->_operation     [i] = PORT_READ(in_DECOD_IN_OPERATION     [i]);
81                entry->_no_execute    [i] = PORT_READ(in_DECOD_IN_NO_EXECUTE    [i]);
82                entry->_is_delay_slot [i] = PORT_READ(in_DECOD_IN_IS_DELAY_SLOT [i]);
83#ifdef DEBUG
84                entry->_address       [i] = PORT_READ(in_DECOD_IN_ADDRESS       [i]);
85#endif
86                entry->_address_next  [i] = PORT_READ(in_DECOD_IN_ADDRESS_NEXT  [i]);
87                entry->_has_immediat  [i] = PORT_READ(in_DECOD_IN_HAS_IMMEDIAT  [i]);
88                entry->_immediat      [i] = PORT_READ(in_DECOD_IN_IMMEDIAT      [i]);
89                entry->_read_ra       [i] = PORT_READ(in_DECOD_IN_READ_RA       [i]);
90                entry->_num_reg_ra    [i] = PORT_READ(in_DECOD_IN_NUM_REG_RA    [i]);
91                entry->_read_rb       [i] = PORT_READ(in_DECOD_IN_READ_RB       [i]);
92                entry->_num_reg_rb    [i] = PORT_READ(in_DECOD_IN_NUM_REG_RB    [i]);
93                entry->_read_rc       [i] = PORT_READ(in_DECOD_IN_READ_RC       [i]);
94                entry->_num_reg_rc    [i] = PORT_READ(in_DECOD_IN_NUM_REG_RC    [i]);
95                entry->_write_rd      [i] = PORT_READ(in_DECOD_IN_WRITE_RD      [i]);
96                entry->_num_reg_rd    [i] = PORT_READ(in_DECOD_IN_NUM_REG_RD    [i]);
97                entry->_write_re      [i] = PORT_READ(in_DECOD_IN_WRITE_RE      [i]);
98                entry->_num_reg_re    [i] = PORT_READ(in_DECOD_IN_NUM_REG_RE    [i]);
99                entry->_exception_use [i] = PORT_READ(in_DECOD_IN_EXCEPTION_USE [i]);
100                entry->_exception     [i] = PORT_READ(in_DECOD_IN_EXCEPTION     [i]);
101
102                reg_NB_INST [context] ++;
103
104                log_printf(TRACE,Decod_queue,FUNCTION,_("    * nb_inst : %d"),reg_NB_INST [context]);
105                log_printf(TRACE,Decod_queue,FUNCTION,_("    * PUSH queue"));
106              }
107          }
108
109#ifdef STATISTICS
110        if (usage_is_set(_usage,USE_STATISTICS))
111          {
112            if (nb_decod_in > 0)
113              {
114                if (nb_decod_in == _param->_nb_inst_decod)
115                  (*_stat_decode_in_full) ++;
116                else
117                  (*_stat_decode_in_average) += nb_decod_in;
118              }
119            else
120              {
121                (*_stat_decode_in_empty) ++;
122              }
123          }
124#endif
125        }
126
127        //--------------------------------------------------------------------
128        //-----[ DECOD_OUT ]--------------------------------------------------
129        //--------------------------------------------------------------------
130        if (not reg_QUEUE->empty())
131          {
132            bool find = false;
133           
134            for (uint32_t i=0; i<_param->_nb_inst_decod; i++)
135              {
136                // Test transaction : if ok then invalid slot
137                // In order by rename logic
138                if (internal_DECOD_OUT_VAL [i] and internal_DECOD_OUT_ACK[i])
139                  {
140                    log_printf(TRACE,Decod_queue,FUNCTION,_("  * DECOD_OUT [%d]"),i);
141               
142#ifdef DEBUG_TEST
143                    if (reg_LAST_SLOT != i)
144                      throw ERRORMORPHEO(FUNCTION,toString(_("reg_LAST_SLOT (%d) is different at decod_out port (%d)."),reg_LAST_SLOT,i));
145#endif
146                    reg_LAST_SLOT ++;
147
148                    reg_QUEUE->front()->_val [i] = 0;
149
150                    Tcontext_t context = reg_QUEUE->front()->_context_id [i];
151                    log_printf(TRACE,Decod_queue,FUNCTION,_("    * context : %d"),context);
152                   
153                    reg_NB_INST       [context] --;
154                    if (reg_NB_INST_EVENT [context] > 0)
155                    reg_NB_INST_EVENT [context] --;
156
157                    log_printf(TRACE,Decod_queue,FUNCTION,_("    * nb_inst : %d"),reg_NB_INST [context]);
158                  }
159                // Test if slot is (again) valid, if yes, then have less one instruction in the entry
160                find |= reg_QUEUE->front()->_val [i];
161              }
162           
163            // test if can free the entry : test if have consume all entry
164            if (not find) // no valid instruction in current slot
165              {
166                log_printf(TRACE,Decod_queue,FUNCTION,_("    * POP  queue"));
167
168                // can pop the slot
169                delete reg_QUEUE->front();
170                reg_QUEUE->pop_front();
171
172                reg_LAST_SLOT = 0;
173              }
174          }
175
176        //--------------------------------------------------------------------
177        //-----[ CONTEXT_EVENT ]----------------------------------------------
178        //--------------------------------------------------------------------
179        for (uint32_t i=0; i<_param->_nb_context; i++)
180          if (PORT_READ(in_CONTEXT_EVENT [i]))
181            reg_NB_INST_EVENT [i] = reg_NB_INST [i];
182      }
183
184#if defined(DEBUG) and defined(DEBUG_Decod_queue) and (DEBUG >= DEBUG_TRACE)
185    log_printf(TRACE,Decod_queue,FUNCTION,"  * Dump decod_queue");
186    log_printf(TRACE,Decod_queue,FUNCTION,"    * reg_LAST_SLOT : %d",reg_LAST_SLOT);
187    uint32_t x=0;
188    for (std::list<decod_queue_entry_t*>::iterator it=reg_QUEUE->begin();
189         it!=reg_QUEUE->end();
190         it++)
191      {
192        for (uint32_t i=0; i<_param->_nb_inst_decod; i++)
193          {
194            if ((*it)->_val [i])
195              log_printf(TRACE,Decod_queue,FUNCTION,"    * [%.4d][%.4d] %.1d, %.3d %.2d, %.2d %.3d %.1d %.1d, 0x%.8x (0x%.8x), %.1d 0x%.8x, %.1d %.2d, %.1d %.2d, %.1d %.2d, %.1d %.2d, %.1d %.2d, %.1d %.2d"
196                         ,x
197                         ,i
198                         ,(*it)->_val           [i]
199                         ,(*it)->_context_id    [i]
200                         ,(*it)->_depth         [i]
201                         ,(*it)->_type          [i]
202                         ,(*it)->_operation     [i]
203                         ,(*it)->_no_execute    [i]
204                         ,(*it)->_is_delay_slot [i]
205                         ,(*it)->_address       [i]
206                         ,(*it)->_address       [i]<<2
207                         ,(*it)->_has_immediat  [i]
208                         ,(*it)->_immediat      [i]
209                         ,(*it)->_read_ra       [i]
210                         ,(*it)->_num_reg_ra    [i]
211                         ,(*it)->_read_rb       [i]
212                         ,(*it)->_num_reg_rb    [i]
213                         ,(*it)->_read_rc       [i]
214                         ,(*it)->_num_reg_rc    [i]
215                         ,(*it)->_write_rd      [i]
216                         ,(*it)->_num_reg_rd    [i]
217                         ,(*it)->_write_re      [i]
218                         ,(*it)->_num_reg_re    [i]
219                         ,(*it)->_exception_use [i]
220                         ,(*it)->_exception     [i]
221                         );
222            else
223              log_printf(TRACE,Decod_queue,FUNCTION,"    * [%.4d][%.4d] %d"
224                         ,x
225                         ,i
226                         ,(*it)->_val           [i]
227                         );
228
229          }
230        x++;
231      }
232#endif
233   
234#ifdef STATISTICS
235    if (usage_is_set(_usage,USE_STATISTICS))
236      { 
237        (*_stat_use_queue) += reg_QUEUE->size();
238        for (uint32_t i=0; i<_param->_nb_context; i++)
239          (*_stat_nb_inst [i]) += reg_NB_INST [i];
240      }
241#endif
242
243    log_end(Decod_queue,FUNCTION);
244  };
245
246}; // end namespace decod_queue
247}; // end namespace decod_unit
248}; // end namespace front_end
249}; // end namespace multi_front_end
250}; // end namespace core
251
252}; // end namespace behavioural
253}; // end namespace morpheo             
254#endif
Note: See TracBrowser for help on using the repository browser.