Changeset 42 for trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Shifter/src/Shifter_vhdl_body.cpp
- Timestamp:
- Jul 5, 2007, 5:50:19 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Shifter/src/Shifter_vhdl_body.cpp
r2 r42 15 15 16 16 17 void Shifter::vhdl_body (Vhdl & vhdl)17 void Shifter::vhdl_body (Vhdl * & vhdl) 18 18 { 19 19 //uint32_t log2_size_data = static_cast<uint32_t>(ceil(log2(_param._size_data))); 20 20 21 vhdl .set_body ("-- Compute all case of shift");21 vhdl->set_body ("-- Compute all case of shift"); 22 22 23 23 for (uint32_t i=0; i<_param._nb_port; i++) … … 25 25 //-----[ Shift logic Left ]-------------------------------------------- 26 26 if (_param._have_shift_logic_left) 27 vhdl .set_body ("shift_logic_left_"+toString(i)+" <= TO_STDLOGICVECTOR(TO_BITVECTOR(in_SHIFTER_DATA_"+toString(i)+") sll CONV_INTEGER(shift_"+toString(i)+"));");27 vhdl->set_body ("shift_logic_left_"+toString(i)+" <= TO_STDLOGICVECTOR(TO_BITVECTOR(in_SHIFTER_"+toString(i)+"_DATA) sll CONV_INTEGER(shift_"+toString(i)+"));"); 28 28 //-----[ Shift logic Right ]------------------------------------------- 29 29 if (_param._have_shift_logic_right) 30 vhdl .set_body ("shift_logic_right_"+toString(i)+" <= TO_STDLOGICVECTOR(TO_BITVECTOR(in_SHIFTER_DATA_"+toString(i)+") srl CONV_INTEGER(shift_"+toString(i)+"));");30 vhdl->set_body ("shift_logic_right_"+toString(i)+" <= TO_STDLOGICVECTOR(TO_BITVECTOR(in_SHIFTER_"+toString(i)+"_DATA) srl CONV_INTEGER(shift_"+toString(i)+"));"); 31 31 //-----[ Shift arithmetic Left ]--------------------------------------- 32 32 if (_param._have_shift_arithmetic_left) 33 vhdl .set_body ("shift_arithmetic_left_"+toString(i)+" <= TO_STDLOGICVECTOR(TO_BITVECTOR(in_SHIFTER_DATA_"+toString(i)+") sla CONV_INTEGER(shift_"+toString(i)+"));");33 vhdl->set_body ("shift_arithmetic_left_"+toString(i)+" <= TO_STDLOGICVECTOR(TO_BITVECTOR(in_SHIFTER_"+toString(i)+"_DATA) sla CONV_INTEGER(shift_"+toString(i)+"));"); 34 34 //-----[ Shift arithmetic Right ]-------------------------------------- 35 35 if (_param._have_shift_arithmetic_right) 36 vhdl .set_body ("shift_arithmetic_right_"+toString(i)+" <= TO_STDLOGICVECTOR(TO_BITVECTOR(in_SHIFTER_DATA_"+toString(i)+") sra CONV_INTEGER(shift_"+toString(i)+"));");36 vhdl->set_body ("shift_arithmetic_right_"+toString(i)+" <= TO_STDLOGICVECTOR(TO_BITVECTOR(in_SHIFTER_"+toString(i)+"_DATA) sra CONV_INTEGER(shift_"+toString(i)+"));"); 37 37 //-----[ Rotate Left ]------------------------------------------------- 38 38 if (_param._have_rotate_left) 39 vhdl .set_body ("rotate_left_"+toString(i)+" <= TO_STDLOGICVECTOR(TO_BITVECTOR(in_SHIFTER_DATA_"+toString(i)+") rol CONV_INTEGER(shift_"+toString(i)+"));");39 vhdl->set_body ("rotate_left_"+toString(i)+" <= TO_STDLOGICVECTOR(TO_BITVECTOR(in_SHIFTER_"+toString(i)+"_DATA) rol CONV_INTEGER(shift_"+toString(i)+"));"); 40 40 //-----[ Rotate Right ]------------------------------------------------ 41 41 if (_param._have_rotate_right) 42 vhdl .set_body ("rotate_right_"+toString(i)+" <= TO_STDLOGICVECTOR(TO_BITVECTOR(in_SHIFTER_DATA_"+toString(i)+") ror CONV_INTEGER(shift_"+toString(i)+"));");42 vhdl->set_body ("rotate_right_"+toString(i)+" <= TO_STDLOGICVECTOR(TO_BITVECTOR(in_SHIFTER_"+toString(i)+"_DATA) ror CONV_INTEGER(shift_"+toString(i)+"));"); 43 43 } 44 44 45 45 if (_param._size_data_completion > 0) 46 46 { 47 vhdl .set_body ("");48 vhdl .set_body ("-- Mask");47 vhdl->set_body (""); 48 vhdl->set_body ("-- Mask"); 49 49 50 50 for (uint32_t i=0; i<_param._nb_port; i++) … … 53 53 54 54 if (_param._type_completion_bool == true) 55 print_shifter_completion = "in_SHIFTER_ CARRY_IN";55 print_shifter_completion = "in_SHIFTER_"+toString(i)+"_CARRY_IN"; 56 56 else 57 print_shifter_completion = "in_SHIFTER_ COMPLETION";57 print_shifter_completion = "in_SHIFTER_"+toString(i)+"_COMPLETION"; 58 58 59 59 if (_param._size_data == _param._size_data_completion) 60 60 { 61 vhdl .set_body ("shifter_completion_left_"+toString(i)+" <= "+print_shifter_completion+"_"+toString(i)+";");62 vhdl .set_body ("shifter_completion_right_"+toString(i)+" <= "+print_shifter_completion+"_"+toString(i)+";");61 vhdl->set_body ("shifter_completion_left_"+toString(i)+" <= "+print_shifter_completion+";"); 62 vhdl->set_body ("shifter_completion_right_"+toString(i)+" <= "+print_shifter_completion+";"); 63 63 } 64 64 else 65 65 { 66 vhdl .set_body ("shifter_completion_left_"+toString(i)+std_logic_range(_param._size_data-1,_param._size_data_completion)+" <= "+std_logic_others(_param._size_data-_param._size_data_completion,0)+";");67 vhdl .set_body ("shifter_completion_left_"+toString(i)+std_logic_range(_param._size_data_completion )+" <= "+print_shifter_completion+"_"+toString(i)+";");68 69 vhdl .set_body ("shifter_completion_right_"+toString(i)+std_logic_range(_param._size_data-1,_param._size_data-_param._size_data_completion)+" <= "+print_shifter_completion+"_"+toString(i)+";");70 vhdl .set_body ("shifter_completion_right_"+toString(i)+std_logic_range(_param._size_data-_param._size_data_completion )+" <= "+std_logic_others(_param._size_data-_param._size_data_completion,0)+";");71 } 72 73 vhdl .set_body ("mask_completion_left_"+toString(i)+" <= TO_STDLOGICVECTOR(TO_BITVECTOR(cst_completion) sll CONV_INTEGER(shift_"+toString(i)+"));");74 vhdl .set_body ("mask_completion_right_"+toString(i)+" <= TO_STDLOGICVECTOR(TO_BITVECTOR(cst_completion) srl CONV_INTEGER(shift_"+toString(i)+"));");66 vhdl->set_body ("shifter_completion_left_"+toString(i)+std_logic_range(_param._size_data-1,_param._size_data_completion)+" <= "+std_logic_others(_param._size_data-_param._size_data_completion,0)+";"); 67 vhdl->set_body ("shifter_completion_left_"+toString(i)+std_logic_range(_param._size_data_completion )+" <= "+print_shifter_completion+";"); 68 69 vhdl->set_body ("shifter_completion_right_"+toString(i)+std_logic_range(_param._size_data-1,_param._size_data-_param._size_data_completion)+" <= "+print_shifter_completion+";"); 70 vhdl->set_body ("shifter_completion_right_"+toString(i)+std_logic_range(_param._size_data-_param._size_data_completion )+" <= "+std_logic_others(_param._size_data-_param._size_data_completion,0)+";"); 71 } 72 73 vhdl->set_body ("mask_completion_left_"+toString(i)+" <= TO_STDLOGICVECTOR(TO_BITVECTOR(cst_completion) sll CONV_INTEGER(shift_"+toString(i)+"));"); 74 vhdl->set_body ("mask_completion_right_"+toString(i)+" <= TO_STDLOGICVECTOR(TO_BITVECTOR(cst_completion) srl CONV_INTEGER(shift_"+toString(i)+"));"); 75 75 } 76 76 } 77 77 78 78 79 vhdl .set_body ("");80 vhdl .set_body ("-- Multiplexor");79 vhdl->set_body (""); 80 vhdl->set_body ("-- Multiplexor"); 81 81 82 82 for (uint32_t i=0; i<_param._nb_port; i++) 83 83 { 84 vhdl .set_body ("out_SHIFTER_DATA_"+toString(i)+"<=");84 vhdl->set_body ("out_SHIFTER_"+toString(i)+"_DATA <="); 85 85 string print_else = " "; 86 86 … … 95 95 { 96 96 have_when = true; 97 print_when += " in_SHIFTER_ DIRECTION_"+toString(i)+"= cst_is_direction_left ";98 print_and = " and "; 99 } 100 if (_param._rotate == external_rotate) 101 { 102 have_when = true; 103 print_when += print_and+" in_SHIFTER_ TYPE_"+toString(i)+"= cst_is_type_shift ";97 print_when += " in_SHIFTER_"+toString(i)+"_DIRECTION = cst_is_direction_left "; 98 print_and = " and "; 99 } 100 if (_param._rotate == external_rotate) 101 { 102 have_when = true; 103 print_when += print_and+" in_SHIFTER_"+toString(i)+"_TYPE = cst_is_type_shift "; 104 104 print_and = " and "; 105 105 } … … 107 107 { 108 108 have_when = true; 109 print_when += print_and+" in_SHIFTER_ CARRY_"+toString(i)+"= cst_is_carry_arithmetic";110 } 111 112 if (have_when) 113 print_when = "when " + print_when; 114 115 vhdl .set_body ("\t"+print_else+" shift_arithmetic_left_"+toString(i)+" "+print_when);109 print_when += print_and+" in_SHIFTER_"+toString(i)+"_CARRY = cst_is_carry_arithmetic"; 110 } 111 112 if (have_when) 113 print_when = "when " + print_when; 114 115 vhdl->set_body ("\t"+print_else+" shift_arithmetic_left_"+toString(i)+" "+print_when); 116 116 print_else = "else"; 117 117 } … … 126 126 { 127 127 have_when = true; 128 print_when += " in_SHIFTER_ DIRECTION_"+toString(i)+"= cst_is_direction_right";129 print_and = " and "; 130 } 131 if (_param._rotate == external_rotate) 132 { 133 have_when = true; 134 print_when += print_and+" in_SHIFTER_ TYPE_"+toString(i)+"= cst_is_type_shift ";128 print_when += " in_SHIFTER_"+toString(i)+"_DIRECTION = cst_is_direction_right"; 129 print_and = " and "; 130 } 131 if (_param._rotate == external_rotate) 132 { 133 have_when = true; 134 print_when += print_and+" in_SHIFTER_"+toString(i)+"_TYPE = cst_is_type_shift "; 135 135 print_and = " and "; 136 136 } … … 138 138 { 139 139 have_when = true; 140 print_when += print_and+" in_SHIFTER_ CARRY_"+toString(i)+"= cst_is_carry_arithmetic";141 } 142 143 if (have_when) 144 print_when = "when " + print_when; 145 146 vhdl .set_body ("\t"+print_else+" shift_arithmetic_right_"+toString(i)+" "+print_when);140 print_when += print_and+" in_SHIFTER_"+toString(i)+"_CARRY = cst_is_carry_arithmetic"; 141 } 142 143 if (have_when) 144 print_when = "when " + print_when; 145 146 vhdl->set_body ("\t"+print_else+" shift_arithmetic_right_"+toString(i)+" "+print_when); 147 147 print_else = "else"; 148 148 } … … 157 157 { 158 158 have_when = true; 159 print_when += " in_SHIFTER_ DIRECTION_"+toString(i)+"= cst_is_direction_left ";160 print_and = " and "; 161 } 162 if (_param._rotate == external_rotate) 163 { 164 have_when = true; 165 print_when += print_and+" in_SHIFTER_ TYPE_"+toString(i)+"= cst_is_type_shift ";159 print_when += " in_SHIFTER_"+toString(i)+"_DIRECTION = cst_is_direction_left "; 160 print_and = " and "; 161 } 162 if (_param._rotate == external_rotate) 163 { 164 have_when = true; 165 print_when += print_and+" in_SHIFTER_"+toString(i)+"_TYPE = cst_is_type_shift "; 166 166 print_and = " and "; 167 167 } … … 169 169 { 170 170 have_when = true; 171 print_when += print_and+" in_SHIFTER_ CARRY_"+toString(i)+"= cst_is_carry_logic ";171 print_when += print_and+" in_SHIFTER_"+toString(i)+"_CARRY = cst_is_carry_logic "; 172 172 } 173 173 … … 182 182 print_expr_completion = "(shift_logic_left_"+toString(i)+" and mask_completion_left_"+toString(i)+" ) or ( shifter_completion_left_"+toString(i)+" and not mask_completion_left_"+toString(i)+" )"; 183 183 184 vhdl .set_body ("\t"+print_else+" "+print_expr_completion+" "+print_when);184 vhdl->set_body ("\t"+print_else+" "+print_expr_completion+" "+print_when); 185 185 print_else = "else"; 186 186 } … … 195 195 { 196 196 have_when = true; 197 print_when += " in_SHIFTER_ DIRECTION_"+toString(i)+"= cst_is_direction_right";198 print_and = " and "; 199 } 200 if (_param._rotate == external_rotate) 201 { 202 have_when = true; 203 print_when += print_and+" in_SHIFTER_ TYPE_"+toString(i)+"= cst_is_type_shift ";197 print_when += " in_SHIFTER_"+toString(i)+"_DIRECTION = cst_is_direction_right"; 198 print_and = " and "; 199 } 200 if (_param._rotate == external_rotate) 201 { 202 have_when = true; 203 print_when += print_and+" in_SHIFTER_"+toString(i)+"_TYPE = cst_is_type_shift "; 204 204 print_and = " and "; 205 205 } … … 207 207 { 208 208 have_when = true; 209 print_when += print_and+" in_SHIFTER_ CARRY_"+toString(i)+"= cst_is_carry_logic ";209 print_when += print_and+" in_SHIFTER_"+toString(i)+"_CARRY = cst_is_carry_logic "; 210 210 } 211 211 … … 220 220 print_expr_completion = "(shift_logic_right_"+toString(i)+" and mask_completion_right_"+toString(i)+") or ( shifter_completion_right_"+toString(i)+" and not mask_completion_right_"+toString(i)+")"; 221 221 222 vhdl .set_body ("\t"+print_else+" "+print_expr_completion+" "+print_when);222 vhdl->set_body ("\t"+print_else+" "+print_expr_completion+" "+print_when); 223 223 print_else = "else"; 224 224 } … … 233 233 { 234 234 have_when = true; 235 print_when += " in_SHIFTER_ DIRECTION_"+toString(i)+"= cst_is_direction_left ";236 print_and = " and "; 237 } 238 if (_param._rotate == external_rotate) 239 { 240 have_when = true; 241 print_when += print_and+" in_SHIFTER_ TYPE_"+toString(i)+"= cst_is_type_rotate";242 print_and = " and "; 243 } 244 245 if (have_when) 246 print_when = "when " + print_when; 247 248 vhdl .set_body ("\t"+print_else+" rotate_left_"+toString(i)+" "+print_when);235 print_when += " in_SHIFTER_"+toString(i)+"_DIRECTION = cst_is_direction_left "; 236 print_and = " and "; 237 } 238 if (_param._rotate == external_rotate) 239 { 240 have_when = true; 241 print_when += print_and+" in_SHIFTER_"+toString(i)+"_TYPE = cst_is_type_rotate"; 242 print_and = " and "; 243 } 244 245 if (have_when) 246 print_when = "when " + print_when; 247 248 vhdl->set_body ("\t"+print_else+" rotate_left_"+toString(i)+" "+print_when); 249 249 print_else = "else"; 250 250 } … … 259 259 { 260 260 have_when = true; 261 print_when += " in_SHIFTER_ DIRECTION_"+toString(i)+"= cst_is_direction_right";262 print_and = " and "; 263 } 264 if (_param._rotate == external_rotate) 265 { 266 have_when = true; 267 print_when += print_and+" in_SHIFTER_ TYPE_"+toString(i)+"= cst_is_type_rotate";268 print_and = " and "; 269 } 270 271 if (have_when) 272 print_when = "when " + print_when; 273 274 vhdl .set_body ("\t"+print_else+" rotate_right_"+toString(i)+" "+print_when);275 print_else = "else"; 276 } 277 vhdl .set_body (";");261 print_when += " in_SHIFTER_"+toString(i)+"_DIRECTION = cst_is_direction_right"; 262 print_and = " and "; 263 } 264 if (_param._rotate == external_rotate) 265 { 266 have_when = true; 267 print_when += print_and+" in_SHIFTER_"+toString(i)+"_TYPE = cst_is_type_rotate"; 268 print_and = " and "; 269 } 270 271 if (have_when) 272 print_when = "when " + print_when; 273 274 vhdl->set_body ("\t"+print_else+" rotate_right_"+toString(i)+" "+print_when); 275 print_else = "else"; 276 } 277 vhdl->set_body (";"); 278 278 } 279 279
Note: See TracChangeset
for help on using the changeset viewer.