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 | |
---|
16 | Counter::Counter |
---|
17 | ( |
---|
18 | #ifdef SYSTEMC |
---|
19 | sc_module_name name, |
---|
20 | #else |
---|
21 | std::string name, |
---|
22 | #endif |
---|
23 | #ifdef STATISTICS |
---|
24 | morpheo::behavioural::Parameters_Statistics * param_statistics, |
---|
25 | #endif |
---|
26 | morpheo::behavioural::generic::counter::Parameters param, |
---|
27 | Tusage_t usage): |
---|
28 | _name (name), |
---|
29 | _param (param), |
---|
30 | _usage (usage) |
---|
31 | { |
---|
32 | log_printf(FUNC,Counter,"Counter","Begin"); |
---|
33 | |
---|
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()); |
---|
41 | allocation (); |
---|
42 | |
---|
43 | #ifdef STATISTICS |
---|
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 | } |
---|
51 | #endif |
---|
52 | |
---|
53 | #ifdef VHDL |
---|
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 | } |
---|
61 | #endif |
---|
62 | |
---|
63 | #ifdef SYSTEMC |
---|
64 | |
---|
65 | if (usage_is_set(_usage,USE_SYSTEMC)) |
---|
66 | { |
---|
67 | #if defined(STATISTICS) or defined(VHDL_TESTBENCH) |
---|
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(); |
---|
73 | #endif |
---|
74 | |
---|
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 | |
---|
82 | #ifdef SYSTEMCASS_SPECIFIC |
---|
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 |
---|
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 |
---|
101 | if (usage_is_set(_usage,USE_STATISTICS)) |
---|
102 | { |
---|
103 | delete _stat; |
---|
104 | } |
---|
105 | #endif |
---|
106 | |
---|
107 | log_printf(INFO,Core,FUNCTION,_("<%s> Deallocation"),_name.c_str()); |
---|
108 | deallocation (); |
---|
109 | |
---|
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 |
---|