1 | /* |
---|
2 | * $Id: Shifter.cpp 88 2008-12-10 18:31:39Z rosiere $ |
---|
3 | * |
---|
4 | * [ Description ] |
---|
5 | * |
---|
6 | */ |
---|
7 | |
---|
8 | #include "Behavioural/Generic/Shifter/include/Shifter.h" |
---|
9 | |
---|
10 | namespace morpheo { |
---|
11 | namespace behavioural { |
---|
12 | namespace generic { |
---|
13 | namespace shifter { |
---|
14 | |
---|
15 | |
---|
16 | #undef FUNCTION |
---|
17 | #define FUNCTION "Shifter::Shifter" |
---|
18 | Shifter::Shifter ( |
---|
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::shifter::Parameters *param |
---|
28 | ,morpheo::behavioural::Tusage_t usage ): |
---|
29 | _name (name) |
---|
30 | ,_param (param) |
---|
31 | ,_usage (usage) |
---|
32 | { |
---|
33 | |
---|
34 | #if DEBUG_Shifter == true |
---|
35 | log_printf(INFO,Shifter,FUNCTION,_("<%s> Parameters"),_name.c_str()); |
---|
36 | |
---|
37 | std::cout << *param << std::endl; |
---|
38 | #endif |
---|
39 | |
---|
40 | allocation (); |
---|
41 | |
---|
42 | #ifdef STATISTICS |
---|
43 | if (usage_is_set(_usage,USE_STATISTICS)) |
---|
44 | { |
---|
45 | // Allocation of statistics |
---|
46 | statistics_declaration(param_statistics); |
---|
47 | } |
---|
48 | #endif |
---|
49 | |
---|
50 | #ifdef VHDL |
---|
51 | if (usage_is_set(_usage,USE_VHDL)) |
---|
52 | { |
---|
53 | // generate the vhdl |
---|
54 | vhdl(); |
---|
55 | } |
---|
56 | #endif |
---|
57 | |
---|
58 | #ifdef SYSTEMC |
---|
59 | if (usage_is_set(_usage,USE_SYSTEMC)) |
---|
60 | { |
---|
61 | #if (defined(STATISTICS) || defined (VHDL_TESTBENCH)) |
---|
62 | SC_METHOD (transition); |
---|
63 | dont_initialize (); |
---|
64 | sensitive << (*(in_CLOCK)).pos(); |
---|
65 | #endif |
---|
66 | |
---|
67 | SC_METHOD (genMealy_shift); |
---|
68 | dont_initialize (); |
---|
69 | sensitive << (*(in_CLOCK)).neg(); |
---|
70 | for (uint32_t i=0; i<param->_nb_port; i++) |
---|
71 | { |
---|
72 | sensitive << (*(in_SHIFTER_DATA [i])); |
---|
73 | if (param->_shift_value == 0) |
---|
74 | sensitive << (*(in_SHIFTER_SHIFT [i])); |
---|
75 | if (param->_direction == external_direction) |
---|
76 | sensitive << (*(in_SHIFTER_DIRECTION [i])); |
---|
77 | if (_param->_rotate == external_rotate) |
---|
78 | sensitive << (*(in_SHIFTER_TYPE [i])); |
---|
79 | if (param->_carry == external_carry) |
---|
80 | sensitive << (*(in_SHIFTER_CARRY [i])); |
---|
81 | if (param->_carry == external_completion) |
---|
82 | if (_param->_type_completion_bool == true) |
---|
83 | sensitive << (*(in_SHIFTER_CARRY_IN [i])); |
---|
84 | else |
---|
85 | sensitive << (*(in_SHIFTER_COMPLETION[i])); |
---|
86 | } |
---|
87 | |
---|
88 | #ifdef SYSTEMCASS_SPECIFIC |
---|
89 | // List dependency information |
---|
90 | for (uint32_t i=0; i<param->_nb_port; i++) |
---|
91 | { |
---|
92 | (*(out_SHIFTER_DATA [i])) (*(in_SHIFTER_DATA [i])); |
---|
93 | if (param->_shift_value == 0) |
---|
94 | (*(out_SHIFTER_DATA [i])) (*(in_SHIFTER_SHIFT [i])); |
---|
95 | if (param->_direction == external_direction) |
---|
96 | (*(out_SHIFTER_DATA [i])) (*(in_SHIFTER_DIRECTION [i])); |
---|
97 | if (_param->_rotate == external_rotate) |
---|
98 | (*(out_SHIFTER_DATA [i])) (*(in_SHIFTER_TYPE [i])); |
---|
99 | if (param->_carry == external_carry) |
---|
100 | (*(out_SHIFTER_DATA [i])) (*(in_SHIFTER_CARRY [i])); |
---|
101 | if (param->_carry == external_completion) |
---|
102 | if (_param->_type_completion_bool == true) |
---|
103 | (*(out_SHIFTER_DATA [i])) (*(in_SHIFTER_CARRY_IN [i])); |
---|
104 | else |
---|
105 | (*(out_SHIFTER_DATA [i])) (*(in_SHIFTER_COMPLETION[i])); |
---|
106 | } |
---|
107 | #endif |
---|
108 | } |
---|
109 | #endif |
---|
110 | }; |
---|
111 | |
---|
112 | #undef FUNCTION |
---|
113 | #define FUNCTION "Shifter::~Shifter" |
---|
114 | Shifter::~Shifter (void) |
---|
115 | { |
---|
116 | #ifdef STATISTICS |
---|
117 | if (usage_is_set(_usage,USE_STATISTICS)) |
---|
118 | delete _stat; |
---|
119 | #endif |
---|
120 | |
---|
121 | deallocation (); |
---|
122 | }; |
---|
123 | |
---|
124 | }; // end namespace shifter |
---|
125 | }; // end namespace generic |
---|
126 | |
---|
127 | }; // end namespace behavioural |
---|
128 | }; // end namespace morpheo |
---|