[10] | 1 | /* |
---|
| 2 | * $Id: test.cpp 97 2008-12-19 15:34:00Z rosiere $ |
---|
| 3 | * |
---|
| 4 | * [ Description ] |
---|
| 5 | * |
---|
| 6 | * Test |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | #define NB_ITERATION 512 |
---|
[82] | 10 | #define CYCLE_MAX (1024*NB_ITERATION) |
---|
[10] | 11 | |
---|
[15] | 12 | #include "Behavioural/Generic/Select/Select_Priority_Fixed/SelfTest/include/test.h" |
---|
[44] | 13 | #include "Common/include/Test.h" |
---|
[10] | 14 | |
---|
| 15 | void test (string name, |
---|
[57] | 16 | morpheo::behavioural::generic::select::select_priority_fixed::Parameters * _param) |
---|
[10] | 17 | { |
---|
| 18 | cout << "<" << name << "> : Simulation SystemC" << endl; |
---|
| 19 | |
---|
[57] | 20 | #ifdef STATISTICS |
---|
| 21 | morpheo::behavioural::Parameters_Statistics * _param_stat = new morpheo::behavioural::Parameters_Statistics (5,50); |
---|
| 22 | #endif |
---|
[88] | 23 | |
---|
| 24 | Tusage_t _usage = USE_ALL; |
---|
| 25 | |
---|
| 26 | // _usage = usage_unset(_usage,USE_SYSTEMC ); |
---|
| 27 | // _usage = usage_unset(_usage,USE_VHDL ); |
---|
| 28 | // _usage = usage_unset(_usage,USE_VHDL_TESTBENCH ); |
---|
| 29 | // _usage = usage_unset(_usage,USE_VHDL_TESTBENCH_ASSERT); |
---|
| 30 | // _usage = usage_unset(_usage,USE_POSITION ); |
---|
| 31 | // _usage = usage_unset(_usage,USE_STATISTICS ); |
---|
| 32 | // _usage = usage_unset(_usage,USE_INFORMATION ); |
---|
| 33 | |
---|
[82] | 34 | Select_Priority_Fixed * _Select_Priority_Fixed = new Select_Priority_Fixed |
---|
| 35 | (name.c_str(), |
---|
[10] | 36 | #ifdef STATISTICS |
---|
[82] | 37 | _param_stat, |
---|
[10] | 38 | #endif |
---|
[82] | 39 | _param, |
---|
[88] | 40 | _usage); |
---|
[10] | 41 | |
---|
| 42 | #ifdef SYSTEMC |
---|
| 43 | /********************************************************************* |
---|
| 44 | * Déclarations des signaux |
---|
| 45 | *********************************************************************/ |
---|
| 46 | sc_clock * CLOCK ; |
---|
[15] | 47 | sc_signal<Tcontrol_t> * NRESET; |
---|
[10] | 48 | sc_signal<Tcontrol_t> ** VAL ; |
---|
| 49 | sc_signal<Tcontrol_t> ** ACK ; |
---|
| 50 | sc_signal<Tentity_t > * ENTITY; |
---|
| 51 | sc_signal<Tcontrol_t> * ENTITY_ACK; |
---|
| 52 | |
---|
| 53 | string rename; |
---|
| 54 | |
---|
| 55 | CLOCK = new sc_clock ("clock", 1.0, 0.5); |
---|
[15] | 56 | NRESET = new sc_signal<Tcontrol_t> ("NRESET"); |
---|
[57] | 57 | VAL = new sc_signal<Tcontrol_t> * [_param->_nb_entity]; |
---|
| 58 | ACK = new sc_signal<Tcontrol_t> * [_param->_nb_entity]; |
---|
[10] | 59 | |
---|
[57] | 60 | for (uint32_t i=0; i<_param->_nb_entity; i++) |
---|
[10] | 61 | { |
---|
| 62 | rename = "VAL_"+toString(i); |
---|
| 63 | VAL [i] = new sc_signal<Tcontrol_t> (rename.c_str()); |
---|
| 64 | rename = "ACK_"+toString(i); |
---|
| 65 | ACK [i] = new sc_signal<Tcontrol_t> (rename.c_str()); |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | ENTITY = new sc_signal<Tentity_t> ("entity"); |
---|
| 69 | ENTITY_ACK = new sc_signal<Tcontrol_t> ("entity_ack"); |
---|
| 70 | |
---|
| 71 | /******************************************************** |
---|
| 72 | * Instanciation |
---|
| 73 | ********************************************************/ |
---|
| 74 | |
---|
[15] | 75 | cout << "<" << name << "> Instanciation of _Select_Priority_Fixed" << endl; |
---|
[10] | 76 | |
---|
[15] | 77 | (*(_Select_Priority_Fixed->in_CLOCK )) (*(CLOCK )); |
---|
| 78 | (*(_Select_Priority_Fixed->in_NRESET)) (*(NRESET)); |
---|
| 79 | |
---|
[57] | 80 | for (uint32_t i=0; i<_param->_nb_entity; i++) |
---|
[10] | 81 | { |
---|
[15] | 82 | (*(_Select_Priority_Fixed-> in_VAL [i])) (*(VAL [i])); |
---|
[57] | 83 | if (_param->_encoding_one_hot) |
---|
[15] | 84 | (*(_Select_Priority_Fixed->out_ACK [i])) (*(ACK [i])); |
---|
[10] | 85 | } |
---|
[57] | 86 | if (_param->_encoding_compact) |
---|
[10] | 87 | { |
---|
[15] | 88 | (*(_Select_Priority_Fixed->out_ENTITY )) (*(ENTITY )); |
---|
| 89 | (*(_Select_Priority_Fixed->out_ENTITY_ACK)) (*(ENTITY_ACK)); |
---|
[10] | 90 | } |
---|
| 91 | /******************************************************** |
---|
| 92 | * Simulation - Begin |
---|
| 93 | ********************************************************/ |
---|
| 94 | |
---|
| 95 | cout << "<" << name << "> Start Simulation ............" << endl; |
---|
[97] | 96 | Time * _time = new Time(); |
---|
[10] | 97 | |
---|
[57] | 98 | if (_param->_nb_entity > (8*sizeof (Tentity_t))) |
---|
[10] | 99 | throw ErrorMorpheo("No Selftest with nb_entity higher at "+toString(8*sizeof (Tentity_t))); |
---|
| 100 | |
---|
| 101 | // Initialisation |
---|
| 102 | const uint32_t seed = 0; |
---|
| 103 | //const uint32_t seed = static_cast<uint32_t>(time(NULL)); |
---|
| 104 | |
---|
| 105 | srand(seed); |
---|
| 106 | |
---|
| 107 | Tentity_t entity; |
---|
| 108 | |
---|
| 109 | sc_start(0); |
---|
| 110 | //cout << "{"+toString(static_cast<uint32_t>(sc_simulation_time()))+"} Initialisation" << endl; |
---|
| 111 | |
---|
| 112 | cout << "{"+toString(static_cast<uint32_t>(sc_simulation_time()))+"} Loop of Test" << endl; |
---|
| 113 | |
---|
| 114 | for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++) |
---|
| 115 | { |
---|
| 116 | entity = 0; |
---|
| 117 | bool find = false; |
---|
| 118 | |
---|
[57] | 119 | for (uint32_t i=0; i<_param->_nb_entity; i++) |
---|
[10] | 120 | { |
---|
| 121 | Tcontrol_t val = rand() % 2; |
---|
| 122 | |
---|
| 123 | VAL [i]->write(val); |
---|
| 124 | |
---|
| 125 | if (not find and val) |
---|
| 126 | { |
---|
| 127 | find = true; |
---|
| 128 | entity = i; |
---|
| 129 | } |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | sc_start(1); |
---|
| 133 | |
---|
| 134 | cout << "wait entity : " << entity << endl; |
---|
| 135 | |
---|
| 136 | entity = (find)?entity:0; |
---|
| 137 | |
---|
[57] | 138 | if (_param->_encoding_one_hot) |
---|
[10] | 139 | TEST(Tcontrol_t, ACK [entity]->read(), find ); |
---|
[57] | 140 | if (_param->_encoding_compact) |
---|
[10] | 141 | { |
---|
| 142 | TEST(Tentity_t , ENTITY ->read(), entity); // burk |
---|
| 143 | TEST(Tcontrol_t, ENTITY_ACK ->read(), find ); // burk |
---|
| 144 | } |
---|
| 145 | } |
---|
| 146 | |
---|
| 147 | /******************************************************** |
---|
| 148 | * Simulation - End |
---|
| 149 | ********************************************************/ |
---|
| 150 | |
---|
[97] | 151 | delete _time; |
---|
[10] | 152 | cout << "<" << name << "> ............ Stop Simulation" << endl; |
---|
| 153 | |
---|
[40] | 154 | delete CLOCK; |
---|
| 155 | delete NRESET; |
---|
| 156 | delete [] VAL ; |
---|
| 157 | delete [] ACK ; |
---|
| 158 | delete ENTITY ; |
---|
| 159 | delete ENTITY_ACK; |
---|
[10] | 160 | #endif |
---|
| 161 | |
---|
[15] | 162 | delete _Select_Priority_Fixed; |
---|
[10] | 163 | } |
---|