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

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

add two component :

  • Write Queue (in Moore version)
  • Execute Queue

add macro to help the interface allocation : Allocation.h

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