[78] | 1 | /* |
---|
| 2 | * $Id: test.cpp 88 2008-12-10 18:31:39Z rosiere $ |
---|
| 3 | * |
---|
| 4 | * [ Description ] |
---|
| 5 | * |
---|
| 6 | * Test |
---|
| 7 | */ |
---|
| 8 | |
---|
[82] | 9 | #define NB_ITERATION 10 |
---|
| 10 | #define CYCLE_MAX (128*NB_ITERATION) |
---|
| 11 | |
---|
[78] | 12 | #include "Behavioural/Generic/Victim/SelfTest/include/test.h" |
---|
| 13 | #include "Common/include/Test.h" |
---|
| 14 | #include "Behavioural/include/Allocation.h" |
---|
| 15 | |
---|
| 16 | void test (string name, |
---|
| 17 | morpheo::behavioural::generic::victim::Parameters * _param) |
---|
| 18 | { |
---|
| 19 | msg(_("<%s> : Simulation SystemC.\n"),name.c_str()); |
---|
| 20 | |
---|
| 21 | #ifdef STATISTICS |
---|
| 22 | morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5,50); |
---|
| 23 | #endif |
---|
| 24 | |
---|
[88] | 25 | Tusage_t _usage = USE_ALL; |
---|
| 26 | |
---|
| 27 | // _usage = usage_unset(_usage,USE_SYSTEMC ); |
---|
| 28 | // _usage = usage_unset(_usage,USE_VHDL ); |
---|
| 29 | // _usage = usage_unset(_usage,USE_VHDL_TESTBENCH ); |
---|
| 30 | // _usage = usage_unset(_usage,USE_VHDL_TESTBENCH_ASSERT); |
---|
| 31 | // _usage = usage_unset(_usage,USE_POSITION ); |
---|
| 32 | // _usage = usage_unset(_usage,USE_STATISTICS ); |
---|
| 33 | // _usage = usage_unset(_usage,USE_INFORMATION ); |
---|
| 34 | |
---|
[78] | 35 | Victim * _Victim = new Victim (name.c_str(), |
---|
| 36 | #ifdef STATISTICS |
---|
[82] | 37 | _parameters_statistics, |
---|
[78] | 38 | #endif |
---|
[82] | 39 | _param, |
---|
[88] | 40 | _usage); |
---|
[78] | 41 | |
---|
| 42 | #ifdef SYSTEMC |
---|
| 43 | /********************************************************************* |
---|
| 44 | * Déclarations des signaux |
---|
| 45 | *********************************************************************/ |
---|
| 46 | string rename; |
---|
| 47 | |
---|
| 48 | sc_clock * in_CLOCK = new sc_clock ("clock", 1.0, 0.5); |
---|
| 49 | sc_signal<Tcontrol_t> * in_NRESET = new sc_signal<Tcontrol_t> ("NRESET"); |
---|
| 50 | |
---|
| 51 | ALLOC1_SC_SIGNAL( in_ACCESS_VAL ," in_ACCESS_VAL ",Tcontrol_t,_param->_nb_access); |
---|
| 52 | ALLOC1_SC_SIGNAL(out_ACCESS_ACK ,"out_ACCESS_ACK ",Tcontrol_t,_param->_nb_access); |
---|
| 53 | ALLOC1_SC_SIGNAL( in_ACCESS_ADDRESS," in_ACCESS_ADDRESS",Taddress_t,_param->_nb_access); |
---|
| 54 | ALLOC1_SC_SIGNAL( in_ACCESS_HIT ," in_ACCESS_HIT ",Tcontrol_t,_param->_nb_access); |
---|
| 55 | ALLOC1_SC_SIGNAL( in_ACCESS_ENTITY ," in_ACCESS_ENTITY ",Tentity_t ,_param->_nb_access); |
---|
| 56 | ALLOC1_SC_SIGNAL(out_ACCESS_VICTIM ,"out_ACCESS_VICTIM ",Tentity_t ,_param->_nb_access); |
---|
| 57 | |
---|
| 58 | /******************************************************** |
---|
| 59 | * Instanciation |
---|
| 60 | ********************************************************/ |
---|
| 61 | |
---|
| 62 | msg(_("<%s> : Instanciation of _Victim.\n"),name.c_str()); |
---|
| 63 | |
---|
| 64 | (*(_Victim->in_CLOCK)) (*(in_CLOCK)); |
---|
| 65 | (*(_Victim->in_NRESET)) (*(in_NRESET)); |
---|
| 66 | |
---|
| 67 | INSTANCE1_SC_SIGNAL(_Victim, in_ACCESS_VAL ,_param->_nb_access); |
---|
| 68 | INSTANCE1_SC_SIGNAL(_Victim,out_ACCESS_ACK ,_param->_nb_access); |
---|
| 69 | if (_param->_have_port_address) |
---|
| 70 | INSTANCE1_SC_SIGNAL(_Victim, in_ACCESS_ADDRESS,_param->_nb_access); |
---|
| 71 | INSTANCE1_SC_SIGNAL(_Victim, in_ACCESS_HIT ,_param->_nb_access); |
---|
| 72 | INSTANCE1_SC_SIGNAL(_Victim, in_ACCESS_ENTITY ,_param->_nb_access); |
---|
| 73 | INSTANCE1_SC_SIGNAL(_Victim,out_ACCESS_VICTIM ,_param->_nb_access); |
---|
| 74 | |
---|
| 75 | msg(_("<%s> : Start Simulation ............\n"),name.c_str()); |
---|
| 76 | |
---|
| 77 | Time * _time = new Time(); |
---|
| 78 | |
---|
| 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 | |
---|
| 90 | SC_START(0); |
---|
| 91 | LABEL("Initialisation"); |
---|
| 92 | |
---|
| 93 | LABEL("Reset"); |
---|
| 94 | in_NRESET->write(0); |
---|
| 95 | SC_START(5); |
---|
| 96 | in_NRESET->write(1); |
---|
| 97 | |
---|
| 98 | LABEL("Loop of Test"); |
---|
| 99 | |
---|
| 100 | for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++) |
---|
| 101 | { |
---|
| 102 | LABEL("Iteration %d",iteration); |
---|
| 103 | |
---|
| 104 | SC_START(1); |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | /******************************************************** |
---|
| 108 | * Simulation - End |
---|
| 109 | ********************************************************/ |
---|
| 110 | |
---|
| 111 | TEST_OK ("End of Simulation"); |
---|
| 112 | delete _time; |
---|
| 113 | |
---|
| 114 | msg(_("<%s> : ............ Stop Simulation\n"),name.c_str()); |
---|
| 115 | |
---|
| 116 | delete _Victim; |
---|
| 117 | |
---|
| 118 | delete in_CLOCK; |
---|
| 119 | delete in_NRESET; |
---|
| 120 | |
---|
| 121 | delete [] in_ACCESS_VAL ; |
---|
| 122 | delete [] out_ACCESS_ACK ; |
---|
| 123 | delete [] in_ACCESS_ADDRESS; |
---|
| 124 | delete [] in_ACCESS_HIT ; |
---|
| 125 | delete [] in_ACCESS_ENTITY ; |
---|
| 126 | delete [] out_ACCESS_VICTIM ; |
---|
| 127 | #endif |
---|
| 128 | |
---|
| 129 | #ifdef STATISTICS |
---|
| 130 | delete _parameters_statistics; |
---|
| 131 | #endif |
---|
| 132 | } |
---|