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