[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 | |
---|
| 15 | #define LABEL(str) \ |
---|
| 16 | { \ |
---|
| 17 | cout << "{"+toString(static_cast<uint32_t>(sc_simulation_time()))+"} " << str << endl; \ |
---|
| 18 | } while(0) |
---|
| 19 | |
---|
| 20 | #define SC_START(cycle) \ |
---|
| 21 | do \ |
---|
| 22 | { \ |
---|
| 23 | if (static_cast<uint32_t>(sc_simulation_time()) > CYCLE_MAX) \ |
---|
| 24 | { \ |
---|
| 25 | TEST_KO("Maximal cycles Reached"); \ |
---|
| 26 | } \ |
---|
| 27 | sc_start(cycle); \ |
---|
| 28 | } while(0) |
---|
| 29 | |
---|
[2] | 30 | void test (string name, |
---|
[50] | 31 | morpheo::behavioural::@NAMESPACE_USE::Parameters * _param) |
---|
[2] | 32 | { |
---|
| 33 | cout << "<" << name << "> : Simulation SystemC" << endl; |
---|
| 34 | |
---|
[53] | 35 | #ifdef STATISTICS |
---|
| 36 | morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5,50); |
---|
| 37 | #endif |
---|
| 38 | |
---|
[2] | 39 | @COMPONENT * _@COMPONENT = new @COMPONENT (name.c_str(), |
---|
| 40 | #ifdef STATISTICS |
---|
[53] | 41 | _parameters_statistics, |
---|
[2] | 42 | #endif |
---|
[53] | 43 | _param); |
---|
[2] | 44 | |
---|
| 45 | #ifdef SYSTEMC |
---|
| 46 | /********************************************************************* |
---|
| 47 | * Déclarations des signaux |
---|
| 48 | *********************************************************************/ |
---|
[53] | 49 | sc_clock * in_CLOCK; |
---|
| 50 | sc_signal<Tcontrol_t> * in_NRESET; |
---|
[2] | 51 | |
---|
| 52 | string rename; |
---|
| 53 | |
---|
[53] | 54 | in_CLOCK = new sc_clock ("clock", 1.0, 0.5); |
---|
| 55 | in_NRESET = new sc_signal<Tcontrol_t> ("NRESET"); |
---|
[2] | 56 | |
---|
| 57 | /******************************************************** |
---|
| 58 | * Instanciation |
---|
| 59 | ********************************************************/ |
---|
| 60 | |
---|
| 61 | cout << "<" << name << "> Instanciation of _@COMPONENT" << endl; |
---|
| 62 | |
---|
[53] | 63 | (*(_@COMPONENT->in_CLOCK)) (*(in_CLOCK)); |
---|
| 64 | (*(_@COMPONENT->in_NRESET)) (*(in_NRESET)); |
---|
[2] | 65 | |
---|
[15] | 66 | |
---|
| 67 | cout << "<" << name << "> Start Simulation ............" << endl; |
---|
[50] | 68 | Time * _time = new Time(); |
---|
[15] | 69 | |
---|
[2] | 70 | /******************************************************** |
---|
| 71 | * Simulation - Begin |
---|
| 72 | ********************************************************/ |
---|
| 73 | |
---|
| 74 | // Initialisation |
---|
| 75 | |
---|
| 76 | const uint32_t seed = 0; |
---|
| 77 | //const uint32_t seed = static_cast<uint32_t>(time(NULL)); |
---|
| 78 | |
---|
| 79 | srand(seed); |
---|
| 80 | |
---|
[50] | 81 | SC_START(0); |
---|
[15] | 82 | LABEL("Initialisation"); |
---|
[2] | 83 | |
---|
[15] | 84 | LABEL("Loop of Test"); |
---|
[2] | 85 | |
---|
| 86 | for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++) |
---|
| 87 | { |
---|
[15] | 88 | LABEL("Iteration "+toString(iteration)); |
---|
[2] | 89 | |
---|
[50] | 90 | SC_START(1); |
---|
[2] | 91 | } |
---|
| 92 | |
---|
| 93 | /******************************************************** |
---|
| 94 | * Simulation - End |
---|
| 95 | ********************************************************/ |
---|
| 96 | |
---|
[50] | 97 | TEST_OK ("End of Simulation"); |
---|
| 98 | delete _time; |
---|
[2] | 99 | cout << "<" << name << "> ............ Stop Simulation" << endl; |
---|
| 100 | |
---|
[15] | 101 | delete CLOCK; |
---|
| 102 | delete NRESET; |
---|
[2] | 103 | #endif |
---|
| 104 | |
---|
| 105 | delete _@COMPONENT; |
---|
[53] | 106 | #ifdef SYSTEMC |
---|
| 107 | delete _parameters_statistics; |
---|
| 108 | #endif |
---|
[2] | 109 | } |
---|