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

Last change on this file was 139, checked in by rosiere, 14 years ago
  • Add test for all configuration
  • RAT : add rat scheme (depth_save)
  • Property svn:keywords set to Id
File size: 8.9 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id: Decod_queue_function_multi_fifo_transition.cpp 139 2010-07-30 14:47:27Z 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#ifdef STATISTICS
77                entry->_instruction   [0] = PORT_READ(in_DECOD_IN_INSTRUCTION   [i]);
78#endif
79                entry->_type          [0] = PORT_READ(in_DECOD_IN_TYPE          [i]);
80                entry->_operation     [0] = PORT_READ(in_DECOD_IN_OPERATION     [i]);
81                entry->_no_execute    [0] = PORT_READ(in_DECOD_IN_NO_EXECUTE    [i]);
82                entry->_is_delay_slot [0] = PORT_READ(in_DECOD_IN_IS_DELAY_SLOT [i]);
83                entry->_save_rat      [0] = PORT_READ(in_DECOD_IN_SAVE_RAT      [i]);
84#ifdef DEBUG
85                entry->_address       [0] = PORT_READ(in_DECOD_IN_ADDRESS       [i]);
86#endif
87                entry->_address_next  [0] = PORT_READ(in_DECOD_IN_ADDRESS_NEXT  [i]);
88                entry->_has_immediat  [0] = PORT_READ(in_DECOD_IN_HAS_IMMEDIAT  [i]);
89                entry->_immediat      [0] = PORT_READ(in_DECOD_IN_IMMEDIAT      [i]);
90                entry->_read_ra       [0] = PORT_READ(in_DECOD_IN_READ_RA       [i]);
91                entry->_num_reg_ra    [0] = PORT_READ(in_DECOD_IN_NUM_REG_RA    [i]);
92                entry->_read_rb       [0] = PORT_READ(in_DECOD_IN_READ_RB       [i]);
93                entry->_num_reg_rb    [0] = PORT_READ(in_DECOD_IN_NUM_REG_RB    [i]);
94                entry->_read_rc       [0] = PORT_READ(in_DECOD_IN_READ_RC       [i]);
95                entry->_num_reg_rc    [0] = PORT_READ(in_DECOD_IN_NUM_REG_RC    [i]);
96                entry->_write_rd      [0] = PORT_READ(in_DECOD_IN_WRITE_RD      [i]);
97                entry->_num_reg_rd    [0] = PORT_READ(in_DECOD_IN_NUM_REG_RD    [i]);
98                entry->_write_re      [0] = PORT_READ(in_DECOD_IN_WRITE_RE      [i]);
99                entry->_num_reg_re    [0] = PORT_READ(in_DECOD_IN_NUM_REG_RE    [i]);
100                entry->_exception_use [0] = PORT_READ(in_DECOD_IN_EXCEPTION_USE [i]);
101                entry->_exception     [0] = PORT_READ(in_DECOD_IN_EXCEPTION     [i]);
102
103                // Update pointer
104                reg_NUM_BANK_TAIL = (reg_NUM_BANK_TAIL+1)%_param->_nb_bank;
105                reg_NB_INST [context] ++;
106
107                log_printf(TRACE,Decod_queue,FUNCTION,_("    * nb_inst : %d"),reg_NB_INST [context]);
108                log_printf(TRACE,Decod_queue,FUNCTION,_("    * PUSH queue"));
109              }
110
111#ifdef STATISTICS
112        if (usage_is_set(_usage,USE_STATISTICS))
113          {
114            if (nb_decod_in > 0)
115              {
116                if (nb_decod_in == _param->_nb_inst_decod)
117                  (*_stat_decode_in_full) ++;
118                else
119                  (*_stat_decode_in_average) += nb_decod_in;
120              }
121            else
122              {
123                (*_stat_decode_in_empty) ++;
124              }
125          }
126#endif
127        }
128
129        //--------------------------------------------------------------------
130        //-----[ DECOD_OUT ]--------------------------------------------------
131        //--------------------------------------------------------------------
132        {
133          bool can_continue = true; // in_order
134
135          for (uint32_t i=0; i<_param->_nb_inst_decod; i++)
136            if (can_continue and (internal_DECOD_OUT_VAL [i] and internal_DECOD_OUT_ACK[i]))
137              {
138                log_printf(TRACE,Decod_queue,FUNCTION,_("  * DECOD_OUT [%d]"),i);
139               
140                uint32_t num_bank = reg_NUM_BANK_HEAD;
141
142                Tcontext_t context = reg_QUEUE[num_bank].front()->_context_id [0];
143
144                log_printf(TRACE,Decod_queue,FUNCTION,_("    * context : %d"),context);
145
146                // Pop the slot
147                delete reg_QUEUE[num_bank].front();
148                reg_QUEUE[num_bank].pop_front();
149
150                // Update pointer
151                reg_NUM_BANK_HEAD = (reg_NUM_BANK_HEAD+1)%_param->_nb_bank;
152               
153                reg_NB_INST       [context] --;
154                if (reg_NB_INST_EVENT [context] > 0)
155                reg_NB_INST_EVENT [context] --;
156              }
157            else
158              can_continue = false;
159        }
160
161        //--------------------------------------------------------------------
162        //-----[ CONTEXT_EVENT ]----------------------------------------------
163        //--------------------------------------------------------------------
164        for (uint32_t i=0; i<_param->_nb_context; i++)
165          if (PORT_READ(in_CONTEXT_EVENT [i]))
166            reg_NB_INST_EVENT [i] = reg_NB_INST [i];
167
168        //--------------------------------------------------------------------
169        //-----[ OTHERS ]-----------------------------------------------------
170        //--------------------------------------------------------------------
171
172#if defined(DEBUG) and defined(DEBUG_Decod_queue) and (DEBUG >= DEBUG_TRACE)
173    log_printf(TRACE,Decod_queue,FUNCTION,"  * Dump decod_queue");
174    log_printf(TRACE,Decod_queue,FUNCTION,"    * reg_NUM_BANK_HEAD     : %d",reg_NUM_BANK_HEAD);
175    log_printf(TRACE,Decod_queue,FUNCTION,"    * reg_NUM_BANK_TAIL     : %d",reg_NUM_BANK_TAIL);
176    for (uint32_t i=0; i<_param->_nb_context; i++)
177      {
178    log_printf(TRACE,Decod_queue,FUNCTION,"    * reg_NB_INST       [%d] : %d",i,reg_NB_INST [i]);
179    log_printf(TRACE,Decod_queue,FUNCTION,"    * reg_NB_INST_EVENT [%d] : %d",i,reg_NB_INST_EVENT [i]);
180      }
181    for (uint32_t i=0; i<_param->_nb_bank; ++i)
182      {
183        uint32_t x=0;
184        uint32_t num_bank = (reg_NUM_BANK_HEAD+i)%_param->_nb_bank;
185        for (std::list<decod_queue_entry_t*>::iterator it=reg_QUEUE[num_bank].begin();
186             it!=reg_QUEUE[num_bank].end();
187             it++)
188          {
189            log_printf(TRACE,Decod_queue,FUNCTION,"    * [%.4d][%.4d] %.3d %.2d, %.2d %.3d %.1d %.1d %.1d, 0x%.8x (0x%.8x), %.1d 0x%.8x, %.1d %.2d, %.1d %.2d, %.1d %.2d, %.1d %.2d, %.1d %.2d, %.1d %.2d"
190                       ,i
191                       ,x
192                       ,(*it)->_context_id    [0]
193                       ,(*it)->_depth         [0]
194                       ,(*it)->_type          [0]
195                       ,(*it)->_operation     [0]
196                       ,(*it)->_no_execute    [0]
197                       ,(*it)->_is_delay_slot [0]
198                       ,(*it)->_save_rat      [0]
199                       ,(*it)->_address       [0]
200                       ,(*it)->_address       [0]<<2
201                       ,(*it)->_has_immediat  [0]
202                       ,(*it)->_immediat      [0]
203                       ,(*it)->_read_ra       [0]
204                       ,(*it)->_num_reg_ra    [0]
205                       ,(*it)->_read_rb       [0]
206                       ,(*it)->_num_reg_rb    [0]
207                       ,(*it)->_read_rc       [0]
208                       ,(*it)->_num_reg_rc    [0]
209                       ,(*it)->_write_rd      [0]
210                       ,(*it)->_num_reg_rd    [0]
211                       ,(*it)->_write_re      [0]
212                       ,(*it)->_num_reg_re    [0]
213                       ,(*it)->_exception_use [0]
214                       ,(*it)->_exception     [0]
215                       );
216            x++;
217          }
218      }
219#endif
220   
221#ifdef STATISTICS
222    if (usage_is_set(_usage,USE_STATISTICS))
223      { 
224        for (uint32_t i=0; i<_param->_nb_bank; ++i)
225          (*_stat_use_queue) += reg_QUEUE[i].size();
226        for (uint32_t i=0; i<_param->_nb_context; i++)
227          (*_stat_nb_inst [i]) += reg_NB_INST [i];
228      }
229#endif
230      }
231
232    log_end(Decod_queue,FUNCTION);
233  };
234 
235}; // end namespace decod_queue
236}; // end namespace decod_unit
237}; // end namespace front_end
238}; // end namespace multi_front_end
239}; // end namespace core
240
241}; // end namespace behavioural
242}; // end namespace morpheo             
243#endif
Note: See TracBrowser for help on using the repository browser.