source: trunk/IPs/systemC/processor/Morpheo/Behavioural/New_Component_vbe/SelfTest/src/test.cpp @ 78

Last change on this file since 78 was 76, checked in by rosiere, 16 years ago

Add new component : Read_unit (no tested)
Change functionnal_unit : now use type and operation to execute the good function
Change New_Component's script

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