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 @ 124

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

1) Add test and configuration
2) Fix Bug
3) Add log file in load store unit
4) Fix Bug in environment

  • 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 124 2009-06-17 12:11:25Z 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          bool find = false;
54#endif
55          for (uint32_t i=0; i<_param->_nb_inst_decod; i++)
56            if (PORT_READ(in_DECOD_IN_VAL [i]) and internal_DECOD_IN_ACK[i])
57              {
58                log_printf(TRACE,Decod_queue,FUNCTION,_("  * DECOD_IN  [%d]"),i);
59               
60                // Create entry
61                decod_queue_entry_t * entry = new decod_queue_entry_t (1);
62                reg_QUEUE[reg_NUM_BANK_TAIL].push_back(entry);
63               
64#ifdef STATISTICS
65                find = true;
66                if (usage_is_set(_usage,USE_STATISTICS))
67                  (*_stat_sum_inst_enable) ++;
68#endif
69
70                Tcontext_t context = (_param->_have_port_context_id)?PORT_READ(in_DECOD_IN_CONTEXT_ID [i]):0;
71
72                log_printf(TRACE,Decod_queue,FUNCTION,_("    * context : %d"),context);
73
74//              entry->_val           [0] = 1;
75                entry->_context_id    [0] = context;
76                entry->_depth         [0] = (_param->_have_port_depth)?PORT_READ(in_DECOD_IN_DEPTH [i]):0;
77                entry->_type          [0] = PORT_READ(in_DECOD_IN_TYPE          [i]);
78                entry->_operation     [0] = PORT_READ(in_DECOD_IN_OPERATION     [i]);
79                entry->_no_execute    [0] = PORT_READ(in_DECOD_IN_NO_EXECUTE    [i]);
80                entry->_is_delay_slot [0] = PORT_READ(in_DECOD_IN_IS_DELAY_SLOT [i]);
81#ifdef DEBUG
82                entry->_address       [0] = PORT_READ(in_DECOD_IN_ADDRESS       [i]);
83#endif
84                entry->_address_next  [0] = PORT_READ(in_DECOD_IN_ADDRESS_NEXT  [i]);
85                entry->_has_immediat  [0] = PORT_READ(in_DECOD_IN_HAS_IMMEDIAT  [i]);
86                entry->_immediat      [0] = PORT_READ(in_DECOD_IN_IMMEDIAT      [i]);
87                entry->_read_ra       [0] = PORT_READ(in_DECOD_IN_READ_RA       [i]);
88                entry->_num_reg_ra    [0] = PORT_READ(in_DECOD_IN_NUM_REG_RA    [i]);
89                entry->_read_rb       [0] = PORT_READ(in_DECOD_IN_READ_RB       [i]);
90                entry->_num_reg_rb    [0] = PORT_READ(in_DECOD_IN_NUM_REG_RB    [i]);
91                entry->_read_rc       [0] = PORT_READ(in_DECOD_IN_READ_RC       [i]);
92                entry->_num_reg_rc    [0] = PORT_READ(in_DECOD_IN_NUM_REG_RC    [i]);
93                entry->_write_rd      [0] = PORT_READ(in_DECOD_IN_WRITE_RD      [i]);
94                entry->_num_reg_rd    [0] = PORT_READ(in_DECOD_IN_NUM_REG_RD    [i]);
95                entry->_write_re      [0] = PORT_READ(in_DECOD_IN_WRITE_RE      [i]);
96                entry->_num_reg_re    [0] = PORT_READ(in_DECOD_IN_NUM_REG_RE    [i]);
97                entry->_exception_use [0] = PORT_READ(in_DECOD_IN_EXCEPTION_USE [i]);
98                entry->_exception     [0] = PORT_READ(in_DECOD_IN_EXCEPTION     [i]);
99
100                // Update pointer
101                reg_NUM_BANK_TAIL = (reg_NUM_BANK_TAIL+1)%_param->_nb_bank;
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#ifdef STATISTICS
109          if (usage_is_set(_usage,USE_STATISTICS))
110            if (find)
111              (*_stat_sum_transaction_decod_in) ++;
112#endif
113        }
114
115        //--------------------------------------------------------------------
116        //-----[ DECOD_OUT ]--------------------------------------------------
117        //--------------------------------------------------------------------
118        {
119          bool can_continue = true; // in_order
120
121          for (uint32_t i=0; i<_param->_nb_inst_decod; i++)
122            if (can_continue and (internal_DECOD_OUT_VAL [i] and internal_DECOD_OUT_ACK[i]))
123              {
124                log_printf(TRACE,Decod_queue,FUNCTION,_("  * DECOD_OUT [%d]"),i);
125               
126                uint32_t num_bank = reg_NUM_BANK_HEAD;
127
128                Tcontext_t context = reg_QUEUE[num_bank].front()->_context_id [0];
129
130                log_printf(TRACE,Decod_queue,FUNCTION,_("    * context : %d"),context);
131
132                // Pop the slot
133                delete reg_QUEUE[num_bank].front();
134                reg_QUEUE[num_bank].pop_front();
135
136                // Update pointer
137                reg_NUM_BANK_HEAD = (reg_NUM_BANK_HEAD+1)%_param->_nb_bank;
138               
139                reg_NB_INST       [context] --;
140                if (reg_NB_INST_EVENT [context] > 0)
141                reg_NB_INST_EVENT [context] --;
142              }
143            else
144              can_continue = false;
145        }
146
147        //--------------------------------------------------------------------
148        //-----[ CONTEXT_EVENT ]----------------------------------------------
149        //--------------------------------------------------------------------
150        for (uint32_t i=0; i<_param->_nb_context; i++)
151          if (PORT_READ(in_CONTEXT_EVENT [i]))
152            reg_NB_INST_EVENT [i] = reg_NB_INST [i];
153
154        //--------------------------------------------------------------------
155        //-----[ OTHERS ]-----------------------------------------------------
156        //--------------------------------------------------------------------
157
158#if defined(DEBUG) and defined(DEBUG_Decod_queue) and (DEBUG >= DEBUG_TRACE)
159    log_printf(TRACE,Decod_queue,FUNCTION,"  * Dump decod_queue");
160    log_printf(TRACE,Decod_queue,FUNCTION,"    * reg_NUM_BANK_HEAD     : %d",reg_NUM_BANK_HEAD);
161    log_printf(TRACE,Decod_queue,FUNCTION,"    * reg_NUM_BANK_TAIL     : %d",reg_NUM_BANK_TAIL);
162    for (uint32_t i=0; i<_param->_nb_context; i++)
163      {
164    log_printf(TRACE,Decod_queue,FUNCTION,"    * reg_NB_INST       [%d] : %d",i,reg_NB_INST [i]);
165    log_printf(TRACE,Decod_queue,FUNCTION,"    * reg_NB_INST_EVENT [%d] : %d",i,reg_NB_INST_EVENT [i]);
166      }
167    for (uint32_t i=0; i<_param->_nb_bank; ++i)
168      {
169        uint32_t x=0;
170        uint32_t num_bank = (reg_NUM_BANK_HEAD+i)%_param->_nb_bank;
171        for (std::list<decod_queue_entry_t*>::iterator it=reg_QUEUE[num_bank].begin();
172             it!=reg_QUEUE[num_bank].end();
173             it++)
174          {
175            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"
176                       ,i
177                       ,x
178                       ,(*it)->_context_id    [0]
179                       ,(*it)->_depth         [0]
180                       ,(*it)->_type          [0]
181                       ,(*it)->_operation     [0]
182                       ,(*it)->_no_execute    [0]
183                       ,(*it)->_is_delay_slot [0]
184                       ,(*it)->_address       [0]
185                       ,(*it)->_address       [0]<<2
186                       ,(*it)->_has_immediat  [0]
187                       ,(*it)->_immediat      [0]
188                       ,(*it)->_read_ra       [0]
189                       ,(*it)->_num_reg_ra    [0]
190                       ,(*it)->_read_rb       [0]
191                       ,(*it)->_num_reg_rb    [0]
192                       ,(*it)->_read_rc       [0]
193                       ,(*it)->_num_reg_rc    [0]
194                       ,(*it)->_write_rd      [0]
195                       ,(*it)->_num_reg_rd    [0]
196                       ,(*it)->_write_re      [0]
197                       ,(*it)->_num_reg_re    [0]
198                       ,(*it)->_exception_use [0]
199                       ,(*it)->_exception     [0]
200                       );
201            x++;
202          }
203      }
204#endif
205   
206#ifdef STATISTICS
207    if (usage_is_set(_usage,USE_STATISTICS))
208      { 
209        for (uint32_t i=0; i<_param->_nb_bank; ++i)
210          *(_stat_use_queue) += reg_QUEUE[i].size();
211        for (uint32_t i=0; i<_param->_nb_context; i++)
212          *(_stat_nb_inst [i]) += reg_NB_INST [i];
213      }
214#endif
215      }
216
217    log_end(Decod_queue,FUNCTION);
218  };
219 
220}; // end namespace decod_queue
221}; // end namespace decod_unit
222}; // end namespace front_end
223}; // end namespace multi_front_end
224}; // end namespace core
225
226}; // end namespace behavioural
227}; // end namespace morpheo             
228#endif
Note: See TracBrowser for help on using the repository browser.