| 433 | |
| 434 | |
| 435 | bool cHardwareBCR::SingleProcess(cAvidaContext& ctx, bool speculative) |
| 436 | { |
| 437 | // If speculatively stalled, stay that way until a real instruction comes |
| 438 | if (speculative && m_spec_stall) return false; |
| 439 | |
| 440 | |
| 441 | // Mark this organism as running... |
| 442 | m_organism->SetRunning(true); |
| 443 | |
| 444 | |
| 445 | // Handle if this organism died while speculatively executing |
| 446 | if (!speculative && m_spec_die) { |
| 447 | m_organism->Die(ctx); |
| 448 | m_organism->SetRunning(false); |
| 449 | return false; |
| 450 | } |
| 451 | |
| 452 | |
| 453 | cPhenotype& phenotype = m_organism->GetPhenotype(); |
| 454 | |
| 455 | |
| 456 | if (m_spec_stall) { |
| 457 | m_spec_stall = false; |
| 458 | } else { |
| 459 | // Update cycle counts |
| 460 | m_cycle_count++; |
| 461 | phenotype.IncCPUCyclesUsed(); |
| 462 | if (!m_no_cpu_cycle_time) phenotype.IncTimeUsed(); |
| 463 | |
| 464 | // Wake any stalled threads |
| 465 | for (int i = 0; i < m_threads.GetSize(); i++) { |
| 466 | if (!m_threads[i].active && m_threads[i].wait_reg == -1) m_threads[i].active = true; |
| 467 | } |
| 468 | |
| 469 | // Reset behavioral class |
| 470 | m_behav_class_used[0] = false; |
| 471 | m_behav_class_used[1] = false; |
| 472 | m_behav_class_used[2] = false; |
| 473 | |
| 474 | // Reset execution state |
| 475 | m_cur_uop = 0; |
| 476 | m_cur_thread = 0; |
| 477 | } |
| 478 | |
| 479 | // Execute specified number of micro ops per cpu cycle on each thread in a round robin fashion |
| 480 | const int uop_ratio = m_inst_set->GetUOpsPerCycle(); |
| 481 | for (; m_cur_uop < uop_ratio; m_cur_uop++) { |
| 482 | for (m_cur_thread = (m_cur_thread < m_threads.GetSize()) ? m_cur_thread : 0; m_cur_thread < m_threads.GetSize(); m_cur_thread++) { |
| 483 | // Setup the hardware for the next instruction to be executed. |
| 484 | |
| 485 | // If the currently selected thread is inactive, proceed to the next thread |
| 486 | if (!m_threads[m_cur_thread].running || !m_threads[m_cur_thread].active) continue; |
| 487 | |
| 488 | m_advance_ip = true; |
| 489 | Head& ip = m_threads[m_cur_thread].heads[hIP]; |
| 490 | ip.Adjust(); |
| 491 | |
| 492 | // Print the status of this CPU at each step... |
nothing calls this directly
no test coverage detected