From 4d039375deb558ff482a7266d869a3bed768f9c9 Mon Sep 17 00:00:00 2001 From: Cay Date: Sun, 18 Feb 2024 18:25:27 -0500 Subject: [PATCH 1/7] Add UpdateStage and UpdateCoprocessor, add a visual_line_to_data function that uses datapath_state --- src/agent.rs | 5 +- src/agent/datapath_reducer.rs | 19 +- src/agent/messages.rs | 4 +- src/bin/main.rs | 2 +- src/emulation_core/mips/control_signals.rs | 25 +- src/emulation_core/mips/coprocessor.rs | 5 +- src/emulation_core/mips/instruction.rs | 21 +- src/emulation_core/mips/line_info.rs | 314 +++++++++++++++++++++ src/emulation_core/riscv/line_info.rs | 311 ++++++++++++++++++++ src/ui/footer/component.rs | 6 +- src/ui/visual_datapath/mod.rs | 84 +++--- src/ui/visual_datapath/utils.rs | 19 +- 12 files changed, 732 insertions(+), 83 deletions(-) diff --git a/src/agent.rs b/src/agent.rs index a93658f6a..794b80830 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -58,12 +58,13 @@ pub async fn emulation_core_agent(scope: ReactorScope) DatapathUpdate::MIPS(MipsStateUpdate::UpdateRegisters(datapath.registers)); let memory_update = DatapathUpdate::MIPS(MipsStateUpdate::UpdateMemory(datapath.memory.clone())); - let stage_update = - DatapathUpdate::MIPS(MipsStateUpdate::UpdateStage(datapath.current_stage)); + let stage_update = DatapathUpdate::MIPS(MipsStateUpdate::UpdateStage(datapath.current_stage.clone())); + let coprocessor_update = DatapathUpdate::MIPS(MipsStateUpdate::UpdateCoprocessor(datapath.coprocessor.clone())); state.scope.send(state_update).await.unwrap(); state.scope.send(register_update).await.unwrap(); state.scope.send(memory_update).await.unwrap(); state.scope.send(stage_update).await.unwrap(); + state.scope.send(coprocessor_update).await.unwrap(); } } } diff --git a/src/agent/datapath_reducer.rs b/src/agent/datapath_reducer.rs index 63bfc7902..dcbe98b5a 100644 --- a/src/agent/datapath_reducer.rs +++ b/src/agent/datapath_reducer.rs @@ -1,6 +1,7 @@ use crate::agent::messages::MipsStateUpdate; use crate::emulation_core::architectures::AvailableDatapaths::MIPS; use crate::emulation_core::architectures::{AvailableDatapaths, DatapathUpdate}; +use crate::emulation_core::mips::coprocessor::MipsFpCoprocessor; use crate::emulation_core::mips::datapath::{DatapathState, Stage}; use crate::emulation_core::mips::memory::Memory; use crate::emulation_core::mips::registers::GpRegisters; @@ -19,6 +20,7 @@ pub struct MipsCoreState { pub registers: GpRegisters, pub memory: Memory, pub current_stage: Stage, + pub coprocessor: MipsFpCoprocessor } impl Default for DatapathReducer { @@ -42,25 +44,36 @@ impl Reducible for DatapathReducer { state, registers: self.mips.registers, memory: self.mips.memory.clone(), - current_stage: self.mips.current_stage, + current_stage: self.mips.current_stage.clone(), + coprocessor: self.mips.coprocessor.clone(), }, MipsStateUpdate::UpdateRegisters(registers) => MipsCoreState { state: self.mips.state.clone(), registers, memory: self.mips.memory.clone(), - current_stage: self.mips.current_stage, + current_stage: self.mips.current_stage.clone(), + coprocessor: self.mips.coprocessor.clone(), }, MipsStateUpdate::UpdateMemory(memory) => MipsCoreState { state: self.mips.state.clone(), registers: self.mips.registers, memory, - current_stage: self.mips.current_stage, + current_stage: self.mips.current_stage.clone(), + coprocessor: self.mips.coprocessor.clone(), }, MipsStateUpdate::UpdateStage(stage) => MipsCoreState { state: self.mips.state.clone(), registers: self.mips.registers, memory: self.mips.memory.clone(), current_stage: stage, + coprocessor: self.mips.coprocessor.clone(), + }, + MipsStateUpdate::UpdateCoprocessor(coprocessor) => MipsCoreState { + state: self.mips.state.clone(), + registers: self.mips.registers, + memory: self.mips.memory.clone(), + current_stage: self.mips.current_stage.clone(), + coprocessor }, }, }, diff --git a/src/agent/messages.rs b/src/agent/messages.rs index 664c2deaa..d44f41dd3 100644 --- a/src/agent/messages.rs +++ b/src/agent/messages.rs @@ -1,7 +1,8 @@ +use crate::emulation_core::mips::coprocessor::MipsFpCoprocessor; +use crate::emulation_core::{architectures::AvailableDatapaths, mips::datapath::Stage}; use crate::emulation_core::mips::datapath::DatapathState; use crate::emulation_core::mips::memory::Memory; use crate::emulation_core::mips::registers::GpRegisters; -use crate::emulation_core::{architectures::AvailableDatapaths, mips::datapath::Stage}; use serde::{Deserialize, Serialize}; /// Commands sent from the UI thread to the worker thread. @@ -26,4 +27,5 @@ pub enum MipsStateUpdate { UpdateRegisters(GpRegisters), UpdateMemory(Memory), UpdateStage(Stage), + UpdateCoprocessor(MipsFpCoprocessor), } diff --git a/src/bin/main.rs b/src/bin/main.rs index 011ea91d2..5f505212c 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -522,7 +522,7 @@ fn app(props: &AppProps) -> Html { // Console -