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 @ 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.2 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id: Ifetch_queue_function_no_assoc_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/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        if (PORT_READ(in_ADDRESS_VAL) and internal_ADDRESS_ACK)
54          {
55            log_printf(TRACE,Ifetch_queue,FUNCTION,"  * ADDRESS : Transaction");
56            log_printf(TRACE,Ifetch_queue,FUNCTION,"    * reg_PTR_WRITE : %d",reg_PTR_WRITE);
57            log_printf(TRACE,Ifetch_queue,FUNCTION,"    * ADDRESS       : 0x%x",PORT_READ(in_ADDRESS_INSTRUCTION_ADDRESS));
58
59            // New slot in ifetch_queue is allocated
60           
61            _queue[reg_PTR_WRITE]->_state = IFETCH_QUEUE_STATE_WAIT_RSP;
62             
63#ifdef STATISTICS
64            if (usage_is_set(_usage,USE_STATISTICS))
65              (*_sum_transaction_address) ++;
66#endif
67
68            for (uint32_t i=0; i<_param->_nb_instruction; i++)
69              {
70                Tcontrol_t enable = PORT_READ(in_ADDRESS_INSTRUCTION_ENABLE [i]);
71#ifdef STATISTICS
72                if (usage_is_set(_usage,USE_STATISTICS))
73                  (*_sum_inst_enable) += enable;
74#endif
75                _queue[reg_PTR_WRITE]->_instruction_enable [i]      = enable;
76              }
77
78            _queue[reg_PTR_WRITE]->_address                     = PORT_READ(in_ADDRESS_INSTRUCTION_ADDRESS);
79            _queue[reg_PTR_WRITE]->_inst_ifetch_ptr             = (_param->_have_port_inst_ifetch_ptr)?PORT_READ(in_ADDRESS_INST_IFETCH_PTR            ):0;
80            _queue[reg_PTR_WRITE]->_branch_state                = PORT_READ(in_ADDRESS_BRANCH_STATE);
81            _queue[reg_PTR_WRITE]->_branch_update_prediction_id = (_param->_have_port_depth)?PORT_READ(in_ADDRESS_BRANCH_UPDATE_PREDICTION_ID):0;
82           
83            reg_PTR_WRITE = (reg_PTR_WRITE+1)%_param->_size_queue;
84          }
85
86        // ==========================================================
87        // =====[ DECOD ]============================================
88        // ==========================================================
89        bool have_instruction_decod  = false;
90        bool have_instruction_enable = false;
91        for (uint32_t i=0; i<_param->_nb_instruction; i++)
92          {
93            if (internal_DECOD_VAL [i] and PORT_READ(in_DECOD_ACK[i]))
94              {
95                log_printf(TRACE,Ifetch_queue,FUNCTION,"  * DECOD [%d] : Transaction",i);
96
97                have_instruction_decod = true;
98                _queue[reg_PTR_READ]->_instruction_enable [i] = false;
99              }
100            have_instruction_enable |= _queue[reg_PTR_READ]->_instruction_enable [i];
101          }
102
103        // Test if all is decoded
104        if (have_instruction_decod and not have_instruction_enable)
105          {
106            // all is decod
107            _queue[reg_PTR_READ]->_state = IFETCH_QUEUE_STATE_EMPTY;
108            reg_PTR_READ = (reg_PTR_READ+1)%_param->_size_queue;
109          }
110         
111        // ==========================================================
112        // =====[ ICACHE_RSP ]=======================================
113        // ==========================================================
114        if (PORT_READ(in_ICACHE_RSP_VAL) and internal_ICACHE_RSP_ACK)
115          {
116            log_printf(TRACE,Ifetch_queue,FUNCTION,"  * ICACHE_RSP : Transaction");
117
118            Tpacket_t ptr = (_param->_have_port_ifetch_queue_ptr)?PORT_READ(in_ICACHE_RSP_PACKET_ID):0;
119           
120            for (uint32_t i=0; i<_param->_nb_instruction; i++)
121              _queue[ptr]->_instruction [i]      = PORT_READ(in_ICACHE_RSP_INSTRUCTION [i]);
122           
123            switch (PORT_READ(in_ICACHE_RSP_ERROR))
124              {
125              case ICACHE_ERROR_NONE      : _queue[ptr]->_exception = EXCEPTION_IFETCH_NONE     ; break;
126              case ICACHE_ERROR_BUS_ERROR : _queue[ptr]->_exception = EXCEPTION_IFETCH_BUS_ERROR; break;
127              default : ERRORMORPHEO(FUNCTION,"icache_rsp_error : unknow value.");
128              }
129
130            switch (_queue[ptr]->_state)
131              {
132              case IFETCH_QUEUE_STATE_WAIT_RSP       : _queue[ptr]->_state = IFETCH_QUEUE_STATE_HAVE_RSP; break;
133              case IFETCH_QUEUE_STATE_ERROR_WAIT_RSP : _queue[ptr]->_state = IFETCH_QUEUE_STATE_EMPTY   ; break;
134              default : ERRORMORPHEO(FUNCTION,"icache_rsp : invalid ifetch_queue state.");
135              }
136          }
137
138        // ==========================================================
139        // =====[ EVENT_RESET ]======================================
140        // ==========================================================
141        if (PORT_READ(in_EVENT_RESET_VAL) and internal_EVENT_RESET_ACK)
142          {
143            log_printf(TRACE,Ifetch_queue,FUNCTION,"  * EVENT_RESET : Transaction");
144
145            // Scan all entry of queue and test the status
146            for (uint32_t i=0; i<_param->_size_queue; i++)
147              switch (_queue[i]->_state)
148              {
149              case IFETCH_QUEUE_STATE_ERROR_WAIT_RSP :                                                        break;
150              case IFETCH_QUEUE_STATE_WAIT_RSP       : _queue[i]->_state = IFETCH_QUEUE_STATE_ERROR_WAIT_RSP; break;
151              default                                : _queue[i]->_state = IFETCH_QUEUE_STATE_EMPTY         ; break;
152              }
153
154            // all entry is empty (or wait respons to flush)
155            // reset ptr
156            //   1) reg_PTR_READ = reg_PTR_WRITE =  = 0
157            //   2) reg_PTR_READ = reg_PTR_WRITE
158            // 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)
159            reg_PTR_READ = reg_PTR_WRITE;
160          }
161
162#if defined(DEBUG) and (DEBUG >= DEBUG_TRACE)
163        log_printf(TRACE,Ifetch_queue,FUNCTION,"  * Dump ifetch_queue");
164        log_printf(TRACE,Ifetch_queue,FUNCTION,"    * reg_PTR_WRITE : %d",reg_PTR_WRITE);
165        log_printf(TRACE,Ifetch_queue,FUNCTION,"    * reg_PTR_READ  : %d",reg_PTR_READ );
166        for (uint32_t i=0; i<_param->_size_queue; i++)
167          {
168            log_printf(TRACE,Ifetch_queue,FUNCTION,"    * [%d] 0x%.8x (0x%.8x) %d - %d %d %d - %s",
169                       i, 
170                       _queue [i]->_address,
171                       _queue [i]->_address<<2,
172                       _queue [i]->_inst_ifetch_ptr,
173                       _queue [i]->_branch_state,
174                       _queue [i]->_branch_update_prediction_id,
175                       _queue [i]->_exception,
176                       toString(_queue [i]->_state).c_str()
177                       );
178           
179            for (uint32_t j=0; j<_param->_nb_instruction; j++)
180              log_printf(TRACE,Ifetch_queue,FUNCTION,"      * %d 0x%.8x", _queue [i]->_instruction_enable[j], _queue [i]->_instruction[j]);
181          }
182#endif
183
184#ifdef STATISTICS
185        if (usage_is_set(_usage,USE_STATISTICS))
186          for (uint32_t i=0; i<_param->_size_queue; i++)
187            switch (_queue[i]->_state)
188              {
189              case IFETCH_QUEUE_STATE_EMPTY          : break;
190              case IFETCH_QUEUE_STATE_WAIT_RSP       : (*_sum_use_queue_wait_rsp      ) ++; break;
191              case IFETCH_QUEUE_STATE_HAVE_RSP       : (*_sum_use_queue_have_rsp      ) ++; break;
192              case IFETCH_QUEUE_STATE_ERROR_WAIT_RSP : (*_sum_use_queue_error_wait_rsp) ++; break;
193              default : break;
194              }
195#endif
196      }
197
198    log_end(Ifetch_queue,FUNCTION);
199  };
200
201}; // end namespace ifetch_queue
202}; // end namespace ifetch_unit
203}; // end namespace front_end
204}; // end namespace multi_front_end
205}; // end namespace core
206
207}; // end namespace behavioural
208}; // end namespace morpheo             
209#endif
Note: See TracBrowser for help on using the repository browser.