Changeset 116 for trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic
- Timestamp:
- Apr 30, 2009, 3:51:41 PM (16 years ago)
- Location:
- trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic
- Files:
-
- 4 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Comparator/src/Comparator_vhdl_xilinx_body.cpp
r113 r116 20 20 { 21 21 log_begin(Comparator,FUNCTION); 22 vhdl->set_body (""); 22 vhdl->set_body (0,"ins_c_compare_v9_0 : c_compare_v9_0"); 23 vhdl->set_body (1,"generic map ("); 24 vhdl->set_body (2,"c_width => "+toString(_param->_size_data)+","); 25 vhdl->set_body (2,"c_data_type => "+toString(!_param->_is_signed)+", -- 0 = signed, 1 = unsigned"); 26 std::string print_res_pin = ""; 27 switch (_param->_type) 28 { 29 case COMPARATOR_EQUAL : 30 vhdl->set_body (2,"c_has_a_eq_b => 1)"); 31 print_res_pin = "a_eq_b"; 32 break; 33 case COMPARATOR_NOT_EQUAL : 34 vhdl->set_body (2,"c_has_a_eq_b => 0,"); 35 vhdl->set_body (2,"c_has_a_ne_b => 1)"); 36 print_res_pin = "a_ne_b"; 37 break; 38 case COMPARATOR_GREATER : 39 vhdl->set_body (2,"c_has_a_eq_b => 0,"); 40 vhdl->set_body (2,"c_has_a_gt_b => 1)"); 41 print_res_pin = "a_gt_b"; 42 break; 43 case COMPARATOR_GREATER_OR_EQUAL : 44 vhdl->set_body (2,"c_has_a_eq_b => 0,"); 45 vhdl->set_body (2,"c_has_a_ge_b => 1)"); 46 print_res_pin = "a_ge_b"; 47 break; 48 case COMPARATOR_LESS : 49 vhdl->set_body (2,"c_has_a_eq_b => 0,"); 50 vhdl->set_body (2,"c_has_a_lt_b => 1)"); 51 print_res_pin = "a_lt_b"; 52 break; 53 case COMPARATOR_LESS_OR_EQUAL : 54 vhdl->set_body (2,"c_has_a_eq_b => 0,"); 55 vhdl->set_body (2,"c_has_a_le_b => 1)"); 56 print_res_pin = "a_le_b"; 57 break; 58 } 59 60 vhdl->set_body (1,"port map ("); 61 vhdl->set_body (2,"a => in_COMPARE_DATA_0,"); 62 vhdl->set_body (2,"b => in_COMPARE_DATA_1,"); 63 vhdl->set_body (2,print_res_pin+" => out_COMPARE_TEST);"); 64 23 65 log_end(Comparator,FUNCTION); 24 66 }; -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Multiplier/SelfTest/configuration.cfg
r112 r116 1 1 Multiplier 2 16 32 *2 #size_data 3 0 1 +1 #sign 4 6 32 *3 #latency 5 1 1 +1 #delay -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Multiplier/SelfTest/include/test.h
r112 r116 11 11 #endif 12 12 13 #define NB_ITERATION 1 13 #define NB_ITERATION 128 14 14 #define CYCLE_MAX (1024*NB_ITERATION) 15 15 -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Multiplier/SelfTest/src/main.cpp
r112 r116 7 7 8 8 #include "Behavioural/Generic/Multiplier/SelfTest/include/test.h" 9 #include "Behavioural/include/Selftest.h" 9 10 10 #define NB_PARAMS 011 #define NB_PARAMS 4 11 12 12 13 void usage (int argc, char * argv[]) … … 14 15 err (_("<Usage> %s name_instance list_params.\n"),argv[0]); 15 16 err (_("list_params is :\n")); 16 err (_(" * ()\n")); 17 err (_(" * size_data (uint32_t)\n")); 18 err (_(" * sign (bool )\n")); 19 err (_(" * latency (uint32_t)\n")); 20 err (_(" * delay (uint32_t)\n")); 17 21 18 22 exit (1); … … 30 34 uint32_t x = 1; 31 35 36 uint32_t _size_data; 37 bool _sign ; 38 uint32_t _latency ; 39 uint32_t _delay ; 40 32 41 string name = argv[x++]; 42 43 SELFTEST0(_size_data,uint32_t,argv,x); 44 SELFTEST0(_sign ,bool ,argv,x); 45 SELFTEST0(_latency ,uint32_t,argv,x); 46 SELFTEST0(_delay ,uint32_t,argv,x); 33 47 34 48 int _return = EXIT_SUCCESS; … … 37 51 morpheo::behavioural::generic::multiplier::Parameters * param = new morpheo::behavioural::generic::multiplier::Parameters 38 52 ( 53 _size_data, 54 _sign , 55 _latency , 56 _delay , 39 57 true //is_toplevel 40 58 ); -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Multiplier/SelfTest/src/test.cpp
r112 r116 9 9 #include "Behavioural/Generic/Multiplier/SelfTest/include/test.h" 10 10 #include "Behavioural/include/Allocation.h" 11 #include "Common/include/BitManipulation.h" 11 12 12 13 void test (string name, … … 50 51 sc_clock * in_CLOCK = new sc_clock ("clock", 1.0, 0.5); 51 52 sc_signal<Tcontrol_t> * in_NRESET = new sc_signal<Tcontrol_t> ("NRESET"); 52 53 54 sc_signal<Tdata_t > * in_MULTIPLIER_DATA_IN_0; 55 sc_signal<Tdata_t > * in_MULTIPLIER_DATA_IN_1; 56 sc_signal<Tcontrol_t> * in_MULTIPLIER_NSTALL ; 57 58 sc_signal<Tdata_t > * out_MULTIPLIER_DATA_LSB_OUT; 59 sc_signal<Tdata_t > * out_MULTIPLIER_DATA_MSB_OUT; 60 61 62 ALLOC0_SC_SIGNAL( in_MULTIPLIER_DATA_IN_0,"in_MULTIPLIER_DATA_IN_0",Tdata_t ); 63 ALLOC0_SC_SIGNAL( in_MULTIPLIER_DATA_IN_1,"in_MULTIPLIER_DATA_IN_1",Tdata_t ); 64 ALLOC0_SC_SIGNAL( in_MULTIPLIER_NSTALL ,"in_MULTIPLIER_NSTALL ",Tcontrol_t); 65 66 ALLOC0_SC_SIGNAL(out_MULTIPLIER_DATA_LSB_OUT,"out_MULTIPLIER_DATA_LSB_OUT",Tdata_t ); 67 ALLOC0_SC_SIGNAL(out_MULTIPLIER_DATA_MSB_OUT,"out_MULTIPLIER_DATA_MSB_OUT",Tdata_t ); 68 53 69 /******************************************************** 54 70 * Instanciation … … 60 76 (*(_Multiplier->in_NRESET)) (*(in_NRESET)); 61 77 78 INSTANCE0_SC_SIGNAL(_Multiplier, in_MULTIPLIER_DATA_IN_0); 79 INSTANCE0_SC_SIGNAL(_Multiplier, in_MULTIPLIER_DATA_IN_1); 80 INSTANCE0_SC_SIGNAL(_Multiplier, in_MULTIPLIER_NSTALL); 81 82 INSTANCE0_SC_SIGNAL(_Multiplier,out_MULTIPLIER_DATA_LSB_OUT); 83 INSTANCE0_SC_SIGNAL(_Multiplier,out_MULTIPLIER_DATA_MSB_OUT); 62 84 63 85 msg(_("<%s> : Start Simulation ............\n"),name.c_str()); … … 89 111 { 90 112 LABEL("Iteration %d",iteration); 113 114 uint64_t data0 = range<uint64_t>(rand(),_param->_size_data); 115 uint64_t data1 = range<uint64_t>(rand(),_param->_size_data); 116 117 in_MULTIPLIER_DATA_IN_0->write(static_cast<Tdata_t>(data0)); 118 in_MULTIPLIER_DATA_IN_1->write(static_cast<Tdata_t>(data1)); 119 in_MULTIPLIER_NSTALL->write(static_cast<Tcontrol_t>(1)); 120 121 sc_uint<32> res_lsb = 0; 122 sc_uint<32> res_msb = 0; 123 124 switch (_param->_size_data) 125 { 126 case 8 : 127 { 128 if (_param->_sign){ // 0 = signed, 1 = unsigned 129 sc_uint<16> mask = 0xff; 130 sc_uint<16> tmp = (static_cast<sc_uint<16> >(data0)) * (static_cast<sc_uint<16> >(data1)); 131 res_lsb = tmp.range(7,0); 132 res_msb = tmp.range(15,8); 133 } 134 else{ 135 sc_int<8> data_0 = static_cast<sc_int<8> >(data0); 136 sc_int<8> data_1 = static_cast<sc_int<8> >(data1); 137 sc_int<16> tmp = (static_cast<sc_int<16> >(data_0) * 138 static_cast<sc_int<16> >(data_1)); 139 res_lsb = static_cast<Tdata_t>(_param->_mask & tmp); 140 res_msb = static_cast<Tdata_t>(_param->_mask & (tmp>>8)); 141 } 142 break; 143 } 144 case 16 : 145 { 146 if (_param->_sign){ // 0 = signed, 1 = unsigned 147 sc_uint<32> mask = 0xffff; 148 sc_uint<32> tmp = (static_cast<sc_uint<32> >(data0)) * (static_cast<sc_uint<32> >(data1)); 149 res_lsb = tmp.range(15,0); 150 res_msb = tmp.range(31,16); 151 } 152 else{ 153 sc_int<16> data_0 = static_cast<sc_int<16> >(data0); 154 sc_int<16> data_1 = static_cast<sc_int<16> >(data1); 155 sc_int<32> tmp = (static_cast<sc_int<32> >(data_0) * 156 static_cast<sc_int<32> >(data_1)); 157 res_lsb = static_cast<Tdata_t>(_param->_mask & tmp); 158 res_msb = static_cast<Tdata_t>(_param->_mask & (tmp>>16)); 159 160 cout << "data_0 : " << std::hex << data_0 << std::dec << " - dec : " << data_0<< endl; 161 cout << "data_1 : " << std::hex << data_1 << std::dec << " - dec : " << data_1<< endl; 162 cout << "tmp : " << std::hex << tmp << std::dec << " - dec : " << tmp << endl; 163 cout << "res_lsb : " << std::hex << res_lsb << std::dec << endl; 164 cout << "res_msb : " << std::hex << res_msb << std::dec << endl; 165 } 166 break; 167 } 168 case 32 : 169 { 170 if (_param->_sign){ // 0 = signed, 1 = unsigned 171 sc_uint<32> data_0 = static_cast<sc_uint<32> >(data0); 172 sc_uint<32> data_1 = static_cast<sc_uint<32> >(data1); 173 sc_uint<64> tmp = (data0) * (data1); 174 res_lsb = static_cast<Tdata_t>(_param->_mask & tmp); 175 res_msb = static_cast<Tdata_t>(_param->_mask & (tmp>>32)); 176 177 cout << "tmp : " << std::hex << tmp << std::dec << endl; 178 } 179 else{ 180 sc_int<32> data_0 = static_cast<sc_int<32> >(data0); 181 sc_int<32> data_1 = static_cast<sc_int<32> >(data1); 182 sc_int<64> tmp = (data0) * (data1); 183 res_lsb = static_cast<Tdata_t>(_param->_mask & tmp); 184 res_msb = static_cast<Tdata_t>(_param->_mask & (tmp>>32)); 185 186 cout << "data_0 : " << std::hex << data_0 << std::dec << endl; 187 cout << "data_1 : " << std::hex << data_1 << std::dec << endl; 188 cout << "tmp : " << std::hex << tmp << std::dec << endl; 189 cout << "res_lsb : " << std::hex << res_lsb << std::dec << endl; 190 cout << "res_msb : " << std::hex << res_msb << std::dec << endl; 191 192 193 } 194 break; 195 } 196 // case 64 : 197 // { 198 // if (_param->_sign){ 0 = signed, 1 = unsigned 199 // uint64_t tmp = static_cast<uint64_t>(data0) * static_cast<uint64_t>(data1); 200 // res_lsb = tmp; 201 // } 202 // else{ 203 // int64_t tmp = static_cast< int64_t>(data0) * static_cast< int64_t>(data1); 204 // res_lsb = 0xffffffffffffffff&tmp; 205 // } 206 // break; 207 // } 208 default : 209 { 210 TEST_KO("Invalid size for the test."); 211 } 212 } 213 SC_START(_param->_latency); 214 TEST(Tdata_t,out_MULTIPLIER_DATA_LSB_OUT->read(),res_lsb); 215 TEST(Tdata_t,out_MULTIPLIER_DATA_MSB_OUT->read(),res_msb); 91 216 92 217 SC_START(1); … … 104 229 delete in_CLOCK; 105 230 delete in_NRESET; 231 232 DELETE0_SC_SIGNAL( in_MULTIPLIER_DATA_IN_0); 233 DELETE0_SC_SIGNAL( in_MULTIPLIER_DATA_IN_1); 234 DELETE0_SC_SIGNAL( in_MULTIPLIER_NSTALL); 235 DELETE0_SC_SIGNAL(out_MULTIPLIER_DATA_LSB_OUT); 236 DELETE0_SC_SIGNAL(out_MULTIPLIER_DATA_MSB_OUT); 237 106 238 } 107 239 #endif -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Multiplier/include/Multiplier.h
r112 r116 29 29 30 30 #include <iostream> 31 #include <vector> 31 32 32 33 namespace morpheo { … … 57 58 #ifdef SYSTEMC 58 59 // ~~~~~[ Interface ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 60 59 61 // ~~~~~[ Interface : "" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 60 62 public : SC_CLOCK * in_CLOCK ; 61 63 public : SC_IN (Tcontrol_t) * in_NRESET ; 62 64 65 // ~~~~~[ Interface : "multiplier" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 66 public : SC_IN (Tdata_t) * in_MULTIPLIER_DATA_IN_0; 67 public : SC_IN (Tdata_t) * in_MULTIPLIER_DATA_IN_1; 68 public : SC_IN (Tcontrol_t) * in_MULTIPLIER_NSTALL; 69 70 public : SC_OUT(Tdata_t) * out_MULTIPLIER_DATA_LSB_OUT; 71 public : SC_OUT(Tdata_t) * out_MULTIPLIER_DATA_MSB_OUT; 72 73 63 74 // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 64 75 65 76 // ~~~~~[ Register ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 66 77 private : std::vector<result_t> * _pipeline; 67 78 // ~~~~~[ Internal ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 79 private : Tdata_t sig_MULTIPLIER_DATA_IN_0; 80 private : Tdata_t sig_MULTIPLIER_DATA_IN_1; 68 81 #endif 69 82 … … 99 112 #ifdef SYSTEMC 100 113 public : void transition (void); 101 //public : void genMoore(void);114 public : void genMealy (void); 102 115 #endif 103 116 … … 106 119 private : void vhdl_declaration (Vhdl * & vhdl); 107 120 private : void vhdl_body (Vhdl * & vhdl); 121 122 private : void vhdl_xilinx_declaration (Vhdl * & vhdl); 123 private : void vhdl_xilinx_body (Vhdl * & vhdl); 108 124 #endif 109 125 -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Multiplier/include/Parameters.h
r112 r116 11 11 #include "Behavioural/include/Parameters.h" 12 12 #include "Common/include/Debug.h" 13 #include "Behavioural/Generic/Multiplier/include/Types.h" 13 14 14 15 namespace morpheo { … … 21 22 { 22 23 //-----[ fields ]------------------------------------------------------------ 24 public : uint32_t _size_data; 25 public : bool _sign ; 26 public : uint32_t _latency ; 27 public : uint32_t _delay ; 28 29 public : Tdata_t _mask ; 30 // public : Tdata_t _shift_sign; 23 31 24 32 //-----[ methods ]----------------------------------------------------------- 25 public : Parameters (bool is_toplevel=false); 33 public : Parameters (uint32_t size_data, 34 bool sign , 35 uint32_t latency , 36 uint32_t delay , 37 bool is_toplevel=false); 26 38 //public : Parameters (Parameters & param) ; 27 39 public : ~Parameters (void); -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Multiplier/include/Types.h
r112 r116 16 16 namespace multiplier { 17 17 18 typedef Tgeneral_data_t Tdata_t; 19 20 typedef struct 21 { 22 Tdata_t MSB; 23 Tdata_t LSB; 24 } result_t; 18 25 19 26 }; // end namespace multiplier -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Multiplier/src/Multiplier.cpp
r112 r116 77 77 # endif 78 78 79 // log_printf(INFO,Multiplier,FUNCTION,_("<%s> : Method - genMoore"),_name.c_str());79 log_printf(INFO,Multiplier,FUNCTION,_("<%s> : Method - genMealy"),_name.c_str()); 80 80 81 // SC_METHOD (genMoore); 82 // dont_initialize (); 83 // sensitive << (*(in_CLOCK)).neg(); // need internal register 81 SC_METHOD (genMealy); 82 dont_initialize (); 83 sensitive << (*(in_CLOCK)).neg(); // need internal register 84 85 if (_param->_latency == 0) 86 sensitive << (*(in_MULTIPLIER_DATA_IN_0)) 87 << (*(in_MULTIPLIER_DATA_IN_1)); 84 88 85 //# ifdef SYSTEMCASS_SPECIFIC86 //// List dependency information87 //# endif89 # ifdef SYSTEMCASS_SPECIFIC 90 // List dependency information 91 # endif 88 92 89 93 #endif -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Multiplier/src/Multiplier_allocation.cpp
r112 r116 53 53 in_NRESET = interface->set_signal_in <Tcontrol_t> ("nreset",1, RESET_VHDL_YES); 54 54 } 55 56 // ~~~~~[ Interface "multiplier" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 57 { 58 ALLOC0_INTERFACE_BEGIN("multiplier", IN, WEST, _("Multiplier's interface.")); 59 60 ALLOC0_SIGNAL_IN ( in_MULTIPLIER_DATA_IN_0,"data_in_0",Tdata_t ,_param->_size_data); 61 ALLOC0_SIGNAL_IN ( in_MULTIPLIER_DATA_IN_1,"data_in_1",Tdata_t ,_param->_size_data); 62 ALLOC0_SIGNAL_IN ( in_MULTIPLIER_NSTALL ,"nstall" ,Tcontrol_t,1); 63 ALLOC0_SIGNAL_OUT(out_MULTIPLIER_DATA_LSB_OUT ,"data_lsb_out" ,Tdata_t ,_param->_size_data); 64 ALLOC0_SIGNAL_OUT(out_MULTIPLIER_DATA_MSB_OUT ,"data_msb_out" ,Tdata_t ,_param->_size_data); 65 66 ALLOC0_INTERFACE_END(); 67 } 68 69 // ~~~~~[ Register ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 70 #ifdef SYSTEMC 71 if (usage_is_set(_usage,USE_SYSTEMC_BODY)) 72 { 73 _pipeline = new std::vector<result_t>(_param->_latency+1); 74 } 75 #endif 76 55 77 // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 56 78 -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Multiplier/src/Multiplier_deallocation.cpp
r112 r116 25 25 delete in_CLOCK ; 26 26 delete in_NRESET; 27 28 DELETE0_SIGNAL(in_MULTIPLIER_DATA_IN_0,_param->_size_data); 29 DELETE0_SIGNAL(in_MULTIPLIER_DATA_IN_1,_param->_size_data); 30 DELETE0_SIGNAL(in_MULTIPLIER_NSTALL ,1); 31 32 DELETE0_SIGNAL(out_MULTIPLIER_DATA_LSB_OUT,_param->_size_data); 33 DELETE0_SIGNAL(out_MULTIPLIER_DATA_MSB_OUT,_param->_size_data); 34 27 35 } 28 36 // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 37 #ifdef SYSTEMC 38 if (usage_is_set(_usage,USE_SYSTEMC_BODY)) 39 { 40 delete _pipeline; 41 } 42 #endif 29 43 30 44 delete _component; -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Multiplier/src/Multiplier_transition.cpp
r112 r116 20 20 { 21 21 log_begin(Multiplier,FUNCTION); 22 22 23 // Test if stall 24 if (PORT_READ(in_MULTIPLIER_NSTALL)) 25 { 26 // Pop a slot of array 27 for (uint32_t i=1;i<_pipeline->size();i++) 28 _pipeline->at(i-1)=_pipeline->at(i); 29 30 result_t data; 31 32 switch (_param->_size_data) 33 { 34 case 8 : 35 { 36 if (_param->_sign) // 0 = signed, 1 = unsigned 37 { 38 sc_uint<8> data_0 = static_cast<sc_uint<8> >(PORT_READ(in_MULTIPLIER_DATA_IN_0)); 39 sc_uint<8> data_1 = static_cast<sc_uint<8> >(PORT_READ(in_MULTIPLIER_DATA_IN_1)); 40 sc_uint<16> tmp = (static_cast<sc_uint<16> >(data_0) * 41 static_cast<sc_uint<16> >(data_1)); 42 43 data.LSB = static_cast<Tdata_t>(_param->_mask & tmp); 44 data.MSB = static_cast<Tdata_t>(_param->_mask & (tmp>>8)); 45 46 // std::cout << "uint8 : data_0 : " << std::hex << data_0 << std::dec << std::endl; 47 // std::cout << "uint8 : data_1 : " << std::hex << data_1 << std::dec << std::endl; 48 // std::cout << "uint8 : tmp : " << std::hex << tmp << std::dec << std::endl; 49 // std::cout << "uint8 : lsb : " << std::hex << data.LSB << std::dec << std::endl; 50 // std::cout << "uint8 : msb : " << std::hex << data.MSB << std::dec << std::endl; 51 52 // log_printf(TRACE,Multiplier,FUNCTION," * signed"); 53 // log_printf(TRACE,Multiplier,FUNCTION," * data0 = %llx(%lld)",data_0, data_0); 54 // log_printf(TRACE,Multiplier,FUNCTION," * data1 = %llx(%lld)",data_1, data_1); 55 // log_printf(TRACE,Multiplier,FUNCTION," * res = %llx(%lld)",tmp, tmp); 56 // log_printf(TRACE,Multiplier,FUNCTION," * LSB = %x (%d)",data.LSB, data.LSB); 57 // log_printf(TRACE,Multiplier,FUNCTION," * MSB = %x (%d)",data.MSB, data.MSB); 58 } 59 else 60 { 61 sc_int<8> data_0 = static_cast<sc_int<8> >(PORT_READ(in_MULTIPLIER_DATA_IN_0)); 62 sc_int<8> data_1 = static_cast<sc_int<8> >(PORT_READ(in_MULTIPLIER_DATA_IN_1)); 63 sc_int<16> tmp = (static_cast<sc_int<16> >(data_0) * 64 static_cast<sc_int<16> >(data_1)); 65 66 data.LSB = static_cast<Tdata_t>(_param->_mask & tmp); 67 data.MSB = static_cast<Tdata_t>(_param->_mask & (tmp>>8)); 68 69 // std::cout << "int8 : data_0 : " << std::hex << data_0 << std::dec << std::endl; 70 // std::cout << "int8 : data_1 : " << std::hex << data_1 << std::dec << std::endl; 71 // std::cout << "int8 : tmp : " << std::hex << tmp << std::dec << std::endl; 72 // std::cout << "int8 : lsb : " << std::hex << data.LSB << std::dec << std::endl; 73 // std::cout << "int8 : msb : " << std::hex << data.MSB << std::dec << std::endl; 74 75 // log_printf(TRACE,Multiplier,FUNCTION," * signed"); 76 // log_printf(TRACE,Multiplier,FUNCTION," * data0 = %llx(%lld)",data_0, data_0); 77 // log_printf(TRACE,Multiplier,FUNCTION," * data1 = %llx(%lld)",data_1, data_1); 78 // log_printf(TRACE,Multiplier,FUNCTION," * res = %llx(%lld)",tmp, tmp); 79 // log_printf(TRACE,Multiplier,FUNCTION," * LSB = %x (%d)",data.LSB, data.LSB); 80 // log_printf(TRACE,Multiplier,FUNCTION," * MSB = %x (%d)",data.MSB, data.MSB); 81 } 82 break; 83 } 84 case 16 : 85 { 86 if (_param->_sign) // 0 = signed, 1 = unsigned 87 { 88 sc_uint<16> data_0 = static_cast<sc_uint<16> >(PORT_READ(in_MULTIPLIER_DATA_IN_0)); 89 sc_uint<16> data_1 = static_cast<sc_uint<16> >(PORT_READ(in_MULTIPLIER_DATA_IN_1)); 90 sc_uint<32> tmp = (static_cast<sc_uint<32> >(data_0) * 91 static_cast<sc_uint<32> >(data_1)); 92 93 data.LSB = static_cast<Tdata_t>(_param->_mask & tmp); 94 data.MSB = static_cast<Tdata_t>(_param->_mask & (tmp>>16)); 95 96 // std::cout << "uint16 : data_0 : " << std::hex << data_0 << std::dec << std::endl; 97 // std::cout << "uint16 : data_1 : " << std::hex << data_1 << std::dec << std::endl; 98 // std::cout << "uint16 : tmp : " << std::hex << tmp << std::dec << std::endl; 99 // std::cout << "uint16 : lsb : " << std::hex << data.LSB << std::dec << std::endl; 100 // std::cout << "uint16 : msb : " << std::hex << data.MSB << std::dec << std::endl; 101 102 // log_printf(TRACE,Multiplier,FUNCTION," * signed"); 103 // log_printf(TRACE,Multiplier,FUNCTION," * data0 = %llx(%lld)",data_0, data_0); 104 // log_printf(TRACE,Multiplier,FUNCTION," * data1 = %llx(%lld)",data_1, data_1); 105 // log_printf(TRACE,Multiplier,FUNCTION," * res = %llx(%lld)",tmp, tmp); 106 // log_printf(TRACE,Multiplier,FUNCTION," * LSB = %x (%d)",data.LSB, data.LSB); 107 // log_printf(TRACE,Multiplier,FUNCTION," * MSB = %x (%d)",data.MSB, data.MSB); 108 } 109 else 110 { 111 sc_int<16> data_0 = static_cast<sc_int<16> >(PORT_READ(in_MULTIPLIER_DATA_IN_0)); 112 sc_int<16> data_1 = static_cast<sc_int<16> >(PORT_READ(in_MULTIPLIER_DATA_IN_1)); 113 sc_int<32> tmp = (static_cast<sc_int<32> >(data_0) * 114 static_cast<sc_int<32> >(data_1)); 115 116 data.LSB = static_cast<Tdata_t>(_param->_mask & tmp); 117 data.MSB = static_cast<Tdata_t>(_param->_mask & (tmp>>16)); 118 119 std::cout << "int16 : data_0 : " << std::hex << data_0 << std::dec << " - dec : " << data_0 << std::endl; 120 std::cout << "int16 : data_1 : " << std::hex << data_1 << std::dec << " - dec : " << data_1 << std::endl; 121 std::cout << "int16 : tmp : " << std::hex << tmp << std::dec << " - dec : " << tmp << std::endl; 122 std::cout << "int16 : lsb : " << std::hex << data.LSB << std::dec << std::endl; 123 std::cout << "int16 : msb : " << std::hex << data.MSB << std::dec << std::endl; 124 125 // log_printf(TRACE,Multiplier,FUNCTION," * signed"); 126 // log_printf(TRACE,Multiplier,FUNCTION," * data0 = %llx(%lld)",data_0, data_0); 127 // log_printf(TRACE,Multiplier,FUNCTION," * data1 = %llx(%lld)",data_1, data_1); 128 // log_printf(TRACE,Multiplier,FUNCTION," * res = %llx(%lld)",tmp, tmp); 129 // log_printf(TRACE,Multiplier,FUNCTION," * LSB = %x (%d)",data.LSB, data.LSB); 130 // log_printf(TRACE,Multiplier,FUNCTION," * MSB = %x (%d)",data.MSB, data.MSB); 131 } 132 break; 133 } 134 case 32 : 135 { 136 if (_param->_sign) // 0 = signed, 1 = unsigned 137 { 138 sc_uint<32> data_0 = static_cast<sc_uint<32> >(PORT_READ(in_MULTIPLIER_DATA_IN_0)); 139 sc_uint<32> data_1 = static_cast<sc_uint<32> >(PORT_READ(in_MULTIPLIER_DATA_IN_1)); 140 sc_uint<64> tmp = (static_cast<sc_uint<64> >(data_0) * 141 static_cast<sc_uint<64> >(data_1)); 142 143 data.LSB = static_cast<Tdata_t>(_param->_mask & tmp); 144 data.MSB = static_cast<Tdata_t>(_param->_mask & (tmp>>32)); 145 146 // std::cout << "uint32 : data_0 : " << std::hex << data_0 << std::dec << std::endl; 147 // std::cout << "uint32 : data_1 : " << std::hex << data_1 << std::dec << std::endl; 148 // std::cout << "uint32 : tmp : " << std::hex << tmp << std::dec << std::endl; 149 // std::cout << "uint32 : lsb : " << std::hex << data.LSB << std::dec << std::endl; 150 // std::cout << "uint32 : msb : " << std::hex << data.MSB << std::dec << std::endl; 151 152 // log_printf(TRACE,Multiplier,FUNCTION," * signed"); 153 // log_printf(TRACE,Multiplier,FUNCTION," * data0 = %llx(%lld)",data_0, data_0); 154 // log_printf(TRACE,Multiplier,FUNCTION," * data1 = %llx(%lld)",data_1, data_1); 155 // log_printf(TRACE,Multiplier,FUNCTION," * res = %llx(%lld)",tmp, tmp); 156 // log_printf(TRACE,Multiplier,FUNCTION," * LSB = %x (%d)",data.LSB, data.LSB); 157 // log_printf(TRACE,Multiplier,FUNCTION," * MSB = %x (%d)",data.MSB, data.MSB); 158 } 159 else 160 { 161 sc_int<32> data_0 = static_cast<sc_int<32> >(PORT_READ(in_MULTIPLIER_DATA_IN_0)); 162 sc_int<32> data_1 = static_cast<sc_int<32> >(PORT_READ(in_MULTIPLIER_DATA_IN_1)); 163 sc_int<64> tmp = (static_cast<sc_int<64> >(data_0) * 164 static_cast<sc_int<64> >(data_1)); 165 166 data.LSB = static_cast<Tdata_t>(_param->_mask & tmp); 167 data.MSB = static_cast<Tdata_t>(_param->_mask & (tmp>>32)); 168 169 // std::cout << "int32 : data_0 : " << std::hex << data_0 << std::dec << std::endl; 170 // std::cout << "int32 : data_1 : " << std::hex << data_1 << std::dec << std::endl; 171 // std::cout << "int32 : tmp : " << std::hex << tmp << std::dec << std::endl; 172 // std::cout << "int32 : lsb : " << std::hex << data.LSB << std::dec << std::endl; 173 // std::cout << "int32 : msb : " << std::hex << data.MSB << std::dec << std::endl; 174 175 // log_printf(TRACE,Multiplier,FUNCTION," * signed"); 176 // log_printf(TRACE,Multiplier,FUNCTION," * data0 = %llx(%lld)",data_0, data_0); 177 // log_printf(TRACE,Multiplier,FUNCTION," * data1 = %llx(%lld)",data_1, data_1); 178 // log_printf(TRACE,Multiplier,FUNCTION," * res = %llx(%lld)",tmp, tmp); 179 // log_printf(TRACE,Multiplier,FUNCTION," * LSB = %x (%d)",data.LSB, data.LSB); 180 // log_printf(TRACE,Multiplier,FUNCTION," * MSB = %x (%d)",data.MSB, data.MSB); 181 } 182 break; 183 } 184 default : 185 { 186 break; 187 } 188 } 189 190 _pipeline->at(_param->_latency-1) = data; 191 192 } 193 23 194 #if defined(STATISTICS) or defined(VHDL_TESTBENCH) 24 195 end_cycle (); 25 196 #endif 26 197 27 198 log_end(Multiplier,FUNCTION); 28 199 }; -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Multiplier/src/Multiplier_vhdl.cpp
r112 r116 27 27 _component->vhdl_instance(vhdl); 28 28 29 // default architecture 29 30 vhdl_declaration (vhdl); 30 31 vhdl_body (vhdl); 32 33 // Xilinx architecture 34 vhdl->set_architecture("xilinx"); 35 vhdl_xilinx_declaration (vhdl); 36 vhdl_xilinx_body (vhdl); 31 37 32 38 vhdl->generate_file(); -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Multiplier/src/Parameters.cpp
r112 r116 7 7 8 8 #include "Behavioural/Generic/Multiplier/include/Parameters.h" 9 #include "Common/include/BitManipulation.h" 9 10 10 11 namespace morpheo { … … 16 17 #undef FUNCTION 17 18 #define FUNCTION "Multiplier::Parameters" 18 Parameters::Parameters (bool is_toplevel) 19 Parameters::Parameters (uint32_t size_data, 20 bool sign , 21 uint32_t latency , 22 uint32_t delay , 23 bool is_toplevel) 19 24 { 25 20 26 log_begin(Multiplier,FUNCTION); 27 28 _size_data = size_data; 29 _sign = sign ; 30 _latency = latency ; 31 _delay = delay ; 32 _mask = gen_mask<Tdata_t>(_size_data); 33 // _shift_sign = size_data-1; 21 34 22 35 test(); … … 35 48 // { 36 49 // log_begin(Multiplier,FUNCTION); 37 // test(); 50 // test();x 38 51 // log_end(Multiplier,FUNCTION); 39 52 // }; -
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Multiplier/src/Parameters_msg_error.cpp
r112 r116 24 24 Parameters_test test ("Multiplier"); 25 25 26 if ((_size_data < 2) or (_size_data > 64)) 27 test.error(toString(_("size_data (%d) 's valid range is 2 to 64.\n"),_size_data)); 28 29 if (_delay > 1) 30 test.error(toString(_("delay must be set at 1\n"))); 31 32 if (_latency > 32) 33 test.error(toString(_("latency's valid range is 0 to 32\n"))); 34 26 35 log_end(Multiplier,FUNCTION); 27 36
Note: See TracChangeset
for help on using the changeset viewer.