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

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

Add Load store queue -> but not terminated and tested
Add article to sympa 2007 -> but no started

File size: 7.5 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           
63            bool            exception_alignement= (mask_memory_access(operation) & address) != 0;
64                                                   
65            if (is_operation_memory_store(operation) == true)
66              {
67                // =======================
68                // ===== STORE_QUEUE =====
69                // =======================
70                // There a two store request type :
71                //   - first is operation with address and data
72                //   - second is the information of re order buffer : the store become not speculative and can access at the data cache
73
74                log_printf(TRACE,Load_store_unit,FUNCTION,"store_queue");
75                log_printf(TRACE,Load_store_unit,FUNCTION," * PUSH");
76               
77                // Write pointer is define in rename stage :
78                Tlsq_ptr_t           index         = PORT_READ(in_MEMORY_IN_STORE_QUEUE_PTR_WRITE);
79                log_printf(TRACE,Load_store_unit,FUNCTION,"   * index         : %d",index);
80               
81                // Need read : state and exception.
82                Tstore_queue_state_t old_state     = _store_queue [index]._state;
83                Tstore_queue_state_t new_state     = old_state;
84                bool                 update_info   = false;
85
86                Texception_t         old_exception = _store_queue [index]._exception;
87                Texception_t         new_exception = old_exception;
88
89                // Compute next state
90                switch (old_state)
91                  {
92                  case STORE_QUEUE_EMPTY                   :
93                    {
94                      if (is_operation_memory_store_head(operation) == true)
95                        {
96                          new_state = STORE_QUEUE_NO_VALID_NO_SPECULATIVE;
97
98                          // test if is a speculation
99                          if (operation == OPERATION_MEMORY_STORE_HEAD_KO)
100                            new_exception = EXCEPTION_MEMORY_MISS_SPECULATION;
101                          else
102                            new_exception = EXCEPTION_MEMORY_NONE;
103                        }
104                      else
105                        {
106                          new_state = STORE_QUEUE_VALID_SPECULATIVE;
107
108                          // Test if have an exception
109                          if (exception_alignement == true)
110                            new_exception = EXCEPTION_MEMORY_ALIGNMENT;
111                          else
112                            new_exception = EXCEPTION_MEMORY_NONE;
113
114                          update_info = true;
115                        }
116                      break;
117                    }
118                  case STORE_QUEUE_NO_VALID_NO_SPECULATIVE :
119                    {
120//                    if (is_operation_memory_store_head(operation) == false)
121//                      {
122                          new_state = STORE_QUEUE_VALID_NO_SPECULATIVE;
123
124                          // Test if have a new exception (priority : miss_speculation)
125                          if ((old_exception == EXCEPTION_MEMORY_NONE) and
126                              (exception_alignement == true))
127                            new_exception = EXCEPTION_MEMORY_ALIGNMENT;
128
129                          update_info = true;
130                          break;
131//                      }
132                    }
133                  case STORE_QUEUE_VALID_SPECULATIVE       :
134                    {
135//                    if (is_operation_memory_store_head(operation) == true)
136//                      {
137                          new_state = STORE_QUEUE_VALID_NO_SPECULATIVE;
138
139                          if (operation == OPERATION_MEMORY_STORE_HEAD_KO)
140                            new_exception = EXCEPTION_MEMORY_MISS_SPECULATION;
141
142                          break;
143//                      }
144                    }
145                  case STORE_QUEUE_VALID_NO_SPECULATIVE    :
146                  case STORE_QUEUE_COMMIT                  :
147                    {
148                      ErrorMorpheo("<Load_store_unit::function_speculative_load_commit_transition> Invalid state and operation");
149                    }
150                  }
151
152                _store_queue [index]._state     = new_state;
153                _store_queue [index]._exception = new_exception;
154               
155                if (update_info == true)
156                  {
157                    log_printf(TRACE,Load_store_unit,FUNCTION,"   * Update information");
158
159                    _store_queue [index]._context_id           = PORT_READ(in_MEMORY_IN_CONTEXT_ID  );
160                    _store_queue [index]._packet_id            = PORT_READ(in_MEMORY_IN_PACKET_ID   );
161#ifdef HAVE_MEMORY_OUT_OPERATION
162                    _store_queue [index]._operation            = operation;
163#endif
164#ifdef HAVE_MEMORY_OUT_TYPE
165                    _store_queue [index]._type                 = PORT_READ(in_MEMORY_IN_TYPE        );
166#endif
167                    _store_queue [index]._load_queue_ptr_write = PORT_READ(in_MEMORY_IN_LOAD_QUEUE_PTR_WRITE);
168                    _store_queue [index]._address              = address;
169                    _store_queue [index]._wdata                = PORT_READ(in_MEMORY_IN_DATA_RB     );
170//                  _store_queue [index]._write_rd             = PORT_READ(in_MEMORY_IN_WRITE_RD    );
171//                  _store_queue [index]._num_reg_rd           = PORT_READ(in_MEMORY_IN_NUM_REG_RD  );
172                  }
173              }
174            else
175              {
176//              // ====================================
177//              // ===== SPECULATIVE_ACCESS_QUEUE =====
178//              // ====================================
179
180//              // In speculative access queue, they are many type's request
181//              log_printf(TRACE,Load_store_unit,FUNCTION,"speculative_access_queue");
182//              log_printf(TRACE,Load_store_unit,FUNCTION," * PUSH");
183               
184//              // Write in reservation station
185//              uint32_t index = _speculative_access_queue_control->push();
186               
187//              log_printf(TRACE,Load_store_unit,FUNCTION,"   * index         : %d",index);
188              }
189          }
190
191        //================================================================
192        // Interface "MEMORY_OUT"
193        //================================================================
194
195        if ((    internal_MEMORY_OUT_VAL  == 1) and
196            (PORT_READ(in_MEMORY_OUT_ACK) == 1))
197          {
198            switch (internal_MEMORY_OUT_SELECT_QUEUE)
199              {
200              case SELECT_STORE_QUEUE :
201                {
202                  // =======================
203                  // ===== STORE_QUEUE =====
204                  // =======================
205                 
206                  // Entry flush and increase the read pointer
207                 
208                  _store_queue [internal_MEMORY_STORE_QUEUE_PTR_READ]._state = STORE_QUEUE_EMPTY;
209                 
210                  internal_MEMORY_STORE_QUEUE_PTR_READ = (internal_MEMORY_STORE_QUEUE_PTR_READ+1)%_param->_size_store_queue;
211
212                  break;
213                }
214              case SELECT_LOAD_QUEUE :
215              case SELECT_LOAD_QUEUE_SPECULATIVE :
216                break;
217              }
218          }
219      }
220
221    log_printf(FUNC,Load_store_unit,FUNCTION,"End");
222  };
223
224}; // end namespace load_store_unit
225}; // end namespace execute_unit
226}; // end namespace multi_execute_unit
227}; // end namespace execute_loop
228}; // end namespace multi_execute_loop
229}; // end namespace core
230
231}; // end namespace behavioural
232}; // end namespace morpheo             
233#endif
234//#endif
Note: See TracBrowser for help on using the repository browser.