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

Last change on this file since 72 was 72, checked in by rosiere, 16 years ago
  • SystemC de l'unite fonctionnelle.
  • gestion des groupes / instructions custom
File size: 3.3 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    msg (_("{%d} "),static_cast<uint32_t>(sc_simulation_time()));       \
18    msg (str);                                                          \
19    msg (_("\n"));                                                      \
20  } while(0)
21
22#define SC_START(cycle_offset)                                                       \
23  do                                                                                 \
24    {                                                                                \
25      /*cout << "SC_START (begin)" << endl;*/                                        \
26                                                                                     \
27      uint32_t cycle_current = static_cast<uint32_t>(sc_simulation_time());          \
28      if (cycle_offset != 0)                                                         \
29        {                                                                            \
30          cout << "##########[ cycle "<< cycle_current+cycle_offset << " ]" << endl; \
31        }                                                                            \
32                                                                                     \
33      if (cycle_current > CYCLE_MAX)                                                 \
34        {                                                                            \
35          TEST_KO("Maximal cycles Reached");                                         \
36        }                                                                            \
37                                                                                     \
38      sc_start(cycle_offset);                                                        \
39                                                                                     \
40      /*cout << "SC_START (end  )" << endl;*/                                        \
41    } while(0)
42
43void test (string name,
44           morpheo::behavioural::@NAMESPACE_USE::Parameters * _param)
45{
46  msg(_("<%s> : Simulation SystemC.\n"),name.c_str());
47
48#ifdef STATISTICS
49  morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5,50);
50#endif
51
52  @COMPONENT * _@COMPONENT = new @COMPONENT (name.c_str(),
53#ifdef STATISTICS
54                                             _parameters_statistics,
55#endif
56                                             _param);
57 
58#ifdef SYSTEMC
59  /*********************************************************************
60   * Déclarations des signaux
61   *********************************************************************/
62  string rename;
63
64  sc_clock              *  in_CLOCK  = new sc_clock ("clock", 1.0, 0.5);         
65  sc_signal<Tcontrol_t> *  in_NRESET = new sc_signal<Tcontrol_t> ("NRESET");
66 
67  /********************************************************
68   * Instanciation
69   ********************************************************/
70 
71  msg(_("<%s> : Instanciation of _@COMPONENT.\n"),name.c_str());
72
73  (*(_@COMPONENT->in_CLOCK))        (*(in_CLOCK));
74  (*(_@COMPONENT->in_NRESET))       (*(in_NRESET));
75
76
77  msg(_("<%s> : Start Simulation ............\n"),name.c_str());
78   
79  Time * _time = new Time();
80
81  /********************************************************
82   * Simulation - Begin
83   ********************************************************/
84
85  // Initialisation
86
87  const uint32_t seed = 0;
88//const uint32_t seed = static_cast<uint32_t>(time(NULL));
89
90  srand(seed);
91
92  SC_START(0);
93  LABEL("Initialisation");
94
95  LABEL("Reset");
96  in_NRESET->write(0);
97  SC_START(5);
98  in_NRESET->write(1); 
99
100  LABEL("Loop of Test");
101
102  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
103    {
104      LABEL("Iteration %d",iteration);
105
106      SC_START(1);
107    }
108
109  /********************************************************
110   * Simulation - End
111   ********************************************************/
112
113  TEST_OK ("End of Simulation");
114  delete _time;
115
116  msg(_("<%s> : ............ Stop Simulation\n"),name.c_str());
117
118  delete in_CLOCK;
119  delete in_NRESET;
120#endif
121
122  delete _@COMPONENT;
123#ifdef STATISTICS
124  delete _parameters_statistics;
125#endif
126}
Note: See TracBrowser for help on using the repository browser.