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

Last change on this file since 53 was 53, checked in by rosiere, 17 years ago
  • Banc de registre multi banc
  • Banc de registre générique.
File size: 3.2 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#ifdef STATISTICS
36  morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5,50);
37#endif
38
39  @COMPONENT * _@COMPONENT = new @COMPONENT (name.c_str(),
40#ifdef STATISTICS
41                                             _parameters_statistics,
42#endif
43                                             _param);
44 
45#ifdef SYSTEMC
46  /*********************************************************************
47   * Déclarations des signaux
48   *********************************************************************/
49  sc_clock                               * in_CLOCK;
50  sc_signal<Tcontrol_t>                  * in_NRESET;
51
52  string rename;
53
54  in_CLOCK                                = new sc_clock ("clock", 1.0, 0.5);
55  in_NRESET                               = new sc_signal<Tcontrol_t> ("NRESET");
56 
57  /********************************************************
58   * Instanciation
59   ********************************************************/
60 
61  cout << "<" << name << "> Instanciation of _@COMPONENT" << endl;
62 
63  (*(_@COMPONENT->in_CLOCK))        (*(in_CLOCK));
64  (*(_@COMPONENT->in_NRESET))       (*(in_NRESET));
65
66
67  cout << "<" << name << "> Start Simulation ............" << endl;
68  Time * _time = new Time();
69
70  /********************************************************
71   * Simulation - Begin
72   ********************************************************/
73
74  // Initialisation
75
76  const uint32_t seed = 0;
77//const uint32_t seed = static_cast<uint32_t>(time(NULL));
78
79  srand(seed);
80
81  SC_START(0);
82  LABEL("Initialisation");
83
84  LABEL("Loop of Test");
85
86  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
87    {
88      LABEL("Iteration "+toString(iteration));
89
90      SC_START(1);
91    }
92
93  /********************************************************
94   * Simulation - End
95   ********************************************************/
96
97  TEST_OK ("End of Simulation");
98  delete _time;
99  cout << "<" << name << "> ............ Stop Simulation" << endl;
100
101  delete CLOCK;
102  delete NRESET;
103#endif
104
105  delete _@COMPONENT;
106#ifdef SYSTEMC
107  delete _parameters_statistics;
108#endif
109}
Note: See TracBrowser for help on using the repository browser.