source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Rename_unit/Load_Store_pointer_unit/SelfTest/src/test.cpp @ 78

Last change on this file since 78 was 78, checked in by rosiere, 16 years ago

Add :

  • Execute_loop (must be test systemC)
  • Prediction
    • Direction : predifined scheme
    • Branch Target Buffer
  • iFetch_unit
    • ifetch_queue
    • pc management
  • Decod_unit
    • coming soon : support for custom operation
  • Rename_unit
    • RAT
    • Free_list
    • Dependence RAW check
    • Load store unit pointer
  • New Environnement (hierarchy_memory will remove in a next version)


Modif :

  • Manage Custom Operation
  • All component in execute_loop to use the new statistics management

Not Finish :

  • Return Address Stack
  • Environnement
File size: 15.7 KB
Line 
1/*
2 * $Id$
3 *
4 * [ Description ]
5 *
6 * Test
7 */
8
9#include "Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Rename_unit/Load_Store_pointer_unit/SelfTest/include/test.h"
10#include "Common/include/Test.h"
11#include "Common/include/Max.h"
12#include "Behavioural/include/Allocation.h"
13#include <list>
14
15#define NB_ITERATION  256
16#define CYCLE_MAX     (128*NB_ITERATION)
17
18#define LABEL(str...)                                                   \
19  {                                                                     \
20    msg (_("{%d} "),static_cast<uint32_t>(sc_simulation_time()));       \
21    msg (str);                                                          \
22    msg (_("\n"));                                                      \
23  } while(0)
24
25#define SC_START(cycle_offset)                                                       \
26  do                                                                                 \
27    {                                                                                \
28      /*cout << "SC_START (begin)" << endl;*/                                        \
29                                                                                     \
30      uint32_t cycle_current = static_cast<uint32_t>(sc_simulation_time());          \
31      if (cycle_offset != 0)                                                         \
32        {                                                                            \
33          cout << "##########[ cycle "<< cycle_current+cycle_offset << " ]" << endl; \
34        }                                                                            \
35                                                                                     \
36      if (cycle_current > CYCLE_MAX)                                                 \
37        {                                                                            \
38          TEST_KO("Maximal cycles Reached");                                         \
39        }                                                                            \
40                                                                                     \
41      sc_start(cycle_offset);                                                        \
42                                                                                     \
43      /*cout << "SC_START (end  )" << endl;*/                                        \
44    } while(0)
45
46class request_t
47{
48public : Tcontext_t   _front_end_id         ;
49public : Tcontext_t   _context_id           ;
50public : Ttype_t      _type                 ;
51public : Toperation_t _operation            ;
52public : Tlsq_ptr_t   _store_queue_ptr_write;
53public : Tlsq_ptr_t   _load_queue_ptr_write ;
54 
55public : request_t (Tcontext_t   front_end_id         ,
56                    Tcontext_t   context_id           ,
57                    Ttype_t      type                 ,
58                    Toperation_t operation            ,
59                    Tlsq_ptr_t   store_queue_ptr_write,
60                    Tlsq_ptr_t   load_queue_ptr_write )
61  {
62    _front_end_id          = front_end_id         ;
63    _context_id            = context_id           ;
64    _type                  = type                 ;
65    _operation             = operation            ;
66    _store_queue_ptr_write = store_queue_ptr_write;
67    _load_queue_ptr_write  = load_queue_ptr_write ;
68  } 
69};
70
71void test (string name,
72           morpheo::behavioural::core::multi_ooo_engine::ooo_engine::rename_unit::load_store_pointer_unit::Parameters * _param)
73{
74  msg(_("<%s> : Simulation SystemC.\n"),name.c_str());
75
76#ifdef STATISTICS
77  morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5,50);
78#endif
79
80  Load_Store_pointer_unit * _Load_Store_pointer_unit = new Load_Store_pointer_unit (name.c_str(),
81#ifdef STATISTICS
82                                             _parameters_statistics,
83#endif
84                                             _param);
85 
86#ifdef SYSTEMC
87  /*********************************************************************
88   * Déclarations des signaux
89   *********************************************************************/
90  string rename;
91
92  sc_clock              *  in_CLOCK  = new sc_clock ("clock", 1.0, 0.5);         
93  sc_signal<Tcontrol_t> *  in_NRESET = new sc_signal<Tcontrol_t> ("NRESET");
94
95  ALLOC1_SC_SIGNAL( in_INSERT_VAL                  ," in_INSERT_VAL                  ",Tcontrol_t  ,_param->_nb_inst_insert);
96  ALLOC1_SC_SIGNAL(out_INSERT_ACK                  ,"out_INSERT_ACK                  ",Tcontrol_t  ,_param->_nb_inst_insert);
97  ALLOC1_SC_SIGNAL( in_INSERT_FRONT_END_ID         ," in_INSERT_FRONT_END_ID         ",Tcontext_t  ,_param->_nb_inst_insert);
98  ALLOC1_SC_SIGNAL( in_INSERT_CONTEXT_ID           ," in_INSERT_CONTEXT_ID           ",Tcontext_t  ,_param->_nb_inst_insert);
99  ALLOC1_SC_SIGNAL( in_INSERT_TYPE                 ," in_INSERT_TYPE                 ",Ttype_t     ,_param->_nb_inst_insert);
100  ALLOC1_SC_SIGNAL( in_INSERT_OPERATION            ," in_INSERT_OPERATION            ",Toperation_t,_param->_nb_inst_insert);
101  ALLOC1_SC_SIGNAL(out_INSERT_STORE_QUEUE_PTR_WRITE,"out_INSERT_STORE_QUEUE_PTR_WRITE",Tlsq_ptr_t  ,_param->_nb_inst_insert);
102  ALLOC1_SC_SIGNAL(out_INSERT_LOAD_QUEUE_PTR_WRITE ,"out_INSERT_LOAD_QUEUE_PTR_WRITE ",Tlsq_ptr_t  ,_param->_nb_inst_insert);
103  ALLOC1_SC_SIGNAL( in_RETIRE_VAL                  ," in_RETIRE_VAL                  ",Tcontrol_t  ,_param->_nb_inst_retire);
104  ALLOC1_SC_SIGNAL(out_RETIRE_ACK                  ,"out_RETIRE_ACK                  ",Tcontrol_t  ,_param->_nb_inst_retire);
105  ALLOC1_SC_SIGNAL( in_RETIRE_FRONT_END_ID         ," in_RETIRE_FRONT_END_ID         ",Tcontext_t  ,_param->_nb_inst_retire);
106  ALLOC1_SC_SIGNAL( in_RETIRE_CONTEXT_ID           ," in_RETIRE_CONTEXT_ID           ",Tcontext_t  ,_param->_nb_inst_retire);
107  ALLOC1_SC_SIGNAL( in_RETIRE_TYPE                 ," in_RETIRE_TYPE                 ",Ttype_t     ,_param->_nb_inst_retire);
108  ALLOC1_SC_SIGNAL( in_RETIRE_OPERATION            ," in_RETIRE_OPERATION            ",Toperation_t,_param->_nb_inst_retire);
109  ALLOC1_SC_SIGNAL( in_RETIRE_STORE_QUEUE_PTR_WRITE," in_RETIRE_STORE_QUEUE_PTR_WRITE",Tlsq_ptr_t  ,_param->_nb_inst_retire);
110  ALLOC1_SC_SIGNAL( in_RETIRE_LOAD_QUEUE_PTR_WRITE ," in_RETIRE_LOAD_QUEUE_PTR_WRITE ",Tlsq_ptr_t  ,_param->_nb_inst_retire);
111 
112  /********************************************************
113   * Instanciation
114   ********************************************************/
115 
116  msg(_("<%s> : Instanciation of _Load_Store_pointer_unit.\n"),name.c_str());
117
118  (*(_Load_Store_pointer_unit->in_CLOCK))        (*(in_CLOCK));
119  (*(_Load_Store_pointer_unit->in_NRESET))       (*(in_NRESET));
120
121  INSTANCE1_SC_SIGNAL(_Load_Store_pointer_unit, in_INSERT_VAL                  ,_param->_nb_inst_insert);
122  INSTANCE1_SC_SIGNAL(_Load_Store_pointer_unit,out_INSERT_ACK                  ,_param->_nb_inst_insert);
123  if (_param->_have_port_front_end_id)
124  INSTANCE1_SC_SIGNAL(_Load_Store_pointer_unit, in_INSERT_FRONT_END_ID         ,_param->_nb_inst_insert);
125  if (_param->_have_port_context_id)
126  INSTANCE1_SC_SIGNAL(_Load_Store_pointer_unit, in_INSERT_CONTEXT_ID           ,_param->_nb_inst_insert);
127  INSTANCE1_SC_SIGNAL(_Load_Store_pointer_unit, in_INSERT_TYPE                 ,_param->_nb_inst_insert);
128  INSTANCE1_SC_SIGNAL(_Load_Store_pointer_unit, in_INSERT_OPERATION            ,_param->_nb_inst_insert);
129  INSTANCE1_SC_SIGNAL(_Load_Store_pointer_unit,out_INSERT_STORE_QUEUE_PTR_WRITE,_param->_nb_inst_insert);
130  if (_param->_have_port_load_queue_ptr)
131  INSTANCE1_SC_SIGNAL(_Load_Store_pointer_unit,out_INSERT_LOAD_QUEUE_PTR_WRITE ,_param->_nb_inst_insert);
132
133  INSTANCE1_SC_SIGNAL(_Load_Store_pointer_unit, in_RETIRE_VAL                  ,_param->_nb_inst_retire);
134  INSTANCE1_SC_SIGNAL(_Load_Store_pointer_unit,out_RETIRE_ACK                  ,_param->_nb_inst_retire);
135  if (_param->_have_port_front_end_id)
136  INSTANCE1_SC_SIGNAL(_Load_Store_pointer_unit, in_RETIRE_FRONT_END_ID         ,_param->_nb_inst_retire);
137  if (_param->_have_port_context_id)
138  INSTANCE1_SC_SIGNAL(_Load_Store_pointer_unit, in_RETIRE_CONTEXT_ID           ,_param->_nb_inst_retire);
139  INSTANCE1_SC_SIGNAL(_Load_Store_pointer_unit, in_RETIRE_TYPE                 ,_param->_nb_inst_retire);
140  INSTANCE1_SC_SIGNAL(_Load_Store_pointer_unit, in_RETIRE_OPERATION            ,_param->_nb_inst_retire);
141  INSTANCE1_SC_SIGNAL(_Load_Store_pointer_unit, in_RETIRE_STORE_QUEUE_PTR_WRITE,_param->_nb_inst_retire);
142  if (_param->_have_port_load_queue_ptr)
143  INSTANCE1_SC_SIGNAL(_Load_Store_pointer_unit, in_RETIRE_LOAD_QUEUE_PTR_WRITE ,_param->_nb_inst_retire);
144
145  msg(_("<%s> : Start Simulation ............\n"),name.c_str());
146   
147  Time * _time = new Time();
148
149  /********************************************************
150   * Simulation - Begin
151   ********************************************************/
152
153  // Initialisation
154
155  const uint32_t seed = 0;
156//const uint32_t seed = static_cast<uint32_t>(time(NULL));
157
158  srand(seed);
159
160  const  int32_t percent_transaction_insert = 75;
161  const  int32_t percent_transaction_retire = 75;
162 
163  Ttype_t      type     [2];
164  type [0] = TYPE_MEMORY;
165  type [1] = TYPE_ALU;
166
167  Toperation_t operation[2];
168  operation [0] = OPERATION_MEMORY_LOAD_8_Z;
169  operation [1] = OPERATION_MEMORY_STORE_32;
170 
171  list<request_t> rob;
172  list<request_t>::iterator it;
173
174  Tlsq_ptr_t _STORE_QUEUE_PTR_WRITE [_param->_nb_load_store_queue];
175  bool       _STORE_QUEUE_USE       [_param->_nb_load_store_queue][max<uint32_t>(_param->_size_store_queue,_param->_nb_load_store_queue)];
176  Tlsq_ptr_t _STORE_QUEUE_NB_USE    [_param->_nb_load_store_queue];
177  Tlsq_ptr_t _LOAD_QUEUE_PTR_WRITE  [_param->_nb_load_store_queue];
178  bool       _LOAD_QUEUE_USE        [_param->_nb_load_store_queue][max<uint32_t>(_param->_size_load_queue,_param->_nb_load_store_queue)];
179
180  for (uint32_t i=0; i<_param->_nb_load_store_queue; i++)
181    {
182      _STORE_QUEUE_PTR_WRITE [i] = 0;
183      _STORE_QUEUE_NB_USE    [i] = 0;
184      _LOAD_QUEUE_PTR_WRITE  [i] = 0;
185
186      for (uint32_t j=0; j<max<uint32_t>(_param->_size_store_queue,_param->_nb_load_store_queue); j++)
187        _STORE_QUEUE_USE       [i][j] = false;
188      for (uint32_t j=0; j<max<uint32_t>(_param->_size_load_queue,_param->_nb_load_store_queue); j++)
189        _LOAD_QUEUE_USE        [i][j] = false;
190    }
191
192  SC_START(0);
193  LABEL("Initialisation");
194
195  LABEL("Reset");
196  in_NRESET->write(0);
197  SC_START(5);
198  in_NRESET->write(1); 
199
200  LABEL("Loop of Test");
201
202  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
203    {
204      LABEL("Iteration %d",iteration);
205
206      for (uint32_t i=0; i<_param->_nb_inst_insert; i++)
207        {
208          in_INSERT_VAL          [i] ->write((rand()%100)<percent_transaction_insert);
209          Tcontext_t front_end_id = rand()%_param->_nb_front_end;
210          in_INSERT_FRONT_END_ID [i] ->write(front_end_id);
211          in_INSERT_CONTEXT_ID   [i] ->write(rand()%_param->_nb_context[front_end_id]);
212          in_INSERT_TYPE         [i] ->write(type     [rand()%2]);
213          in_INSERT_OPERATION    [i] ->write(operation[rand()%2]);
214        }
215     
216      it = rob.begin();
217      for (uint32_t i=0; i<_param->_nb_inst_retire; i++)
218        {
219          in_RETIRE_VAL          [i] ->write(((rand()%100)<percent_transaction_retire) and (i< rob.size()));
220         
221          if (i< rob.size())
222            {
223              in_RETIRE_FRONT_END_ID          [i]->write(it->_front_end_id         );
224              in_RETIRE_CONTEXT_ID            [i]->write(it->_context_id           );
225              in_RETIRE_TYPE                  [i]->write(it->_type                 );
226              in_RETIRE_OPERATION             [i]->write(it->_operation            );
227              in_RETIRE_STORE_QUEUE_PTR_WRITE [i]->write(it->_store_queue_ptr_write);
228              in_RETIRE_LOAD_QUEUE_PTR_WRITE  [i]->write(it->_load_queue_ptr_write );
229             
230              it++;
231            }
232        }
233     
234      SC_START(0);
235
236      it = rob.begin();
237      for (uint32_t i=0; i<_param->_nb_inst_retire; i++)
238        {
239          bool pop = false;
240          if (in_RETIRE_VAL[i]->read())
241            {
242              if (in_RETIRE_TYPE [i]->read() != TYPE_MEMORY)
243                TEST(Tcontrol_t, out_RETIRE_ACK[i]->read(),true);
244             
245              if (out_RETIRE_ACK[i]->read())
246                {
247                  pop = true;
248
249                  LABEL("RETIRE[%d] Transaction accepted",i);
250                  if (it->_type == TYPE_MEMORY)
251                    {
252                      LABEL(" * Type MEMORY");
253                      if (is_operation_memory_store(it->_operation))
254                        {
255                          LABEL("   * Operation STORE");
256                          uint32_t lsq = _param->_link_load_store_unit_with_thread[it->_front_end_id][it->_context_id];
257                          uint32_t ptr = it->_store_queue_ptr_write;
258                         
259                          LABEL("     * lsq : %d",lsq);
260                          LABEL("     * ptr : %d",ptr);
261
262                          _STORE_QUEUE_NB_USE    [lsq]      --;
263                          _STORE_QUEUE_USE       [lsq][ptr] = false;
264                        }
265                      else
266                        {
267                          LABEL("   * Operation LOAD");
268                          uint32_t lsq = _param->_link_load_store_unit_with_thread[it->_front_end_id][it->_context_id];
269                          uint32_t ptr = it->_load_queue_ptr_write;
270
271                          LABEL("     * lsq : %d",lsq);
272                          LABEL("     * ptr : %d",ptr);
273                         
274                          _LOAD_QUEUE_USE       [lsq][ptr] = false;
275                        }
276                    }
277                  it = rob.erase(it);
278                }
279            }
280
281          if ((pop == false) and (i< rob.size()))
282            it++;
283        }
284
285      for (uint32_t i=0; i<_param->_nb_inst_insert; i++)
286        if (in_INSERT_VAL[i]->read())
287          {
288            if (in_INSERT_TYPE [i]->read() != TYPE_MEMORY)
289              TEST(Tcontrol_t, out_INSERT_ACK[i]->read(),true);
290
291            if (out_INSERT_ACK[i]->read())
292              {
293                rob.push_back(request_t( in_INSERT_FRONT_END_ID          [i]->read(),
294                                         in_INSERT_CONTEXT_ID            [i]->read(),
295                                         in_INSERT_TYPE                  [i]->read(),
296                                         in_INSERT_OPERATION             [i]->read(),
297                                        out_INSERT_STORE_QUEUE_PTR_WRITE [i]->read(),
298                                        out_INSERT_LOAD_QUEUE_PTR_WRITE  [i]->read()));
299
300                LABEL("INSERT[%d] Transaction accepted",i);
301
302                if (in_INSERT_TYPE [i]->read() == TYPE_MEMORY)
303                  {
304                    LABEL(" * Type MEMORY");
305                    if (is_operation_memory_store(in_INSERT_OPERATION [i]->read()))
306                      {
307                        LABEL("   * Operation STORE");
308                        uint32_t lsq = _param->_link_load_store_unit_with_thread[in_INSERT_FRONT_END_ID[i]->read()][in_INSERT_CONTEXT_ID[i]->read()];
309                        uint32_t ptr = _STORE_QUEUE_PTR_WRITE [lsq];
310
311                        LABEL("     * lsq : %d",lsq);
312                        LABEL("     * ptr : %d",ptr);
313                       
314                        TEST(bool      , _STORE_QUEUE_USE       [lsq][ptr], false);
315                        TEST(Tlsq_ptr_t, out_INSERT_STORE_QUEUE_PTR_WRITE [i]->read(),ptr                         );
316                        TEST(Tlsq_ptr_t, out_INSERT_LOAD_QUEUE_PTR_WRITE  [i]->read(),_LOAD_QUEUE_PTR_WRITE  [lsq]);
317                        TEST(bool      ,static_cast<uint32_t>(_STORE_QUEUE_NB_USE [lsq]+1)<_param->_size_store_queue[lsq], true);
318                       
319                        _STORE_QUEUE_PTR_WRITE [lsq]      = (ptr+1)%_param->_size_store_queue[lsq];
320                        _STORE_QUEUE_NB_USE    [lsq]      ++;
321                        _STORE_QUEUE_USE       [lsq][ptr] = true;
322                      }
323                    else
324                      {
325                        LABEL("   * Operation LOAD");
326                        uint32_t lsq = _param->_link_load_store_unit_with_thread[in_INSERT_FRONT_END_ID[i]->read()][in_INSERT_CONTEXT_ID[i]->read()];
327                        uint32_t ptr = _LOAD_QUEUE_PTR_WRITE [lsq];
328                       
329                        LABEL("     * lsq : %d",lsq);
330                        LABEL("     * ptr : %d",ptr);
331
332                        TEST(bool      , _LOAD_QUEUE_USE       [lsq][ptr], false);
333                        TEST(Tlsq_ptr_t, out_INSERT_STORE_QUEUE_PTR_WRITE [i]->read(),_STORE_QUEUE_PTR_WRITE  [lsq]);
334                        TEST(Tlsq_ptr_t, out_INSERT_LOAD_QUEUE_PTR_WRITE  [i]->read(),ptr                         );
335                       
336                        _LOAD_QUEUE_PTR_WRITE [lsq]      = (ptr+1)%_param->_size_load_queue[lsq];
337                        _LOAD_QUEUE_USE       [lsq][ptr] = true;
338                      }
339                  }
340              }
341          }
342
343
344    for (uint32_t i=0; i<_param->_nb_load_store_queue; i++)
345      {
346        std::string str;
347
348        LABEL("LOAD_STORE_QUEUE [%d]",i);
349
350        LABEL(" * STORE_QUEUE_PTR_WRITE : %d",_STORE_QUEUE_PTR_WRITE [i]);
351        LABEL(" * STORE_QUEUE_NB_USE    : %d",_STORE_QUEUE_NB_USE    [i]);
352
353        str = "";
354        for (uint32_t j=0; j<_param->_size_store_queue[i]; j++)
355          str += toString(_STORE_QUEUE_USE [i][j]) + " ";
356        LABEL(" * %s",str.c_str());
357       
358        LABEL(" * LOAD_QUEUE_PTR_WRITE  : %d",_LOAD_QUEUE_PTR_WRITE [i]);
359
360        str = "";
361        for (uint32_t j=0; j<_param->_size_load_queue[i]; j++)
362          str += toString(_LOAD_QUEUE_USE [i][j]) + " ";
363        LABEL(" * %s",str.c_str());
364      }
365
366
367      SC_START(1);
368    }
369
370  /********************************************************
371   * Simulation - End
372   ********************************************************/
373
374  TEST_OK ("End of Simulation");
375  delete _time;
376
377  msg(_("<%s> : ............ Stop Simulation\n"),name.c_str());
378
379  delete in_CLOCK;
380  delete in_NRESET;
381
382  delete []  in_INSERT_VAL                  ;
383  delete [] out_INSERT_ACK                  ;
384  delete []  in_INSERT_FRONT_END_ID         ;
385  delete []  in_INSERT_CONTEXT_ID           ;
386  delete []  in_INSERT_TYPE                 ;
387  delete []  in_INSERT_OPERATION            ;
388  delete [] out_INSERT_STORE_QUEUE_PTR_WRITE;
389  delete [] out_INSERT_LOAD_QUEUE_PTR_WRITE ;
390  delete []  in_RETIRE_VAL                  ;
391  delete [] out_RETIRE_ACK                  ;
392  delete []  in_RETIRE_FRONT_END_ID         ;
393  delete []  in_RETIRE_CONTEXT_ID           ;
394  delete []  in_RETIRE_TYPE                 ;
395  delete []  in_RETIRE_OPERATION            ;
396  delete []  in_RETIRE_STORE_QUEUE_PTR_WRITE;
397  delete []  in_RETIRE_LOAD_QUEUE_PTR_WRITE ;
398 
399#endif
400
401  delete _Load_Store_pointer_unit;
402#ifdef STATISTICS
403  delete _parameters_statistics;
404#endif
405}
Note: See TracBrowser for help on using the repository browser.