diff options
author | David Li <li.davidm96@gmail.com> | 2016-01-16 10:05:46 -0700 |
---|---|---|
committer | David Li <li.davidm96@gmail.com> | 2016-01-16 10:05:46 -0700 |
commit | 007e7f9c0fbc71c789d5a551012c2f6724e25e6b (patch) | |
tree | b52de4f301a50e17527955a07824683686fd64bd /src | |
parent | a2947b0108ac0196078d2365adfdb7090643284d (diff) |
Stop game once score reached
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 24 | ||||
-rw-r--r-- | src/shareable_cache.rs | 1 | ||||
-rw-r--r-- | src/system.rs | 12 |
3 files changed, 30 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs index ce1f336..f4ef2cc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -138,12 +138,30 @@ fn main() { let mut simulator = simulator::Simulator::new( cores, memory_ref.clone(), steppable_caches, system); - // let cycles = 0x1000000; - let cycles = 0x50000; + let cycles = 0x1000000; + // let cycles = 0x50000; let start = time::precise_time_s(); - simulator.run_max(cycles); + match simulator.run_max(cycles) { + simulator::HaltReason::OutOfCycles => { + println!("Out of cycles, halting..."); + }, + simulator::HaltReason::SystemHalt => { + println!("Team has reached payload goal, halting..."); + }, + simulator::HaltReason::CoresHalted => { + println!("All cores have stopped, halting..."); + }, + } let end = time::precise_time_s(); + for (core_id, cycles_stalled, total_cycles) in simulator.report().iter().cloned() { + println!("Core {}: stalled {:08} of {:08} cycles ({:.2}%)", + core_id, + cycles_stalled, + total_cycles, + 100.0 * (cycles_stalled as f32) / (total_cycles as f32)); + } + println!("{} cycles in {:04} seconds ({} cycles/sec)", cycles, end - start, (cycles as f64) / (end - start)); let (p1, p2) = memory_ref.borrow().score(); diff --git a/src/shareable_cache.rs b/src/shareable_cache.rs index e61e907..3a2dd56 100644 --- a/src/shareable_cache.rs +++ b/src/shareable_cache.rs @@ -99,7 +99,6 @@ macro_rules! check_traps { $cache.borrow_mut().$write_value($address, $value); if num_traps_set > 0 { - println!("Traps set: {}", num_traps_set); match result { Ok(()) => { info!("[memory] core {}: {} write trap(s) set at address {:x},\ diff --git a/src/system.rs b/src/system.rs index a69beb4..f0f3095 100644 --- a/src/system.rs +++ b/src/system.rs @@ -3,20 +3,21 @@ use std::cell::RefCell; use std::rc::Rc; use rustv::isa; -use rustv::memory::{Mmu, SharedMemory}; +use rustv::memory::{MemoryInterface, Mmu}; use rustv::register_file::RegisterFile; use rustv::syscall; use rustv::trap::Trap; +use memory_tracker::MemoryTracker; use shareable_cache::ShareableCache; pub struct SyscallHandler<'a> { - memory: SharedMemory<'a>, + memory: Rc<RefCell<MemoryTracker>>, caches: Vec<Rc<RefCell<ShareableCache<'a>>>>, } impl<'a> SyscallHandler<'a> { - pub fn new(memory: SharedMemory<'a>, + pub fn new(memory: Rc<RefCell<MemoryTracker>>, caches: Vec<Rc<RefCell<ShareableCache<'a>>>>) -> SyscallHandler<'a> { SyscallHandler { @@ -93,4 +94,9 @@ impl<'a> syscall::SyscallHandler for SyscallHandler<'a> { } } } + + fn should_halt(&self) -> bool { + let (p1, p2) = self.memory.borrow().score(); + (p1 >= 0x1000000) || (p2 >= 0x1000000) + } } |