source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Counter/src/Counter.cpp

Last change on this file was 132, checked in by rosiere, 15 years ago

1) add constant method - compatibility with SystemC
2) add Script to test sensitive list
3) fix bug in sensitive list

  • Property svn:keywords set to Id
File size: 2.7 KB
Line 
1/*
2 * $Id: Counter.cpp 132 2009-07-11 16:39:35Z rosiere $
3 *
4 * [ Description ]
5 *
6 */
7
8#include "Behavioural/Generic/Counter/include/Counter.h"
9
10namespace morpheo                    {
11namespace behavioural {
12namespace generic {
13namespace counter {
14
15#undef FUNCTION
16#define FUNCTION "Counter::Counter"
17  Counter::Counter
18  (
19#ifdef SYSTEMC
20  sc_module_name name,
21#else
22  std::string name,
23#endif
24#ifdef STATISTICS
25  morpheo::behavioural::Parameters_Statistics * param_statistics,
26#endif
27  morpheo::behavioural::generic::counter::Parameters * param,
28   Tusage_t usage):
29    _name  (name),
30    _param (param),
31    _usage (usage)
32  {
33    log_begin(Counter,FUNCTION);
34
35// #if DEBUG_Counter == true
36//     log_printf(INFO,Counter,FUNCTION,_("<%s> Parameters"),_name.c_str());
37
38//     std::cout << *param << std::endl;
39// #endif   
40
41    log_printf(INFO,Core,FUNCTION,_("<%s> Allocation"),_name.c_str());
42    allocation ();
43
44#ifdef STATISTICS
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      }
52#endif
53
54#ifdef VHDL
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      }
62#endif
63
64#ifdef SYSTEMC
65
66    if (usage_is_set(_usage,USE_SYSTEMC))
67      {
68#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
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();
74#endif
75
76        log_printf(INFO,Core,FUNCTION,_("<%s> Method - genMealy"),_name.c_str());
77        SC_METHOD (genMealy);
78        dont_initialize ();
79        sensitive << (*(in_NRESET));
80        for (uint32_t i=0; i<_param->_nb_port; i++)
81          sensitive << *(in_COUNTER_DATA   [i])
82                    << *(in_COUNTER_ADDSUB [i]);
83       
84#ifdef SYSTEMCASS_SPECIFIC
85        // List dependency information
86        for (uint32_t i=0; i<_param->_nb_port; i++)
87          {
88            (*(out_COUNTER_DATA [i])) (*(in_COUNTER_DATA   [i]));
89            (*(out_COUNTER_DATA [i])) (*(in_COUNTER_ADDSUB [i]));
90          }
91#endif   
92      }
93
94#endif
95    log_end(Counter,FUNCTION);
96  };
97 
98#undef FUNCTION
99#define FUNCTION "Counter::~Counter"
100  Counter::~Counter (void)
101  {
102    log_begin(Counter,FUNCTION);
103
104#ifdef STATISTICS
105    if (usage_is_set(_usage,USE_STATISTICS))
106      {
107        delete _stat;
108      }
109#endif
110
111    log_printf(INFO,Core,FUNCTION,_("<%s> Deallocation"),_name.c_str());
112    deallocation ();
113
114    log_end(Counter,FUNCTION);
115  };
116
117}; // end namespace counter
118}; // end namespace generic
119
120}; // end namespace behavioural
121}; // end namespace morpheo             
Note: See TracBrowser for help on using the repository browser.