[2] | 1 | /* |
---|
| 2 | * $Id$ |
---|
| 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 | #ifdef SYSTEMC |
---|
| 17 | Shifter::Shifter (sc_module_name name, |
---|
| 18 | #else |
---|
| 19 | Shifter::Shifter (string name, |
---|
| 20 | #endif |
---|
| 21 | #ifdef STATISTICS |
---|
| 22 | morpheo::behavioural::Parameters_Statistics param_statistics, |
---|
| 23 | #endif |
---|
| 24 | morpheo::behavioural::generic::shifter::Parameters param ): |
---|
| 25 | _name (name) |
---|
| 26 | ,_param (param) |
---|
| 27 | { |
---|
| 28 | #ifdef STATISTICS |
---|
| 29 | // Allocation of statistics |
---|
| 30 | _stat = new Statistics (static_cast<string>(_name), |
---|
| 31 | param_statistics , |
---|
| 32 | param); |
---|
| 33 | #endif |
---|
| 34 | |
---|
| 35 | #ifdef VHDL_TESTBENCH |
---|
| 36 | // Creation of a testbench |
---|
| 37 | // -> port |
---|
| 38 | // -> clock's signals |
---|
| 39 | _vhdl_testbench = new Vhdl_Testbench (_name); |
---|
| 40 | vhdl_testbench_port (*_vhdl_testbench); |
---|
| 41 | _vhdl_testbench->set_clock ("in_CLOCK",false); |
---|
| 42 | #endif |
---|
| 43 | |
---|
| 44 | #ifdef VHDL |
---|
| 45 | // generate the vhdl |
---|
| 46 | vhdl(); |
---|
| 47 | #endif |
---|
| 48 | |
---|
| 49 | #ifdef SYSTEMC |
---|
| 50 | allocation (); |
---|
| 51 | |
---|
| 52 | #if (defined(STATISTICS) || defined (VHDL_TESTBENCH)) |
---|
| 53 | SC_METHOD (transition); |
---|
| 54 | dont_initialize (); |
---|
| 55 | sensitive_pos << *(in_CLOCK); |
---|
| 56 | #endif |
---|
| 57 | |
---|
| 58 | SC_METHOD (genMealy_shift); |
---|
| 59 | dont_initialize (); |
---|
| 60 | sensitive_neg << *(in_CLOCK); |
---|
| 61 | for (uint32_t i=0; i<param._nb_port; i++) |
---|
| 62 | { |
---|
| 63 | sensitive << (*(in_SHIFTER_DATA [i])); |
---|
| 64 | if (param._shift_value == 0) |
---|
| 65 | sensitive << (*(in_SHIFTER_SHIFT [i])); |
---|
| 66 | if (param._direction == external_direction) |
---|
| 67 | sensitive << (*(in_SHIFTER_DIRECTION [i])); |
---|
| 68 | if (_param._rotate == external_rotate) |
---|
| 69 | sensitive << (*(in_SHIFTER_TYPE [i])); |
---|
| 70 | if (param._carry == external_carry) |
---|
| 71 | sensitive << (*(in_SHIFTER_CARRY [i])); |
---|
| 72 | if (param._carry == external_completion) |
---|
| 73 | if (_param._type_completion_bool == true) |
---|
| 74 | sensitive << (*(in_SHIFTER_CARRY_IN [i])); |
---|
| 75 | else |
---|
| 76 | sensitive << (*(in_SHIFTER_COMPLETION[i])); |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | #ifdef SYSTEMCASS_SPECIFIC |
---|
| 80 | // List dependency information |
---|
| 81 | for (uint32_t i=0; i<param._nb_port; i++) |
---|
| 82 | { |
---|
| 83 | (*(out_SHIFTER_DATA [i])) (*(in_SHIFTER_DATA [i])); |
---|
| 84 | if (param._shift_value == 0) |
---|
| 85 | (*(out_SHIFTER_DATA [i])) (*(in_SHIFTER_SHIFT [i])); |
---|
| 86 | if (param._direction == external_direction) |
---|
| 87 | (*(out_SHIFTER_DATA [i])) (*(in_SHIFTER_DIRECTION [i])); |
---|
| 88 | if (_param._rotate == external_rotate) |
---|
| 89 | (*(out_SHIFTER_DATA [i])) (*(in_SHIFTER_TYPE [i])); |
---|
| 90 | if (param._carry == external_carry) |
---|
| 91 | (*(out_SHIFTER_DATA [i])) (*(in_SHIFTER_CARRY [i])); |
---|
| 92 | if (param._carry == external_completion) |
---|
| 93 | if (_param._type_completion_bool == true) |
---|
| 94 | (*(out_SHIFTER_DATA [i])) (*(in_SHIFTER_CARRY_IN [i])); |
---|
| 95 | else |
---|
| 96 | (*(out_SHIFTER_DATA [i])) (*(in_SHIFTER_COMPLETION[i])); |
---|
| 97 | } |
---|
| 98 | #endif |
---|
| 99 | |
---|
| 100 | #endif |
---|
| 101 | }; |
---|
| 102 | |
---|
| 103 | Shifter::~Shifter (void) |
---|
| 104 | { |
---|
| 105 | #ifdef SYSTEMC |
---|
| 106 | deallocation (); |
---|
| 107 | #endif |
---|
| 108 | |
---|
| 109 | #ifdef VHDL_TESTBENCH |
---|
| 110 | // generate the test bench |
---|
| 111 | _vhdl_testbench->generate_file(); |
---|
| 112 | delete _vhdl_testbench; |
---|
| 113 | #endif |
---|
| 114 | |
---|
| 115 | #ifdef STATISTICS |
---|
| 116 | _stat->generate_file(statistics(0)); |
---|
| 117 | |
---|
| 118 | delete _stat; |
---|
| 119 | #endif |
---|
| 120 | }; |
---|
| 121 | |
---|
| 122 | }; // end namespace shifter |
---|
| 123 | }; // end namespace generic |
---|
| 124 | |
---|
| 125 | }; // end namespace behavioural |
---|
| 126 | }; // end namespace morpheo |
---|