- Timestamp:
- Apr 14, 2009, 8:39:12 PM (15 years ago)
- Location:
- trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Queue/SelfTest/src
- Files:
-
- 4 added
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Queue/SelfTest/src/main.cpp
r101 r113 2 2 * $Id$ 3 3 * 4 * [ 4 * [ Description ] 5 5 * 6 6 */ 7 7 8 #include "Behavioural/Generic/Queue/SelfTest/include/t est.h"8 #include "Behavioural/Generic/Queue/SelfTest/include/top.h" 9 9 10 #define NB_PARAMS 5 10 #ifndef MTI_SYSTEMC 11 # ifndef SYSTEMC 12 int main (int argc, char * argv[]) 13 # else 14 int sc_main (int argc, char * argv[]) 15 # endif 16 { 17 int _return = EXIT_SUCCESS; 11 18 12 void usage (int argc, char * argv[])13 {14 cerr << "<Usage> " << argv[0] << " name_instance list_params" << endl15 << "list_params is :" << endl16 << " - size_queue (uint32_t)" << endl17 << " - size_data (uint32_t)" << endl18 << " - nb_port_slot (uint32_t)" << endl19 << " - have_port_write (bool )" << endl20 << " - have_port_read (bool )" << endl21 << "" << endl;22 23 for (int i=0; i<argc; i++)24 cerr << argv[i] << " ";25 cerr << endl;26 27 exit (1);28 }29 30 #ifndef SYSTEMC31 int main (int argc, char * argv[])32 #else33 int sc_main (int argc, char * argv[])34 #endif35 {36 if (argc != 2+NB_PARAMS)37 usage (argc, argv);38 39 uint32_t x = 1;40 41 const string name = argv[x++];42 const uint32_t size_queue = fromString<uint32_t>(argv[x++]);43 const uint32_t size_data = fromString<uint32_t>(argv[x++]);44 const uint32_t nb_port_slot = fromString<uint32_t>(argv[x++]);45 const bool have_port_write = fromString<bool>(argv[x++]);46 const bool have_port_read = fromString<bool>(argv[x++]);47 19 try 48 20 { 49 morpheo::behavioural::generic::queue::Parameters * param = new morpheo::behavioural::generic::queue::Parameters 50 (size_queue, 51 size_data , 52 nb_port_slot, 53 have_port_write, 54 have_port_read 55 ); 56 57 cout << param->print(1); 58 59 test (name,param); 21 top * my_top = new top ("my_top",argc,argv); 22 23 my_top->test(); 24 25 delete my_top; 60 26 } 61 27 catch (morpheo::ErrorMorpheo & error) 62 28 { 63 cout << "<" << name << "> : " << error.what ();64 exit (EXIT_FAILURE);29 msgError(_("%s\n"),error.what ()); 30 _return = EXIT_FAILURE; 65 31 } 66 catch (...) 32 33 try 67 34 { 68 cerr << "<" << name << "> : This test must generate a error" << endl; 69 exit (EXIT_FAILURE); 35 if (_return == EXIT_SUCCESS) 36 TEST_OK("Queue : no error"); 37 else 38 TEST_KO("Queue : a lot of error"); 39 } 40 catch (morpheo::ErrorMorpheo & error) 41 { 42 // msgError(_("<%s> :\n%s"),name.c_str(), error.what ()); 43 _return = EXIT_FAILURE; 70 44 } 71 45 72 return (EXIT_SUCCESS);46 return _return; 73 47 } 74 48 #endif -
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.