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

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

1) Add modelsim simulation systemC
2) Modelsim cosimulation systemC / VHDL is not finish !!!! (cf execute_queue and write_unit)
3) Add multi architecture
5) Add template for comparator, multiplier and divider
6) Change Message
Warning) Various test macro have change, many selftest can't compile

  • Property svn:keywords set to Id
File size: 9.3 KB
Line 
1/*
2 * $Id: test.cpp 113 2009-04-14 18:39:12Z 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  sc_signal<Tcontrol_t        > **  in_POP_VAL        ;
53  sc_signal<Tcontrol_t        > ** out_POP_ACK        ;
54  sc_signal<Tcontrol_t        > **  in_POP_GPR_VAL    ; // write_rd
55  sc_signal<Tgeneral_address_t> ** out_POP_GPR_NUM_REG; // num_reg_rd
56  sc_signal<Tcontrol_t        > **  in_POP_SPR_VAL    ; // write_re
57  sc_signal<Tspecial_address_t> ** out_POP_SPR_NUM_REG; // num_reg_re
58  sc_signal<Tcontrol_t        > **  in_PUSH_GPR_VAL    ; // gpr_free (cf stat_list)
59  sc_signal<Tcontrol_t        > ** out_PUSH_GPR_ACK    ;
60  sc_signal<Tgeneral_address_t> **  in_PUSH_GPR_NUM_REG;
61  sc_signal<Tcontrol_t        > **  in_PUSH_SPR_VAL    ; // spr_free (cf stat_list)
62  sc_signal<Tcontrol_t        > ** out_PUSH_SPR_ACK    ;
63  sc_signal<Tspecial_address_t> **  in_PUSH_SPR_NUM_REG;
64
65  ALLOC1_SC_SIGNAL( in_POP_VAL         ," in_POP_VAL         ",Tcontrol_t        ,_param->_nb_pop );
66  ALLOC1_SC_SIGNAL(out_POP_ACK         ,"out_POP_ACK         ",Tcontrol_t        ,_param->_nb_pop );
67  ALLOC1_SC_SIGNAL( in_POP_GPR_VAL     ," in_POP_GPR_VAL     ",Tcontrol_t        ,_param->_nb_pop );
68  ALLOC1_SC_SIGNAL(out_POP_GPR_NUM_REG ,"out_POP_GPR_NUM_REG ",Tgeneral_address_t,_param->_nb_pop );
69  ALLOC1_SC_SIGNAL( in_POP_SPR_VAL     ," in_POP_SPR_VAL     ",Tcontrol_t        ,_param->_nb_pop );
70  ALLOC1_SC_SIGNAL(out_POP_SPR_NUM_REG ,"out_POP_SPR_NUM_REG ",Tspecial_address_t,_param->_nb_pop );
71  ALLOC1_SC_SIGNAL( in_PUSH_GPR_VAL    ," in_PUSH_GPR_VAL    ",Tcontrol_t        ,_param->_nb_push);
72  ALLOC1_SC_SIGNAL(out_PUSH_GPR_ACK    ,"out_PUSH_GPR_ACK    ",Tcontrol_t        ,_param->_nb_push);
73  ALLOC1_SC_SIGNAL( in_PUSH_GPR_NUM_REG," in_PUSH_GPR_NUM_REG",Tgeneral_address_t,_param->_nb_push);
74  ALLOC1_SC_SIGNAL( in_PUSH_SPR_VAL    ," in_PUSH_SPR_VAL    ",Tcontrol_t        ,_param->_nb_push);
75  ALLOC1_SC_SIGNAL(out_PUSH_SPR_ACK    ,"out_PUSH_SPR_ACK    ",Tcontrol_t        ,_param->_nb_push);
76  ALLOC1_SC_SIGNAL( in_PUSH_SPR_NUM_REG," in_PUSH_SPR_NUM_REG",Tspecial_address_t,_param->_nb_push);
77   
78  /********************************************************
79   * Instanciation
80   ********************************************************/
81 
82  msg(_("<%s> : Instanciation of _Free_List_unit.\n"),name.c_str());
83
84  (*(_Free_List_unit->in_CLOCK))        (*(in_CLOCK));
85  (*(_Free_List_unit->in_NRESET))       (*(in_NRESET));
86
87  INSTANCE1_SC_SIGNAL(_Free_List_unit, in_POP_VAL         ,_param->_nb_pop );
88  INSTANCE1_SC_SIGNAL(_Free_List_unit,out_POP_ACK         ,_param->_nb_pop );
89  INSTANCE1_SC_SIGNAL(_Free_List_unit, in_POP_GPR_VAL     ,_param->_nb_pop );
90  INSTANCE1_SC_SIGNAL(_Free_List_unit,out_POP_GPR_NUM_REG ,_param->_nb_pop );
91  INSTANCE1_SC_SIGNAL(_Free_List_unit, in_POP_SPR_VAL     ,_param->_nb_pop );
92  INSTANCE1_SC_SIGNAL(_Free_List_unit,out_POP_SPR_NUM_REG ,_param->_nb_pop );
93  INSTANCE1_SC_SIGNAL(_Free_List_unit, in_PUSH_GPR_VAL    ,_param->_nb_push);
94  INSTANCE1_SC_SIGNAL(_Free_List_unit,out_PUSH_GPR_ACK    ,_param->_nb_push);
95  INSTANCE1_SC_SIGNAL(_Free_List_unit, in_PUSH_GPR_NUM_REG,_param->_nb_push);
96  INSTANCE1_SC_SIGNAL(_Free_List_unit, in_PUSH_SPR_VAL    ,_param->_nb_push);
97  INSTANCE1_SC_SIGNAL(_Free_List_unit,out_PUSH_SPR_ACK    ,_param->_nb_push);
98  INSTANCE1_SC_SIGNAL(_Free_List_unit, in_PUSH_SPR_NUM_REG,_param->_nb_push);
99
100  msg(_("<%s> : Start Simulation ............\n"),name.c_str());
101   
102  Time * _time = new Time();
103
104  /********************************************************
105   * Simulation - Begin
106   ********************************************************/
107
108  // Initialisation
109
110  const uint32_t seed = 0;
111//const uint32_t seed = static_cast<uint32_t>(time(NULL));
112
113  srand(seed);
114
115  const  int32_t percent_transaction_pop  = 75;
116  const  int32_t percent_transaction_push = 75;
117
118  bool gpr_free [_param->_nb_general_register];
119  bool spr_free [_param->_nb_general_register];
120
121  for (uint32_t i=0; i<_param->_nb_general_register; i++)
122    gpr_free [i] = false;
123  for (uint32_t i=0; i<_param->_nb_special_register; i++)
124    spr_free [i] = false;
125
126  SC_START(0);
127  LABEL("Initialisation");
128
129  LABEL("Reset");
130  in_NRESET->write(0);
131  SC_START(5);
132  in_NRESET->write(1); 
133
134     
135  LABEL("After reset all free-list is empty");
136
137  // Test GPR
138  for (uint32_t i=0; i<_param->_nb_pop; i++)
139    {
140      in_POP_GPR_VAL [i]->write(1);
141    }
142  SC_START(0);
143
144  for (uint32_t i=0; i<_param->_nb_pop; i++)
145    TEST(Tcontrol_t, out_POP_ACK[i]->read(), false);
146
147  // Test SPR
148  for (uint32_t i=0; i<_param->_nb_pop; i++)
149    {
150      in_POP_GPR_VAL [i]->write(0);
151      in_POP_SPR_VAL [i]->write(1);
152    }
153  SC_START(0);
154
155  for (uint32_t i=0; i<_param->_nb_pop; i++)
156    TEST(Tcontrol_t, out_POP_ACK[i]->read(), false);
157
158  // Reset val
159  for (uint32_t i=0; i<_param->_nb_pop; i++)
160    {
161      in_POP_GPR_VAL [i]->write(0);
162      in_POP_SPR_VAL [i]->write(0);
163    }
164
165  LABEL("Loop of Test");
166
167  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
168    {
169      LABEL("Iteration %d",iteration);
170
171      int32_t nb_request = 32;
172
173      while (nb_request > 1)
174        {
175          for (uint32_t i=0; i<_param->_nb_push; i++)
176            {
177              Tgeneral_address_t gpr_reg = rand()%_param->_nb_general_register;
178              in_PUSH_GPR_VAL     [i]->write(not gpr_free[gpr_reg] and ((rand()%100)<percent_transaction_push));
179              in_PUSH_GPR_NUM_REG [i]->write(gpr_reg);
180             
181              Tspecial_address_t spr_reg = rand()%_param->_nb_special_register;
182              in_PUSH_SPR_VAL     [i]->write(not spr_free[spr_reg] and ((rand()%100)<percent_transaction_push));
183              in_PUSH_SPR_NUM_REG [i]->write(spr_reg);
184            }
185         
186          for (uint32_t i=0; i<_param->_nb_pop; i++)
187            {
188              in_POP_VAL     [i]->write((rand()%100)<percent_transaction_pop);
189              in_POP_GPR_VAL [i]->write(rand()%2);
190              in_POP_SPR_VAL [i]->write(rand()%2);
191            }
192         
193          SC_START(0);
194         
195          for (uint32_t i=0; i<_param->_nb_pop; i++)
196            if (in_POP_VAL [i]->read() and out_POP_ACK[i]->read())
197              {
198                nb_request --;
199                if (in_POP_GPR_VAL [i]->read())
200                  {
201                    Tgeneral_address_t reg = out_POP_GPR_NUM_REG [i]->read();
202                   
203                    TEST(bool, gpr_free[reg],true);
204
205//                  Tgeneral_address_t bank = reg >> _param->_bank_gpr_size_slot;
206//                  TEST(bool, (bank >= (i*_param->_nb_bank_by_pop)) and (bank < ((i+1)*_param->_nb_bank_by_pop)), true);
207
208                    gpr_free[reg] = false;
209                  }
210               
211                if (in_POP_SPR_VAL [i]->read())
212                  {
213                    Tspecial_address_t reg = out_POP_SPR_NUM_REG [i]->read();
214                   
215                    TEST(bool,spr_free[reg],true);
216                   
217//                  Tspecial_address_t bank = reg >> _param->_bank_spr_size_slot;
218//                  TEST(bool, (bank >= (i*_param->_nb_bank_by_pop)) and (bank < ((i+1)*_param->_nb_bank_by_pop)), true);
219
220                    spr_free[reg] = false;
221                  }
222              }
223         
224          for (uint32_t i=0; i<_param->_nb_push; i++)
225            {
226              if (in_PUSH_GPR_VAL [i]->read() and out_PUSH_GPR_ACK [i]->read())
227                gpr_free[in_PUSH_GPR_NUM_REG [i]->read()] = true;
228              if (in_PUSH_SPR_VAL [i]->read() and out_PUSH_SPR_ACK [i]->read())
229                spr_free[in_PUSH_SPR_NUM_REG [i]->read()] = true;
230            }
231          SC_START(1);
232        }
233    }
234
235  /********************************************************
236   * Simulation - End
237   ********************************************************/
238
239  TEST_OK ("End of Simulation");
240  delete _time;
241
242  msg(_("<%s> : ............ Stop Simulation\n"),name.c_str());
243
244  delete in_CLOCK;
245  delete in_NRESET;
246
247  delete []  in_POP_VAL         ;
248  delete [] out_POP_ACK         ;
249  delete []  in_POP_GPR_VAL     ;
250  delete [] out_POP_GPR_NUM_REG ;
251  delete []  in_POP_SPR_VAL     ;
252  delete [] out_POP_SPR_NUM_REG ;
253  delete []  in_PUSH_GPR_VAL    ;
254  delete [] out_PUSH_GPR_ACK    ;
255  delete []  in_PUSH_GPR_NUM_REG;
256  delete []  in_PUSH_SPR_VAL    ;
257  delete [] out_PUSH_SPR_ACK    ;
258  delete []  in_PUSH_SPR_NUM_REG;
259#endif
260
261  delete _Free_List_unit;
262#ifdef STATISTICS
263  delete _parameters_statistics;
264#endif
265}
Note: See TracBrowser for help on using the repository browser.