diff options
author | David Li <li.davidm96@gmail.com> | 2015-12-30 10:24:36 -0700 |
---|---|---|
committer | David Li <li.davidm96@gmail.com> | 2015-12-30 10:24:36 -0700 |
commit | b0f627e9df022cedefee871bdaa64c8e06198a1c (patch) | |
tree | f23684fc8ced573c7bda1eac5957a729f4ff2b40 /src/lib.rs | |
parent | 6abcabdc03a1aa6072481fb825442c282836101c (diff) |
Convert simulator to using cache
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -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), |