source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Ifetch_unit/Ifetch_queue/src/Ifetch_queue_function_no_assoc_transition.cpp @ 145

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

1) add test with SPECINT2K
2) new config of Selftest
3) modif RAT to support multiple depth_save ... but not finish (need fix Update Prediction Table)
4) add Function_pointer but need fix

  • Property svn:keywords set to Id
File size: 8.6 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id: Ifetch_queue_function_no_assoc_transition.cpp 145 2010-10-13 18:15:51Z rosiere $
4 *
5 * [ Description ]
6 *
7 */
8
9#include "Behavioural/Core/Multi_Front_end/Front_end/Ifetch_unit/Ifetch_queue/include/Ifetch_queue.h"
10
11namespace morpheo                    {
12namespace behavioural {
13namespace core {
14namespace multi_front_end {
15namespace front_end {
16namespace ifetch_unit {
17namespace ifetch_queue {
18
19
20#undef  FUNCTION
21#define FUNCTION "Ifetch_queue::function_no_assoc_transition"
22  void Ifetch_queue::function_no_assoc_transition (void)
23  {
24    log_begin(Ifetch_queue,FUNCTION);
25    log_function(Ifetch_queue,FUNCTION,_name.c_str());
26
27    if (PORT_READ(in_NRESET) == 0)
28      {
29        reg_PTR_READ  = 0;
30        reg_PTR_WRITE = 0;
31
32        for (uint32_t i=0; i<_param->_size_queue; i++)
33          {
34            _queue [i]->_state = IFETCH_QUEUE_STATE_EMPTY;
35            _queue [i]->_address                     = 0; // not necessary
36            _queue [i]->_inst_ifetch_ptr             = 0; // not necessary
37            _queue [i]->_branch_state                = 0; // not necessary
38            _queue [i]->_branch_update_prediction_id = 0; // not necessary
39            _queue [i]->_exception                   = 0; // not necessary
40
41            for (uint32_t j=0; j<_param->_nb_instruction; j++)
42              {
43            _queue [i]->_instruction             [j] = 0; // not necessary
44            _queue [i]->_instruction_enable      [j] = 0; // not necessary
45              }
46          }
47      }
48    else
49      {
50        // ==========================================================
51        // =====[ ADDRESS ]==========================================
52        // ==========================================================
53#ifdef STATISTICS
54        uint32_t stat_nb_inst_fetch=0;
55#endif
56
57        if (PORT_READ(in_ADDRESS_VAL) and internal_ADDRESS_ACK)
58          {
59            log_printf(TRACE,Ifetch_queue,FUNCTION,"  * ADDRESS : Transaction");
60            log_printf(TRACE,Ifetch_queue,FUNCTION,"    * reg_PTR_WRITE : %d",reg_PTR_WRITE);
61            log_printf(TRACE,Ifetch_queue,FUNCTION,"    * ADDRESS       : 0x%x",PORT_READ(in_ADDRESS_INSTRUCTION_ADDRESS));
62
63            // New slot in ifetch_queue is allocated
64           
65            _queue[reg_PTR_WRITE]->_state = IFETCH_QUEUE_STATE_WAIT_RSP;
66             
67#ifdef STATISTICS
68            if (usage_is_set(_usage,USE_STATISTICS))
69              (*_sum_transaction_address) ++;
70#endif
71
72            for (uint32_t i=0; i<_param->_nb_instruction; i++)
73              {
74                Tcontrol_t enable = PORT_READ(in_ADDRESS_INSTRUCTION_ENABLE [i]);
75#ifdef STATISTICS
76                 stat_nb_inst_fetch += enable;
77#endif
78                _queue[reg_PTR_WRITE]->_instruction_enable [i]      = enable;
79              }
80
81            _queue[reg_PTR_WRITE]->_address                     = PORT_READ(in_ADDRESS_INSTRUCTION_ADDRESS);
82            _queue[reg_PTR_WRITE]->_inst_ifetch_ptr             = (_param->_have_port_inst_ifetch_ptr)?PORT_READ(in_ADDRESS_INST_IFETCH_PTR            ):0;
83            _queue[reg_PTR_WRITE]->_branch_state                = PORT_READ(in_ADDRESS_BRANCH_STATE);
84            _queue[reg_PTR_WRITE]->_branch_update_prediction_id = (_param->_have_port_depth)?PORT_READ(in_ADDRESS_BRANCH_UPDATE_PREDICTION_ID):0;
85           
86            reg_PTR_WRITE = (reg_PTR_WRITE+1)%_param->_size_queue;
87          }
88#ifdef STATISTICS
89        if (usage_is_set(_usage,USE_STATISTICS))
90          (*_stat_nb_inst_fetch) += stat_nb_inst_fetch;
91#endif
92
93        // ==========================================================
94        // =====[ DECOD ]============================================
95        // ==========================================================
96        bool have_instruction_decod  = false;
97        bool have_instruction_enable = false;
98        for (uint32_t i=0; i<_param->_nb_instruction; i++)
99          {
100            if (internal_DECOD_VAL [i] and PORT_READ(in_DECOD_ACK[i]))
101              {
102                log_printf(TRACE,Ifetch_queue,FUNCTION,"  * DECOD [%d] : Transaction",i);
103
104                have_instruction_decod = true;
105                _queue[reg_PTR_READ]->_instruction_enable [i] = false;
106              }
107            have_instruction_enable |= _queue[reg_PTR_READ]->_instruction_enable [i];
108          }
109
110        // Test if all is decoded
111        if (have_instruction_decod and not have_instruction_enable)
112          {
113            // all is decod
114            _queue[reg_PTR_READ]->_state = IFETCH_QUEUE_STATE_EMPTY;
115            reg_PTR_READ = (reg_PTR_READ+1)%_param->_size_queue;
116          }
117         
118        // ==========================================================
119        // =====[ ICACHE_RSP ]=======================================
120        // ==========================================================
121        if (PORT_READ(in_ICACHE_RSP_VAL) and internal_ICACHE_RSP_ACK)
122          {
123            log_printf(TRACE,Ifetch_queue,FUNCTION,"  * ICACHE_RSP : Transaction");
124
125            Tpacket_t ptr = (_param->_have_port_ifetch_queue_ptr)?PORT_READ(in_ICACHE_RSP_PACKET_ID):0;
126           
127            for (uint32_t i=0; i<_param->_nb_instruction; i++)
128              _queue[ptr]->_instruction [i]      = PORT_READ(in_ICACHE_RSP_INSTRUCTION [i]);
129           
130            switch (PORT_READ(in_ICACHE_RSP_ERROR))
131              {
132              case ICACHE_ERROR_NONE      : _queue[ptr]->_exception = EXCEPTION_IFETCH_NONE     ; break;
133              case ICACHE_ERROR_BUS_ERROR : _queue[ptr]->_exception = EXCEPTION_IFETCH_BUS_ERROR; break;
134              default : ERRORMORPHEO(FUNCTION,"icache_rsp_error : unknow value.");
135              }
136
137            switch (_queue[ptr]->_state)
138              {
139              case IFETCH_QUEUE_STATE_WAIT_RSP       : _queue[ptr]->_state = IFETCH_QUEUE_STATE_HAVE_RSP; break;
140              case IFETCH_QUEUE_STATE_ERROR_WAIT_RSP : _queue[ptr]->_state = IFETCH_QUEUE_STATE_EMPTY   ; break;
141              default : ERRORMORPHEO(FUNCTION,"icache_rsp : invalid ifetch_queue state.");
142              }
143          }
144
145        // ==========================================================
146        // =====[ EVENT_RESET ]======================================
147        // ==========================================================
148        if (PORT_READ(in_EVENT_RESET_VAL) and internal_EVENT_RESET_ACK)
149          {
150            log_printf(TRACE,Ifetch_queue,FUNCTION,"  * EVENT_RESET : Transaction");
151
152            // Scan all entry of queue and test the status
153            for (uint32_t i=0; i<_param->_size_queue; i++)
154              switch (_queue[i]->_state)
155              {
156              case IFETCH_QUEUE_STATE_ERROR_WAIT_RSP :                                                        break;
157              case IFETCH_QUEUE_STATE_WAIT_RSP       : _queue[i]->_state = IFETCH_QUEUE_STATE_ERROR_WAIT_RSP; break;
158              default                                : _queue[i]->_state = IFETCH_QUEUE_STATE_EMPTY         ; break;
159              }
160
161            // all entry is empty (or wait respons to flush)
162            // reset ptr
163            //   1) reg_PTR_READ = reg_PTR_WRITE =  = 0
164            //   2) reg_PTR_READ = reg_PTR_WRITE
165            // In method 1), the probalitie than the entry pointed by reg_PTR_WRITE is a slot with state "error_wait_rsp" is more importate that the method 2)
166            reg_PTR_READ = reg_PTR_WRITE;
167          }
168
169#if defined(DEBUG) and (DEBUG >= DEBUG_TRACE)
170        log_printf(TRACE,Ifetch_queue,FUNCTION,"  * Dump ifetch_queue");
171        log_printf(TRACE,Ifetch_queue,FUNCTION,"    * reg_PTR_WRITE : %d",reg_PTR_WRITE);
172        log_printf(TRACE,Ifetch_queue,FUNCTION,"    * reg_PTR_READ  : %d",reg_PTR_READ );
173        for (uint32_t i=0; i<_param->_size_queue; i++)
174          {
175            uint32_t index=(i+reg_PTR_READ)%_param->_size_queue;
176            log_printf(TRACE,Ifetch_queue,FUNCTION,"    * [%d] 0x%.8x (0x%.8x) %d - %d %d %d - %s",
177                       index, 
178                       _queue [index]->_address,
179                       _queue [index]->_address<<2,
180                       _queue [index]->_inst_ifetch_ptr,
181                       _queue [index]->_branch_state,
182                       _queue [index]->_branch_update_prediction_id,
183                       _queue [index]->_exception,
184                       toString(_queue [index]->_state).c_str()
185                       );
186           
187            if (_queue [index]->_state != IFETCH_QUEUE_STATE_EMPTY)
188              for (uint32_t j=0; j<_param->_nb_instruction; j++)
189                log_printf(TRACE,Ifetch_queue,FUNCTION,"      * %d 0x%.8x (0x%.8x)", _queue [index]->_instruction_enable[j], _queue [index]->_instruction[j],(_queue [index]->_address+j)<<2);
190          }
191#endif
192
193#ifdef STATISTICS
194        if (usage_is_set(_usage,USE_STATISTICS))
195          for (uint32_t i=0; i<_param->_size_queue; i++)
196            switch (_queue[i]->_state)
197              {
198              case IFETCH_QUEUE_STATE_EMPTY          : break;
199              case IFETCH_QUEUE_STATE_WAIT_RSP       : (*_sum_use_queue_wait_rsp      ) ++; break;
200              case IFETCH_QUEUE_STATE_HAVE_RSP       : (*_sum_use_queue_have_rsp      ) ++; break;
201              case IFETCH_QUEUE_STATE_ERROR_WAIT_RSP : (*_sum_use_queue_error_wait_rsp) ++; break;
202              default : break;
203              }
204#endif
205      }
206
207    log_end(Ifetch_queue,FUNCTION);
208  };
209
210}; // end namespace ifetch_queue
211}; // end namespace ifetch_unit
212}; // end namespace front_end
213}; // end namespace multi_front_end
214}; // end namespace core
215
216}; // end namespace behavioural
217}; // end namespace morpheo             
218#endif
Note: See TracBrowser for help on using the repository browser.