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
RevLine 
[2]1/*
2 * $Id$
3 *
4 * [ Description ]
5 *
6 * Test
7 */
8
9#include "Behavioural/@DIRECTORY/SelfTest/include/test.h"
[44]10#include "Common/include/Test.h"
[2]11
[50]12#define NB_ITERATION  1
13#define CYCLE_MAX     (128*NB_ITERATION)
14
[72]15#define LABEL(str...)                                                   \
[71]16  {                                                                     \
[72]17    msg (_("{%d} "),static_cast<uint32_t>(sc_simulation_time()));       \
18    msg (str);                                                          \
19    msg (_("\n"));                                                      \
20  } while(0)
[50]21
[71]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)
[55]42
[2]43void test (string name,
[50]44           morpheo::behavioural::@NAMESPACE_USE::Parameters * _param)
[2]45{
[71]46  msg(_("<%s> : Simulation SystemC.\n"),name.c_str());
[2]47
[53]48#ifdef STATISTICS
49  morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5,50);
50#endif
51
[2]52  @COMPONENT * _@COMPONENT = new @COMPONENT (name.c_str(),
53#ifdef STATISTICS
[53]54                                             _parameters_statistics,
[2]55#endif
[53]56                                             _param);
[2]57 
58#ifdef SYSTEMC
59  /*********************************************************************
60   * Déclarations des signaux
61   *********************************************************************/
62  string rename;
63
[67]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");
[2]66 
67  /********************************************************
68   * Instanciation
69   ********************************************************/
70 
[71]71  msg(_("<%s> : Instanciation of _@COMPONENT.\n"),name.c_str());
72
[53]73  (*(_@COMPONENT->in_CLOCK))        (*(in_CLOCK));
74  (*(_@COMPONENT->in_NRESET))       (*(in_NRESET));
[2]75
[15]76
[71]77  msg(_("<%s> : Start Simulation ............\n"),name.c_str());
78   
[50]79  Time * _time = new Time();
[15]80
[2]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
[50]92  SC_START(0);
[15]93  LABEL("Initialisation");
[2]94
[67]95  LABEL("Reset");
96  in_NRESET->write(0);
97  SC_START(5);
98  in_NRESET->write(1); 
99
[15]100  LABEL("Loop of Test");
[2]101
102  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
103    {
[72]104      LABEL("Iteration %d",iteration);
[2]105
[50]106      SC_START(1);
[2]107    }
108
109  /********************************************************
110   * Simulation - End
111   ********************************************************/
112
[50]113  TEST_OK ("End of Simulation");
114  delete _time;
[2]115
[71]116  msg(_("<%s> : ............ Stop Simulation\n"),name.c_str());
117
[55]118  delete in_CLOCK;
119  delete in_NRESET;
[2]120#endif
121
122  delete _@COMPONENT;
[55]123#ifdef STATISTICS
[53]124  delete _parameters_statistics;
125#endif
[2]126}
Note: See TracBrowser for help on using the repository browser.