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