- Timestamp:
- Apr 14, 2009, 8:39:12 PM (15 years ago)
- Location:
- trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Counter
- Files:
-
- 4 added
- 11 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Counter/Makefile.defs
r81 r113 2 2 # $Id$ 3 3 # 4 # [ 4 # [ Description ] 5 5 # 6 6 # Makefile 7 7 # 8 8 9 #-----[ Directory ]---------------------------------------- 9 ENTITY = Counter 10 11 #-----[ Directory ]---------------------------------------- 10 12 DIR_COMPONENT_MORPHEO = ../../.. 11 13 DIR_MORPHEO = $(DIR_COMPONENT)/$(DIR_COMPONENT_MORPHEO) -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Counter/SelfTest/include/top.h
r112 r113 2 2 * $Id$ 3 3 * 4 * [ 4 * [ Description ] 5 5 * 6 * Test " RegisterFile"6 * Test "Counter" 7 7 */ 8 8 … … 11 11 #endif 12 12 13 # include <string>14 # include <iostream>13 #define NB_ITERATION 1024 14 #define CYCLE_MAX (1024*NB_ITERATION) 15 15 16 #include "Common/include/Test.h" 16 17 #include "Common/include/Time.h" 17 18 #include "Behavioural/Generic/Counter/include/Counter.h" … … 21 22 using namespace morpheo::behavioural; 22 23 using namespace morpheo::behavioural::generic; 23 24 24 using namespace morpheo::behavioural::generic::counter; 25 25 26 void test (string name, 27 morpheo::behavioural::generic::counter::Parameters param); 26 SC_MODULE(top) 27 { 28 #ifdef SYSTEMC 29 private: sc_clock * in_CLOCK ; 30 private: sc_signal<Tcontrol_t> * in_NRESET; 31 private: sc_signal<Tdata_t> ** in_COUNTER_DATA ;// [param->_nb_port] 32 private: sc_signal<Tcontrol_t> ** in_COUNTER_ADDSUB;// [param->_nb_port] 33 private: sc_signal<Tdata_t> ** out_COUNTER_DATA ;// [param->_nb_port] 34 #endif 35 36 private: std::string name ; 37 private: morpheo::behavioural::generic::counter::Parameters * param; 38 #ifdef STATISTICS 39 private: morpheo::behavioural::Parameters_Statistics * param_stat; 40 #endif 41 private: Counter * component; 42 43 private: void usage (string exec); 44 private: void allocation (void); 45 private: void deallocation (void); 46 public : void test (void); 47 48 #ifdef MTI_SYSTEMC 49 SC_CTOR(top::top); 50 #else 51 public : top (sc_module_name module_name,int argc, char * argv[]); 52 #endif 53 public : ~top(void); 54 }; -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Counter/SelfTest/src/main.cpp
r81 r113 2 2 * $Id$ 3 3 * 4 * [ 4 * [ Description ] 5 5 * 6 6 */ 7 7 8 #include "Behavioural/Generic/Counter/SelfTest/include/t est.h"8 #include "Behavioural/Generic/Counter/SelfTest/include/top.h" 9 9 10 #define NB_PARAMS 2 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 (string exec) 13 { 14 cerr << "<Usage> " << exec << " name_instance list_params" << endl 15 << "list_params is :" << endl 16 << " - size_data (unsigned int)" << endl 17 << " - nb_port (unsigned int)" << endl; 19 try 20 { 21 top * my_top = new top ("my_top",argc,argv); 18 22 19 exit (1); 23 my_top->test(); 24 25 delete my_top; 26 } 27 catch (morpheo::ErrorMorpheo & error) 28 { 29 msg (_("%s\n"),error.what ()); 30 _return = EXIT_FAILURE; 31 } 32 33 try 34 { 35 if (_return == EXIT_SUCCESS) 36 TEST_OK("Counter : no error"); 37 else 38 TEST_KO("Counter : a lot of error"); 39 } 40 catch (morpheo::ErrorMorpheo & error) 41 { 42 // msg (_("<%s> :\n%s"),name.c_str(), error.what ()); 43 _return = EXIT_FAILURE; 44 } 45 46 return _return; 20 47 } 21 22 #ifndef SYSTEMC23 int main (int argc, char * argv[])24 #else25 int sc_main (int argc, char * argv[])26 48 #endif 27 {28 if (argc != 2+NB_PARAMS)29 usage (argv[0]);30 31 cout << "<test0> : Classic usage" << endl;32 cout << "<test0> : Typical parameters" << endl;33 const string name = argv[1];34 const uint32_t size_data = atoi(argv[2]);35 const uint32_t nb_port = atoi(argv[3]);36 37 morpheo::behavioural::generic::counter::Parameters param (size_data,38 nb_port );39 40 test (name,param);41 42 return (EXIT_SUCCESS);43 }44 -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Counter/SelfTest/src/top_test.cpp
r112 r113 7 7 */ 8 8 9 #define NB_ITERATION 1024 10 #define CYCLE_MAX 1024*NB_ITERATION 9 #include "Behavioural/Generic/Counter/SelfTest/include/top.h" 11 10 12 #include "Behavioural/Generic/Counter/SelfTest/include/test.h" 13 #include "Common/include/Test.h" 14 15 void test (string name, 16 morpheo::behavioural::generic::counter::Parameters param) 11 void top::test (void) 17 12 { 18 cout << "<" << name << "> : Simulation SystemC" << endl;19 20 try21 {22 cout << param.print(1);23 param.test();24 }25 catch (morpheo::ErrorMorpheo & error)26 {27 cout << "<" << name << "> : " << error.what ();28 return;29 }30 catch (...)31 {32 cerr << "<" << name << "> : This test must generate a error" << endl;33 exit (EXIT_FAILURE);34 }35 #ifdef STATISTICS36 morpheo::behavioural::Parameters_Statistics * param_stat = new morpheo::behavioural::Parameters_Statistics (5,50);37 #endif38 39 Tusage_t _usage = USE_ALL;40 41 // _usage = usage_unset(_usage,USE_SYSTEMC );42 // _usage = usage_unset(_usage,USE_VHDL );43 // _usage = usage_unset(_usage,USE_VHDL_TESTBENCH );44 // _usage = usage_unset(_usage,USE_VHDL_TESTBENCH_ASSERT);45 // _usage = usage_unset(_usage,USE_POSITION );46 // _usage = usage_unset(_usage,USE_STATISTICS );47 // _usage = usage_unset(_usage,USE_INFORMATION );48 49 Counter * _Counter = new Counter (name.c_str(),50 #ifdef STATISTICS51 param_stat,52 #endif53 param,54 _usage);55 56 13 #ifdef SYSTEMC 57 /*********************************************************************58 * Déclarations des signaux59 *********************************************************************/60 sc_clock CLOCK ("clock", 1.0, 0.5);61 sc_signal<Tcontrol_t> RESET;62 sc_signal<Tdata_t> DATA_IN [param._nb_port];63 sc_signal<Tcontrol_t> ADDSUB [param._nb_port];64 sc_signal<Tdata_t> DATA_OUT [param._nb_port];65 66 /********************************************************67 * Instanciation68 ********************************************************/69 70 cout << "<" << name << "> Instanciation of _Counter" << endl;71 72 (*(_Counter->in_CLOCK)) (CLOCK);73 (*(_Counter->in_NRESET)) (RESET);74 75 for (uint32_t i=0; i<param._nb_port; i++)76 {77 (*(_Counter-> in_COUNTER_DATA [i])) (DATA_IN [i]);78 (*(_Counter-> in_COUNTER_ADDSUB[i])) (ADDSUB [i]);79 (*(_Counter->out_COUNTER_DATA [i])) (DATA_OUT [i]);80 }81 82 14 Time * _time = new Time(); 83 15 … … 92 24 //srand(TIME(NULL)); 93 25 94 Tdata_t data_in [param ._nb_port];95 Tdata_t data_out [param ._nb_port];96 Tcontrol_t addsub [param ._nb_port];26 Tdata_t data_in [param->_nb_port]; 27 Tdata_t data_out [param->_nb_port]; 28 Tcontrol_t addsub [param->_nb_port]; 97 29 98 sc_start(0);30 SC_CYCLE(0); 99 31 100 RESET.write(1);32 in_NRESET->write(1); 101 33 102 cout << "{"+toString(static_cast<uint32_t>(sc_simulation_time()))+"} Initialisation" << endl;34 LABEL("Initialisation"); 103 35 104 cout << "{"+toString(static_cast<uint32_t>(sc_simulation_time()))+"} Loop of Test" << endl;36 LABEL("Loop of Test"); 105 37 106 38 for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++) 107 39 { 108 cout << "{" << static_cast<uint32_t>(sc_simulation_time()) << "} Itération " << iteration << endl; 109 for (uint32_t i=0; i<param._nb_port; i++) 40 LABEL("Iteration %d",iteration); 41 42 for (uint32_t i=0; i<param->_nb_port; i++) 110 43 { 111 Tdata_t data = rand()%param ._data_max;44 Tdata_t data = rand()%param->_data_max; 112 45 data_in [i] = data; 113 46 addsub [i] = (rand()%2)==1; 114 47 115 DATA_IN [i].write(data );116 ADDSUB [i].write(addsub [i]);48 LABEL("in_COUNTER_DATA [%d] = %d",i,data ); 49 LABEL("in_COUNTER_ADDSUB [%d] = %d" ,i,addsub [i]); 117 50 118 data_out [i] = (addsub[i]==1)?((data<param._data_max)?data+1:data):((data>0)?data-1:data); 51 in_COUNTER_DATA [i]->write(data ); 52 in_COUNTER_ADDSUB [i]->write(addsub [i]); 53 54 data_out [i] = (addsub[i]==1)?((data<param->_data_max)?data+1:data):((data>0)?data-1:data); 119 55 } 120 56 121 sc_start(0);122 123 for (uint32_t i=0; i<param ._nb_port; i++)57 SC_CYCLE(0); 58 59 for (uint32_t i=0; i<param->_nb_port; i++) 124 60 { 125 cout << hex 126 << " [" << i << "] " 127 << data_in [i]; 61 string op = (addsub[i] == 1)?"++":"--"; 62 LABEL("0x%d %s = 0x%d",i,op.c_str(),out_COUNTER_DATA [i]->read()); 128 63 129 if (addsub[i] == 1) 130 cout << " ++"; 131 else 132 cout << " --"; 133 134 cout << " = " 135 << DATA_OUT [i].read(); 136 137 TEST(Tdata_t,DATA_OUT [i].read(),data_out [i]); 138 139 cout << std::dec << endl; 64 TEST(Tdata_t,out_COUNTER_DATA [i]->read(),data_out [i]); 140 65 } 141 66 142 sc_start(1);67 SC_CYCLE(1); 143 68 } 144 69 145 sc_start(1);70 SC_CYCLE(1); 146 71 147 72 /******************************************************** … … 149 74 ********************************************************/ 150 75 76 sc_stop(); 77 151 78 delete _time; 152 79 153 80 cout << "<" << name << "> ............ Stop Simulation" << endl; 154 155 81 #endif 156 157 delete _Counter;158 #ifdef STATISTICS159 delete param_stat;160 #endif161 162 82 } -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Counter/include/Counter.h
r88 r113 40 40 // -----[ fields ]---------------------------------------------------- 41 41 // Parameters 42 protected : const std::string _name;43 protected : const Parameters _param;44 private : const Tusage_t _usage;42 protected : const std::string _name; 43 protected : const Parameters * _param; 44 private : const Tusage_t _usage; 45 45 46 46 #ifdef STATISTICS … … 79 79 morpheo::behavioural::Parameters_Statistics * param_statistics, 80 80 #endif 81 Parameters param,82 Tusage_t usage);81 Parameters * param, 82 Tusage_t usage); 83 83 84 84 // public : Counter (Parameters param ); 85 85 public : ~Counter (void); 86 86 -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Counter/src/Counter.cpp
r88 r113 13 13 namespace counter { 14 14 15 15 #undef FUNCTION 16 #define FUNCTION "Counter::Counter" 16 17 Counter::Counter 17 18 ( … … 24 25 morpheo::behavioural::Parameters_Statistics * param_statistics, 25 26 #endif 26 morpheo::behavioural::generic::counter::Parameters param,27 morpheo::behavioural::generic::counter::Parameters * param, 27 28 Tusage_t usage): 28 29 _name (name), … … 30 31 _usage (usage) 31 32 { 32 log_ printf(FUNC,Counter,"Counter","Begin");33 log_begin(Counter,FUNCTION); 33 34 34 #if DEBUG_Counter == true35 log_printf(INFO,Counter,FUNCTION,_("<%s> Parameters"),_name.c_str());35 // #if DEBUG_Counter == true 36 // log_printf(INFO,Counter,FUNCTION,_("<%s> Parameters"),_name.c_str()); 36 37 37 std::cout <<param << std::endl;38 #endif38 // std::cout << *param << std::endl; 39 // #endif 39 40 40 41 log_printf(INFO,Core,FUNCTION,_("<%s> Allocation"),_name.c_str()); … … 76 77 SC_METHOD (genMealy); 77 78 dont_initialize (); 78 for (uint32_t i=0; i<_param ._nb_port; i++)79 for (uint32_t i=0; i<_param->_nb_port; i++) 79 80 sensitive << *(in_COUNTER_DATA [i]) 80 81 << *(in_COUNTER_ADDSUB [i]); … … 82 83 #ifdef SYSTEMCASS_SPECIFIC 83 84 // List dependency information 84 for (uint32_t i=0; i<_param ._nb_port; i++)85 for (uint32_t i=0; i<_param->_nb_port; i++) 85 86 { 86 87 (*(out_COUNTER_DATA [i])) (*(in_COUNTER_DATA [i])); … … 91 92 92 93 #endif 93 log_ printf(FUNC,Counter,"Counter","End");94 log_end(Counter,FUNCTION); 94 95 }; 95 96 97 #undef FUNCTION 98 #define FUNCTION "Counter::~Counter" 96 99 Counter::~Counter (void) 97 100 { 98 log_ printf(FUNC,Counter,"~Counter","Begin");101 log_begin(Counter,FUNCTION); 99 102 100 103 #ifdef STATISTICS … … 108 111 deallocation (); 109 112 110 log_ printf(FUNC,Counter,"~Counter","End");113 log_end(Counter,FUNCTION); 111 114 }; 112 115 -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Counter/src/Counter_allocation.cpp
r112 r113 21 21 22 22 Entity * entity = _component->set_entity (_name 23 , "Counter"23 ,_param->_type 24 24 #ifdef POSITION 25 25 ,COMBINATORY … … 45 45 // ~~~~~[ Interface : "counter" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 46 46 { 47 ALLOC1_INTERFACE_BEGIN("counter", IN, SOUTH, _("Counter interface"), _param ._nb_port);47 ALLOC1_INTERFACE_BEGIN("counter", IN, SOUTH, _("Counter interface"), _param->_nb_port); 48 48 49 ALLOC1_SIGNAL_IN ( in_COUNTER_DATA ,"data" ,Tdata_t ,_param ._size_data);49 ALLOC1_SIGNAL_IN ( in_COUNTER_DATA ,"data" ,Tdata_t ,_param->_size_data); 50 50 ALLOC1_SIGNAL_IN ( in_COUNTER_ADDSUB,"addsub",Tcontrol_t,1 ); 51 ALLOC1_SIGNAL_OUT(out_COUNTER_DATA ,"data" ,Tdata_t ,_param ._size_data);51 ALLOC1_SIGNAL_OUT(out_COUNTER_DATA ,"data" ,Tdata_t ,_param->_size_data); 52 52 53 ALLOC1_INTERFACE_END(_param ._nb_port);53 ALLOC1_INTERFACE_END(_param->_nb_port); 54 54 } 55 55 -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Counter/src/Counter_deallocation.cpp
r112 r113 24 24 delete in_NRESET; 25 25 26 DELETE1_SIGNAL( in_COUNTER_DATA , _param ._nb_port,_param._size_data);27 DELETE1_SIGNAL( in_COUNTER_ADDSUB, _param ._nb_port,1 );28 DELETE1_SIGNAL(out_COUNTER_DATA , _param ._nb_port,_param._size_data);26 DELETE1_SIGNAL( in_COUNTER_DATA , _param->_nb_port,_param->_size_data); 27 DELETE1_SIGNAL( in_COUNTER_ADDSUB, _param->_nb_port,1 ); 28 DELETE1_SIGNAL(out_COUNTER_DATA , _param->_nb_port,_param->_size_data); 29 29 } 30 30 -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Counter/src/Counter_genMealy.cpp
r81 r113 18 18 log_printf(FUNC,Counter,"genMealy","Begin"); 19 19 20 for (uint32_t i=0; i<_param ._nb_port; i++)20 for (uint32_t i=0; i<_param->_nb_port; i++) 21 21 { 22 22 Tcontrol_t addsub = PORT_READ(in_COUNTER_ADDSUB [i]); … … 28 28 if (addsub == 1) 29 29 { 30 if (data_out < _param ._data_max)30 if (data_out < _param->_data_max) 31 31 data_out++; 32 32 } -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Counter/src/Counter_statistics_declaration.cpp
r81 r113 21 21 22 22 _stat = new Stat (static_cast<std::string>(_name), 23 "Counter",23 _param->_type, 24 24 param_statistics); 25 25 -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Counter/src/Counter_vhdl_body.cpp
r81 r113 19 19 vhdl->set_body (""); 20 20 21 for (uint32_t i=0; i<_param ._nb_port; i++)21 for (uint32_t i=0; i<_param->_nb_port; i++) 22 22 { 23 23 std::string counter_inc, counter_dec; 24 24 25 if (_param ._size_data > 1)25 if (_param->_size_data > 1) 26 26 { 27 27 counter_inc = "in_COUNTER_"+toString(i)+"_DATA+1"; … … 35 35 36 36 vhdl->set_body ("out_COUNTER_"+toString(i)+"_DATA <="); 37 if (_param ._size_data > 1)37 if (_param->_size_data > 1) 38 38 { 39 39 vhdl->set_body ("\tin_COUNTER_"+toString(i)+"_DATA+1 when in_COUNTER_"+toString(i)+"_ADDSUB = '1' and in_COUNTER_"+toString(i)+"_DATA < cst_max else"); -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Counter/src/Counter_vhdl_declaration.cpp
r81 r113 19 19 log_printf(FUNC,Counter,"vhdl_declaration","Begin"); 20 20 21 if (_param ._size_data > 1)21 if (_param->_size_data > 1) 22 22 { 23 vhdl->set_constant ("cst_min",_param ._size_data,std_logic_others(_param._size_data,0));24 vhdl->set_constant ("cst_max",_param ._size_data,std_logic_others(_param._size_data,1));23 vhdl->set_constant ("cst_min",_param->_size_data,std_logic_others(_param->_size_data,0)); 24 vhdl->set_constant ("cst_max",_param->_size_data,std_logic_others(_param->_size_data,1)); 25 25 } 26 26 -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Counter/src/Parameters.cpp
r88 r113 16 16 Parameters::Parameters (uint32_t size_data, 17 17 uint32_t nb_port ): 18 behavioural::Parameters("Counter"), 18 19 _size_data(size_data), 19 20 _nb_port (nb_port ),
Note: See TracChangeset
for help on using the changeset viewer.