source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Execute_unit/Execute_unit/Load_store_unit/src/Load_store_unit_function_speculative_load_commit_transition.cpp @ 62

Last change on this file since 62 was 62, checked in by rosiere, 17 years ago

Modification en profondeur de Component-port_map.
Compilation ok pour Register_unit ... a tester (systemC et vhdl)

File size: 8.6 KB
Line 
1#ifdef SYSTEMC
2//#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
3/*
4 * $Id$
5 *
6 * [ Description ]
7 *
8 */
9
10#include "Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Execute_unit/Execute_unit/Load_store_unit/include/Load_store_unit.h"
11
12namespace morpheo                    {
13namespace behavioural {
14namespace core {
15namespace multi_execute_loop {
16namespace execute_loop {
17namespace multi_execute_unit {
18namespace execute_unit {
19namespace load_store_unit {
20
21
22#undef  FUNCTION
23#define FUNCTION "Load_store_unit::function_speculative_load_commit_transition"
24  void Load_store_unit::function_speculative_load_commit_transition (void)
25  {
26    log_printf(FUNC,Load_store_unit,FUNCTION,"Begin");
27
28    if (PORT_READ(in_NRESET) == 0)
29      {
30        // Reset : clear all queue
31        _speculative_access_queue_control->clear();
32        internal_MEMORY_STORE_QUEUE_PTR_READ = 0;
33        internal_MEMORY_LOAD_QUEUE_PTR_READ  = 0;
34
35        for (uint32_t i=0; i< _param->_size_store_queue             ; i++)
36          _store_queue              [i]._state = STORE_QUEUE_EMPTY;
37
38        for (uint32_t i=0; i< _param->_size_load_queue              ; i++)
39          _load_queue               [i]._state = LOAD_QUEUE_EMPTY;
40
41        for (uint32_t i=0; i< _param->_size_speculative_access_queue; i++)
42          _speculative_access_queue [i]._state = SPECULATIVE_ACCESS_QUEUE_EMPTY;
43      }
44    else
45      {
46        //================================================================
47        // Interface "MEMORY_IN"
48        //================================================================
49
50        if ((PORT_READ(in_MEMORY_IN_VAL) == 1) and
51            (    internal_MEMORY_IN_ACK  == 1))
52          {
53            // Test operation :
54            //~~~~~~~~~~~~~~~~~
55            //  store  in store_queue
56            //  load   in speculation_access_queue
57            //  others in speculation_access_queue
58
59            Toperation_t    operation            = PORT_READ(in_MEMORY_IN_OPERATION);
60            Tgeneral_data_t address              = (PORT_READ(in_MEMORY_IN_IMMEDIAT) +
61                                                    PORT_READ(in_MEMORY_IN_DATA_RA ));
62            bool            exception_alignement = (mask_memory_access(operation) & address) != 0;
63                                                   
64            if (is_operation_memory_store(operation) == true)
65              {
66                // =======================
67                // ===== STORE_QUEUE =====
68                // =======================
69                // There a two store request type :
70                //   - first is operation with address and data
71                //   - second is the information of re order buffer : the store become not speculative and can access at the data cache
72
73                log_printf(TRACE,Load_store_unit,FUNCTION,"store_queue");
74                log_printf(TRACE,Load_store_unit,FUNCTION," * PUSH");
75               
76                // Write pointer is define in rename stage :
77                Tlsq_ptr_t           index         = PORT_READ(in_MEMORY_IN_STORE_QUEUE_PTR_WRITE);
78                log_printf(TRACE,Load_store_unit,FUNCTION,"   * index         : %d",index);
79               
80                // Need read : state and exception.
81                Tstore_queue_state_t old_state     = _store_queue [index]._state;
82                Tstore_queue_state_t new_state     = old_state;
83                bool                 update_info   = false;
84
85                Texception_t         old_exception = _store_queue [index]._exception;
86                Texception_t         new_exception = old_exception;
87
88                // Compute next state
89                switch (old_state)
90                  {
91                  case STORE_QUEUE_EMPTY                   :
92                    {
93                      if (is_operation_memory_store_head(operation) == true)
94                        {
95                          new_state = STORE_QUEUE_NO_VALID_NO_SPECULATIVE;
96
97                          // test if is a speculation
98                          if (operation == OPERATION_MEMORY_STORE_HEAD_KO)
99                            new_exception = EXCEPTION_MEMORY_MISS_SPECULATION;
100                          else
101                            new_exception = EXCEPTION_MEMORY_NONE;
102                        }
103                      else
104                        {
105                          new_state = STORE_QUEUE_VALID_SPECULATIVE;
106
107                          // Test if have an exception
108                          if (exception_alignement == true)
109                            new_exception = EXCEPTION_MEMORY_ALIGNMENT;
110                          else
111                            new_exception = EXCEPTION_MEMORY_NONE;
112
113                          update_info = true;
114                        }
115                      break;
116                    }
117                  case STORE_QUEUE_NO_VALID_NO_SPECULATIVE :
118                    {
119//                    if (is_operation_memory_store_head(operation) == false)
120//                      {
121                          new_state = STORE_QUEUE_VALID_NO_SPECULATIVE;
122
123                          // Test if have a new exception (priority : miss_speculation)
124                          if ((old_exception == EXCEPTION_MEMORY_NONE) and
125                              (exception_alignement == true))
126                            new_exception = EXCEPTION_MEMORY_ALIGNMENT;
127
128                          update_info = true;
129                          break;
130//                      }
131                    }
132                  case STORE_QUEUE_VALID_SPECULATIVE       :
133                    {
134//                    if (is_operation_memory_store_head(operation) == true)
135//                      {
136                          new_state = STORE_QUEUE_VALID_NO_SPECULATIVE;
137
138                          if (operation == OPERATION_MEMORY_STORE_HEAD_KO)
139                            new_exception = EXCEPTION_MEMORY_MISS_SPECULATION;
140
141                          break;
142//                      }
143                    }
144                  case STORE_QUEUE_VALID_NO_SPECULATIVE    :
145                  case STORE_QUEUE_COMMIT                  :
146                    {
147                      ErrorMorpheo("<Load_store_unit::function_speculative_load_commit_transition> Invalid state and operation");
148                    }
149                  }
150
151                _store_queue [index]._state     = new_state;
152                _store_queue [index]._exception = new_exception;
153               
154                if (update_info == true)
155                  {
156                    log_printf(TRACE,Load_store_unit,FUNCTION,"   * Update information");
157
158                    _store_queue [index]._context_id           = PORT_READ(in_MEMORY_IN_CONTEXT_ID  );
159                    _store_queue [index]._packet_id            = PORT_READ(in_MEMORY_IN_PACKET_ID   );
160                    _store_queue [index]._dcache_type          = operation_to_dcache_type(operation);
161                    _store_queue [index]._uncached             = 0; // is the MMU that have this info
162                    _store_queue [index]._load_queue_ptr_write = PORT_READ(in_MEMORY_IN_LOAD_QUEUE_PTR_WRITE);
163                    _store_queue [index]._address              = address;
164                    _store_queue [index]._wdata                = PORT_READ(in_MEMORY_IN_DATA_RB     );
165//                  _store_queue [index]._write_rd             = PORT_READ(in_MEMORY_IN_WRITE_RD    );
166//                  _store_queue [index]._num_reg_rd           = PORT_READ(in_MEMORY_IN_NUM_REG_RD  );
167                  }
168              }
169            else
170              {
171//              // ====================================
172//              // ===== SPECULATIVE_ACCESS_QUEUE =====
173//              // ====================================
174
175//              // In speculative access queue, they are many type's request
176//              log_printf(TRACE,Load_store_unit,FUNCTION,"speculative_access_queue");
177//              log_printf(TRACE,Load_store_unit,FUNCTION," * PUSH");
178               
179//              // Write in reservation station
180//              uint32_t index = _speculative_access_queue_control->push();
181               
182//              log_printf(TRACE,Load_store_unit,FUNCTION,"   * index         : %d",index);
183              }
184          }
185
186        //================================================================
187        // Interface "MEMORY_OUT"
188        //================================================================
189
190        if ((    internal_MEMORY_OUT_VAL  == 1) and
191            (PORT_READ(in_MEMORY_OUT_ACK) == 1))
192          {
193            switch (internal_MEMORY_OUT_SELECT_QUEUE)
194              {
195              case SELECT_STORE_QUEUE :
196                {
197                  // =======================
198                  // ===== STORE_QUEUE =====
199                  // =======================
200                 
201                  // Entry flush and increase the read pointer
202                 
203                  _store_queue [internal_MEMORY_STORE_QUEUE_PTR_READ]._state = STORE_QUEUE_EMPTY;
204                 
205                  internal_MEMORY_STORE_QUEUE_PTR_READ = (internal_MEMORY_STORE_QUEUE_PTR_READ+1)%_param->_size_store_queue;
206
207                  break;
208                }
209              case SELECT_LOAD_QUEUE :
210              case SELECT_LOAD_QUEUE_SPECULATIVE :
211                break;
212              }
213          }
214
215        //================================================================
216        // Interface "DCACHE_REQ"
217        //================================================================
218        if ((    internal_DCACHE_REQ_VAL  == 1) and
219            (PORT_READ(in_DCACHE_REQ_ACK) == 1))
220          {
221            switch (internal_DCACHE_REQ_SELECT_QUEUE)
222              {
223              case SELECT_STORE_QUEUE :
224                {
225                  // =======================
226                  // ===== STORE_QUEUE =====
227                  // =======================
228                 
229                  // Entry flush and increase the read pointer
230                 
231                  _store_queue [internal_MEMORY_STORE_QUEUE_PTR_READ]._state = STORE_QUEUE_COMMIT;
232
233                  break;
234                }
235              case SELECT_LOAD_QUEUE :
236              case SELECT_LOAD_QUEUE_SPECULATIVE :
237                break;
238              }
239          }
240
241#if DEBUG>=DEBUG_TRACE
242        // ***** dump store queue
243        cout << "Dump store queue" << endl
244             << "ptr_read : " << toString(static_cast<uint32_t>(internal_MEMORY_STORE_QUEUE_PTR_READ)) << endl;
245       
246        for (uint32_t i=0; i<_param->_size_store_queue; i++)
247          {
248            uint32_t j = (internal_MEMORY_STORE_QUEUE_PTR_READ+i)%_param->_size_store_queue;
249            cout << "{" << j << "}" << endl
250                 << _store_queue[j] << endl;
251          }
252#endif
253      }
254
255    log_printf(FUNC,Load_store_unit,FUNCTION,"End");
256  };
257
258}; // end namespace load_store_unit
259}; // end namespace execute_unit
260}; // end namespace multi_execute_unit
261}; // end namespace execute_loop
262}; // end namespace multi_execute_loop
263}; // end namespace core
264
265}; // end namespace behavioural
266}; // end namespace morpheo             
267#endif
268//#endif
Note: See TracBrowser for help on using the repository browser.