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

Last change on this file since 109 was 109, checked in by rosiere, 15 years ago

1) Configuration : instance configuration file : regroup similar instance
2) Configuration : timing default = 0
3) Debug/Commit_unit : Add watch dog timer
4) Issue_queue : Test parameters : add test if type is optionnal
5) Cor_glue : Fix insert index
6) Free_list : remove bank_by_pop (else deadlock)
7) Update Free List : add register to source event

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