source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Decod_unit/SelfTest/src/test.cpp @ 88

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

Almost complete design
with Test and test platform

  • Property svn:keywords set to Id
File size: 30.6 KB
Line 
1/*
2 * $Id: test.cpp 88 2008-12-10 18:31:39Z rosiere $
3 *
4 * [ Description ]
5 *
6 * Test
7 */
8
9#define NB_ITERATION  1
10#define CYCLE_MAX     (10240*NB_ITERATION)
11
12#include "Behavioural/Core/Multi_Front_end/Front_end/Decod_unit/SelfTest/include/test.h"
13#include "Behavioural/Core/Multi_Front_end/Front_end/Decod_unit/Decod/SelfTest/include/Decod_request.h"
14#include "Common/include/Test.h"
15#include "Behavioural/include/Allocation.h"
16
17void test (string name,
18           morpheo::behavioural::core::multi_front_end::front_end::decod_unit::Parameters * _param)
19{
20  msg(_("<%s> : Simulation SystemC.\n"),name.c_str());
21
22#ifdef STATISTICS
23  morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5,CYCLE_MAX);
24#endif
25
26  Tusage_t _usage = USE_ALL;
27
28//   _usage = usage_unset(_usage,USE_SYSTEMC              );
29//   _usage = usage_unset(_usage,USE_VHDL                 );
30//   _usage = usage_unset(_usage,USE_VHDL_TESTBENCH       );
31//   _usage = usage_unset(_usage,USE_VHDL_TESTBENCH_ASSERT);
32//   _usage = usage_unset(_usage,USE_POSITION             );
33//   _usage = usage_unset(_usage,USE_STATISTICS           );
34//   _usage = usage_unset(_usage,USE_INFORMATION          );
35
36  Decod_unit * _Decod_unit = new Decod_unit
37    (name.c_str(),
38#ifdef STATISTICS
39     _parameters_statistics,
40#endif
41     _param,
42     _usage);
43 
44#ifdef SYSTEMC
45  if (usage_is_set(_usage,USE_SYSTEMC))
46    {
47  /*********************************************************************
48   * Déclarations des signaux
49   *********************************************************************/
50  string rename;
51
52  sc_clock              *  in_CLOCK  = new sc_clock ("clock", 1.0, 0.5);         
53  sc_signal<Tcontrol_t> *  in_NRESET = new sc_signal<Tcontrol_t> ("NRESET");
54
55  ALLOC2_SC_SIGNAL( in_IFETCH_VAL                         ," in_IFETCH_VAL                         ",Tcontrol_t         ,_param->_nb_context, _param->_nb_inst_fetch[it1]);
56  ALLOC2_SC_SIGNAL(out_IFETCH_ACK                         ,"out_IFETCH_ACK                         ",Tcontrol_t         ,_param->_nb_context, _param->_nb_inst_fetch[it1]);
57  ALLOC2_SC_SIGNAL( in_IFETCH_INSTRUCTION                 ," in_IFETCH_INSTRUCTION                 ",Tinstruction_t     ,_param->_nb_context, _param->_nb_inst_fetch[it1]);
58
59  ALLOC1_SC_SIGNAL(in_IFETCH_CONTEXT_ID                   ,"in_IFETCH_CONTEXT_ID                   ",Tcontext_t         ,_param->_nb_context);
60  ALLOC1_SC_SIGNAL(in_IFETCH_ADDRESS                      ,"in_IFETCH_ADDRESS                      ",Tgeneral_address_t ,_param->_nb_context);
61//ALLOC1_SC_SIGNAL(in_IFETCH_ADDRESS_NEXT                 ,"in_IFETCH_ADDRESS_NEXT                 ",Tgeneral_address_t ,_param->_nb_context);
62  ALLOC1_SC_SIGNAL(in_IFETCH_INST_IFETCH_PTR              ,"in_IFETCH_INST_IFETCH_PTR              ",Tinst_ifetch_ptr_t ,_param->_nb_context);
63  ALLOC1_SC_SIGNAL(in_IFETCH_BRANCH_STATE                 ,"in_IFETCH_BRANCH_STATE                 ",Tbranch_state_t    ,_param->_nb_context);
64  ALLOC1_SC_SIGNAL(in_IFETCH_BRANCH_UPDATE_PREDICTION_ID  ,"in_IFETCH_BRANCH_UPDATE_PREDICTION_ID  ",Tprediction_ptr_t  ,_param->_nb_context);
65  ALLOC1_SC_SIGNAL(in_IFETCH_EXCEPTION                    ,"in_IFETCH_EXCEPTION                    ",Texception_t       ,_param->_nb_context);
66
67  ALLOC1_SC_SIGNAL(out_DECOD_VAL                          ,"out_DECOD_VAL                          ",Tcontrol_t         ,_param->_nb_inst_decod);
68  ALLOC1_SC_SIGNAL( in_DECOD_ACK                          ," in_DECOD_ACK                          ",Tcontrol_t         ,_param->_nb_inst_decod);
69  ALLOC1_SC_SIGNAL(out_DECOD_CONTEXT_ID                   ,"out_DECOD_CONTEXT_ID                   ",Tcontext_t         ,_param->_nb_inst_decod);
70  ALLOC1_SC_SIGNAL(out_DECOD_DEPTH                        ,"out_DECOD_DEPTH                        ",Tdepth_t           ,_param->_nb_inst_decod);
71  ALLOC1_SC_SIGNAL(out_DECOD_TYPE                         ,"out_DECOD_TYPE                         ",Ttype_t            ,_param->_nb_inst_decod);
72  ALLOC1_SC_SIGNAL(out_DECOD_OPERATION                    ,"out_DECOD_OPERATION                    ",Toperation_t       ,_param->_nb_inst_decod);
73  ALLOC1_SC_SIGNAL(out_DECOD_NO_EXECUTE                   ,"out_DECOD_NO_EXECUTE                   ",Tcontrol_t         ,_param->_nb_inst_decod); 
74  ALLOC1_SC_SIGNAL(out_DECOD_IS_DELAY_SLOT                ,"out_DECOD_IS_DELAY_SLOT                ",Tcontrol_t         ,_param->_nb_inst_decod);
75  ALLOC1_SC_SIGNAL(out_DECOD_ADDRESS                      ,"out_DECOD_ADDRESS                      ",Tgeneral_data_t    ,_param->_nb_inst_decod);
76  ALLOC1_SC_SIGNAL(out_DECOD_HAS_IMMEDIAT                 ,"out_DECOD_HAS_IMMEDIAT                 ",Tcontrol_t         ,_param->_nb_inst_decod);
77  ALLOC1_SC_SIGNAL(out_DECOD_IMMEDIAT                     ,"out_DECOD_IMMEDIAT                     ",Tgeneral_data_t    ,_param->_nb_inst_decod);
78  ALLOC1_SC_SIGNAL(out_DECOD_READ_RA                      ,"out_DECOD_READ_RA                      ",Tcontrol_t         ,_param->_nb_inst_decod);
79  ALLOC1_SC_SIGNAL(out_DECOD_NUM_REG_RA                   ,"out_DECOD_NUM_REG_RA                   ",Tgeneral_address_t ,_param->_nb_inst_decod);
80  ALLOC1_SC_SIGNAL(out_DECOD_READ_RB                      ,"out_DECOD_READ_RB                      ",Tcontrol_t         ,_param->_nb_inst_decod);
81  ALLOC1_SC_SIGNAL(out_DECOD_NUM_REG_RB                   ,"out_DECOD_NUM_REG_RB                   ",Tgeneral_address_t ,_param->_nb_inst_decod);
82  ALLOC1_SC_SIGNAL(out_DECOD_READ_RC                      ,"out_DECOD_READ_RC                      ",Tcontrol_t         ,_param->_nb_inst_decod);
83  ALLOC1_SC_SIGNAL(out_DECOD_NUM_REG_RC                   ,"out_DECOD_NUM_REG_RC                   ",Tspecial_address_t ,_param->_nb_inst_decod);
84  ALLOC1_SC_SIGNAL(out_DECOD_WRITE_RD                     ,"out_DECOD_WRITE_RD                     ",Tcontrol_t         ,_param->_nb_inst_decod);
85  ALLOC1_SC_SIGNAL(out_DECOD_NUM_REG_RD                   ,"out_DECOD_NUM_REG_RD                   ",Tgeneral_address_t ,_param->_nb_inst_decod);
86  ALLOC1_SC_SIGNAL(out_DECOD_WRITE_RE                     ,"out_DECOD_WRITE_RE                     ",Tcontrol_t         ,_param->_nb_inst_decod);
87  ALLOC1_SC_SIGNAL(out_DECOD_NUM_REG_RE                   ,"out_DECOD_NUM_REG_RE                   ",Tspecial_address_t ,_param->_nb_inst_decod);
88  ALLOC1_SC_SIGNAL(out_DECOD_EXCEPTION_USE                ,"out_DECOD_EXCEPTION_USE                ",Texception_t       ,_param->_nb_inst_decod);
89  ALLOC1_SC_SIGNAL(out_DECOD_EXCEPTION                    ,"out_DECOD_EXCEPTION                    ",Texception_t       ,_param->_nb_inst_decod);
90
91  ALLOC1_SC_SIGNAL(out_PREDICT_VAL                        ,"out_PREDICT_VAL                        ",Tcontrol_t         ,_param->_nb_inst_decod);
92  ALLOC1_SC_SIGNAL( in_PREDICT_ACK                        ," in_PREDICT_ACK                        ",Tcontrol_t         ,_param->_nb_inst_decod);
93  ALLOC1_SC_SIGNAL(out_PREDICT_CONTEXT_ID                 ,"out_PREDICT_CONTEXT_ID                 ",Tcontext_t         ,_param->_nb_inst_decod);
94  ALLOC1_SC_SIGNAL(out_PREDICT_MATCH_INST_IFETCH_PTR      ,"out_PREDICT_MATCH_INST_IFETCH_PTR      ",Tcontrol_t         ,_param->_nb_inst_decod);
95  ALLOC1_SC_SIGNAL(out_PREDICT_BRANCH_STATE               ,"out_PREDICT_BRANCH_STATE               ",Tbranch_state_t    ,_param->_nb_inst_decod);
96  ALLOC1_SC_SIGNAL(out_PREDICT_BRANCH_UPDATE_PREDICTION_ID,"out_PREDICT_BRANCH_UPDATE_PREDICTION_ID",Tprediction_ptr_t  ,_param->_nb_inst_decod);
97  ALLOC1_SC_SIGNAL(out_PREDICT_BRANCH_CONDITION           ,"out_PREDICT_BRANCH_CONDITION           ",Tbranch_condition_t,_param->_nb_inst_decod);
98//ALLOC1_SC_SIGNAL(out_PREDICT_BRANCH_STACK_WRITE         ,"out_PREDICT_BRANCH_STACK_WRITE         ",Tcontrol_t         ,_param->_nb_inst_decod);
99  ALLOC1_SC_SIGNAL(out_PREDICT_BRANCH_DIRECTION           ,"out_PREDICT_BRANCH_DIRECTION           ",Tcontrol_t         ,_param->_nb_inst_decod);
100  ALLOC1_SC_SIGNAL(out_PREDICT_ADDRESS_SRC                ,"out_PREDICT_ADDRESS_SRC                ",Tgeneral_data_t    ,_param->_nb_inst_decod);
101  ALLOC1_SC_SIGNAL(out_PREDICT_ADDRESS_DEST               ,"out_PREDICT_ADDRESS_DEST               ",Tgeneral_data_t    ,_param->_nb_inst_decod);
102//ALLOC1_SC_SIGNAL( in_PREDICT_CAN_CONTINUE               ," in_PREDICT_CAN_CONTINUE               ",Tcontrol_t         ,_param->_nb_inst_decod);
103
104  ALLOC1_SC_SIGNAL( in_DEPTH_MIN                          ," in_DEPTH_MIN                          ",Tdepth_t           ,_param->_nb_context);
105  ALLOC1_SC_SIGNAL( in_DEPTH_MAX                          ," in_DEPTH_MAX                          ",Tdepth_t           ,_param->_nb_context);
106
107  ALLOC1_SC_SIGNAL(out_NB_INST_DECOD_ALL                  ,"out_NB_INST_DECOD_ALL                  ",Tcounter_t         ,_param->_nb_context);
108
109  ALLOC1_SC_SIGNAL( in_CONTEXT_DECOD_ENABLE               ," in_CONTEXT_DECOD_ENABLE               ",Tcontrol_t         ,_param->_nb_context);
110  ALLOC1_SC_SIGNAL( in_CONTEXT_DEPTH                      ," in_CONTEXT_DEPTH                      ",Tdepth_t           ,_param->_nb_context);
111
112  ALLOC_SC_SIGNAL( out_CONTEXT_EVENT_VAL                  ,"out_CONTEXT_EVENT_VAL                  ",Tcontrol_t         );
113  ALLOC_SC_SIGNAL(  in_CONTEXT_EVENT_ACK                  ," in_CONTEXT_EVENT_ACK                  ",Tcontrol_t         );
114  ALLOC_SC_SIGNAL( out_CONTEXT_EVENT_CONTEXT_ID           ,"out_CONTEXT_EVENT_CONTEXT_ID           ",Tcontext_t         );
115  ALLOC_SC_SIGNAL( out_CONTEXT_EVENT_DEPTH                ,"out_CONTEXT_EVENT_DEPTH                ",Tdepth_t           );
116  ALLOC_SC_SIGNAL( out_CONTEXT_EVENT_TYPE                 ,"out_CONTEXT_EVENT_TYPE                 ",Tevent_type_t      );
117  ALLOC_SC_SIGNAL( out_CONTEXT_EVENT_IS_DELAY_SLOT        ,"out_CONTEXT_EVENT_IS_DELAY_SLOT        ",Tcontrol_t         );
118  ALLOC_SC_SIGNAL( out_CONTEXT_EVENT_ADDRESS              ,"out_CONTEXT_EVENT_ADDRESS              ",Tgeneral_data_t    );
119  ALLOC_SC_SIGNAL( out_CONTEXT_EVENT_ADDRESS_EPCR         ,"out_CONTEXT_EVENT_ADDRESS_EPCR         ",Tgeneral_data_t    );
120 
121  /********************************************************
122   * Instanciation
123   ********************************************************/
124 
125  msg(_("<%s> : Instanciation of _Decod_unit.\n"),name.c_str());
126
127  (*(_Decod_unit->in_CLOCK))        (*(in_CLOCK));
128  (*(_Decod_unit->in_NRESET))       (*(in_NRESET));
129
130  INSTANCE2_SC_SIGNAL(_Decod_unit, in_IFETCH_VAL                         ,_param->_nb_context, _param->_nb_inst_fetch[it1]);
131  INSTANCE2_SC_SIGNAL(_Decod_unit,out_IFETCH_ACK                         ,_param->_nb_context, _param->_nb_inst_fetch[it1]);
132  INSTANCE2_SC_SIGNAL(_Decod_unit, in_IFETCH_INSTRUCTION                 ,_param->_nb_context, _param->_nb_inst_fetch[it1]);
133  if (_param->_have_port_context_id)
134  INSTANCE1_SC_SIGNAL(_Decod_unit,in_IFETCH_CONTEXT_ID                   ,_param->_nb_context);
135  INSTANCE1_SC_SIGNAL(_Decod_unit,in_IFETCH_ADDRESS                      ,_param->_nb_context);
136//INSTANCE1_SC_SIGNAL(_Decod_unit,in_IFETCH_ADDRESS_NEXT                 ,_param->_nb_context);
137
138  for (uint32_t i=0; i<_param->_nb_context; ++i)
139    {
140      if (_param->_have_port_inst_ifetch_ptr)
141        INSTANCE_SC_SIGNAL(_Decod_unit,in_IFETCH_INST_IFETCH_PTR[i]);
142      if (_param->_have_port_depth)
143        INSTANCE_SC_SIGNAL(_Decod_unit,in_IFETCH_BRANCH_UPDATE_PREDICTION_ID [i]);
144    }
145
146  INSTANCE1_SC_SIGNAL(_Decod_unit,in_IFETCH_BRANCH_STATE                 ,_param->_nb_context);
147  INSTANCE1_SC_SIGNAL(_Decod_unit,in_IFETCH_EXCEPTION                    ,_param->_nb_context);
148
149  INSTANCE1_SC_SIGNAL(_Decod_unit,out_DECOD_VAL                          ,_param->_nb_inst_decod);
150  INSTANCE1_SC_SIGNAL(_Decod_unit, in_DECOD_ACK                          ,_param->_nb_inst_decod);
151  if (_param->_have_port_context_id)
152  INSTANCE1_SC_SIGNAL(_Decod_unit,out_DECOD_CONTEXT_ID                   ,_param->_nb_inst_decod);
153  if (_param->_have_port_depth)
154  INSTANCE1_SC_SIGNAL(_Decod_unit,out_DECOD_DEPTH                        ,_param->_nb_inst_decod);
155  INSTANCE1_SC_SIGNAL(_Decod_unit,out_DECOD_TYPE                         ,_param->_nb_inst_decod);
156  INSTANCE1_SC_SIGNAL(_Decod_unit,out_DECOD_OPERATION                    ,_param->_nb_inst_decod);
157  INSTANCE1_SC_SIGNAL(_Decod_unit,out_DECOD_NO_EXECUTE                   ,_param->_nb_inst_decod);
158  INSTANCE1_SC_SIGNAL(_Decod_unit,out_DECOD_IS_DELAY_SLOT                ,_param->_nb_inst_decod);
159  INSTANCE1_SC_SIGNAL(_Decod_unit,out_DECOD_ADDRESS                      ,_param->_nb_inst_decod);
160  INSTANCE1_SC_SIGNAL(_Decod_unit,out_DECOD_HAS_IMMEDIAT                 ,_param->_nb_inst_decod);
161  INSTANCE1_SC_SIGNAL(_Decod_unit,out_DECOD_IMMEDIAT                     ,_param->_nb_inst_decod);
162  INSTANCE1_SC_SIGNAL(_Decod_unit,out_DECOD_READ_RA                      ,_param->_nb_inst_decod);
163  INSTANCE1_SC_SIGNAL(_Decod_unit,out_DECOD_NUM_REG_RA                   ,_param->_nb_inst_decod);
164  INSTANCE1_SC_SIGNAL(_Decod_unit,out_DECOD_READ_RB                      ,_param->_nb_inst_decod);
165  INSTANCE1_SC_SIGNAL(_Decod_unit,out_DECOD_NUM_REG_RB                   ,_param->_nb_inst_decod);
166  INSTANCE1_SC_SIGNAL(_Decod_unit,out_DECOD_READ_RC                      ,_param->_nb_inst_decod);
167  INSTANCE1_SC_SIGNAL(_Decod_unit,out_DECOD_NUM_REG_RC                   ,_param->_nb_inst_decod);
168  INSTANCE1_SC_SIGNAL(_Decod_unit,out_DECOD_WRITE_RD                     ,_param->_nb_inst_decod);
169  INSTANCE1_SC_SIGNAL(_Decod_unit,out_DECOD_NUM_REG_RD                   ,_param->_nb_inst_decod);
170  INSTANCE1_SC_SIGNAL(_Decod_unit,out_DECOD_WRITE_RE                     ,_param->_nb_inst_decod);
171  INSTANCE1_SC_SIGNAL(_Decod_unit,out_DECOD_NUM_REG_RE                   ,_param->_nb_inst_decod);
172  INSTANCE1_SC_SIGNAL(_Decod_unit,out_DECOD_EXCEPTION_USE                ,_param->_nb_inst_decod);
173  INSTANCE1_SC_SIGNAL(_Decod_unit,out_DECOD_EXCEPTION                    ,_param->_nb_inst_decod);
174
175  INSTANCE1_SC_SIGNAL(_Decod_unit,out_PREDICT_VAL                        ,_param->_nb_inst_decod);
176  INSTANCE1_SC_SIGNAL(_Decod_unit, in_PREDICT_ACK                        ,_param->_nb_inst_decod);
177  if (_param->_have_port_context_id)
178  INSTANCE1_SC_SIGNAL(_Decod_unit,out_PREDICT_CONTEXT_ID                 ,_param->_nb_inst_decod);
179  INSTANCE1_SC_SIGNAL(_Decod_unit,out_PREDICT_MATCH_INST_IFETCH_PTR      ,_param->_nb_inst_decod);
180  INSTANCE1_SC_SIGNAL(_Decod_unit,out_PREDICT_BRANCH_STATE               ,_param->_nb_inst_decod);
181  if (_param->_have_port_depth)
182  INSTANCE1_SC_SIGNAL(_Decod_unit,out_PREDICT_BRANCH_UPDATE_PREDICTION_ID,_param->_nb_inst_decod);
183  INSTANCE1_SC_SIGNAL(_Decod_unit,out_PREDICT_BRANCH_CONDITION           ,_param->_nb_inst_decod);
184//INSTANCE1_SC_SIGNAL(_Decod_unit,out_PREDICT_BRANCH_STACK_WRITE         ,_param->_nb_inst_decod);
185  INSTANCE1_SC_SIGNAL(_Decod_unit,out_PREDICT_BRANCH_DIRECTION           ,_param->_nb_inst_decod);
186  INSTANCE1_SC_SIGNAL(_Decod_unit,out_PREDICT_ADDRESS_SRC                ,_param->_nb_inst_decod);
187  INSTANCE1_SC_SIGNAL(_Decod_unit,out_PREDICT_ADDRESS_DEST               ,_param->_nb_inst_decod);
188//INSTANCE1_SC_SIGNAL(_Decod_unit, in_PREDICT_CAN_CONTINUE               ,_param->_nb_inst_decod);
189
190  INSTANCE1_SC_SIGNAL(_Decod_unit, in_DEPTH_MAX                          ,_param->_nb_context);
191
192  INSTANCE1_SC_SIGNAL(_Decod_unit,out_NB_INST_DECOD_ALL                  ,_param->_nb_context);
193
194  INSTANCE1_SC_SIGNAL(_Decod_unit, in_CONTEXT_DECOD_ENABLE               ,_param->_nb_context);
195
196  for (uint32_t i=0; i<_param->_nb_context; ++i)
197    if (_param->_have_port_depth)
198      {
199        INSTANCE_SC_SIGNAL(_Decod_unit, in_DEPTH_MIN     [i]);
200        INSTANCE_SC_SIGNAL(_Decod_unit, in_CONTEXT_DEPTH [i]);
201      }
202
203  INSTANCE_SC_SIGNAL( _Decod_unit,out_CONTEXT_EVENT_VAL                  );
204  INSTANCE_SC_SIGNAL( _Decod_unit, in_CONTEXT_EVENT_ACK                  );
205  if (_param->_have_port_context_id)
206  INSTANCE_SC_SIGNAL( _Decod_unit,out_CONTEXT_EVENT_CONTEXT_ID           );
207  if (_param->_have_port_depth)
208  INSTANCE_SC_SIGNAL( _Decod_unit,out_CONTEXT_EVENT_DEPTH                );
209  INSTANCE_SC_SIGNAL( _Decod_unit,out_CONTEXT_EVENT_TYPE                 );
210  INSTANCE_SC_SIGNAL( _Decod_unit,out_CONTEXT_EVENT_IS_DELAY_SLOT        );
211  INSTANCE_SC_SIGNAL( _Decod_unit,out_CONTEXT_EVENT_ADDRESS              );
212  INSTANCE_SC_SIGNAL( _Decod_unit,out_CONTEXT_EVENT_ADDRESS_EPCR         );
213
214  msg(_("<%s> : Start Simulation ............\n"),name.c_str());
215   
216  Time * _time = new Time();
217
218  /********************************************************
219   * Simulation - Begin
220   ********************************************************/
221
222  // Initialisation
223
224  const uint32_t seed = 0;
225//const uint32_t seed = static_cast<uint32_t>(time(NULL));
226
227  const  int32_t percent_transaction_ifetch  = 100;
228  const  int32_t percent_transaction_decod   = 100;
229  const  int32_t percent_transaction_predict = 100;
230  const  int32_t percent_transaction_event   = 100;
231
232  srand(seed);
233
234  SC_START(0);
235  LABEL("Initialisation");
236
237  LABEL("Reset");
238  in_NRESET->write(0);
239  SC_START(5);
240  in_NRESET->write(1); 
241
242  LABEL("Loop of Test");
243
244  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
245    {
246      LABEL("Iteration %d",iteration);
247
248      Decod_request request [_param->_nb_context];
249      list<entry_t> respons [_param->_nb_context];
250
251      uint32_t nb_request  = 0;
252
253      uint32_t delay_slot_previous [_param->_nb_context];
254      uint32_t delay_slot_current  [_param->_nb_context];
255      uint32_t delay_slot_next     [_param->_nb_context];
256
257      for (uint32_t i=0; i<_param->_nb_context; i++)
258        {
259          nb_request += request[i].size();
260          delay_slot_current  [i] = false;
261          delay_slot_next     [i] = false;
262
263          in_DEPTH_MIN       [i]->write(0);
264          in_DEPTH_MAX       [i]->write(0);
265          in_CONTEXT_DEPTH   [i]->write(0);
266        }
267
268      while (nb_request > 0)
269        {
270          for (uint32_t i=0; i<_param->_nb_context; i++)
271            {
272              delay_slot_previous  [i] = false;
273             
274              in_CONTEXT_DECOD_ENABLE [i]->write((rand()%100)<percent_transaction_decod);
275
276              for (uint32_t j=0; j<_param->_nb_inst_fetch[i]; j++)
277                in_IFETCH_VAL [i][j]->write(0);
278                 
279              if ((rand()%100)<percent_transaction_ifetch)
280                {
281                  list<entry_t>::iterator it = request[i].begin();
282                 
283                  if (it!=request [i].end())
284                    {
285                      uint32_t lsb = it->_address%_param->_nb_inst_fetch[i];
286                     
287                      in_IFETCH_ADDRESS         [i]->write(it->_address-lsb);
288                      in_IFETCH_BRANCH_STATE    [i]->write(BRANCH_STATE_NONE);
289                      if (_param->_have_port_inst_ifetch_ptr)
290                      in_IFETCH_INST_IFETCH_PTR [i]->write(0);
291
292                      // Alignement
293                      for (uint32_t j=lsb; j<_param->_nb_inst_fetch[i]; j++)
294                        {
295                          in_IFETCH_VAL                         [i][j]->write(1);
296                          in_IFETCH_INSTRUCTION                 [i][j]->write(it->_instruction);
297//                        in_IFETCH_ADDRESS_NEXT                [i]->write(it->_address_next);
298                          if (it->_type == TYPE_BRANCH)
299                          in_IFETCH_BRANCH_STATE                [i]->write(it->_branch_state);
300                          in_IFETCH_BRANCH_UPDATE_PREDICTION_ID [i]->write(it->_branch_update_prediction_id);
301                          in_IFETCH_EXCEPTION                   [i]->write(it->_exception_ifetch);
302                         
303                          if ((it->_is_delay_slot) or
304                              ((++it)==request [i].end()))
305                            break;
306                        }
307                    }
308                }
309            }
310         
311          {
312            bool previous_ack = true;
313             
314            for (uint32_t i=0; i<_param->_nb_inst_decod; i++)
315              {
316                bool ack = previous_ack and ((rand()%100)<percent_transaction_decod);
317                in_DECOD_ACK [i]->write(ack);
318               
319                previous_ack = ack;
320
321                in_PREDICT_ACK          [i]->write((rand()%100)<percent_transaction_predict);
322//              in_PREDICT_CAN_CONTINUE [i]->write(0);
323              }
324          }
325
326          in_CONTEXT_EVENT_ACK->write((rand()%100)<percent_transaction_event);
327
328          SC_START(0);
329
330          uint32_t find_event = false;
331          for (uint32_t i=0; i<_param->_nb_context; i++)
332            for (uint32_t j=0; j<_param->_nb_inst_fetch[i]; j++)
333              if (in_IFETCH_VAL[i][j]->read() and out_IFETCH_ACK[i][j]->read())
334                {
335                  LABEL("IFETCH      [%d][%d] : transaction",i,j);
336                 
337                  entry_t entry = request [i].front();
338                  LABEL("  * address 0x%x",entry._address);
339                 
340                  respons [i].push_back(entry);
341                  request [i].pop_front();
342 
343                  if (entry._type == TYPE_BRANCH)
344                    {
345                      delay_slot_next     [i] = true;
346                     
347                      // find good decod
348                      uint32_t x;
349
350                      for (x=0; x<=_param->_nb_inst_decod; x++)
351                        {
352                          if (x==_param->_nb_inst_decod)
353                            TEST_KO("No find predict transaction");
354
355                          Tcontext_t ctxt = (_param->_have_port_context_id)?out_PREDICT_CONTEXT_ID[x]->read():0;
356
357                          if ((ctxt == i) and
358                              (out_PREDICT_VAL [x]->read() and in_PREDICT_ACK [x]->read()))
359                            break;
360                        }
361
362                      LABEL("PREDICT     [%d]    : transaction",);
363                     
364                     
365                      TEST(Tcontrol_t         , out_PREDICT_MATCH_INST_IFETCH_PTR       [x]->read(),((entry._address)%_param->_nb_inst_fetch[i]) == 0);
366                      TEST(Tbranch_state_t    , out_PREDICT_BRANCH_STATE                [x]->read(), entry._branch_state               );
367                      if (_param->_have_port_depth)
368                      TEST(Tprediction_ptr_t  , out_PREDICT_BRANCH_UPDATE_PREDICTION_ID [x]->read(), entry._branch_update_prediction_id);
369                      TEST(Tbranch_condition_t, out_PREDICT_BRANCH_CONDITION            [x]->read(), entry._branch_condition           );
370//                    TEST(Tcontrol_t         , out_PREDICT_BRANCH_STACK_WRITE          [x]->read(), entry._branch_stack_write         );
371                      TEST(Tcontrol_t         , out_PREDICT_BRANCH_DIRECTION            [x]->read(), entry._branch_direction           );
372                      TEST(Tgeneral_data_t    , out_PREDICT_ADDRESS_SRC                 [x]->read(), entry._address                    );
373                      TEST(Tgeneral_data_t    , out_PREDICT_ADDRESS_DEST                [x]->read(), entry._branch_address_dest        );
374                    }
375                 
376//                TEST(bool, find_event, false); // can continue decod after event
377                  if (entry._context_event_type != EVENT_TYPE_NONE)
378                    {
379                      find_event = true;
380                     
381                      LABEL("CONTEXT_EVENT      : transaction");
382                     
383                      if (_param->_have_port_context_id)
384                      TEST(Tcontext_t     ,out_CONTEXT_EVENT_CONTEXT_ID   ->read(), i);
385                      if (_param->_have_port_depth)
386                      TEST(Tcontext_t     ,out_CONTEXT_EVENT_DEPTH        ->read(), entry._depth);
387                      TEST(Tevent_type_t  ,out_CONTEXT_EVENT_TYPE         ->read(), entry._context_event_type);
388                      TEST(Tcontrol_t     ,out_CONTEXT_EVENT_IS_DELAY_SLOT->read(), entry._is_delay_slot);
389                      TEST(Tgeneral_data_t,out_CONTEXT_EVENT_ADDRESS      ->read(), entry._address      );
390                      TEST(Tgeneral_data_t,out_CONTEXT_EVENT_ADDRESS_EPCR ->read(), entry._address_next );
391                    }
392                 
393                  TEST(bool, delay_slot_previous [i], false); // can't continue
394                  delay_slot_previous [i] = delay_slot_current  [i];
395                  delay_slot_current  [i] = delay_slot_next     [i];
396                  delay_slot_next     [i] = false;
397                }
398
399          for (uint32_t i=0; i<_param->_nb_inst_decod; i++)
400            if (out_DECOD_VAL[i]->read() and in_DECOD_ACK[i]->read())
401              {
402                Tcontext_t context = (_param->_have_port_context_id)?out_DECOD_CONTEXT_ID[i]->read():0;
403
404                LABEL("DECOD       [%d]    : transaction",);
405
406                TEST(bool              ,respons [context].empty(), false);
407
408                LABEL(" * context         : %d",context);
409                LABEL(" * instruction     : 0x%x",respons [context].front()._instruction);
410
411                if (_param->_have_port_depth)
412                TEST(Tdepth_t          ,  out_DECOD_DEPTH         [i]->read(), respons [context].front()._depth        );
413                TEST(Ttype_t           ,  out_DECOD_TYPE          [i]->read(), respons [context].front()._type         );
414                TEST(Toperation_t      ,  out_DECOD_OPERATION     [i]->read(), respons [context].front()._operation    );
415//              TEST(Tcontrol_t        ,  out_DECOD_NO_EXECUTE    [i]->read(), respons [context].front()._no_execute   );
416                TEST(Tcontrol_t        ,  out_DECOD_IS_DELAY_SLOT [i]->read(), respons [context].front()._is_delay_slot);
417                TEST(Tgeneral_data_t   ,  out_DECOD_ADDRESS       [i]->read(), respons [context].front()._address      );
418                TEST(Tcontrol_t        ,  out_DECOD_HAS_IMMEDIAT  [i]->read(), respons [context].front()._has_immediat );
419                if (respons [context].front()._has_immediat)
420                TEST(Tgeneral_data_t   ,  out_DECOD_IMMEDIAT      [i]->read(), respons [context].front()._immediat     );
421                TEST(Tcontrol_t        ,  out_DECOD_READ_RA       [i]->read(), respons [context].front()._read_ra      );
422                if (respons [context].front()._read_ra)
423                TEST(Tgeneral_address_t,  out_DECOD_NUM_REG_RA    [i]->read(), respons [context].front()._num_reg_ra   );
424                TEST(Tcontrol_t        ,  out_DECOD_READ_RB       [i]->read(), respons [context].front()._read_rb      );
425                if (respons [context].front()._read_rb)
426                TEST(Tgeneral_address_t,  out_DECOD_NUM_REG_RB    [i]->read(), respons [context].front()._num_reg_rb   );
427                TEST(Tcontrol_t        ,  out_DECOD_READ_RC       [i]->read(), respons [context].front()._read_rc      );
428                if (respons [context].front()._read_rc)
429                TEST(Tspecial_address_t,  out_DECOD_NUM_REG_RC    [i]->read(), respons [context].front()._num_reg_rc   );
430                TEST(Tcontrol_t        ,  out_DECOD_WRITE_RD      [i]->read(), respons [context].front()._write_rd     );
431                if (respons [context].front()._write_rd)
432                TEST(Tgeneral_address_t,  out_DECOD_NUM_REG_RD    [i]->read(), respons [context].front()._num_reg_rd   );
433                TEST(Tcontrol_t        ,  out_DECOD_WRITE_RE      [i]->read(), respons [context].front()._write_re     );
434                if (respons [context].front()._write_re)
435                TEST(Tspecial_address_t,  out_DECOD_NUM_REG_RE    [i]->read(), respons [context].front()._num_reg_re   );
436                TEST(Texception_t      ,  out_DECOD_EXCEPTION_USE [i]->read(), respons [context].front()._exception_use);
437//              TEST(Texception_t      ,  out_DECOD_EXCEPTION     [i]->read(), respons [context].front()._exception    );
438
439                respons [context].pop_front();
440                nb_request --;
441              }
442
443          TEST(bool, (out_CONTEXT_EVENT_VAL->read() and in_CONTEXT_EVENT_ACK->read()), find_event);
444
445          SC_START(1);
446        }
447
448      for (uint32_t i=0; i<_param->_nb_context; i++)
449        {
450          TEST(Tcounter_t,out_NB_INST_DECOD_ALL [i]->read(), respons[i].size());
451         
452        }
453    }
454
455  /********************************************************
456   * Simulation - End
457   ********************************************************/
458
459  TEST_OK ("End of Simulation");
460  delete _time;
461
462  msg(_("<%s> : ............ Stop Simulation\n"),name.c_str());
463
464  delete in_CLOCK;
465  delete in_NRESET;
466
467  DELETE2_SC_SIGNAL( in_IFETCH_VAL                         ,_param->_nb_context, _param->_nb_inst_fetch[it1]);
468  DELETE2_SC_SIGNAL(out_IFETCH_ACK                         ,_param->_nb_context, _param->_nb_inst_fetch[it1]);
469  DELETE2_SC_SIGNAL( in_IFETCH_INSTRUCTION                 ,_param->_nb_context, _param->_nb_inst_fetch[it1]);
470  DELETE1_SC_SIGNAL(in_IFETCH_CONTEXT_ID                   ,_param->_nb_context);
471  DELETE1_SC_SIGNAL(in_IFETCH_ADDRESS                      ,_param->_nb_context);
472//DELETE1_SC_SIGNAL(in_IFETCH_ADDRESS_NEXT                 ,_param->_nb_context);
473  DELETE1_SC_SIGNAL(in_IFETCH_INST_IFETCH_PTR              ,_param->_nb_context);
474  DELETE1_SC_SIGNAL(in_IFETCH_BRANCH_STATE                 ,_param->_nb_context);
475  DELETE1_SC_SIGNAL(in_IFETCH_BRANCH_UPDATE_PREDICTION_ID  ,_param->_nb_context);
476  DELETE1_SC_SIGNAL(in_IFETCH_EXCEPTION                    ,_param->_nb_context);
477
478  DELETE1_SC_SIGNAL(out_DECOD_VAL                          ,_param->_nb_inst_decod);
479  DELETE1_SC_SIGNAL( in_DECOD_ACK                          ,_param->_nb_inst_decod);
480  DELETE1_SC_SIGNAL(out_DECOD_CONTEXT_ID                   ,_param->_nb_inst_decod);
481  DELETE1_SC_SIGNAL(out_DECOD_DEPTH                        ,_param->_nb_inst_decod);
482  DELETE1_SC_SIGNAL(out_DECOD_TYPE                         ,_param->_nb_inst_decod);
483  DELETE1_SC_SIGNAL(out_DECOD_OPERATION                    ,_param->_nb_inst_decod);
484  DELETE1_SC_SIGNAL(out_DECOD_NO_EXECUTE                   ,_param->_nb_inst_decod);
485  DELETE1_SC_SIGNAL(out_DECOD_IS_DELAY_SLOT                ,_param->_nb_inst_decod);
486  DELETE1_SC_SIGNAL(out_DECOD_ADDRESS                      ,_param->_nb_inst_decod);
487  DELETE1_SC_SIGNAL(out_DECOD_HAS_IMMEDIAT                 ,_param->_nb_inst_decod);
488  DELETE1_SC_SIGNAL(out_DECOD_IMMEDIAT                     ,_param->_nb_inst_decod);
489  DELETE1_SC_SIGNAL(out_DECOD_READ_RA                      ,_param->_nb_inst_decod);
490  DELETE1_SC_SIGNAL(out_DECOD_NUM_REG_RA                   ,_param->_nb_inst_decod);
491  DELETE1_SC_SIGNAL(out_DECOD_READ_RB                      ,_param->_nb_inst_decod);
492  DELETE1_SC_SIGNAL(out_DECOD_NUM_REG_RB                   ,_param->_nb_inst_decod);
493  DELETE1_SC_SIGNAL(out_DECOD_READ_RC                      ,_param->_nb_inst_decod);
494  DELETE1_SC_SIGNAL(out_DECOD_NUM_REG_RC                   ,_param->_nb_inst_decod);
495  DELETE1_SC_SIGNAL(out_DECOD_WRITE_RD                     ,_param->_nb_inst_decod);
496  DELETE1_SC_SIGNAL(out_DECOD_NUM_REG_RD                   ,_param->_nb_inst_decod);
497  DELETE1_SC_SIGNAL(out_DECOD_WRITE_RE                     ,_param->_nb_inst_decod);
498  DELETE1_SC_SIGNAL(out_DECOD_NUM_REG_RE                   ,_param->_nb_inst_decod);
499  DELETE1_SC_SIGNAL(out_DECOD_EXCEPTION_USE                ,_param->_nb_inst_decod);
500  DELETE1_SC_SIGNAL(out_DECOD_EXCEPTION                    ,_param->_nb_inst_decod);
501
502  DELETE1_SC_SIGNAL(out_PREDICT_VAL                        ,_param->_nb_inst_decod);
503  DELETE1_SC_SIGNAL( in_PREDICT_ACK                        ,_param->_nb_inst_decod);
504  DELETE1_SC_SIGNAL(out_PREDICT_CONTEXT_ID                 ,_param->_nb_inst_decod);
505  DELETE1_SC_SIGNAL(out_PREDICT_MATCH_INST_IFETCH_PTR      ,_param->_nb_inst_decod);
506  DELETE1_SC_SIGNAL(out_PREDICT_BRANCH_STATE               ,_param->_nb_inst_decod);
507  DELETE1_SC_SIGNAL(out_PREDICT_BRANCH_UPDATE_PREDICTION_ID,_param->_nb_inst_decod);
508  DELETE1_SC_SIGNAL(out_PREDICT_BRANCH_CONDITION           ,_param->_nb_inst_decod);
509//DELETE1_SC_SIGNAL(out_PREDICT_BRANCH_STACK_WRITE         ,_param->_nb_inst_decod);
510  DELETE1_SC_SIGNAL(out_PREDICT_BRANCH_DIRECTION           ,_param->_nb_inst_decod);
511  DELETE1_SC_SIGNAL(out_PREDICT_ADDRESS_SRC                ,_param->_nb_inst_decod);
512  DELETE1_SC_SIGNAL(out_PREDICT_ADDRESS_DEST               ,_param->_nb_inst_decod);
513//DELETE1_SC_SIGNAL( in_PREDICT_CAN_CONTINUE               ,_param->_nb_inst_decod);
514
515  DELETE1_SC_SIGNAL( in_DEPTH_MIN                          ,_param->_nb_context);
516  DELETE1_SC_SIGNAL( in_DEPTH_MAX                          ,_param->_nb_context);
517
518  DELETE1_SC_SIGNAL(out_NB_INST_DECOD_ALL                  ,_param->_nb_context);
519
520  DELETE1_SC_SIGNAL( in_CONTEXT_DECOD_ENABLE               ,_param->_nb_context);
521  DELETE1_SC_SIGNAL( in_CONTEXT_DEPTH                      ,_param->_nb_context);
522
523  DELETE_SC_SIGNAL( out_CONTEXT_EVENT_VAL                  );
524  DELETE_SC_SIGNAL(  in_CONTEXT_EVENT_ACK                  );
525  DELETE_SC_SIGNAL( out_CONTEXT_EVENT_CONTEXT_ID           );
526  DELETE_SC_SIGNAL( out_CONTEXT_EVENT_DEPTH                );
527  DELETE_SC_SIGNAL( out_CONTEXT_EVENT_TYPE                 );
528  DELETE_SC_SIGNAL( out_CONTEXT_EVENT_IS_DELAY_SLOT        );
529  DELETE_SC_SIGNAL( out_CONTEXT_EVENT_ADDRESS              );
530  DELETE_SC_SIGNAL( out_CONTEXT_EVENT_ADDRESS_EPCR         );
531    }
532#endif
533
534  delete _Decod_unit;
535#ifdef STATISTICS
536  delete _parameters_statistics;
537#endif
538}
Note: See TracBrowser for help on using the repository browser.