Changeset 113 for trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Queue/SelfTest/src/top_test.cpp
- Timestamp:
- Apr 14, 2009, 8:39:12 PM (15 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Queue/SelfTest/src/top_test.cpp
r111 r113 7 7 */ 8 8 9 # define NB_ITERATION 110 # define CYCLE_MAX (2048*NB_ITERATION)9 #include "Behavioural/Generic/Queue/SelfTest/include/top.h" 10 #include "Behavioural/include/Allocation.h" 11 11 12 #include "Behavioural/Generic/Queue/SelfTest/include/test.h" 13 #include "Behavioural/include/Allocation.h" 14 #include "Common/include/Test.h" 15 16 void test (string name, 17 morpheo::behavioural::generic::queue::Parameters * _param) 12 void top::test (void) 18 13 { 19 cout << "<" << name << "> : Simulation SystemC" << endl;20 21 #ifdef STATISTICS22 morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5,50);23 #endif24 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 35 Queue * _Queue = new Queue36 (name.c_str(),37 #ifdef STATISTICS38 _parameters_statistics,39 #endif40 _param,41 _usage);42 43 14 #ifdef SYSTEMC 44 /********************************************************************* 45 * Déclarations des signaux 46 *********************************************************************/ 47 string rename; 48 49 sc_clock * in_CLOCK = new sc_clock ("clock", 1.0, 0.5); 50 sc_signal<Tcontrol_t> * in_NRESET = new sc_signal<Tcontrol_t> ("NRESET"); 51 52 ALLOC0_SC_SIGNAL( in_INSERT_VAL , "in_INSERT_VAL" ,Tcontrol_t); 53 ALLOC0_SC_SIGNAL(out_INSERT_ACK ,"out_INSERT_ACK" ,Tcontrol_t); 54 ALLOC0_SC_SIGNAL( in_INSERT_DATA, "in_INSERT_DATA",Tdata_t ); 55 ALLOC0_SC_SIGNAL(out_RETIRE_VAL ,"out_RETIRE_VAL" ,Tcontrol_t); 56 ALLOC0_SC_SIGNAL( in_RETIRE_ACK , "in_RETIRE_ACK" ,Tcontrol_t); 57 ALLOC0_SC_SIGNAL(out_RETIRE_DATA,"out_RETIRE_DATA",Tdata_t ); 58 ALLOC1_SC_SIGNAL(out_SLOT_VAL ,"out_SLOT_VAL" ,Tcontrol_t,_param->_nb_port_slot); 59 ALLOC1_SC_SIGNAL(out_SLOT_DATA ,"out_SLOT_DATA" ,Tdata_t ,_param->_nb_port_slot); 60 ALLOC0_SC_SIGNAL(out_PTR_WRITE ,"out_PTR_WRITE" ,Tptr_t ); 61 ALLOC0_SC_SIGNAL(out_PTR_READ ,"out_PTR_READ" ,Tptr_t ); 62 63 /******************************************************** 64 * Instanciation 65 ********************************************************/ 66 67 cout << "<" << name << "> Instanciation of _Queue" << endl; 68 69 (*(_Queue->in_CLOCK)) (*(in_CLOCK)); 70 (*(_Queue->in_NRESET)) (*(in_NRESET)); 71 72 INSTANCE0_SC_SIGNAL(_Queue, in_INSERT_VAL ); 73 INSTANCE0_SC_SIGNAL(_Queue,out_INSERT_ACK ); 74 INSTANCE0_SC_SIGNAL(_Queue, in_INSERT_DATA); 75 INSTANCE0_SC_SIGNAL(_Queue,out_RETIRE_VAL ); 76 INSTANCE0_SC_SIGNAL(_Queue, in_RETIRE_ACK ); 77 INSTANCE0_SC_SIGNAL(_Queue,out_RETIRE_DATA); 78 INSTANCE1_SC_SIGNAL(_Queue,out_SLOT_VAL ,_param->_nb_port_slot); 79 INSTANCE1_SC_SIGNAL(_Queue,out_SLOT_DATA ,_param->_nb_port_slot); 80 if (_param->_have_port_ptr_write) 81 INSTANCE0_SC_SIGNAL(_Queue,out_PTR_WRITE ); 82 if (_param->_have_port_ptr_read ) 83 INSTANCE0_SC_SIGNAL(_Queue,out_PTR_READ ); 84 85 cout << "<" << name << "> Start Simulation ............" << endl; 86 Time * _time = new Time(); 87 88 /******************************************************** 89 * Simulation - Begin 90 ********************************************************/ 91 92 // Initialisation 93 const int32_t percent_insert_transaction = 75; 94 const int32_t percent_retire_transaction = 75; 95 const uint32_t nb_request = 3*_param->_size_queue; 96 97 const uint32_t seed = 0; 98 //const uint32_t seed = static_cast<uint32_t>(time(NULL)); 99 100 srand(seed); 101 102 SC_START(0); 103 LABEL("Initialisation"); 104 105 in_INSERT_VAL -> write(0); 106 in_RETIRE_ACK -> write(0); 107 108 LABEL("Reset"); 109 in_NRESET->write(0); 110 SC_START(5); 111 in_NRESET->write(1); 112 113 LABEL("Loop of Test"); 114 115 uint32_t data_in = 0; 116 uint32_t data_out = 0; 117 uint32_t nb_elt = 0; 118 119 for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++) 15 if (usage_is_set(_usage,USE_SYSTEMC)) 120 16 { 121 LABEL("Iteration %d",iteration); 122 123 while (data_out <= nb_request) 124 { 125 in_INSERT_VAL -> write((rand()%100)<percent_insert_transaction); 126 in_INSERT_DATA -> write(data_in); 127 in_RETIRE_ACK -> write((rand()%100)<percent_retire_transaction); 128 129 SC_START(0); // genMoore 130 131 for (uint32_t i=0; i<_param->_nb_port_slot; ++i) 17 msgInformation(_("<%s> : Start Simulation ............\n"),name.c_str()); 18 19 Time * _time = new Time(); 20 21 /******************************************************** 22 * Simulation - Begin 23 ********************************************************/ 24 25 // Initialisation 26 const int32_t percent_insert_transaction = 75; 27 const int32_t percent_retire_transaction = 75; 28 const uint32_t nb_request = 3*_param->_size_queue; 29 30 const uint32_t seed = 0; 31 //const uint32_t seed = static_cast<uint32_t>(time(NULL)); 32 33 srand(seed); 34 35 SC_CYCLE(0); 36 LABEL("Initialisation"); 37 38 in_INSERT_VAL -> write(0); 39 in_RETIRE_ACK -> write(0); 40 41 LABEL("Reset"); 42 in_NRESET->write(0); 43 SC_CYCLE(5); 44 in_NRESET->write(1); 45 46 LABEL("Loop of Test"); 47 48 uint32_t data_in = 0; 49 uint32_t data_out = 0; 50 uint32_t nb_elt = 0; 51 52 for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++) 53 { 54 LABEL("Iteration %d",iteration); 55 56 while (data_out <= nb_request) 132 57 { 133 TEST(Tcontrol_t, out_SLOT_VAL [i]->read(), (i<nb_elt)); 134 if (i<nb_elt) 135 TEST(Tdata_t , out_SLOT_DATA[i]->read(), data_out+i); 136 58 in_INSERT_VAL -> write((rand()%100)<percent_insert_transaction); 59 in_INSERT_DATA -> write(data_in); 60 in_RETIRE_ACK -> write((rand()%100)<percent_retire_transaction); 61 62 SC_CYCLE(0); // genMoore 63 64 for (uint32_t i=0; i<_param->_nb_port_slot; ++i) 65 { 66 TEST(Tcontrol_t, out_SLOT_VAL [i]->read(), (i<nb_elt)); 67 if (i<nb_elt) 68 TEST(Tdata_t , out_SLOT_DATA[i]->read(), data_out+i); 69 70 } 71 72 if ( in_INSERT_VAL->read() and out_INSERT_ACK->read()) 73 { 74 LABEL ("Transaction with interface : INSERT"); 75 data_in ++; 76 nb_elt ++; 77 } 78 if (out_RETIRE_VAL->read() and in_RETIRE_ACK->read()) 79 { 80 LABEL ("Transaction with interface : RETIRE"); 81 TEST(Tdata_t, out_RETIRE_DATA->read(), data_out); 82 data_out++; 83 nb_elt --; 84 } 85 86 SC_CYCLE(1); 137 87 } 138 139 if ( in_INSERT_VAL->read() and out_INSERT_ACK->read()) 140 { 141 LABEL ("Transaction with interface : INSERT"); 142 data_in ++; 143 nb_elt ++; 144 } 145 if (out_RETIRE_VAL->read() and in_RETIRE_ACK->read()) 146 { 147 LABEL ("Transaction with interface : RETIRE"); 148 TEST(Tdata_t, out_RETIRE_DATA->read(), data_out); 149 data_out++; 150 nb_elt --; 151 } 152 153 SC_START(1); 154 } 88 } 89 90 /******************************************************** 91 * Simulation - End 92 ********************************************************/ 93 94 TEST_OK (""); 95 96 sc_stop(); 97 delete _time; 98 99 msgInformation(_("<%s> : ............ Stop Simulation\n"),name.c_str()); 155 100 } 156 157 /********************************************************158 * Simulation - End159 ********************************************************/160 161 TEST_OK ("End of Simulation");162 delete _time;163 cout << "<" << name << "> ............ Stop Simulation" << endl;164 165 delete in_CLOCK;166 delete in_NRESET;167 168 DELETE0_SC_SIGNAL( in_INSERT_VAL );169 DELETE0_SC_SIGNAL(out_INSERT_ACK );170 DELETE0_SC_SIGNAL( in_INSERT_DATA);171 DELETE0_SC_SIGNAL(out_RETIRE_VAL );172 DELETE0_SC_SIGNAL( in_RETIRE_ACK );173 DELETE0_SC_SIGNAL(out_RETIRE_DATA);174 DELETE1_SC_SIGNAL(out_SLOT_VAL ,_param->_nb_port_slot);175 DELETE1_SC_SIGNAL(out_SLOT_DATA ,_param->_nb_port_slot);176 DELETE0_SC_SIGNAL(out_PTR_WRITE );177 DELETE0_SC_SIGNAL(out_PTR_READ );178 #endif179 180 delete _Queue;181 #ifdef STATISTICS182 delete _parameters_statistics;183 101 #endif 184 102 }
Note: See TracChangeset
for help on using the changeset viewer.