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

Last change on this file since 55 was 55, checked in by rosiere, 17 years ago

Ajout SystemC read_queue et reservation_station
Ajout port au bloc registerfile_monolithic (à ajouter également au bloc registerfile et registerfile_multi_banked)
Modif param : passage de pointeur (attention, tous les composants n'ont pas été tous modifier)

File size: 4.0 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
20static uint32_t cycle = 0;
21
22#define SC_START(cycle_offset)                                          \
23do                                                                      \
24{                                                                       \
25/*cout << "SC_START (begin)" << endl;*/                                 \
26                                                                        \
27  uint32_t cycle_current = static_cast<uint32_t>(sc_simulation_time()); \
28  if (cycle_current != cycle)                                           \
29    {                                                                   \
30      cycle = cycle_current;                                            \
31      cout << "##########[ cycle "<< cycle << " ]" << endl;             \
32    }                                                                   \
33                                                                        \
34  if (cycle_current > CYCLE_MAX)                                        \
35    {                                                                   \
36      TEST_KO("Maximal cycles Reached");                                \
37    }                                                                   \
38  sc_start(cycle_offset);                                               \
39/*cout << "SC_START (end  )" << endl;*/                                 \
40} while(0)
41
42void test (string name,
43           morpheo::behavioural::@NAMESPACE_USE::Parameters * _param)
44{
45  cout << "<" << name << "> : Simulation SystemC" << endl;
46
47#ifdef STATISTICS
48  morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5,50);
49#endif
50
51  @COMPONENT * _@COMPONENT = new @COMPONENT (name.c_str(),
52#ifdef STATISTICS
53                                             _parameters_statistics,
54#endif
55                                             _param);
56 
57#ifdef SYSTEMC
58  /*********************************************************************
59   * Déclarations des signaux
60   *********************************************************************/
61  sc_clock                               * in_CLOCK;
62  sc_signal<Tcontrol_t>                  * in_NRESET;
63
64  string rename;
65
66  in_CLOCK                                = new sc_clock ("clock", 1.0, 0.5);
67  in_NRESET                               = new sc_signal<Tcontrol_t> ("NRESET");
68 
69  /********************************************************
70   * Instanciation
71   ********************************************************/
72 
73  cout << "<" << name << "> Instanciation of _@COMPONENT" << endl;
74 
75  (*(_@COMPONENT->in_CLOCK))        (*(in_CLOCK));
76  (*(_@COMPONENT->in_NRESET))       (*(in_NRESET));
77
78
79  cout << "<" << name << "> Start Simulation ............" << endl;
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("Loop of Test");
97
98  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
99    {
100      LABEL("Iteration "+toString(iteration));
101
102      SC_START(1);
103    }
104
105  /********************************************************
106   * Simulation - End
107   ********************************************************/
108
109  TEST_OK ("End of Simulation");
110  delete _time;
111  cout << "<" << name << "> ............ Stop Simulation" << endl;
112
113  delete in_CLOCK;
114  delete in_NRESET;
115#endif
116
117  delete _@COMPONENT;
118#ifdef STATISTICS
119  delete _parameters_statistics;
120#endif
121}
Note: See TracBrowser for help on using the repository browser.