[2] | 1 | /* |
---|
| 2 | * $Id: Shifter.cpp 132 2009-07-11 16:39:35Z 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 (); |
---|
[132] | 69 | sensitive << (*(in_CLOCK)).neg() |
---|
| 70 | << (*(in_NRESET)); |
---|
[82] | 71 | for (uint32_t i=0; i<param->_nb_port; i++) |
---|
[2] | 72 | { |
---|
| 73 | sensitive << (*(in_SHIFTER_DATA [i])); |
---|
[82] | 74 | if (param->_shift_value == 0) |
---|
[2] | 75 | sensitive << (*(in_SHIFTER_SHIFT [i])); |
---|
[82] | 76 | if (param->_direction == external_direction) |
---|
[2] | 77 | sensitive << (*(in_SHIFTER_DIRECTION [i])); |
---|
[82] | 78 | if (_param->_rotate == external_rotate) |
---|
[2] | 79 | sensitive << (*(in_SHIFTER_TYPE [i])); |
---|
[82] | 80 | if (param->_carry == external_carry) |
---|
[2] | 81 | sensitive << (*(in_SHIFTER_CARRY [i])); |
---|
[82] | 82 | if (param->_carry == external_completion) |
---|
| 83 | if (_param->_type_completion_bool == true) |
---|
[2] | 84 | sensitive << (*(in_SHIFTER_CARRY_IN [i])); |
---|
| 85 | else |
---|
| 86 | sensitive << (*(in_SHIFTER_COMPLETION[i])); |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | #ifdef SYSTEMCASS_SPECIFIC |
---|
| 90 | // List dependency information |
---|
[82] | 91 | for (uint32_t i=0; i<param->_nb_port; i++) |
---|
[2] | 92 | { |
---|
| 93 | (*(out_SHIFTER_DATA [i])) (*(in_SHIFTER_DATA [i])); |
---|
[82] | 94 | if (param->_shift_value == 0) |
---|
[2] | 95 | (*(out_SHIFTER_DATA [i])) (*(in_SHIFTER_SHIFT [i])); |
---|
[82] | 96 | if (param->_direction == external_direction) |
---|
[2] | 97 | (*(out_SHIFTER_DATA [i])) (*(in_SHIFTER_DIRECTION [i])); |
---|
[82] | 98 | if (_param->_rotate == external_rotate) |
---|
[2] | 99 | (*(out_SHIFTER_DATA [i])) (*(in_SHIFTER_TYPE [i])); |
---|
[82] | 100 | if (param->_carry == external_carry) |
---|
[2] | 101 | (*(out_SHIFTER_DATA [i])) (*(in_SHIFTER_CARRY [i])); |
---|
[82] | 102 | if (param->_carry == external_completion) |
---|
| 103 | if (_param->_type_completion_bool == true) |
---|
[2] | 104 | (*(out_SHIFTER_DATA [i])) (*(in_SHIFTER_CARRY_IN [i])); |
---|
| 105 | else |
---|
| 106 | (*(out_SHIFTER_DATA [i])) (*(in_SHIFTER_COMPLETION[i])); |
---|
| 107 | } |
---|
| 108 | #endif |
---|
[88] | 109 | } |
---|
[2] | 110 | #endif |
---|
| 111 | }; |
---|
| 112 | |
---|
[88] | 113 | #undef FUNCTION |
---|
| 114 | #define FUNCTION "Shifter::~Shifter" |
---|
[2] | 115 | Shifter::~Shifter (void) |
---|
| 116 | { |
---|
[88] | 117 | #ifdef STATISTICS |
---|
| 118 | if (usage_is_set(_usage,USE_STATISTICS)) |
---|
| 119 | delete _stat; |
---|
[2] | 120 | #endif |
---|
| 121 | |
---|
[88] | 122 | deallocation (); |
---|
[2] | 123 | }; |
---|
| 124 | |
---|
| 125 | }; // end namespace shifter |
---|
| 126 | }; // end namespace generic |
---|
| 127 | |
---|
| 128 | }; // end namespace behavioural |
---|
| 129 | }; // end namespace morpheo |
---|