diff --git a/mips-lib/src/components/mips_dm.rs b/mips-lib/src/components/mips_dm.rs index eafe1ee..27d8f92 100644 --- a/mips-lib/src/components/mips_dm.rs +++ b/mips-lib/src/components/mips_dm.rs @@ -1,3 +1,4 @@ +#[cfg(feature = "gui-egui")] use crate::gui_egui::mips_mem_view_window::MemViewWindow; use core::cell::RefCell; use std::cell::RefMut; @@ -42,6 +43,7 @@ pub struct DataMem { pub write_enable_input: Input, pub phys_mem_id: String, pub regfile_id: String, + #[cfg(feature = "gui-egui")] pub mem_view: RefCell, } @@ -56,6 +58,7 @@ impl DataMem { phys_mem_id: String, regfile_id: String, ) -> Self { + #[cfg(feature = "gui-egui")] let mem_view = MemViewWindow::new(id.clone(), "Data memory view".into()).set_data_view(None); DataMem { @@ -66,6 +69,7 @@ impl DataMem { data_input: data_input, op_input: op_input, write_enable_input: write_enable_input, + #[cfg(feature = "gui-egui")] mem_view: RefCell::new(mem_view), regfile_id: regfile_id, } @@ -215,6 +219,7 @@ impl Component for DataMem { .unwrap(); // update dynamic symbol PC_IM + #[cfg(feature = "gui-egui")] self.mem_view .borrow_mut() .set_dynamic_symbol("DM_ADRS", address); @@ -362,6 +367,7 @@ impl Component for DataMem { Ok(_) => match mem_op { data_op::NO_OP => Ok(()), _ => { + #[cfg(feature = "gui-egui")] if self.mem_view.borrow().is_break_point(&(address & !0b11)) { Err(Condition::Halt(format!( "Read or write at breakpoint address {:#0x}", @@ -370,6 +376,8 @@ impl Component for DataMem { } else { Ok(()) } + #[cfg(not(feature = "gui-egui"))] + Ok(()) } }, Err(_) => ret, diff --git a/mips-lib/src/components/mips_im.rs b/mips-lib/src/components/mips_im.rs index c9947a3..dbb8b86 100644 --- a/mips-lib/src/components/mips_im.rs +++ b/mips-lib/src/components/mips_im.rs @@ -8,6 +8,7 @@ use syncrim::common::{Component, Condition, Id, Input, InputPort, OutputType, Po use crate::components::physical_mem::{MemOpSize, MipsMem}; use crate::components::RegFile; +#[cfg(feature = "gui-egui")] use crate::gui_egui::mips_mem_view_window::MemViewWindow; use super::PhysicalMem; @@ -24,6 +25,7 @@ pub struct InstrMem { // All components who deal with memory acess this pub phys_mem_id: String, pub regfile_id: String, + #[cfg(feature = "gui-egui")] pub mem_view: RefCell, } @@ -35,6 +37,7 @@ impl InstrMem { phys_mem_id: String, regfile_id: String, ) -> InstrMem { + #[cfg(feature = "gui-egui")] let mem_view = MemViewWindow::new(id.clone(), "instruction memory view".into()).set_code_view(None); InstrMem { @@ -42,6 +45,7 @@ impl InstrMem { pos: pos, pc: pc_input, phys_mem_id: phys_mem_id, + #[cfg(feature = "gui-egui")] mem_view: RefCell::new(mem_view), regfile_id: regfile_id, } @@ -74,6 +78,7 @@ impl Component for InstrMem { pos: pos, pc: dummy_input, phys_mem_id: "dummy".into(), + #[cfg(feature = "gui-egui")] mem_view: RefCell::new(MemViewWindow::new("dummy".into(), "IM dummy".into())), regfile_id: "dummy".into(), })) @@ -123,6 +128,7 @@ impl Component for InstrMem { }; // update dynamic symbol PC_IM + #[cfg(feature = "gui-egui")] self.mem_view.borrow_mut().set_dynamic_symbol("PC_IM", pc); // Get a word at PC with the size of 32bits, read as big endian, @@ -131,10 +137,13 @@ impl Component for InstrMem { Ok(instr) => { simulator.set_out_value(&self.id, INSTR_MEM_INSTRUCTION_ID, instr); // check if pc is at breakpoint + #[cfg(feature = "gui-egui")] match self.mem_view.borrow().is_break_point(&pc) { true => Err(Condition::Halt(format!("Reached breakpoint at {:#0x}", pc))), false => Ok(()), } + #[cfg(not(feature = "gui-egui"))] + Ok(()) } Err(_) => Err(Condition::Error(format!("Unaligned Read, PC = {:#0x}", pc))), } diff --git a/mips-lib/src/components/mips_reg_file.rs b/mips-lib/src/components/mips_reg_file.rs index 3225e5f..184413c 100644 --- a/mips-lib/src/components/mips_reg_file.rs +++ b/mips-lib/src/components/mips_reg_file.rs @@ -61,19 +61,7 @@ impl Component for RegFile { fn to_(&self) { trace!("reg_file"); } - #[cfg(feature = "gui-egui")] - // fn dummy(&self, id: &str, pos: (f32, f32)) -> Box> { - // let dummy_input = Input::new("dummy", "out"); - // Box::new(Rc::new(RegFile { - // id: "dummy".to_string(), - // pos: (0.0, 0.0), - // a1_in: dummy_input.clone(), - // a2_in: dummy_input.clone(), - // a3_in: dummy_input.clone(), - // wd3_in: dummy_input.clone(), - // we3_in: dummy_input.clone(), - // })) - // } + fn get_id_ports(&self) -> (Id, Ports) { ( self.id.clone(), diff --git a/mips-lib/src/components/sz_extend.rs b/mips-lib/src/components/sz_extend.rs index dfcdf92..69e36bf 100644 --- a/mips-lib/src/components/sz_extend.rs +++ b/mips-lib/src/components/sz_extend.rs @@ -26,15 +26,7 @@ impl Component for SignZeroExtend { fn to_(&self) { trace!("pc+4"); } - #[cfg(feature = "gui-egui")] - // fn dummy(&self, _id: &str, _pos: (f32, f32)) -> Box> { - // let dummy_input = Input::new("dummy", "out"); - // Box::new(Rc::new(SignZeroExtend { - // id: "dummy".to_string(), - // pos: (0.0, 0.0), - // signzero_extend_in: dummy_input.clone(), - // })) - // } + fn get_id_ports(&self) -> (Id, Ports) { ( self.id.clone(), diff --git a/mips-lib/src/lib.rs b/mips-lib/src/lib.rs index fefacb3..24f6894 100644 --- a/mips-lib/src/lib.rs +++ b/mips-lib/src/lib.rs @@ -1,5 +1,6 @@ pub mod components; +#[cfg(feature = "gui-egui")] pub mod gui_egui; pub mod helpers;