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