aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorDavid Li <li.davidm96@gmail.com>2015-12-30 10:24:36 -0700
committerDavid Li <li.davidm96@gmail.com>2015-12-30 10:24:36 -0700
commitb0f627e9df022cedefee871bdaa64c8e06198a1c (patch)
treef23684fc8ced573c7bda1eac5957a729f4ff2b40 /src/lib.rs
parent6abcabdc03a1aa6072481fb825442c282836101c (diff)
Convert simulator to using cache
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index ac87f77..4c3db9e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -22,11 +22,16 @@ pub mod simulator;
#[test]
fn it_works() {
+ use std::rc::Rc;
+ use std::cell::RefCell;
+
use std::path::Path;
match binary::Binary::new_from_hex_file(Path::new("../riscv/kernel.hex")) {
Ok(b) => {
let memory = memory::Memory::new_from_binary(0x2000, b);
- let mut simulator = simulator::Simulator::new(1, memory);
+ let memory_ref = Rc::new(RefCell::new(Box::new(memory) as Box<memory::MemoryInterface>));
+ let core = simulator::Core::new(memory_ref.clone());
+ let mut simulator = simulator::Simulator::new(vec![core], memory_ref.clone());
simulator.run();
},
Err(err) => println!("Error: {:?}", err),