/* * $Id: test.cpp 88 2008-12-10 18:31:39Z rosiere $ * * [ Description ] * * Test */ #define NB_ITERATION 1 #define CYCLE_MAX (128*NB_ITERATION) #include "Behavioural/Generic/Victim/Victim_Pseudo_LRU/SelfTest/include/test.h" #include "Common/include/Test.h" void test (string name, morpheo::behavioural::generic::victim::victim_pseudo_lru::Parameters param) { cout << "<" << name << "> : Simulation SystemC" << endl; try { cout << param.print(1); param.test(); } catch (morpheo::ErrorMorpheo & error) { cout << "<" << name << "> : " << error.what (); return; } catch (...) { cerr << "<" << name << "> : This test must generate a error" << endl; exit (EXIT_FAILURE); } #ifdef STATISTICS morpheo::behavioural::Parameters_Statistics * param_stat = new morpheo::behavioural::Parameters_Statistics(5,50); #endif Tusage_t _usage = USE_ALL; // _usage = usage_unset(_usage,USE_SYSTEMC ); // _usage = usage_unset(_usage,USE_VHDL ); // _usage = usage_unset(_usage,USE_VHDL_TESTBENCH ); // _usage = usage_unset(_usage,USE_VHDL_TESTBENCH_ASSERT); // _usage = usage_unset(_usage,USE_POSITION ); // _usage = usage_unset(_usage,USE_STATISTICS ); // _usage = usage_unset(_usage,USE_INFORMATION ); Victim_Pseudo_LRU * _Victim_Pseudo_LRU = new Victim_Pseudo_LRU (name.c_str(), #ifdef STATISTICS param_stat, #endif ¶m, _usage); #ifdef SYSTEMC /********************************************************************* * Déclarations des signaux *********************************************************************/ sc_clock CLOCK ("clock", 1.0, 0.5); sc_signal NRESET ("NRESET"); sc_signal ACCESS_VAL [param._nb_access]; sc_signal ACCESS_ACK [param._nb_access]; sc_signal ACCESS_ADDRESS [param._nb_access]; sc_signal ACCESS_HIT [param._nb_access]; sc_signal ACCESS_ENTITY [param._nb_access]; sc_signal ACCESS_VICTIM [param._nb_access]; /******************************************************** * Instanciation ********************************************************/ cout << "<" << name << "> Instanciation of _Victim_Pseudo_LRU" << endl; (*(_Victim_Pseudo_LRU->in_CLOCK)) (CLOCK); (*(_Victim_Pseudo_LRU->in_NRESET)) (NRESET); for (uint32_t i=0; i in_ACCESS_VAL [i])) (ACCESS_VAL [i]); (*(_Victim_Pseudo_LRU->out_ACCESS_ACK [i])) (ACCESS_ACK [i]); if (param._size_address>1) (*(_Victim_Pseudo_LRU-> in_ACCESS_ADDRESS [i])) (ACCESS_ADDRESS [i]); (*(_Victim_Pseudo_LRU-> in_ACCESS_HIT [i])) (ACCESS_HIT [i]); (*(_Victim_Pseudo_LRU-> in_ACCESS_ENTITY [i])) (ACCESS_ENTITY [i]); (*(_Victim_Pseudo_LRU->out_ACCESS_VICTIM [i])) (ACCESS_VICTIM [i]); } /******************************************************** * Simulation - Begin ********************************************************/ cout << "<" << name << "> Start Simulation ............" << endl; // Initialisation sc_start(0); bool array [param._nb_access][param._nb_entity]; for (uint32_t i=0; i(sc_simulation_time()) << endl; for (uint32_t i=0; i((j+i)1) addr = static_cast((j+i)%param._size_table); else addr = 0; Tentity_t entity = (k+1)%param._nb_entity; ACCESS_VAL [i].write(val ); if (param._size_address>1) ACCESS_ADDRESS [i].write(addr); ACCESS_ENTITY [i].write(entity); sc_start(0); cout << "\t[" << i << "] " << val << " - " << ACCESS_ACK[i].read() << " addr : " << addr << " -> " << entity << endl; } sc_start(1); } for (uint32_t i=0; i(array),0,param._nb_access*param._nb_entity*sizeof(bool)); for (uint32_t k=0; k(sc_simulation_time()) << endl; for (uint32_t i=0; i((j+i)1) addr = static_cast((j+i)%param._size_table); else addr = 0; ACCESS_VAL [i].write(val ); if (param._size_address>1) ACCESS_ADDRESS [i].write(addr); sc_start(0); Tentity_t entity = ACCESS_VICTIM [i].read(); cout << "\t[" << i << "] " << val << " - " << ACCESS_ACK[i].read() << " addr : " << addr << " -> " << entity << endl; TEST(bool,false,((val == true) && (array[i][entity] == true))); // if ((val == true) && (array[i][entity] == true)) // { // cout << "Test KO : Have already give this way" << endl; // exit (1); // } // else array[i][entity] = true; } sc_start(1); } } for (uint32_t i=0; i ............ Stop Simulation" << endl; #endif delete _Victim_Pseudo_LRU; #ifdef STATISTICS delete param_stat; #endif }