[2] | 1 | /* |
---|
| 2 | * $Id: Counter.cpp 113 2009-04-14 18:39:12Z rosiere $ |
---|
| 3 | * |
---|
| 4 | * [ Description ] |
---|
| 5 | * |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #include "Behavioural/Generic/Counter/include/Counter.h" |
---|
| 9 | |
---|
| 10 | namespace morpheo { |
---|
| 11 | namespace behavioural { |
---|
| 12 | namespace generic { |
---|
| 13 | namespace counter { |
---|
| 14 | |
---|
[113] | 15 | #undef FUNCTION |
---|
| 16 | #define FUNCTION "Counter::Counter" |
---|
[82] | 17 | Counter::Counter |
---|
| 18 | ( |
---|
[2] | 19 | #ifdef SYSTEMC |
---|
[82] | 20 | sc_module_name name, |
---|
[2] | 21 | #else |
---|
[82] | 22 | std::string name, |
---|
[2] | 23 | #endif |
---|
| 24 | #ifdef STATISTICS |
---|
[82] | 25 | morpheo::behavioural::Parameters_Statistics * param_statistics, |
---|
[2] | 26 | #endif |
---|
[113] | 27 | morpheo::behavioural::generic::counter::Parameters * param, |
---|
[82] | 28 | Tusage_t usage): |
---|
| 29 | _name (name), |
---|
| 30 | _param (param), |
---|
| 31 | _usage (usage) |
---|
[2] | 32 | { |
---|
[113] | 33 | log_begin(Counter,FUNCTION); |
---|
[2] | 34 | |
---|
[113] | 35 | // #if DEBUG_Counter == true |
---|
| 36 | // log_printf(INFO,Counter,FUNCTION,_("<%s> Parameters"),_name.c_str()); |
---|
[88] | 37 | |
---|
[113] | 38 | // std::cout << *param << std::endl; |
---|
| 39 | // #endif |
---|
[88] | 40 | |
---|
| 41 | log_printf(INFO,Core,FUNCTION,_("<%s> Allocation"),_name.c_str()); |
---|
[42] | 42 | allocation (); |
---|
| 43 | |
---|
[2] | 44 | #ifdef STATISTICS |
---|
[88] | 45 | if (usage_is_set(_usage,USE_STATISTICS)) |
---|
| 46 | { |
---|
| 47 | log_printf(INFO,Core,FUNCTION,_("<%s> Allocation of statistics"),_name.c_str()); |
---|
| 48 | |
---|
| 49 | // Allocation of statistics |
---|
| 50 | statistics_declaration(param_statistics); |
---|
| 51 | } |
---|
[2] | 52 | #endif |
---|
| 53 | |
---|
| 54 | #ifdef VHDL |
---|
[88] | 55 | if (usage_is_set(_usage,USE_VHDL)) |
---|
| 56 | { |
---|
| 57 | // generate the vhdl |
---|
| 58 | log_printf(INFO,Core,FUNCTION,_("<%s> Generate the vhdl"),_name.c_str()); |
---|
| 59 | |
---|
| 60 | vhdl(); |
---|
| 61 | } |
---|
[2] | 62 | #endif |
---|
| 63 | |
---|
| 64 | #ifdef SYSTEMC |
---|
[53] | 65 | |
---|
[88] | 66 | if (usage_is_set(_usage,USE_SYSTEMC)) |
---|
| 67 | { |
---|
[53] | 68 | #if defined(STATISTICS) or defined(VHDL_TESTBENCH) |
---|
[88] | 69 | log_printf(INFO,Core,FUNCTION,_("<%s> Method - transition"),_name.c_str()); |
---|
| 70 | |
---|
| 71 | SC_METHOD (transition); |
---|
| 72 | dont_initialize (); |
---|
| 73 | sensitive << (*(in_CLOCK)).pos(); |
---|
[53] | 74 | #endif |
---|
[2] | 75 | |
---|
[88] | 76 | log_printf(INFO,Core,FUNCTION,_("<%s> Method - genMealy"),_name.c_str()); |
---|
| 77 | SC_METHOD (genMealy); |
---|
| 78 | dont_initialize (); |
---|
[113] | 79 | for (uint32_t i=0; i<_param->_nb_port; i++) |
---|
[88] | 80 | sensitive << *(in_COUNTER_DATA [i]) |
---|
| 81 | << *(in_COUNTER_ADDSUB [i]); |
---|
| 82 | |
---|
[2] | 83 | #ifdef SYSTEMCASS_SPECIFIC |
---|
[88] | 84 | // List dependency information |
---|
[113] | 85 | for (uint32_t i=0; i<_param->_nb_port; i++) |
---|
[88] | 86 | { |
---|
| 87 | (*(out_COUNTER_DATA [i])) (*(in_COUNTER_DATA [i])); |
---|
| 88 | (*(out_COUNTER_DATA [i])) (*(in_COUNTER_ADDSUB [i])); |
---|
| 89 | } |
---|
| 90 | #endif |
---|
[2] | 91 | } |
---|
| 92 | |
---|
| 93 | #endif |
---|
[113] | 94 | log_end(Counter,FUNCTION); |
---|
[2] | 95 | }; |
---|
| 96 | |
---|
[113] | 97 | #undef FUNCTION |
---|
| 98 | #define FUNCTION "Counter::~Counter" |
---|
[2] | 99 | Counter::~Counter (void) |
---|
| 100 | { |
---|
[113] | 101 | log_begin(Counter,FUNCTION); |
---|
[2] | 102 | |
---|
| 103 | #ifdef STATISTICS |
---|
[88] | 104 | if (usage_is_set(_usage,USE_STATISTICS)) |
---|
| 105 | { |
---|
| 106 | delete _stat; |
---|
| 107 | } |
---|
[2] | 108 | #endif |
---|
[88] | 109 | |
---|
| 110 | log_printf(INFO,Core,FUNCTION,_("<%s> Deallocation"),_name.c_str()); |
---|
| 111 | deallocation (); |
---|
| 112 | |
---|
[113] | 113 | log_end(Counter,FUNCTION); |
---|
[2] | 114 | }; |
---|
| 115 | |
---|
| 116 | }; // end namespace counter |
---|
| 117 | }; // end namespace generic |
---|
| 118 | |
---|
| 119 | }; // end namespace behavioural |
---|
| 120 | }; // end namespace morpheo |
---|