Changeset 135 for trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Rename_unit/Register_translation_unit/Stat_List_unit/src/Stat_List_unit_vhdl_body.cpp
- Timestamp:
- Jul 17, 2009, 10:59:05 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Rename_unit/Register_translation_unit/Stat_List_unit/src/Stat_List_unit_vhdl_body.cpp
r81 r135 24 24 { 25 25 log_printf(FUNC,Stat_List_unit,FUNCTION,"Begin"); 26 vhdl->set_body (""); 26 27 uint32_t size_bank = log2(_param->_nb_bank); 28 uint32_t size_gpr_ptr = log2(_param->_nb_general_register_by_bank); 29 uint32_t size_spr_ptr = log2(_param->_nb_special_register_by_bank); 30 31 uint32_t LSB_gpr_num_reg = 0; 32 uint32_t MSB_gpr_num_reg = log2(_param->_nb_general_register_by_bank) - 1; 33 uint32_t LSB_gpr_num_bank = MSB_gpr_num_reg+1; 34 uint32_t MSB_gpr_num_bank = _param->_size_general_register -1 ; 35 36 uint32_t LSB_spr_num_reg = 0; 37 uint32_t MSB_spr_num_reg = log2(_param->_nb_special_register_by_bank) - 1; 38 uint32_t LSB_spr_num_bank = MSB_spr_num_reg+1; 39 uint32_t MSB_spr_num_bank = _param->_size_special_register -1; 40 41 42 vhdl->set_comment(0,"====================================================="); 43 vhdl->set_comment(0,"=====[ CONSTANT ]===================================="); 44 vhdl->set_comment(0,"====================================================="); 45 46 for (uint32_t j=0; j<_param->_nb_inst_insert; j++) 47 vhdl->set_body (0,"internal_INSERT_"+toString(j)+"_ACK <= '1';"); 48 49 for (uint32_t j=0; j<_param->_nb_inst_insert; j++) 50 vhdl->set_body (0," out_INSERT_"+toString(j)+"_ACK <= internal_INSERT_"+toString(j)+"_ACK;"); 51 52 for (uint32_t j=0; j<_param->_nb_inst_retire; j++) 53 vhdl->set_body (0,"internal_RETIRE_"+toString(j)+"_ACK <= '1';"); 54 55 for (uint32_t j=0; j<_param->_nb_inst_retire; j++) 56 vhdl->set_body (0," out_RETIRE_"+toString(j)+"_ACK <= internal_RETIRE_"+toString(j)+"_ACK;"); 57 58 59 vhdl->set_body (0,""); 60 vhdl->set_body (0,"transition: process (in_CLOCK)"); 61 62 // vhdl->set_body (0,"variable gpr_stat_list_next : Tstat_list_gpr;"); 63 // vhdl->set_body (0,"variable spr_stat_list_next : Tstat_list_spr;"); 64 65 vhdl->set_body (0,"begin -- process transition"); 66 vhdl->set_body (1,"if in_CLOCK'event and in_CLOCK = '1' then"); 67 vhdl->set_body (2,"if in_NRESET = '0' then"); 68 69 uint32_t gpr = 0; 70 uint32_t spr = 0; 71 72 vhdl->set_comment(3,"Init Stat List"); 73 vhdl->set_comment(3,"xxx_stat_list : "); 74 75 vhdl->set_comment(3," [0] is_free"); 76 vhdl->set_comment(3," [1] is_link"); 77 78 vhdl->set_body (3,""); 79 vhdl->set_comment(3,"gpr_stat_list"); 80 vhdl->set_body (3,""); 81 for (uint32_t i=0; i<_param->_nb_bank; i++) 82 for (uint32_t j=0; j<_param->_nb_general_register_by_bank; j++) 83 if ((gpr++)<_param->_nb_gpr_use_init) 84 { 85 vhdl->set_body (3,"gpr_stat_list("+toString(i)+")("+toString(j)+")<=\"10\";"); 86 } 87 else 88 { 89 vhdl->set_body (3,"gpr_stat_list("+toString(i)+")("+toString(j)+")<=\"00\";"); 90 } 91 92 vhdl->set_body (3,""); 93 vhdl->set_comment(3,"spr_stat_list"); 94 vhdl->set_body (3,""); 95 for (uint32_t i=0; i<_param->_nb_bank; i++) 96 for (uint32_t j=0; j<_param->_nb_special_register_by_bank; j++) 97 if ((spr++)<_param->_nb_spr_use_init) 98 { 99 vhdl->set_body (3,"spr_stat_list("+toString(i)+")("+toString(j)+")<=\"10\";"); 100 } 101 else 102 { 103 vhdl->set_body (3,"spr_stat_list("+toString(i)+")("+toString(j)+")<=\"00\";"); 104 } 105 106 vhdl->set_body (3,""); 107 vhdl->set_comment(3,"Init Pointer"); 108 109 #ifdef SYSTEMC_VHDL_COMPATIBILITY 110 if (size_gpr_ptr>0) 111 vhdl->set_body (3,"reg_GPR_PTR_FREE <= "+std_logic_cst(size_gpr_ptr,1)+";"); 112 if (size_spr_ptr>0) 113 vhdl->set_body (3,"reg_SPR_PTR_FREE <= "+std_logic_cst(size_spr_ptr,1)+";"); 114 #else 115 if (size_gpr_ptr>0) 116 vhdl->set_body (3,"reg_GPR_PTR_FREE <= "+std_logic_cst(size_gpr_ptr,0)+";"); 117 if (size_spr_ptr>0) 118 vhdl->set_body (3,"reg_SPR_PTR_FREE <= "+std_logic_cst(size_spr_ptr,0)+";"); 119 #endif 120 121 vhdl->set_body (2,"else"); // in_CLOCK'event and in_CLOCK = '1' 122 123 // vhdl->set_body (2,"gpr_stat_list_next := gpr_stat_list;"); 124 // vhdl->set_body (2,"spr_stat_list_next := spr_stat_list;"); 125 126 vhdl->set_comment(3,"====================================================="); 127 vhdl->set_comment(3,"=====[ INSERT ]======================================"); 128 vhdl->set_comment(3,"====================================================="); 129 130 for (uint32_t i=0; i<_param->_nb_inst_insert; i++) 131 { 132 vhdl->set_body (3,"if ((in_INSERT_"+toString(i)+"_VAL and internal_INSERT_"+toString(i)+"_ACK) = '1') then"); 133 134 { 135 vhdl->set_body (4,"if (in_INSERT_"+toString(i)+"_WRITE_RD = '1') then"); 136 std::string port = "in_INSERT_"+toString(i)+"_NUM_REG_RD_PHY_NEW"; 137 std::string num_bank = (size_bank >0)?("conv_integer("+port+std_logic_range(MSB_gpr_num_bank,LSB_gpr_num_bank)+")"):"0"; 138 std::string num_reg = (size_gpr_ptr>0)?("conv_integer("+port+std_logic_range(MSB_gpr_num_reg ,LSB_gpr_num_reg )+")"):"0"; 139 std::string addr = "("+num_bank+")("+num_reg+")"; 140 141 vhdl->set_body (5,"gpr_stat_list"+addr+" <= \"10\";"); 142 vhdl->set_body (4,"end if;"); // write_rd 143 } 144 145 { 146 vhdl->set_body (4,"if (in_INSERT_"+toString(i)+"_WRITE_RE = '1') then"); 147 std::string port = "in_INSERT_"+toString(i)+"_NUM_REG_RE_PHY_NEW"; 148 std::string num_bank = (size_bank >0)?("conv_integer("+port+std_logic_range(MSB_spr_num_bank,LSB_spr_num_bank)+")"):"0"; 149 std::string num_reg = (size_spr_ptr>0)?("conv_integer("+port+std_logic_range(MSB_spr_num_reg ,LSB_spr_num_reg )+")"):"0"; 150 std::string addr = "("+num_bank+")("+num_reg+")"; 151 vhdl->set_body (5,"spr_stat_list"+addr+" <= \"10\";"); 152 vhdl->set_body (4,"end if;"); // write_re 153 } 154 155 vhdl->set_body (3,"end if;"); // transaction insert 156 } 157 158 vhdl->set_comment(3,"====================================================="); 159 vhdl->set_comment(3,"=====[ RETIRE ]======================================"); 160 vhdl->set_comment(3,"====================================================="); 161 162 for (uint32_t i=0; i<_param->_nb_inst_retire; i++) 163 { 164 vhdl->set_body (3,"if ((in_RETIRE_"+toString(i)+"_VAL and internal_RETIRE_"+toString(i)+"_ACK) = '1') then"); 165 166 std::string restore = "in_RETIRE_"+toString(i)+"_RESTORE"; 167 168 // write rd 169 vhdl->set_body (4,"if (in_RETIRE_"+toString(i)+"_WRITE_RD = '1') then"); 170 { 171 std::string restore_old = "in_RETIRE_"+toString(i)+"_RESTORE_RD_PHY_OLD"; 172 173 { 174 std::string port = "in_RETIRE_"+toString(i)+"_NUM_REG_RD_PHY_OLD"; 175 std::string num_bank = (size_bank >0)?("conv_integer("+port+std_logic_range(MSB_gpr_num_bank,LSB_gpr_num_bank)+")"):"0"; 176 std::string num_reg = (size_gpr_ptr>0)?("conv_integer("+port+std_logic_range(MSB_gpr_num_reg ,LSB_gpr_num_reg )+")"):"0"; 177 std::string addr = "("+num_bank+")("+num_reg+")"; 178 vhdl->set_body (5,"gpr_stat_list"+addr+"(1) <= "+restore+" and "+restore_old+";"); 179 } 180 181 { 182 std::string port = "in_RETIRE_"+toString(i)+"_NUM_REG_RD_PHY_NEW"; 183 std::string num_bank = (size_bank >0)?("conv_integer("+port+std_logic_range(MSB_gpr_num_bank,LSB_gpr_num_bank)+")"):"0"; 184 std::string num_reg = (size_gpr_ptr>0)?("conv_integer("+port+std_logic_range(MSB_gpr_num_reg ,LSB_gpr_num_reg )+")"):"0"; 185 std::string addr = "("+num_bank+")("+num_reg+")"; 186 187 vhdl->set_body (5,"if ("+restore+" = '1') then"); 188 vhdl->set_body (5,"gpr_stat_list"+addr+"(1) <= '0';"); 189 vhdl->set_body (5,"end if;"); // write_rd 190 } 191 } 192 193 vhdl->set_body (4,"end if;"); // write_rd 194 195 // write re 196 vhdl->set_body (4,"if (in_RETIRE_"+toString(i)+"_WRITE_RE = '1') then"); 197 { 198 std::string restore_old = "in_RETIRE_"+toString(i)+"_RESTORE_RE_PHY_OLD"; 199 200 { 201 std::string port = "in_RETIRE_"+toString(i)+"_NUM_REG_RE_PHY_OLD"; 202 std::string num_bank = (size_bank >0)?("conv_integer("+port+std_logic_range(MSB_spr_num_bank,LSB_spr_num_bank)+")"):"0"; 203 std::string num_reg = (size_spr_ptr>0)?("conv_integer("+port+std_logic_range(MSB_spr_num_reg ,LSB_spr_num_reg )+")"):"0"; 204 std::string addr = "("+num_bank+")("+num_reg+")"; 205 vhdl->set_body (5,"spr_stat_list"+addr+"(1) <= "+restore+" and "+restore_old+";"); 206 } 207 208 { 209 std::string port = "in_RETIRE_"+toString(i)+"_NUM_REG_RE_PHY_NEW"; 210 std::string num_bank = (size_bank >0)?("conv_integer("+port+std_logic_range(MSB_spr_num_bank,LSB_spr_num_bank)+")"):"0"; 211 std::string num_reg = (size_spr_ptr>0)?("conv_integer("+port+std_logic_range(MSB_spr_num_reg ,LSB_spr_num_reg )+")"):"0"; 212 std::string addr = "("+num_bank+")("+num_reg+")"; 213 214 vhdl->set_body (5,"if ("+restore+" = '1') then"); 215 vhdl->set_body (5,"spr_stat_list"+addr+"(1) <= '0';"); 216 vhdl->set_body (5,"end if;"); // write_re 217 } 218 } 219 220 vhdl->set_body (4,"end if;"); // write_re 221 vhdl->set_body (3,"end if;"); // transaction retire 222 } 223 224 for (uint32_t i=0; i<_param->_nb_reg_free; i++) 225 { 226 { 227 vhdl->set_comment(3,"====================================================="); 228 vhdl->set_comment(3,"=====[ PUSH_GPR ]===================================="); 229 vhdl->set_comment(3,"====================================================="); 230 vhdl->set_body (3,"if ((internal_PUSH_GPR_"+toString(i)+"_VAL and in_PUSH_GPR_"+toString(i)+"_ACK) = '1') then"); 231 232 std::string num_bank = (size_bank >0)?("conv_integer(internal_PUSH_GPR_"+toString(i)+"_NUM_BANK)"):"0"; 233 std::string num_reg = (size_gpr_ptr>0)?("conv_integer(internal_PUSH_GPR_"+toString(i)+"_NUM_REG )"):"0"; 234 std::string addr = "("+num_bank+")("+num_reg+")"; 235 236 vhdl->set_body (4,"gpr_stat_list"+addr+"(0) <= '1';"); 237 vhdl->set_body (3,"end if;"); 238 } 239 240 { 241 vhdl->set_comment(3,"====================================================="); 242 vhdl->set_comment(3,"=====[ PUSH_SPR ]===================================="); 243 vhdl->set_comment(3,"====================================================="); 244 vhdl->set_body (3,"if ((internal_PUSH_SPR_"+toString(i)+"_VAL and in_PUSH_SPR_"+toString(i)+"_ACK) = '1') then"); 245 246 std::string num_bank = (size_bank >0)?("conv_integer(internal_PUSH_SPR_"+toString(i)+"_NUM_BANK)"):"0"; 247 std::string num_reg = (size_spr_ptr>0)?("conv_integer(internal_PUSH_SPR_"+toString(i)+"_NUM_REG )"):"0"; 248 std::string addr = "("+num_bank+")("+num_reg+")"; 249 250 vhdl->set_body (4,"spr_stat_list"+addr+"(0) <= '1';"); 251 vhdl->set_body (3,"end if;"); 252 } 253 } 254 255 vhdl->set_comment(3,"====================================================="); 256 vhdl->set_comment(3,"=====[ POINTER ]====================================="); 257 vhdl->set_comment(3,"====================================================="); 258 259 if (size_gpr_ptr>0) 260 { 261 if (is_power2(_param->_nb_general_register_by_bank)) 262 { 263 if (size_gpr_ptr == 1) 264 vhdl->set_body (3,"reg_GPR_PTR_FREE <= not reg_GPR_PTR_FREE;"); 265 else 266 vhdl->set_body (3,"reg_GPR_PTR_FREE <= reg_GPR_PTR_FREE - "+std_logic_cst(size_gpr_ptr,1)+";"); 267 } 268 else 269 { 270 throw ERRORMORPHEO(FUNCTION,_(" No Yet Supported : the Number of GPR must a power of 2.")); 271 } 272 } 273 274 if (size_spr_ptr>0) 275 { 276 if (is_power2(_param->_nb_special_register_by_bank)) 277 { 278 if (size_spr_ptr == 1) 279 vhdl->set_body (3,"reg_SPR_PTR_FREE <= not reg_SPR_PTR_FREE;"); 280 else 281 vhdl->set_body (3,"reg_SPR_PTR_FREE <= reg_SPR_PTR_FREE - "+std_logic_cst(size_spr_ptr,1)+";"); 282 } 283 else 284 { 285 throw ERRORMORPHEO(FUNCTION,_(" No Yet Supported : the Number of SPR must a power of 2.")); 286 } 287 } 288 289 vhdl->set_body (2,"end if;"); // in_CLOCK'event and in_CLOCK = '1' 290 vhdl->set_body (1,"end if;"); // if in_NRESET = '0' 291 vhdl->set_body (0,"end process transition;"); 292 293 { 294 vhdl->set_body (0,""); 295 vhdl->set_comment(0,"====================================================="); 296 vhdl->set_comment(0,"=====[ PUSH_GPR ]===================================="); 297 vhdl->set_comment(0,"====================================================="); 298 vhdl->set_body (0,""); 299 300 for (uint32_t i=0; i<_param->_nb_reg_free; i++) 301 { 302 uint32_t offset = i*_param->_nb_bank_by_port_free; 303 std::string address; 304 305 if (size_gpr_ptr > 0) 306 { 307 address = "internal_PUSH_GPR_"+toString(i)+"_NUM_REG"; 308 vhdl->set_body (0,"internal_PUSH_GPR_"+toString(i)+"_NUM_REG <= reg_GPR_PTR_FREE;"); 309 } 310 else 311 { 312 address = "0"; 313 } 314 315 vhdl->set_body (0,"internal_PUSH_GPR_"+toString(i)+"_VAL <= '1' when"); 316 vhdl->set_body (1,"false"); 317 318 for (uint32_t j=0; j<_param->_nb_bank_by_port_free; j++) 319 { 320 std::string num_bank = toString(offset+j); 321 std::string num_reg = "conv_integer("+address+")"; 322 std::string addr = "("+num_bank+")("+num_reg+")"; 323 324 vhdl->set_body (1,"or (gpr_stat_list"+addr+" = \"00\")"); 325 } 326 vhdl->set_body (1,"else '0';"); 327 328 if (size_bank > 0) 329 { 330 vhdl->set_body (0,"internal_PUSH_GPR_"+toString(i)+"_NUM_BANK <= "); 331 for (uint32_t j=0; j<_param->_nb_bank_by_port_free-1; j++) 332 { 333 uint32_t _num_bank = offset+j; 334 std::string num_bank = toString(_num_bank); 335 std::string num_reg = "conv_integer("+address+")"; 336 std::string addr = "("+num_bank+")("+num_reg+")"; 337 338 vhdl->set_body (1,std_logic_cst(size_bank,_num_bank)+" when (gpr_stat_list"+addr+" = \"00\") else"); 339 } 340 vhdl->set_body (1,std_logic_cst(size_bank,offset+_param->_nb_bank_by_port_free-1)+";"); 341 } 342 343 vhdl->set_body (0,"out_PUSH_GPR_"+toString(i)+"_VAL <= internal_PUSH_GPR_"+toString(i)+"_VAL;"); 344 345 if (is_power2(_param->_nb_general_register_by_bank)) 346 { 347 std::string num_bank = (size_bank > 0)?("internal_PUSH_GPR_"+toString(i)+"_NUM_BANK"):""; 348 std::string num_reg = (size_gpr_ptr > 0)?address:""; 349 std::string conc = ((size_gpr_ptr*size_bank) > 0)?" & ":""; 350 351 vhdl->set_body (0,"out_PUSH_GPR_"+toString(i)+"_NUM_REG <= "+num_bank+conc+num_reg+";"); 352 } 353 else 354 { 355 throw ERRORMORPHEO(FUNCTION,_(" No Yet Supported : the Number of GPR must a power of 2.")); 356 } 357 } 358 } 359 360 361 { 362 vhdl->set_body (0,""); 363 vhdl->set_comment(0,"====================================================="); 364 vhdl->set_comment(0,"=====[ PUSH_SPR ]===================================="); 365 vhdl->set_comment(0,"====================================================="); 366 vhdl->set_body (0,""); 367 368 for (uint32_t i=0; i<_param->_nb_reg_free; i++) 369 { 370 uint32_t offset = i*_param->_nb_bank_by_port_free; 371 std::string address; 372 373 if (size_spr_ptr > 0) 374 { 375 address = "internal_PUSH_SPR_"+toString(i)+"_NUM_REG"; 376 vhdl->set_body (0,"internal_PUSH_SPR_"+toString(i)+"_NUM_REG <= reg_SPR_PTR_FREE;"); 377 } 378 else 379 { 380 address = "0"; 381 } 382 383 vhdl->set_body (0,"internal_PUSH_SPR_"+toString(i)+"_VAL <= '1' when"); 384 vhdl->set_body (1,"false"); 385 386 for (uint32_t j=0; j<_param->_nb_bank_by_port_free; j++) 387 { 388 std::string num_bank = toString(offset+j); 389 std::string num_reg = "conv_integer("+address+")"; 390 std::string addr = "("+num_bank+")("+num_reg+")"; 391 392 vhdl->set_body (1,"or (spr_stat_list"+addr+" = \"00\")"); 393 } 394 vhdl->set_body (1,"else '0';"); 395 396 if (size_bank > 0) 397 { 398 vhdl->set_body (0,"internal_PUSH_SPR_"+toString(i)+"_NUM_BANK <= "); 399 for (uint32_t j=0; j<_param->_nb_bank_by_port_free-1; j++) 400 { 401 uint32_t _num_bank = offset+j; 402 std::string num_bank = toString(_num_bank); 403 std::string num_reg = "conv_integer("+address+")"; 404 std::string addr = "("+num_bank+")("+num_reg+")"; 405 406 vhdl->set_body (1,std_logic_cst(size_bank,_num_bank)+" when (spr_stat_list"+addr+" = \"00\") else"); 407 } 408 vhdl->set_body (1,std_logic_cst(size_bank,offset+_param->_nb_bank_by_port_free-1)+";"); 409 } 410 411 vhdl->set_body (0,"out_PUSH_SPR_"+toString(i)+"_VAL <= internal_PUSH_SPR_"+toString(i)+"_VAL;"); 412 413 if (is_power2(_param->_nb_special_register_by_bank)) 414 { 415 std::string num_bank = (size_bank > 0)?("internal_PUSH_SPR_"+toString(i)+"_NUM_BANK"):""; 416 std::string num_reg = (size_spr_ptr > 0)?address:""; 417 std::string conc = ((size_spr_ptr*size_bank) > 0)?" & ":""; 418 419 vhdl->set_body (0,"out_PUSH_SPR_"+toString(i)+"_NUM_REG <= "+num_bank+conc+num_reg+";"); 420 } 421 else 422 { 423 throw ERRORMORPHEO(FUNCTION,_(" No Yet Supported : the Number of SPR must a power of 2.")); 424 } 425 } 426 } 427 27 428 log_printf(FUNC,Stat_List_unit,FUNCTION,"End"); 28 429 };
Note: See TracChangeset
for help on using the changeset viewer.