summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/main.rs b/src/main.rs
index b23d31d..f43a33e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -7,12 +7,12 @@ use std::sync::mpsc::{channel, Receiver, Sender};
use std::thread;
use std::time::Duration;
-mod core;
+mod cpu8051;
mod memory;
-mod rom;
+mod progmem;
-use self::core::Core;
-use self::rom::Rom;
+use self::cpu8051::Cpu8051;
+use self::progmem::ProgramMemory;
enum Control {
Run(bool),
@@ -25,16 +25,16 @@ struct BoundController {
_rx: Receiver<SimData>,
}
-struct BoundCore {
+struct BoundEmu {
_tx: Sender<SimData>,
rx: Receiver<Control>,
}
-fn new_bound_pair() -> (BoundCore, BoundController) {
+fn new_bound_pair() -> (BoundEmu, BoundController) {
let (tx_c, rx_c): (Sender<Control>, Receiver<Control>) = channel();
let (tx_d, rx_d): (Sender<SimData>, Receiver<SimData>) = channel();
(
- BoundCore {
+ BoundEmu {
_tx: tx_d,
rx: rx_c,
},
@@ -76,7 +76,7 @@ fn new_controller(name: &str) -> Result<&dyn Fn(BoundController), i32> {
}
}
-fn core_worker(mut core: Core, bound: BoundCore) {
+fn emu_worker(mut cpu: Cpu8051, bound: BoundEmu) {
let mut should_stop = false;
loop {
if should_stop {
@@ -86,8 +86,8 @@ fn core_worker(mut core: Core, bound: BoundCore) {
}
}
} else {
- println!("0x{:08x}: {}", core.pc(), core.op());
- core.step();
+ println!("0x{:08x}: {}", cpu.pc(), cpu.op());
+ cpu.step();
if let Ok(msg) = bound.rx.recv_timeout(Duration::from_millis(1000)) {
match msg {
Control::Run(run) => should_stop = !run,
@@ -134,7 +134,7 @@ fn main() {
let data =
fs::read_to_string(filename).unwrap_or_else(|_| panic!("Unable to read file {}", filename));
- let core = Core::new().rom(match Rom::from_hex(data) {
+ let cpu = Cpu8051::new().rom(match ProgramMemory::from_hex(data) {
Ok(value) => value,
Err(err_string) => {
println!("{}", err_string);
@@ -142,11 +142,11 @@ fn main() {
}
});
- /* Run core worker and controller */
+ /* Run cpu worker and controller */
let (bound_core, bound_controller) = new_bound_pair();
- core_worker(core, bound_core);
+ emu_worker(cpu, bound_core);
thread::spawn(move || {
let controller = {