source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Decod_unit/Decod_queue/src/Decod_queue_function_multi_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.7 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id: Decod_queue_function_multi_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_multi_fifo_transition"
22  void Decod_queue::function_multi_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        for (uint32_t i=0; i<_param->_nb_bank; ++i)
30          while (not reg_QUEUE[i].empty())
31            {
32              delete reg_QUEUE[i].front();
33              reg_QUEUE[i].pop_front();
34            }
35
36        for (uint32_t i=0; i<_param->_nb_context; i++)
37          {
38            reg_NB_INST       [i]=0;
39            reg_NB_INST_EVENT [i]=0;
40          }
41
42        reg_NUM_BANK_HEAD = 0;
43        reg_NUM_BANK_TAIL = 0;
44      }
45    else
46      {
47        //--------------------------------------------------------------------
48        //-----[ DECOD_IN ]---------------------------------------------------
49        //-------------------------------------------------------------------- 
50
51        {
52#ifdef STATISTICS
53          uint32_t nb_decod_in = 0;
54#endif
55
56          for (uint32_t i=0; i<_param->_nb_inst_decod; i++)
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#ifdef STATISTICS
62                nb_decod_in ++;
63#endif
64 
65                // Create entry
66                decod_queue_entry_t * entry = new decod_queue_entry_t (1);
67                reg_QUEUE[reg_NUM_BANK_TAIL].push_back(entry);
68               
69                Tcontext_t context = (_param->_have_port_context_id)?PORT_READ(in_DECOD_IN_CONTEXT_ID [i]):0;
70
71                log_printf(TRACE,Decod_queue,FUNCTION,_("    * context : %d"),context);
72
73//              entry->_val           [0] = 1;
74                entry->_context_id    [0] = context;
75                entry->_depth         [0] = (_param->_have_port_depth)?PORT_READ(in_DECOD_IN_DEPTH [i]):0;
76                entry->_type          [0] = PORT_READ(in_DECOD_IN_TYPE          [i]);
77                entry->_operation     [0] = PORT_READ(in_DECOD_IN_OPERATION     [i]);
78                entry->_no_execute    [0] = PORT_READ(in_DECOD_IN_NO_EXECUTE    [i]);
79                entry->_is_delay_slot [0] = PORT_READ(in_DECOD_IN_IS_DELAY_SLOT [i]);
80#ifdef DEBUG
81                entry->_address       [0] = PORT_READ(in_DECOD_IN_ADDRESS       [i]);
82#endif
83                entry->_address_next  [0] = PORT_READ(in_DECOD_IN_ADDRESS_NEXT  [i]);
84                entry->_has_immediat  [0] = PORT_READ(in_DECOD_IN_HAS_IMMEDIAT  [i]);
85                entry->_immediat      [0] = PORT_READ(in_DECOD_IN_IMMEDIAT      [i]);
86                entry->_read_ra       [0] = PORT_READ(in_DECOD_IN_READ_RA       [i]);
87                entry->_num_reg_ra    [0] = PORT_READ(in_DECOD_IN_NUM_REG_RA    [i]);
88                entry->_read_rb       [0] = PORT_READ(in_DECOD_IN_READ_RB       [i]);
89                entry->_num_reg_rb    [0] = PORT_READ(in_DECOD_IN_NUM_REG_RB    [i]);
90                entry->_read_rc       [0] = PORT_READ(in_DECOD_IN_READ_RC       [i]);
91                entry->_num_reg_rc    [0] = PORT_READ(in_DECOD_IN_NUM_REG_RC    [i]);
92                entry->_write_rd      [0] = PORT_READ(in_DECOD_IN_WRITE_RD      [i]);
93                entry->_num_reg_rd    [0] = PORT_READ(in_DECOD_IN_NUM_REG_RD    [i]);
94                entry->_write_re      [0] = PORT_READ(in_DECOD_IN_WRITE_RE      [i]);
95                entry->_num_reg_re    [0] = PORT_READ(in_DECOD_IN_NUM_REG_RE    [i]);
96                entry->_exception_use [0] = PORT_READ(in_DECOD_IN_EXCEPTION_USE [i]);
97                entry->_exception     [0] = PORT_READ(in_DECOD_IN_EXCEPTION     [i]);
98
99                // Update pointer
100                reg_NUM_BANK_TAIL = (reg_NUM_BANK_TAIL+1)%_param->_nb_bank;
101                reg_NB_INST [context] ++;
102
103                log_printf(TRACE,Decod_queue,FUNCTION,_("    * nb_inst : %d"),reg_NB_INST [context]);
104                log_printf(TRACE,Decod_queue,FUNCTION,_("    * PUSH queue"));
105              }
106
107#ifdef STATISTICS
108        if (usage_is_set(_usage,USE_STATISTICS))
109          {
110            if (nb_decod_in > 0)
111              {
112                if (nb_decod_in == _param->_nb_inst_decod)
113                  (*_stat_decode_in_full) ++;
114                else
115                  (*_stat_decode_in_average) += nb_decod_in;
116              }
117            else
118              {
119                (*_stat_decode_in_empty) ++;
120              }
121          }
122#endif
123        }
124
125        //--------------------------------------------------------------------
126        //-----[ DECOD_OUT ]--------------------------------------------------
127        //--------------------------------------------------------------------
128        {
129          bool can_continue = true; // in_order
130
131          for (uint32_t i=0; i<_param->_nb_inst_decod; i++)
132            if (can_continue and (internal_DECOD_OUT_VAL [i] and internal_DECOD_OUT_ACK[i]))
133              {
134                log_printf(TRACE,Decod_queue,FUNCTION,_("  * DECOD_OUT [%d]"),i);
135               
136                uint32_t num_bank = reg_NUM_BANK_HEAD;
137
138                Tcontext_t context = reg_QUEUE[num_bank].front()->_context_id [0];
139
140                log_printf(TRACE,Decod_queue,FUNCTION,_("    * context : %d"),context);
141
142                // Pop the slot
143                delete reg_QUEUE[num_bank].front();
144                reg_QUEUE[num_bank].pop_front();
145
146                // Update pointer
147                reg_NUM_BANK_HEAD = (reg_NUM_BANK_HEAD+1)%_param->_nb_bank;
148               
149                reg_NB_INST       [context] --;
150                if (reg_NB_INST_EVENT [context] > 0)
151                reg_NB_INST_EVENT [context] --;
152              }
153            else
154              can_continue = false;
155        }
156
157        //--------------------------------------------------------------------
158        //-----[ CONTEXT_EVENT ]----------------------------------------------
159        //--------------------------------------------------------------------
160        for (uint32_t i=0; i<_param->_nb_context; i++)
161          if (PORT_READ(in_CONTEXT_EVENT [i]))
162            reg_NB_INST_EVENT [i] = reg_NB_INST [i];
163
164        //--------------------------------------------------------------------
165        //-----[ OTHERS ]-----------------------------------------------------
166        //--------------------------------------------------------------------
167
168#if defined(DEBUG) and defined(DEBUG_Decod_queue) and (DEBUG >= DEBUG_TRACE)
169    log_printf(TRACE,Decod_queue,FUNCTION,"  * Dump decod_queue");
170    log_printf(TRACE,Decod_queue,FUNCTION,"    * reg_NUM_BANK_HEAD     : %d",reg_NUM_BANK_HEAD);
171    log_printf(TRACE,Decod_queue,FUNCTION,"    * reg_NUM_BANK_TAIL     : %d",reg_NUM_BANK_TAIL);
172    for (uint32_t i=0; i<_param->_nb_context; i++)
173      {
174    log_printf(TRACE,Decod_queue,FUNCTION,"    * reg_NB_INST       [%d] : %d",i,reg_NB_INST [i]);
175    log_printf(TRACE,Decod_queue,FUNCTION,"    * reg_NB_INST_EVENT [%d] : %d",i,reg_NB_INST_EVENT [i]);
176      }
177    for (uint32_t i=0; i<_param->_nb_bank; ++i)
178      {
179        uint32_t x=0;
180        uint32_t num_bank = (reg_NUM_BANK_HEAD+i)%_param->_nb_bank;
181        for (std::list<decod_queue_entry_t*>::iterator it=reg_QUEUE[num_bank].begin();
182             it!=reg_QUEUE[num_bank].end();
183             it++)
184          {
185            log_printf(TRACE,Decod_queue,FUNCTION,"    * [%.4d][%.4d] %.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"
186                       ,i
187                       ,x
188                       ,(*it)->_context_id    [0]
189                       ,(*it)->_depth         [0]
190                       ,(*it)->_type          [0]
191                       ,(*it)->_operation     [0]
192                       ,(*it)->_no_execute    [0]
193                       ,(*it)->_is_delay_slot [0]
194                       ,(*it)->_address       [0]
195                       ,(*it)->_address       [0]<<2
196                       ,(*it)->_has_immediat  [0]
197                       ,(*it)->_immediat      [0]
198                       ,(*it)->_read_ra       [0]
199                       ,(*it)->_num_reg_ra    [0]
200                       ,(*it)->_read_rb       [0]
201                       ,(*it)->_num_reg_rb    [0]
202                       ,(*it)->_read_rc       [0]
203                       ,(*it)->_num_reg_rc    [0]
204                       ,(*it)->_write_rd      [0]
205                       ,(*it)->_num_reg_rd    [0]
206                       ,(*it)->_write_re      [0]
207                       ,(*it)->_num_reg_re    [0]
208                       ,(*it)->_exception_use [0]
209                       ,(*it)->_exception     [0]
210                       );
211            x++;
212          }
213      }
214#endif
215   
216#ifdef STATISTICS
217    if (usage_is_set(_usage,USE_STATISTICS))
218      { 
219        for (uint32_t i=0; i<_param->_nb_bank; ++i)
220          (*_stat_use_queue) += reg_QUEUE[i].size();
221        for (uint32_t i=0; i<_param->_nb_context; i++)
222          (*_stat_nb_inst [i]) += reg_NB_INST [i];
223      }
224#endif
225      }
226
227    log_end(Decod_queue,FUNCTION);
228  };
229 
230}; // end namespace decod_queue
231}; // end namespace decod_unit
232}; // end namespace front_end
233}; // end namespace multi_front_end
234}; // end namespace core
235
236}; // end namespace behavioural
237}; // end namespace morpheo             
238#endif
Note: See TracBrowser for help on using the repository browser.