From 7b2baeacd3164ea09e5be51550d47e1bc370330b Mon Sep 17 00:00:00 2001 From: ilgeco Date: Thu, 26 Feb 2026 18:43:48 +0100 Subject: [PATCH] Temporary fix rust validator --- .../src/bin/pim-simulator/main.rs | 18 ++++++++++++------ .../src/lib/json_to_instruction/json_isa.rs | 4 ++-- .../json_to_instruction/json_to_executor.rs | 4 ++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/backend-simulators/pim/pim-simulator/src/bin/pim-simulator/main.rs b/backend-simulators/pim/pim-simulator/src/bin/pim-simulator/main.rs index cdfef47..7aa9241 100644 --- a/backend-simulators/pim/pim-simulator/src/bin/pim-simulator/main.rs +++ b/backend-simulators/pim/pim-simulator/src/bin/pim-simulator/main.rs @@ -46,7 +46,10 @@ fn main() -> Result<()> { let mut executor = json_to_executor::json_to_executor(config_json, core_jsons.iter()); populate_crossbar(&args, &mut executor); set_memory(&mut executor, memory); - TRACER.lock().unwrap().init(executor.cpu().num_core(), args.output.clone()); + TRACER + .lock() + .unwrap() + .init(executor.cpu().num_core(), args.output.clone()); executor.execute(); dump_memory(executor, &args)?; Ok(()) @@ -55,13 +58,13 @@ fn main() -> Result<()> { fn populate_crossbar(args: &Args, executor: &mut pimcore::Executable) { let num_cores = executor.cpu_mut().num_core(); - + if let Some(folder) = args.folder.as_ref() { for core_idx in 0..num_cores { let core_folder = folder.join(format!("core_{}", core_idx)); if !core_folder.is_dir() { - continue; + continue; } let mut bin_files: Vec<(u32, std::path::PathBuf)> = std::fs::read_dir(&core_folder) @@ -80,13 +83,16 @@ fn populate_crossbar(args: &Args, executor: &mut pimcore::Executable) { }) .collect(); bin_files.sort_by_key(|&(num, _)| num); - let core = executor.cpu_mut().core(core_idx+1); + let core = executor.cpu_mut().core(core_idx); let (_memory, crossbars) = core.get_memory_crossbar(); for (i, path) in bin_files { let bytes = std::fs::read(path).expect("Failed to read binary file"); - crossbars.get_mut(i as usize) - .unwrap().execute_store(&bytes).unwrap(); + crossbars + .get_mut(i as usize) + .unwrap() + .execute_store(&bytes) + .unwrap(); } } diff --git a/backend-simulators/pim/pim-simulator/src/lib/json_to_instruction/json_isa.rs b/backend-simulators/pim/pim-simulator/src/lib/json_to_instruction/json_isa.rs index 42e1407..e7b9cba 100644 --- a/backend-simulators/pim/pim-simulator/src/lib/json_to_instruction/json_isa.rs +++ b/backend-simulators/pim/pim-simulator/src/lib/json_to_instruction/json_isa.rs @@ -487,7 +487,7 @@ fn json_to_send( let json = json.as_object().expect("Not an object"); assert_eq!("send", json_str!(json, "op")); let rd = json_i64!(json, "rd") as i32; - let core = json_i64!(json, "core") as i32 + 1; + let core = json_i64!(json, "core") as i32; let size = json_i64!(json, "size") as i32; let (offset_select, offset_value) = json_to_offset(json.get("offset").unwrap()); inst_data_builder @@ -508,7 +508,7 @@ fn json_to_recv( let json = json.as_object().expect("Not an object"); assert_eq!("recv", json_str!(json, "op")); let rd = json_i64!(json, "rd") as i32; - let core = json_i64!(json, "core") as i32 + 1; + let core = json_i64!(json, "core") as i32; let size = json_i64!(json, "size") as i32; let (offset_select, offset_value) = json_to_offset(json.get("offset").unwrap()); inst_data_builder diff --git a/backend-simulators/pim/pim-simulator/src/lib/json_to_instruction/json_to_executor.rs b/backend-simulators/pim/pim-simulator/src/lib/json_to_instruction/json_to_executor.rs index 770fe5c..150b957 100644 --- a/backend-simulators/pim/pim-simulator/src/lib/json_to_instruction/json_to_executor.rs +++ b/backend-simulators/pim/pim-simulator/src/lib/json_to_instruction/json_to_executor.rs @@ -23,17 +23,17 @@ pub fn json_to_executor<'a>( let xbar_size = config.get("xbar_size").unwrap().as_array().unwrap(); let rows_crossbar = xbar_size[0].as_i64().unwrap() as i32; let column_corssbar = xbar_size[1].as_i64().unwrap() as i32; - let array_group_map = config.get("array_group_map"); let mut cpu = CPU::new(core_cnt); cpu.reserve_crossbar(xbar_count, column_corssbar * 4, rows_crossbar); let mut core_insts_builder = CoreInstructionsBuilder::new(core_cnt as usize); + cores.next(); for core_indx in 1..=core_cnt { let mut insts_builder = InstructionsBuilder::new(); let mut inst_data_builder = InstructionDataBuilder::new(); inst_data_builder.set_core_indx(core_indx).fix_core_indx(); let json_core = cores .next() - .unwrap_or_else(|| panic!("cores files less than {}", core_indx - 1)); + .unwrap_or_else(|| panic!("cores files less than {}", core_indx )); let json_core_insts = json_core .as_array() .unwrap_or_else(|| panic!("core{} has not a list of instruction", core_indx));