source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Queue/SelfTest/src/test.cpp @ 100

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

1) Bug fix (Operation, Instruction)
2) Modif Return Address Stack
3) Add Soft Test
4) Add Soc Test

  • Property svn:keywords set to Id
File size: 5.3 KB
RevLine 
[67]1/*
2 * $Id: test.cpp 100 2009-01-08 13:06:27Z rosiere $
3 *
4 * [ Description ]
5 *
6 * Test
7 */
8
9#define NB_ITERATION  1
10#define CYCLE_MAX     (2048*NB_ITERATION)
11
[82]12#include "Behavioural/Generic/Queue/SelfTest/include/test.h"
[100]13#include "Behavioural/include/Allocation.h"
[82]14#include "Common/include/Test.h"
[67]15
16void test (string name,
17           morpheo::behavioural::generic::queue::Parameters * _param)
18{
19  cout << "<" << name << "> : Simulation SystemC" << endl;
20
21#ifdef STATISTICS
22  morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5,50);
23#endif
24
[88]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
[82]35  Queue * _Queue = new Queue
36    (name.c_str(),
[67]37#ifdef STATISTICS
[82]38     _parameters_statistics,
[67]39#endif
[82]40     _param,
[88]41     _usage);
[67]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");
[100]51
52  ALLOC0_SC_SIGNAL( in_INSERT_VAL , "in_INSERT_VAL" ,Tcontrol_t);
53  ALLOC0_SC_SIGNAL(out_INSERT_ACK ,"out_INSERT_ACK" ,Tcontrol_t);
54  ALLOC0_SC_SIGNAL( in_INSERT_DATA, "in_INSERT_DATA",Tdata_t   );
55  ALLOC0_SC_SIGNAL(out_RETIRE_VAL ,"out_RETIRE_VAL" ,Tcontrol_t);
56  ALLOC0_SC_SIGNAL( in_RETIRE_ACK , "in_RETIRE_ACK" ,Tcontrol_t);
57  ALLOC0_SC_SIGNAL(out_RETIRE_DATA,"out_RETIRE_DATA",Tdata_t   );
58  ALLOC1_SC_SIGNAL(out_SLOT_VAL   ,"out_SLOT_VAL"   ,Tcontrol_t,_param->_nb_port_slot);
59  ALLOC1_SC_SIGNAL(out_SLOT_DATA  ,"out_SLOT_DATA"  ,Tdata_t   ,_param->_nb_port_slot);
[67]60 
61  /********************************************************
62   * Instanciation
63   ********************************************************/
64 
65  cout << "<" << name << "> Instanciation of _Queue" << endl;
66 
67  (*(_Queue->in_CLOCK))        (*(in_CLOCK));
68  (*(_Queue->in_NRESET))       (*(in_NRESET));
69
[100]70  INSTANCE0_SC_SIGNAL(_Queue, in_INSERT_VAL );
71  INSTANCE0_SC_SIGNAL(_Queue,out_INSERT_ACK );
72  INSTANCE0_SC_SIGNAL(_Queue, in_INSERT_DATA);
73  INSTANCE0_SC_SIGNAL(_Queue,out_RETIRE_VAL );
74  INSTANCE0_SC_SIGNAL(_Queue, in_RETIRE_ACK );
75  INSTANCE0_SC_SIGNAL(_Queue,out_RETIRE_DATA);
76  INSTANCE1_SC_SIGNAL(_Queue,out_SLOT_VAL   ,_param->_nb_port_slot);
77  INSTANCE1_SC_SIGNAL(_Queue,out_SLOT_DATA  ,_param->_nb_port_slot);
[67]78
79  cout << "<" << name << "> Start Simulation ............" << endl;
80  Time * _time = new Time();
81
82  /********************************************************
83   * Simulation - Begin
84   ********************************************************/
85
86  // Initialisation
87  const  int32_t percent_insert_transaction = 75;
88  const  int32_t percent_retire_transaction = 75;
89  const uint32_t nb_request = 3*_param->_size_queue;
90
91  const uint32_t seed = 0;
92//const uint32_t seed = static_cast<uint32_t>(time(NULL));
93
94  srand(seed);
95
96  SC_START(0);
97  LABEL("Initialisation");
98
99  in_INSERT_VAL -> write(0);
100  in_RETIRE_ACK -> write(0);
101
102  LABEL("Reset");
103  in_NRESET->write(0);
104  SC_START(5);
105  in_NRESET->write(1); 
106
107  LABEL("Loop of Test");
108
109  uint32_t data_in  = 0;
110  uint32_t data_out = 0;
[100]111  uint32_t nb_elt   = 0;
[67]112
113  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
114    {
[82]115      LABEL("Iteration %d",iteration);
[67]116
117      while (data_out <= nb_request)
118        {
119          in_INSERT_VAL  -> write((rand()%100)<percent_insert_transaction);
120          in_INSERT_DATA -> write(data_in);
121          in_RETIRE_ACK  -> write((rand()%100)<percent_retire_transaction);
122
123          SC_START(0); // genMoore
124
[100]125          for (uint32_t i=0; i<_param->_nb_port_slot; ++i)
126            {
127              TEST(Tcontrol_t, out_SLOT_VAL [i]->read(), (i<nb_elt));
128              if (i<nb_elt)
129              TEST(Tdata_t   , out_SLOT_DATA[i]->read(), data_out+i);
130               
131            }
132
[67]133          if ( in_INSERT_VAL->read() and out_INSERT_ACK->read())
134            {
135              LABEL ("Transaction with interface : INSERT");
136              data_in ++;
[100]137              nb_elt ++;
[67]138            }
139          if (out_RETIRE_VAL->read() and  in_RETIRE_ACK->read())
140            {
141              LABEL ("Transaction with interface : RETIRE");
142              TEST(Tdata_t, out_RETIRE_DATA->read(), data_out);
143              data_out++;
[100]144              nb_elt --;
[67]145            }
146
147          SC_START(1);
148        }
149    }
150
151  /********************************************************
152   * Simulation - End
153   ********************************************************/
154
155  TEST_OK ("End of Simulation");
156  delete _time;
157  cout << "<" << name << "> ............ Stop Simulation" << endl;
158
159  delete in_CLOCK;
160  delete in_NRESET;
[100]161
162  DELETE0_SC_SIGNAL( in_INSERT_VAL );
163  DELETE0_SC_SIGNAL(out_INSERT_ACK );
164  DELETE0_SC_SIGNAL( in_INSERT_DATA);
165  DELETE0_SC_SIGNAL(out_RETIRE_VAL );
166  DELETE0_SC_SIGNAL( in_RETIRE_ACK );
167  DELETE0_SC_SIGNAL(out_RETIRE_DATA);
168  DELETE1_SC_SIGNAL(out_SLOT_VAL   ,_param->_nb_port_slot);
169  DELETE1_SC_SIGNAL(out_SLOT_DATA  ,_param->_nb_port_slot);
170
[67]171#endif
172
173  delete _Queue;
174#ifdef STATISTICS
175  delete _parameters_statistics;
176#endif
177}
Note: See TracBrowser for help on using the repository browser.