source: trunk/IPs/systemC/processor/Morpheo/Behavioural/New_Component/SelfTest/src/test.cpp @ 50

Last change on this file since 50 was 50, checked in by rosiere, 17 years ago

Changement dans le répertoire "New_Component" afin que les composants nouvellement crées peuvent compiler

File size: 3.0 KB
Line 
1/*
2 * $Id$
3 *
4 * [ Description ]
5 *
6 * Test
7 */
8
9#include "Behavioural/@DIRECTORY/SelfTest/include/test.h"
10#include "Common/include/Test.h"
11
12#define NB_ITERATION  1
13#define CYCLE_MAX     (128*NB_ITERATION)
14
15#define LABEL(str)                                                                       \
16{                                                                                        \
17  cout << "{"+toString(static_cast<uint32_t>(sc_simulation_time()))+"} " << str << endl; \
18} while(0)
19
20#define SC_START(cycle)                                        \
21do                                                             \
22{                                                              \
23  if (static_cast<uint32_t>(sc_simulation_time()) > CYCLE_MAX) \
24    {                                                          \
25      TEST_KO("Maximal cycles Reached");                       \
26    }                                                          \
27  sc_start(cycle);                                             \
28} while(0)
29
30void test (string name,
31           morpheo::behavioural::@NAMESPACE_USE::Parameters * _param)
32{
33  cout << "<" << name << "> : Simulation SystemC" << endl;
34
35  @COMPONENT * _@COMPONENT = new @COMPONENT (name.c_str(),
36#ifdef STATISTICS
37                                             morpheo::behavioural::Parameters_Statistics(5,50),
38#endif
39                                             *_param);
40 
41#ifdef SYSTEMC
42  /*********************************************************************
43   * Déclarations des signaux
44   *********************************************************************/
45  sc_clock                               * CLOCK;
46  sc_signal<Tcontrol_t>                  * NRESET;
47
48  string rename;
49
50  CLOCK                                  = new sc_clock ("clock", 1.0, 0.5);
51  NRESET                                 = new sc_signal<Tcontrol_t> ("NRESET");
52 
53  /********************************************************
54   * Instanciation
55   ********************************************************/
56 
57  cout << "<" << name << "> Instanciation of _@COMPONENT" << endl;
58 
59  (*(_@COMPONENT->in_CLOCK))        (*(CLOCK));
60  (*(_@COMPONENT->in_NRESET))       (*(NRESET));
61
62
63  cout << "<" << name << "> Start Simulation ............" << endl;
64  Time * _time = new Time();
65
66  /********************************************************
67   * Simulation - Begin
68   ********************************************************/
69
70  // Initialisation
71
72  const uint32_t seed = 0;
73//const uint32_t seed = static_cast<uint32_t>(time(NULL));
74
75  srand(seed);
76
77  SC_START(0);
78  LABEL("Initialisation");
79
80  LABEL("Loop of Test");
81
82  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
83    {
84      LABEL("Iteration "+toString(iteration));
85
86      SC_START(1);
87    }
88
89  /********************************************************
90   * Simulation - End
91   ********************************************************/
92
93  TEST_OK ("End of Simulation");
94  delete _time;
95  cout << "<" << name << "> ............ Stop Simulation" << endl;
96
97  delete CLOCK;
98  delete NRESET;
99#endif
100
101  delete _@COMPONENT;
102}
Note: See TracBrowser for help on using the repository browser.