source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Rename_unit/Register_translation_unit/Free_List_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: 9.0 KB
Line 
1/*
2 * $Id$
3 *
4 * [ Description ]
5 *
6 * Test
7 */
8
9#include "Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Rename_unit/Register_translation_unit/Free_List_unit/SelfTest/include/test.h"
10#include "Common/include/Test.h"
11#include "Behavioural/include/Allocation.h"
12
13#define NB_ITERATION  1
14#define CYCLE_MAX     (128*NB_ITERATION)
15
16#define LABEL(str...)                                                   \
17  {                                                                     \
18    msg (_("{%d} "),static_cast<uint32_t>(sc_simulation_time()));       \
19    msg (str);                                                          \
20    msg (_("\n"));                                                      \
21  } while(0)
22
23#define SC_START(cycle_offset)                                                       \
24  do                                                                                 \
25    {                                                                                \
26      /*cout << "SC_START (begin)" << endl;*/                                        \
27                                                                                     \
28      uint32_t cycle_current = static_cast<uint32_t>(sc_simulation_time());          \
29      if (cycle_offset != 0)                                                         \
30        {                                                                            \
31          cout << "##########[ cycle "<< cycle_current+cycle_offset << " ]" << endl; \
32        }                                                                            \
33                                                                                     \
34      if (cycle_current > CYCLE_MAX)                                                 \
35        {                                                                            \
36          TEST_KO("Maximal cycles Reached");                                         \
37        }                                                                            \
38                                                                                     \
39      sc_start(cycle_offset);                                                        \
40                                                                                     \
41      /*cout << "SC_START (end  )" << endl;*/                                        \
42    } while(0)
43
44void test (string name,
45           morpheo::behavioural::core::multi_ooo_engine::ooo_engine::rename_unit::register_translation_unit::free_list_unit::Parameters * _param)
46{
47  msg(_("<%s> : Simulation SystemC.\n"),name.c_str());
48
49#ifdef STATISTICS
50  morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5,50);
51#endif
52
53  Free_List_unit * _Free_List_unit = new Free_List_unit (name.c_str(),
54#ifdef STATISTICS
55                                             _parameters_statistics,
56#endif
57                                             _param);
58 
59#ifdef SYSTEMC
60  /*********************************************************************
61   * Déclarations des signaux
62   *********************************************************************/
63  string rename;
64
65  sc_clock              *  in_CLOCK  = new sc_clock ("clock", 1.0, 0.5);         
66  sc_signal<Tcontrol_t> *  in_NRESET = new sc_signal<Tcontrol_t> ("NRESET");
67
68  ALLOC1_SC_SIGNAL( in_POP_VAL         ," in_POP_VAL         ",Tcontrol_t        ,_param->_nb_pop );
69  ALLOC1_SC_SIGNAL(out_POP_ACK         ,"out_POP_ACK         ",Tcontrol_t        ,_param->_nb_pop );
70  ALLOC1_SC_SIGNAL( in_POP_GPR_VAL     ," in_POP_GPR_VAL     ",Tcontrol_t        ,_param->_nb_pop );
71  ALLOC1_SC_SIGNAL(out_POP_GPR_NUM_REG ,"out_POP_GPR_NUM_REG ",Tgeneral_address_t,_param->_nb_pop );
72  ALLOC1_SC_SIGNAL( in_POP_SPR_VAL     ," in_POP_SPR_VAL     ",Tcontrol_t        ,_param->_nb_pop );
73  ALLOC1_SC_SIGNAL(out_POP_SPR_NUM_REG ,"out_POP_SPR_NUM_REG ",Tspecial_address_t,_param->_nb_pop );
74  ALLOC1_SC_SIGNAL( in_PUSH_GPR_VAL    ," in_PUSH_GPR_VAL    ",Tcontrol_t        ,_param->_nb_push);
75  ALLOC1_SC_SIGNAL(out_PUSH_GPR_ACK    ,"out_PUSH_GPR_ACK    ",Tcontrol_t        ,_param->_nb_push);
76  ALLOC1_SC_SIGNAL( in_PUSH_GPR_NUM_REG," in_PUSH_GPR_NUM_REG",Tgeneral_address_t,_param->_nb_push);
77  ALLOC1_SC_SIGNAL( in_PUSH_SPR_VAL    ," in_PUSH_SPR_VAL    ",Tcontrol_t        ,_param->_nb_push);
78  ALLOC1_SC_SIGNAL(out_PUSH_SPR_ACK    ,"out_PUSH_SPR_ACK    ",Tcontrol_t        ,_param->_nb_push);
79  ALLOC1_SC_SIGNAL( in_PUSH_SPR_NUM_REG," in_PUSH_SPR_NUM_REG",Tspecial_address_t,_param->_nb_push);
80   
81  /********************************************************
82   * Instanciation
83   ********************************************************/
84 
85  msg(_("<%s> : Instanciation of _Free_List_unit.\n"),name.c_str());
86
87  (*(_Free_List_unit->in_CLOCK))        (*(in_CLOCK));
88  (*(_Free_List_unit->in_NRESET))       (*(in_NRESET));
89
90  INSTANCE1_SC_SIGNAL(_Free_List_unit, in_POP_VAL         ,_param->_nb_pop );
91  INSTANCE1_SC_SIGNAL(_Free_List_unit,out_POP_ACK         ,_param->_nb_pop );
92  INSTANCE1_SC_SIGNAL(_Free_List_unit, in_POP_GPR_VAL     ,_param->_nb_pop );
93  INSTANCE1_SC_SIGNAL(_Free_List_unit,out_POP_GPR_NUM_REG ,_param->_nb_pop );
94  INSTANCE1_SC_SIGNAL(_Free_List_unit, in_POP_SPR_VAL     ,_param->_nb_pop );
95  INSTANCE1_SC_SIGNAL(_Free_List_unit,out_POP_SPR_NUM_REG ,_param->_nb_pop );
96  INSTANCE1_SC_SIGNAL(_Free_List_unit, in_PUSH_GPR_VAL    ,_param->_nb_push);
97  INSTANCE1_SC_SIGNAL(_Free_List_unit,out_PUSH_GPR_ACK    ,_param->_nb_push);
98  INSTANCE1_SC_SIGNAL(_Free_List_unit, in_PUSH_GPR_NUM_REG,_param->_nb_push);
99  INSTANCE1_SC_SIGNAL(_Free_List_unit, in_PUSH_SPR_VAL    ,_param->_nb_push);
100  INSTANCE1_SC_SIGNAL(_Free_List_unit,out_PUSH_SPR_ACK    ,_param->_nb_push);
101  INSTANCE1_SC_SIGNAL(_Free_List_unit, in_PUSH_SPR_NUM_REG,_param->_nb_push);
102
103  msg(_("<%s> : Start Simulation ............\n"),name.c_str());
104   
105  Time * _time = new Time();
106
107  /********************************************************
108   * Simulation - Begin
109   ********************************************************/
110
111  // Initialisation
112
113  const uint32_t seed = 0;
114//const uint32_t seed = static_cast<uint32_t>(time(NULL));
115
116  srand(seed);
117
118  const  int32_t percent_transaction_pop  = 75;
119  const  int32_t percent_transaction_push = 75;
120
121  bool gpr_free [_param->_nb_general_register];
122  bool spr_free [_param->_nb_general_register];
123
124  for (uint32_t i=0; i<_param->_nb_general_register; i++)
125    gpr_free [i] = false;
126  for (uint32_t i=0; i<_param->_nb_special_register; i++)
127    spr_free [i] = false;
128
129  SC_START(0);
130  LABEL("Initialisation");
131
132  LABEL("Reset");
133  in_NRESET->write(0);
134  SC_START(5);
135  in_NRESET->write(1); 
136
137     
138  LABEL("After reset all free-list is empty");
139
140  // Test GPR
141  for (uint32_t i=0; i<_param->_nb_pop; i++)
142    {
143      in_POP_GPR_VAL [i]->write(1);
144    }
145  SC_START(0);
146
147  for (uint32_t i=0; i<_param->_nb_pop; i++)
148    TEST(Tcontrol_t, out_POP_ACK[i]->read(), false);
149
150  // Test SPR
151  for (uint32_t i=0; i<_param->_nb_pop; i++)
152    {
153      in_POP_GPR_VAL [i]->write(0);
154      in_POP_SPR_VAL [i]->write(1);
155    }
156  SC_START(0);
157
158  for (uint32_t i=0; i<_param->_nb_pop; i++)
159    TEST(Tcontrol_t, out_POP_ACK[i]->read(), false);
160
161  // Reset val
162  for (uint32_t i=0; i<_param->_nb_pop; i++)
163    {
164      in_POP_GPR_VAL [i]->write(0);
165      in_POP_SPR_VAL [i]->write(0);
166    }
167
168  LABEL("Loop of Test");
169
170  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
171    {
172      LABEL("Iteration %d",iteration);
173
174      int32_t nb_request = 32;
175
176      while (nb_request > 1)
177        {
178          for (uint32_t i=0; i<_param->_nb_push; i++)
179            {
180              Tgeneral_address_t gpr_reg = rand()%_param->_nb_general_register;
181              in_PUSH_GPR_VAL     [i]->write(not gpr_free[gpr_reg] and ((rand()%100)<percent_transaction_push));
182              in_PUSH_GPR_NUM_REG [i]->write(gpr_reg);
183             
184              Tspecial_address_t spr_reg = rand()%_param->_nb_special_register;
185              in_PUSH_SPR_VAL     [i]->write(not spr_free[spr_reg] and ((rand()%100)<percent_transaction_push));
186              in_PUSH_SPR_NUM_REG [i]->write(spr_reg);
187            }
188         
189          for (uint32_t i=0; i<_param->_nb_pop; i++)
190            {
191              in_POP_VAL     [i]->write((rand()%100)<percent_transaction_pop);
192              in_POP_GPR_VAL [i]->write(rand()%2);
193              in_POP_SPR_VAL [i]->write(rand()%2);
194            }
195         
196          SC_START(0);
197         
198          for (uint32_t i=0; i<_param->_nb_pop; i++)
199            if (in_POP_VAL [i]->read() and out_POP_ACK[i]->read())
200              {
201                nb_request --;
202                if (in_POP_GPR_VAL [i]->read())
203                  {
204                    Tgeneral_address_t reg = out_POP_GPR_NUM_REG [i]->read();
205                   
206                    TEST(bool, gpr_free[reg],true);
207
208                    Tgeneral_address_t bank = reg >> _param->_bank_gpr_size_slot;
209                    TEST(bool, (bank >= (i*_param->_nb_bank_by_pop)) and (bank < ((i+1)*_param->_nb_bank_by_pop)), true);
210
211                    gpr_free[reg] = false;
212                  }
213               
214                if (in_POP_SPR_VAL [i]->read())
215                  {
216                    Tspecial_address_t reg = out_POP_SPR_NUM_REG [i]->read();
217                   
218                    TEST(bool,spr_free[reg],true);
219                   
220                    Tspecial_address_t bank = reg >> _param->_bank_spr_size_slot;
221                    TEST(bool, (bank >= (i*_param->_nb_bank_by_pop)) and (bank < ((i+1)*_param->_nb_bank_by_pop)), true);
222
223                    spr_free[reg] = false;
224                  }
225              }
226         
227          for (uint32_t i=0; i<_param->_nb_push; i++)
228            {
229              if (in_PUSH_GPR_VAL [i]->read() and out_PUSH_GPR_ACK [i]->read())
230                gpr_free[in_PUSH_GPR_NUM_REG [i]->read()] = true;
231              if (in_PUSH_SPR_VAL [i]->read() and out_PUSH_SPR_ACK [i]->read())
232                spr_free[in_PUSH_SPR_NUM_REG [i]->read()] = true;
233            }
234          SC_START(1);
235        }
236    }
237
238  /********************************************************
239   * Simulation - End
240   ********************************************************/
241
242  TEST_OK ("End of Simulation");
243  delete _time;
244
245  msg(_("<%s> : ............ Stop Simulation\n"),name.c_str());
246
247  delete in_CLOCK;
248  delete in_NRESET;
249
250  delete []  in_POP_VAL         ;
251  delete [] out_POP_ACK         ;
252  delete []  in_POP_GPR_VAL     ;
253  delete [] out_POP_GPR_NUM_REG ;
254  delete []  in_POP_SPR_VAL     ;
255  delete [] out_POP_SPR_NUM_REG ;
256  delete []  in_PUSH_GPR_VAL    ;
257  delete [] out_PUSH_GPR_ACK    ;
258  delete []  in_PUSH_GPR_NUM_REG;
259  delete []  in_PUSH_SPR_VAL    ;
260  delete [] out_PUSH_SPR_ACK    ;
261  delete []  in_PUSH_SPR_NUM_REG;
262#endif
263
264  delete _Free_List_unit;
265#ifdef STATISTICS
266  delete _parameters_statistics;
267#endif
268}
Note: See TracBrowser for help on using the repository browser.