diff --git a/src/agent.rs b/src/agent.rs index f74dda20b..add746df6 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -1,23 +1,138 @@ //! The agent responsible for running the emulator core on the worker thread and communication functionalities. -use futures::{SinkExt, StreamExt}; +use crate::agent::messages::{Command, MipsStateUpdate}; +use crate::emulation_core::architectures::{DatapathRef, DatapathUpdate}; +use crate::emulation_core::datapath::Datapath; +use crate::emulation_core::mips::datapath::MipsDatapath; +use crate::emulation_core::mips::registers::GpRegisterType; +use futures::{FutureExt, SinkExt, StreamExt}; use gloo_console::log; +use std::time::Duration; +use yew::platform::time::sleep; use yew_agent::prelude::*; pub mod datapath_communicator; +pub mod datapath_reducer; +pub mod messages; /// The main logic for the emulation core agent. All code within this function runs on a worker thread as opposed to /// the UI thread. #[reactor(EmulationCoreAgent)] -pub async fn emulation_core_agent(mut scope: ReactorScope) { +pub async fn emulation_core_agent(scope: ReactorScope) { log!("Hello world!"); - let mut num = 1; - scope.send(num).await.unwrap(); + let mut state = EmulatorCoreAgentState::new(scope); loop { - let msg = scope.next().await; - log!("Got message: ", msg); - num += 1; - scope.send(num).await.unwrap(); - log!("Sent."); + let execution_delay = state.get_delay(); + + // Part 1: Delay/Command Handling + if state.executing { + futures::select! { + // If we get a message, handle the command before attempting to execute. + msg = state.scope.next() => match msg { + Some(msg) => state.handle_command(msg), + None => return, + }, + // Delay to slow execution down to the intended speed. + _ = sleep(Duration::from_millis(execution_delay)).fuse() => {}, + } + } else { + // If we're not currently executing, wait indefinitely until the next message comes in. + match state.scope.next().await { + Some(msg) => state.handle_command(msg), + None => return, + } + } + + // Part 2: Execution + // Execute a single instruction if the emulator core should be executing. + state.execute(); + + // Part 3: Processing State/Sending Updates to UI + // TODO: This is a very naive implementation. Optimization is probably a good idea. + // TODO: Add support for the FP coprocessor updates in MIPS + match state.current_datapath.as_datapath_ref() { + DatapathRef::MIPS(datapath) => { + let state_update = + DatapathUpdate::MIPS(MipsStateUpdate::UpdateState(datapath.state.clone())); + let register_update = + DatapathUpdate::MIPS(MipsStateUpdate::UpdateRegisters(datapath.registers)); + let memory_update = + DatapathUpdate::MIPS(MipsStateUpdate::UpdateMemory(datapath.memory.clone())); + state.scope.send(state_update).await.unwrap(); + state.scope.send(register_update).await.unwrap(); + state.scope.send(memory_update).await.unwrap(); + } + } + } +} + +struct EmulatorCoreAgentState { + current_datapath: Box>, + pub scope: ReactorScope, + speed: u32, + executing: bool, +} + +impl EmulatorCoreAgentState { + pub fn new(scope: ReactorScope) -> EmulatorCoreAgentState { + EmulatorCoreAgentState { + current_datapath: Box::::default(), + scope, + speed: 0, + executing: false, + } + } + + pub fn handle_command(&mut self, command: Command) { + match command { + Command::SetCore(_architecture) => { + todo!() // Implement once we have a RISCV datapath + } + Command::Initialize(initial_pc, mem) => { + self.current_datapath.initialize(initial_pc, mem).unwrap(); + } + Command::SetExecuteSpeed(speed) => { + self.speed = speed; + } + Command::SetRegister(register, value) => { + self.current_datapath.set_register_by_str(®ister, value); + } + Command::SetMemory(ptr, data) => { + self.current_datapath.set_memory(ptr, data); + } + Command::Execute => { + self.executing = true; + } + Command::ExecuteInstruction => { + self.current_datapath.execute_instruction(); + } + Command::ExecuteStage => { + self.current_datapath.execute_stage(); + } + Command::Pause => { + self.executing = false; + } + Command::Reset => { + self.current_datapath.reset(); + } + } + } + + pub fn execute(&mut self) { + // Skip the execution phase if the emulator core is not currently executing. + if !self.executing { + return; + } + self.current_datapath.execute_instruction(); + } + + /// Returns the delay between CPU cycles in milliseconds for the current execution speed. Will return zero if the + /// execution speed is zero. + pub fn get_delay(&self) -> u64 { + if self.speed == 0 { + 0 + } else { + (1000 / self.speed).into() + } } } diff --git a/src/agent/datapath_communicator.rs b/src/agent/datapath_communicator.rs index bdd839e53..5d068388a 100644 --- a/src/agent/datapath_communicator.rs +++ b/src/agent/datapath_communicator.rs @@ -1,4 +1,7 @@ +use crate::agent::datapath_reducer::DatapathReducer; +use crate::agent::messages::Command; use crate::agent::EmulationCoreAgent; +use crate::emulation_core::architectures::AvailableDatapaths; use futures::stream::{SplitSink, SplitStream}; use futures::FutureExt; use futures::SinkExt; @@ -6,7 +9,7 @@ use futures::StreamExt; use gloo_console::log; use gloo_console::warn; use std::cell::RefCell; -use yew::UseForceUpdateHandle; +use yew::UseReducerDispatcher; use yew_agent::reactor::ReactorBridge; /// This struct provides an abstraction over all communication with the worker thread. Any commands to the worker @@ -15,7 +18,7 @@ use yew_agent::reactor::ReactorBridge; /// The DatapathCommunicator will also handle receiving information about the state of the emulation core and maintain /// internal state that can be displayed by the UI. pub struct DatapathCommunicator { - writer: RefCell, i32>>, + writer: RefCell, Command>>, reader: RefCell>>, } @@ -29,6 +32,8 @@ impl PartialEq for &DatapathCommunicator { } impl DatapathCommunicator { + // General operational functions + /// Initialize the DatapathCommunicator using a bridge. pub fn new(bridge: ReactorBridge) -> DatapathCommunicator { let (write, read) = bridge.split(); @@ -42,7 +47,10 @@ impl DatapathCommunicator { /// from the main app component. After updating internal state, the component this was called from will be force /// updated. #[allow(clippy::await_holding_refcell_ref)] - pub async fn listen_for_updates(&self, update_handle: UseForceUpdateHandle) { + pub async fn listen_for_updates( + &self, + dispatcher_handle: UseReducerDispatcher, + ) { let mut reader = match self.reader.try_borrow_mut() { Ok(reader) => reader, Err(_) => { @@ -55,21 +63,78 @@ impl DatapathCommunicator { log!("Waiting..."); let update = reader.next().await; log!(format!("Got update {:?}", update)); - if update.is_none() { - return; + match update { + None => return, + Some(update) => dispatcher_handle.dispatch(update), } - update_handle.force_update(); } } /// Sends a test message to the worker thread. - pub fn send_test_message(&self) { + fn send_message(&self, command: Command) { let mut writer = self.writer.borrow_mut(); writer - .send(1) - // The + .send(command) + // The logic for sending a message is synchronous but the API for writing to a SplitSink is asynchronous, + // so we attempt to resolve the future immediately so we can expose a synchronous API for sending commands. + // If the future doesn't return immediately, there's serious logic changes that need to happen so we just + // log an error message and panic. .now_or_never() .expect("Send function did not immediately return, async logic needed.") .expect("Sending test message error") } + + // Wrapper functions for commands + + /// Sets the current emulation core to the provided architecture. + pub fn set_core(&self, _architecture: AvailableDatapaths) { + todo!() + } + + /// Resets and loads the parsed/assembled instructions provided into the current emulator core. + pub fn initialize(&self, initial_pc: usize, instructions: Vec) { + self.send_message(Command::Initialize(initial_pc, instructions)); + } + + /// Sets the execution speed of the emulator core to the provided speed in hz. If set to zero, the emulator core + /// will execute as fast as possible. + pub fn set_execute_speed(&self, speed: u32) { + self.send_message(Command::SetExecuteSpeed(speed)); + } + + /// Sets the register with the provided name to the provided value. + pub fn set_register(&self, register: String, data: u64) { + self.send_message(Command::SetRegister(register, data)); + } + + /// Copies the contents of `data` to the emulator core's memory at `ptr`. Copies until either the end of `data` or + /// the end of the emulaot core's memory. + pub fn set_memory(&self, ptr: usize, data: Vec) { + self.send_message(Command::SetMemory(ptr, data)); + } + + /// Executes the emulator core at the current set speed. + pub fn execute(&self) { + self.send_message(Command::Execute); + } + + /// Executes a single instruction on the emulator core and pauses. + pub fn execute_instruction(&self) { + self.send_message(Command::ExecuteInstruction); + } + + /// Executes a single stage on the emulator core and pauses. + pub fn execute_stage(&self) { + self.send_message(Command::ExecuteStage); + } + + /// Pauses the core. Does nothing if the emulator core is already paused. + pub fn pause_core(&self) { + self.send_message(Command::Pause); + } + + /// Resets the current core to its default state. + pub fn reset(&self) { + self.send_message(Command::Reset); + } } diff --git a/src/agent/datapath_reducer.rs b/src/agent/datapath_reducer.rs new file mode 100644 index 000000000..55f073675 --- /dev/null +++ b/src/agent/datapath_reducer.rs @@ -0,0 +1,58 @@ +use crate::agent::messages::MipsStateUpdate; +use crate::emulation_core::architectures::AvailableDatapaths::MIPS; +use crate::emulation_core::architectures::{AvailableDatapaths, DatapathUpdate}; +use crate::emulation_core::mips::datapath::DatapathState; +use crate::emulation_core::mips::memory::Memory; +use crate::emulation_core::mips::registers::GpRegisters; +use std::rc::Rc; +use yew::Reducible; + +pub struct DatapathReducer { + pub current_architecture: AvailableDatapaths, + pub mips: MipsCoreState, +} + +#[derive(Default)] +pub struct MipsCoreState { + pub state: DatapathState, + pub registers: GpRegisters, + pub memory: Memory, +} + +impl Default for DatapathReducer { + fn default() -> Self { + Self { + current_architecture: MIPS, + mips: MipsCoreState::default(), + } + } +} + +impl Reducible for DatapathReducer { + type Action = DatapathUpdate; + + fn reduce(self: Rc, action: Self::Action) -> Rc { + Rc::from(match action { + DatapathUpdate::MIPS(update) => Self { + current_architecture: MIPS, + mips: match update { + MipsStateUpdate::UpdateState(state) => MipsCoreState { + state, + registers: self.mips.registers, + memory: self.mips.memory.clone(), + }, + MipsStateUpdate::UpdateRegisters(registers) => MipsCoreState { + state: self.mips.state.clone(), + registers, + memory: self.mips.memory.clone(), + }, + MipsStateUpdate::UpdateMemory(memory) => MipsCoreState { + state: self.mips.state.clone(), + registers: self.mips.registers, + memory, + }, + }, + }, + }) + } +} diff --git a/src/agent/messages.rs b/src/agent/messages.rs new file mode 100644 index 000000000..1bd4379ca --- /dev/null +++ b/src/agent/messages.rs @@ -0,0 +1,28 @@ +use crate::emulation_core::architectures::AvailableDatapaths; +use crate::emulation_core::mips::datapath::DatapathState; +use crate::emulation_core::mips::memory::Memory; +use crate::emulation_core::mips::registers::GpRegisters; +use serde::{Deserialize, Serialize}; + +/// Commands sent from the UI thread to the worker thread. +#[derive(Clone, Debug, Serialize, Deserialize)] +pub enum Command { + SetCore(AvailableDatapaths), + Initialize(usize, Vec), + SetExecuteSpeed(u32), + SetRegister(String, u64), + SetMemory(usize, Vec), + Execute, + ExecuteInstruction, + ExecuteStage, + Pause, + Reset, +} + +/// Information about the emulator core's state sent from the worker thread to the UI thread. +#[derive(Clone, Debug, Serialize, Deserialize)] +pub enum MipsStateUpdate { + UpdateState(DatapathState), + UpdateRegisters(GpRegisters), + UpdateMemory(Memory), +} diff --git a/src/bin/main.rs b/src/bin/main.rs index e0fbc285b..1027bb9e8 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -14,6 +14,7 @@ use monaco::{ }; use std::rc::Rc; use swim::agent::datapath_communicator::DatapathCommunicator; +use swim::agent::datapath_reducer::DatapathReducer; use swim::agent::EmulationCoreAgent; use swim::emulation_core::datapath::Datapath; use swim::emulation_core::mips::datapath::MipsDatapath; @@ -85,13 +86,15 @@ fn app(props: &AppProps) -> Html { // the ability to access and change its contents be mutable. let datapath = use_mut_ref(MipsDatapath::default); + let datapath_state = use_reducer(DatapathReducer::default); + // Start listening for messages from the communicator. This effectively links the worker thread to the main thread // and will force updates whenever its internal state changes. { - let trigger = use_force_update(); + let dispatcher = datapath_state.dispatcher(); use_effect_with_deps( move |communicator| { - spawn_local(communicator.listen_for_updates(trigger)); + spawn_local(communicator.listen_for_updates(dispatcher)); }, props.communicator, ); @@ -99,18 +102,17 @@ fn app(props: &AppProps) -> Html { // This is where code is assembled and loaded into the emulation core's memory. let on_assemble_clicked = { - let communicator = props.communicator; let text_model = Rc::clone(&text_model); let datapath = Rc::clone(&datapath); let parser_text_output = parser_text_output.clone(); let trigger = use_force_update(); + let communicator = props.communicator; let executed_line = executed_line.clone(); let not_highlighted = not_highlighted.clone(); use_callback( move |_, text_model| { - communicator.send_test_message(); // Test message, remove later. let mut datapath = datapath.borrow_mut(); let text_model = text_model.borrow_mut(); @@ -160,7 +162,7 @@ fn app(props: &AppProps) -> Html { // Proceed with loading into memory and expand pseudo-instructions if there are no errors. if marker_jsarray.length() == 0 { // Load the binary into the datapath's memory - match datapath.initialize(assembled) { + match datapath.initialize_legacy(assembled.clone()) { Ok(_) => (), Err(msg) => { // In the case of an error, note this and stop early. @@ -170,6 +172,8 @@ fn app(props: &AppProps) -> Html { // log!(datapath.memory.to_string()); text_model.set_value(&program_info.updated_monaco_string); // Expands pseudo-instructions to their hardware counterpart. datapath.registers.pc = program_info.pc_starting_point as u64; + // Send the binary over to the emulation core thread + communicator.initialize(program_info.pc_starting_point, assembled) } trigger.force_update(); @@ -188,6 +192,7 @@ fn app(props: &AppProps) -> Html { let text_model = Rc::clone(&text_model); let datapath = Rc::clone(&datapath); let trigger = use_force_update(); + let communicator = props.communicator; let executed_line = executed_line.clone(); let not_highlighted = not_highlighted.clone(); @@ -243,6 +248,7 @@ fn app(props: &AppProps) -> Html { // log!(not_highlighted.at(0)); datapath.execute_instruction(); + communicator.execute_instruction(); // done with the highlight, prepare for the next one. executed_line.pop(); @@ -264,6 +270,7 @@ fn app(props: &AppProps) -> Html { let not_highlighted = not_highlighted.clone(); let highlight_decor = highlight_decor; let trigger = use_force_update(); + let communicator = props.communicator; use_callback( move |_, _| { @@ -300,6 +307,7 @@ fn app(props: &AppProps) -> Html { } else { datapath.execute_stage(); } + communicator.execute_stage(); trigger.force_update(); }, (), @@ -313,6 +321,7 @@ fn app(props: &AppProps) -> Html { let datapath = Rc::clone(&datapath); let trigger = use_force_update(); let parser_text_output = parser_text_output.clone(); + let communicator = props.communicator; let executed_line = executed_line; let not_highlighted = not_highlighted; @@ -331,6 +340,7 @@ fn app(props: &AppProps) -> Html { ); parser_text_output.set("".to_string()); datapath.reset(); + communicator.reset(); trigger.force_update(); }, (), @@ -476,7 +486,7 @@ fn app(props: &AppProps) -> Html { // Right column - + } diff --git a/src/emulation_core.rs b/src/emulation_core.rs index e62a37920..ac45cc291 100644 --- a/src/emulation_core.rs +++ b/src/emulation_core.rs @@ -1,4 +1,5 @@ //! The emulation core for the project. +pub mod architectures; pub mod datapath; pub mod mips; diff --git a/src/emulation_core/architectures.rs b/src/emulation_core/architectures.rs new file mode 100644 index 000000000..20cf13478 --- /dev/null +++ b/src/emulation_core/architectures.rs @@ -0,0 +1,18 @@ +use crate::agent::messages::MipsStateUpdate; +use crate::emulation_core::mips::datapath::MipsDatapath; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub enum AvailableDatapaths { + MIPS, + RISCV, +} + +pub enum DatapathRef<'a> { + MIPS(&'a MipsDatapath), +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub enum DatapathUpdate { + MIPS(MipsStateUpdate), +} diff --git a/src/emulation_core/datapath.rs b/src/emulation_core/datapath.rs index b3d1c8deb..4744d3d65 100644 --- a/src/emulation_core/datapath.rs +++ b/src/emulation_core/datapath.rs @@ -1,5 +1,9 @@ //! Module for the API of a generic datapath. +use crate::emulation_core::architectures::DatapathRef; +use crate::emulation_core::mips::line_info::LineInformation; +use crate::emulation_core::mips::memory::Memory; + /// A generic datapath. /// /// This has the ability to execute instructions, and to interface with @@ -22,11 +26,6 @@ pub trait Datapath { /// at the discretion of the developer. type RegisterEnum; - /// The data type that describes memory for this datapath. This must be - /// defined separately. This allows raw access to any parts of memory - /// or its own interface at will. - type MemoryType; - /// Execute a single instruction based on the current state of the /// datapath. Should the datapath support stages, if the datapath is /// midway through a stage, the current instruction will be finished @@ -45,8 +44,18 @@ pub trait Datapath { /// registers should be listed within [`Self::RegisterEnum`]. fn get_register_by_enum(&self, register: Self::RegisterEnum) -> Self::RegisterData; + /// Sets the data in the register indicated by the provided string. If it doesn't exist, + /// this function returns Err. + fn set_register_by_str(&mut self, register: &str, data: Self::RegisterData); + + /// Reset the datapath, load instructions into memory, and un-sets the `is_halted` + /// flag. If the process fails, an [`Err`] is returned. + fn initialize(&mut self, initial_pc: usize, instructions: Vec) -> Result<(), String>; + /// Retrieve all memory as-is. - fn get_memory(&self) -> &Self::MemoryType; + fn get_memory(&self) -> &Memory; + + fn set_memory(&mut self, ptr: usize, data: Vec); /// Returns if the datapath is in a "halted" or "stopped" state. This may /// be true in the case where an error had occurred previously. @@ -54,6 +63,10 @@ pub trait Datapath { /// Restore the datapath to its default state. fn reset(&mut self); + + /// Obtain a reference to the concrete datapath type. Used when datapath-specific logic is + /// needed while dealing with a datapath as a trait object. + fn as_datapath_ref(&self) -> DatapathRef; } /// A datapath that supports a visual diagram component. @@ -61,10 +74,7 @@ pub trait Datapath { /// This requires a corresponding visual diagram with labels that can be mapped /// to the datapath. pub trait VisualDatapath { - /// The information about a piece of the diagram that is returned from the datapath. - type LineInformation; - /// Return the information from the datapath corresponding to the `variable` attribute on a /// part of the visual datapath diagram. - fn visual_line_to_data(&self, variable: &str) -> Self::LineInformation; + fn visual_line_to_data(&self, variable: &str) -> LineInformation; } diff --git a/src/emulation_core/mips/datapath.rs b/src/emulation_core/mips/datapath.rs index 16ac9c9d0..bdec0ddfd 100644 --- a/src/emulation_core/mips/datapath.rs +++ b/src/emulation_core/mips/datapath.rs @@ -52,6 +52,8 @@ use super::control_signals::{floating_point::*, *}; use super::datapath_signals::*; use super::instruction::*; use super::{coprocessor::MipsFpCoprocessor, memory::Memory, registers::GpRegisters}; +use crate::emulation_core::architectures::DatapathRef; +use serde::{Deserialize, Serialize}; /// An implementation of a datapath for the MIPS64 ISA. #[derive(Clone, PartialEq)] @@ -76,7 +78,7 @@ pub struct MipsDatapath { } /// A collection of all the data lines and wires in the datapath. -#[derive(Clone, Default, PartialEq)] +#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] pub struct DatapathState { /// *Data line.* The currently loaded instruction. Initialized after the /// Instruction Fetch stage. @@ -185,6 +187,18 @@ impl Stage { } } +impl From for String { + fn from(val: Stage) -> String { + String::from(match val { + Stage::InstructionFetch => "writeback", + Stage::InstructionDecode => "instruction_fetch", + Stage::Execute => "instruction_decode", + Stage::Memory => "execute", + Stage::WriteBack => "memory", + }) + } +} + impl Default for MipsDatapath { fn default() -> Self { let mut datapath = MipsDatapath { @@ -210,7 +224,6 @@ impl Default for MipsDatapath { impl Datapath for MipsDatapath { type RegisterData = u64; type RegisterEnum = super::registers::GpRegisterType; - type MemoryType = Memory; fn execute_instruction(&mut self) { loop { @@ -255,10 +268,27 @@ impl Datapath for MipsDatapath { self.registers[register] } - fn get_memory(&self) -> &Self::MemoryType { + fn set_register_by_str(&mut self, _register: &str, _data: Self::RegisterData) { + todo!() + } + + fn initialize(&mut self, initial_pc: usize, instructions: Vec) -> Result<(), String> { + self.reset(); + self.load_instructions(instructions)?; + self.registers.pc = initial_pc as u64; + self.is_halted = false; + + Ok(()) + } + + fn get_memory(&self) -> &Memory { &self.memory } + fn set_memory(&mut self, _ptr: usize, _data: Vec) { + todo!() + } + fn is_halted(&self) -> bool { self.is_halted } @@ -266,13 +296,16 @@ impl Datapath for MipsDatapath { fn reset(&mut self) { std::mem::take(self); } + + fn as_datapath_ref(&self) -> DatapathRef { + DatapathRef::MIPS(self) + } } impl MipsDatapath { // ===================== General Functions ===================== - /// Reset the datapath, load instructions into memory, and un-sets the `is_halted` - /// flag. If the process fails, an [`Err`] is returned. - pub fn initialize(&mut self, instructions: Vec) -> Result<(), String> { + /// Legacy initialize function, to be removed later. + pub fn initialize_legacy(&mut self, instructions: Vec) -> Result<(), String> { self.reset(); self.load_instructions(instructions)?; self.is_halted = false; diff --git a/src/emulation_core/mips/line_info.rs b/src/emulation_core/mips/line_info.rs index c28c0a8aa..add7c20ec 100644 --- a/src/emulation_core/mips/line_info.rs +++ b/src/emulation_core/mips/line_info.rs @@ -19,8 +19,6 @@ pub struct LineInformation { } impl VisualDatapath for MipsDatapath { - type LineInformation = LineInformation; - fn visual_line_to_data(&self, variable: &str) -> LineInformation { match variable { "alu_input2" => LineInformation { diff --git a/src/emulation_core/mips/memory.rs b/src/emulation_core/mips/memory.rs index 2abcf1921..6dae642cf 100644 --- a/src/emulation_core/mips/memory.rs +++ b/src/emulation_core/mips/memory.rs @@ -1,9 +1,11 @@ //! Data and instruction memory implementation and API. +use serde::{Deserialize, Serialize}; + // pub const CAPACITY_BYTES: usize = 2^12; // 4KB pub const CAPACITY_BYTES: usize = 64 * 1024; // 64 KB -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct Memory { pub memory: Vec, } diff --git a/src/emulation_core/mips/registers.rs b/src/emulation_core/mips/registers.rs index efd218a83..a4171e87f 100644 --- a/src/emulation_core/mips/registers.rs +++ b/src/emulation_core/mips/registers.rs @@ -1,12 +1,13 @@ //! Register structure and API. +use serde::{Deserialize, Serialize}; use std::ops::{Index, IndexMut}; use std::str::FromStr; use strum::IntoEnumIterator; use strum_macros::{Display, EnumIter, EnumString}; /// Collection of general-purpose registers used by the datapath. -#[derive(Clone, Copy, Debug, Default, PartialEq)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize)] pub struct GpRegisters { pub pc: u64, pub gpr: [u64; 32], diff --git a/src/tests/emulation_core/mips.rs b/src/tests/emulation_core/mips.rs index f04ad427d..9483e3260 100644 --- a/src/tests/emulation_core/mips.rs +++ b/src/tests/emulation_core/mips.rs @@ -15,7 +15,7 @@ pub mod api { // Add instruction into emulation core memory. let instruction = String::from("ori $s0, $zero, 5"); let (_, instruction_bits) = parser(instruction); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.execute_instruction(); @@ -44,7 +44,7 @@ pub mod add { // $t1 = $t1 + $t1 // R-type t1 t1 t1 (shamt) ADD let instructions: Vec = vec![0b000000_01001_01001_01001_00000_100000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; // Assume the register $t1 has the value 5. datapath.registers[GpRegisterType::T1] = 5; @@ -63,7 +63,7 @@ pub mod add { // $s2 = $s0 + $s1 // R-type s0 s1 s2 (shamt) ADD let instructions: Vec = vec![0b000000_10000_10001_10010_00000_100000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[16] = 15; // $s0 datapath.registers.gpr[17] = 40; // $s1 @@ -85,7 +85,7 @@ pub mod add { // $zero = $t3 + $t3 // R-type t3 t3 zero (shamt) ADD let instructions: Vec = vec![0b000000_01011_01011_00000_00000_100000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[11] = 1234; // $t3 @@ -107,7 +107,7 @@ pub mod add { // $t1 = $t4 + $t4 // R-type t4 t4 t1 (shamt) ADD let instructions: Vec = vec![0b000000_01100_01100_01001_00000_100000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; // Assume register $t4 contains 2,454,267,026, a 32-bit integer. datapath.registers.gpr[12] = 0b10010010_01001001_00100100_10010010; @@ -133,7 +133,7 @@ pub mod add { // $t1 = $t4 + $t4 // R-type t4 t4 t1 (shamt) ADD let instructions: Vec = vec![0b000000_01100_01100_01001_00000_100000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; // Assume register $t4 contains 3,528,008,850, a 32-bit integer. datapath.registers.gpr[12] = 0b11010010_01001001_00100100_10010010; @@ -158,7 +158,7 @@ pub mod addu { // $t1 = $t1 + $t1 // R-type t1 t1 t1 (shamt) ADDU let instructions: Vec = vec![0b000000_01001_01001_01001_00000_100001]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; // Assume the register $t1 has the value 5. datapath.registers[GpRegisterType::T1] = 5; @@ -177,7 +177,7 @@ pub mod addu { // $s2 = $s0 + $s1 // R-type s0 s1 s2 (shamt) ADDU let instructions: Vec = vec![0b000000_10000_10001_10010_00000_100001]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[16] = 15; // $s0 datapath.registers.gpr[17] = 40; // $s1 @@ -199,7 +199,7 @@ pub mod addu { // $zero = $t3 + $t3 // R-type t3 t3 zero (shamt) ADDU let instructions: Vec = vec![0b000000_01011_01011_00000_00000_100001]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[11] = 1234; // $t3 @@ -217,7 +217,7 @@ pub mod addu { // $t1 = $t4 + $t4 // R-type t4 t4 t1 (shamt) ADDU let instructions: Vec = vec![0b000000_01100_01100_01001_00000_100001]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; // Assume register $t4 contains 2,454,267,026, a 32-bit integer. datapath.registers.gpr[12] = 0b10010010_01001001_00100100_10010010; @@ -239,7 +239,7 @@ pub mod addu { // $t1 = $t4 + $t4 // R-type t4 t4 t1 (shamt) ADDU let instructions: Vec = vec![0b000000_01100_01100_01001_00000_100001]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; // Assume register $t4 contains 3,528,008,850, a 32-bit integer. datapath.registers.gpr[12] = 0b11010010_01001001_00100100_10010010; @@ -265,7 +265,7 @@ pub mod sub { // $s2 = $s3 - $s2 // R-type s3 s2 s2 (shamt) SUB let instructions: Vec = vec![0b000000_10011_10010_10010_00000_100010]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[19] = 7; // $s3 datapath.registers.gpr[18] = 3; // $s2 @@ -284,7 +284,7 @@ pub mod sub { // $s0 = $s0 - $t0 // R-type s0 t0 s0 (shamt) SUB let instructions: Vec = vec![0b000000_10000_01000_10000_00000_100010]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[16] = 5; // $s0 datapath.registers.gpr[8] = 20; // $t0 @@ -307,7 +307,7 @@ pub mod sub { // $s0 = $s0 - $t0 // R-type s0 t0 s0 (shamt) SUB let instructions: Vec = vec![0b000000_10000_01000_10000_00000_100010]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[16] = 0; // $s0 datapath.registers.gpr[8] = 1; // $t0 @@ -333,7 +333,7 @@ pub mod mul { // $s5 = $t7 * $t6 // R-type t7 t6 s5 MUL SOP30 let instructions: Vec = vec![0b000000_01111_01110_10101_00010_011000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[15] = 8; // $t7 datapath.registers.gpr[14] = 95; // $t6 @@ -351,7 +351,7 @@ pub mod mul { // $s5 = $t7 * $t6 // R-type t7 t6 s5 MUL SOP30 let instructions: Vec = vec![0b000000_01111_01110_10101_00010_011000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[15] = 5; // $t7 datapath.registers.gpr[14] = -5_i64 as u64; // $t6 @@ -369,7 +369,7 @@ pub mod mul { // $s4 = $t6 * $t5 // R-type t6 t5 s4 MUL SOP30 let instructions: Vec = vec![0b000000_01110_01101_10100_00010_011000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[14] = 731_564_544; // $t6 datapath.registers.gpr[13] = 8; // $t5 @@ -397,7 +397,7 @@ pub mod div { // $s4 = $t6 / $t5 // R-type t6 t5 s4 DIV SOP32 let instructions: Vec = vec![0b000000_01110_01101_10100_00010_011010]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[14] = 20; // $t6 datapath.registers.gpr[13] = 2; // $t5 @@ -415,7 +415,7 @@ pub mod div { // $s4 = $t6 / $t5 // R-type t6 t5 s4 DIV SOP32 let instructions: Vec = vec![0b000000_01110_01101_10100_00010_011010]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[14] = 20; // $t6 datapath.registers.gpr[13] = -5_i64 as u64; // $t5 @@ -437,7 +437,7 @@ pub mod or { // $t1 = $t1 & $t1 // R-type t1 t1 t1 (shamt) OR let instructions: Vec = vec![0b000000_01001_01001_01001_00000_100101]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; // Assume the register $t1 has the value 5. datapath.registers[GpRegisterType::T1] = 0x5; @@ -454,7 +454,7 @@ pub mod or { // $s2 = $s0 & $s1 // R-type s0 s1 s2 (shamt) OR let instructions: Vec = vec![0b000000_10000_10001_10010_00000_100101]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[16] = 0x1234; // $s0 datapath.registers.gpr[17] = 0x4321; // $s1 @@ -474,7 +474,7 @@ pub mod or { // $s2 = $s0 & $s1 // R-type s0 s1 s2 (shamt) OR let instructions: Vec = vec![0b000000_10000_10001_10010_00000_100101]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[16] = 0x12341234; // $s0 datapath.registers.gpr[17] = 0x43214321; // $s1 @@ -494,7 +494,7 @@ pub mod or { // $s2 = $s0 & $s1 // R-type s0 s1 s2 (shamt) OR let instructions: Vec = vec![0b000000_10000_10001_10010_00000_100101]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[16] = 0x1234123412341234; // $s0 datapath.registers.gpr[17] = 0x4321432143214321; // $s1 @@ -516,7 +516,7 @@ pub mod or { // $zero = $t3 & $t3 // R-type t3 t3 zero (shamt) OR let instructions: Vec = vec![0b000000_01011_01011_00000_00000_100101]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[11] = 1234; // $t3 @@ -537,7 +537,7 @@ pub mod and { // $t1 = $t1 & $t1 // R-type t1 t1 t1 (shamt) AND let instructions: Vec = vec![0b000000_01001_01001_01001_00000_100100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; // Assume the register $t1 has the value 5. datapath.registers[GpRegisterType::T1] = 0x5; @@ -554,7 +554,7 @@ pub mod and { // $s2 = $s0 & $s1 // R-type s0 s1 s2 (shamt) AND let instructions: Vec = vec![0b000000_10000_10001_10010_00000_100100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[16] = 0x1234; // $s0 datapath.registers.gpr[17] = 0x4321; // $s1 @@ -574,7 +574,7 @@ pub mod and { // $s2 = $s0 & $s1 // R-type s0 s1 s2 (shamt) AND let instructions: Vec = vec![0b000000_10000_10001_10010_00000_100100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[16] = 0x12341234; // $s0 datapath.registers.gpr[17] = 0x43214321; // $s1 @@ -594,7 +594,7 @@ pub mod and { // $s2 = $s0 & $s1 // R-type s0 s1 s2 (shamt) AND let instructions: Vec = vec![0b000000_10000_10001_10010_00000_100100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[16] = 0x1234123412341234; // $s0 datapath.registers.gpr[17] = 0x4321432143214321; // $s1 @@ -616,7 +616,7 @@ pub mod and { // $zero = $t3 & $t3 // R-type t3 t3 zero (shamt) AND let instructions: Vec = vec![0b000000_01011_01011_00000_00000_100100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[11] = 1234; // $t3 @@ -638,7 +638,7 @@ pub mod sll { // something // R-type s1 s2 (shamt) SLL let instructions: Vec = vec![0b000000_00000_10001_10010_00000_000000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[0b10001] = 123; datapath.registers.gpr[0b10010] = 321; @@ -655,7 +655,7 @@ pub mod sll { // Shift left by two logical // R-type s1 s2 (shamt) SLL let instructions: Vec = vec![0b000000_00000_10001_10010_00010_000000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[0b10001] = 0b1010; datapath.registers.gpr[0b10010] = 0; @@ -672,7 +672,7 @@ pub mod sll { // Shift left by two logical // R-type s1 s2 (shamt) SLL let instructions: Vec = vec![0b000000_00000_10001_10010_00010_000000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[0b10001] = 0x7fffffff; datapath.registers.gpr[0b10010] = 0x10101011; @@ -694,7 +694,7 @@ pub mod slt { // $s2 = $s0 < $s1 // R-type s0 s1 s2 (shamt) SLT let instructions: Vec = vec![0b000000_10000_10001_10010_00000_101010]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers[GpRegisterType::S0] = 1; datapath.registers[GpRegisterType::S1] = 123; @@ -712,7 +712,7 @@ pub mod slt { // $s2 = $s0 < $s1 // R-type s0 s1 s2 (shamt) SLT let instructions: Vec = vec![0b000000_10000_10001_10010_00000_101010]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers[GpRegisterType::S0] = 124; datapath.registers[GpRegisterType::S1] = 123; @@ -730,7 +730,7 @@ pub mod slt { // $s2 = $s0 < $s1 // R-type s0 s1 s2 (shamt) SLT let instructions: Vec = vec![0b000000_10000_10001_10010_00000_101010]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers[GpRegisterType::S0] = -124_i64 as u64; datapath.registers[GpRegisterType::S1] = 123; @@ -752,7 +752,7 @@ pub mod sltu { // $s2 = $s0 < $s1 // R-type s0 s1 s2 (shamt) SLTU let instructions: Vec = vec![0b000000_10000_10001_10010_00000_101011]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers[GpRegisterType::S0] = 1; datapath.registers[GpRegisterType::S1] = 123; @@ -770,7 +770,7 @@ pub mod sltu { // $s2 = $s0 < $s1 // R-type s0 s1 s2 (shamt) SLTU let instructions: Vec = vec![0b000000_10000_10001_10010_00000_101011]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers[GpRegisterType::S0] = 124; datapath.registers[GpRegisterType::S1] = 123; @@ -788,7 +788,7 @@ pub mod sltu { // $s2 = $s0 < $s1 // R-type s0 s1 s2 (shamt) SLTU let instructions: Vec = vec![0b000000_10000_10001_10010_00000_101011]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers[GpRegisterType::S0] = -124_i64 as u64; datapath.registers[GpRegisterType::S1] = 123; @@ -809,7 +809,7 @@ pub mod andi { // $s0 = $zero & 12345 // andi $zero $s0 12345 let instructions: Vec = vec![0b001100_00000_10000_0011000000111001]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.execute_instruction(); @@ -824,7 +824,7 @@ pub mod andi { // $s0 = $t0 & 12345 // andi $t0 $s0 12345 let instructions: Vec = vec![0b001100_01000_10000_0011000000111001]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; // In binary: 00111010 11011110 01101000 10110001 datapath.registers.gpr[8] = 987654321; // $t0 @@ -851,7 +851,7 @@ pub mod addi_addiu { // $s0 = $t0 + 0x4 // addi $t0 $s0 4 let instructions: Vec = vec![0b001000_01000_10000_0000000000000100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers[GpRegisterType::T0] = 1; datapath.registers[GpRegisterType::S0] = 123; datapath.execute_instruction(); @@ -871,7 +871,7 @@ pub mod addi_addiu { // $s0 = $t0 + 0x4 // addi $t0 $s0 4 let instructions: Vec = vec![0b001000_01000_10000_0000000000000100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers[GpRegisterType::T0] = 0xffffffff; datapath.registers[GpRegisterType::S0] = 123; datapath.execute_instruction(); @@ -888,7 +888,7 @@ pub mod addi_addiu { // $s0 = $t0 + 0x1 // addi $t0 $s0 1 let instructions: Vec = vec![0b001000_01000_10000_0000000000000001]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers[GpRegisterType::T0] = 0xfffffff1; datapath.execute_instruction(); @@ -903,7 +903,7 @@ pub mod addi_addiu { // $s0 = $t0 + 0x1 // addi $t0 $s0 1 let instructions: Vec = vec![0b001000_01000_10000_0000000000000001]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers[GpRegisterType::T0] = 0xfffffffe; datapath.execute_instruction(); @@ -918,7 +918,7 @@ pub mod addi_addiu { // $s0 = $t0 + 0x4 // addiu $t0 $s0 4 let instructions: Vec = vec![0b001001_01000_10000_0000000000000100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers[GpRegisterType::T0] = 1; datapath.registers[GpRegisterType::S0] = 123; datapath.execute_instruction(); @@ -934,7 +934,7 @@ pub mod addi_addiu { // $s0 = $t0 + 0x4 // addiu $t0 $s0 4 let instructions: Vec = vec![0b001001_01000_10000_0000000000000100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers[GpRegisterType::T0] = 0xffffffff; datapath.registers[GpRegisterType::S0] = 123; datapath.execute_instruction(); @@ -951,7 +951,7 @@ pub mod addi_addiu { // $s0 = $t0 + 0x1 // addi $t0 $s0 1 let instructions: Vec = vec![0b001000_01000_10000_0000000000000001]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers[GpRegisterType::T0] = 0xfffffff1; datapath.execute_instruction(); @@ -969,7 +969,7 @@ pub mod daddi_and_daddiu { // $s0 = $t0 + 0x4 // daddi $t0 $s0 4 let instructions: Vec = vec![0b011000_01000_10000_0000000000000100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers[GpRegisterType::T0] = 1; datapath.registers[GpRegisterType::S0] = 123; datapath.execute_instruction(); @@ -989,7 +989,7 @@ pub mod daddi_and_daddiu { // $s0 = $t0 + 0x1 // daddi $t0 $s0 1 let instructions: Vec = vec![0b011000_01000_10000_0000000000000001]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers[GpRegisterType::T0] = 0xffffffffffffffff; datapath.registers[GpRegisterType::S0] = 123; datapath.execute_instruction(); @@ -1005,7 +1005,7 @@ pub mod daddi_and_daddiu { // $s0 = $t0 + 0x1 // daddi $t0 $s0 1 let instructions: Vec = vec![0b011000_01000_10000_0000000000000001]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers[GpRegisterType::T0] = 0xfffffffffffffff1; datapath.execute_instruction(); @@ -1020,7 +1020,7 @@ pub mod daddi_and_daddiu { // $s0 = $t0 + 0x1 // daddi $t0 $s0 1 let instructions: Vec = vec![0b011000_01000_10000_0000000000000001]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers[GpRegisterType::T0] = 0xfffffffffffffffe; datapath.execute_instruction(); @@ -1035,7 +1035,7 @@ pub mod daddi_and_daddiu { // $s0 = $t0 + 0x4 // daddiu $t0 $s0 4 let instructions: Vec = vec![0b011001_01000_10000_0000000000000100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers[GpRegisterType::T0] = 1; datapath.registers[GpRegisterType::S0] = 123; datapath.execute_instruction(); @@ -1051,7 +1051,7 @@ pub mod daddi_and_daddiu { // $s0 = $t0 + 0x4 // daddiu $t0 $s0 4 let instructions: Vec = vec![0b011001_01000_10000_0000000000000100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers[GpRegisterType::T0] = 0xffffffffffffffff; datapath.registers[GpRegisterType::S0] = 123; datapath.execute_instruction(); @@ -1069,7 +1069,7 @@ pub mod daddi_and_daddiu { // $s0 = $t0 + 0x1 // daddiu $t0 $s0 1 let instructions: Vec = vec![0b011001_01000_10000_0000000000000001]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers[GpRegisterType::T0] = 0xfffffffffffffff1; datapath.execute_instruction(); @@ -1087,7 +1087,7 @@ pub mod ori { // $s0 = $zero | 12345 // ori $zero $s0 12345 let instructions: Vec = vec![0b001101_00000_10000_0011000000111001]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.execute_instruction(); @@ -1102,7 +1102,7 @@ pub mod ori { // $s0 = $t0 | 12345 // ori $t0 $s0 12345 let instructions: Vec = vec![0b001101_01000_10000_0011000000111001]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; // In binary: 00111010 11011110 01101000 10110001 datapath.registers.gpr[8] = 987654321; // $t0 @@ -1133,7 +1133,7 @@ pub mod dadd_daddu { // SPECIAL rs rt rd 0 DADD // 13 13 2 let instructions: Vec = vec![0b000000_01101_01101_00010_00000_101100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; // Assume register $t5 contains 969,093,589,304, which is an integer // that takes up 39 bits. @@ -1159,7 +1159,7 @@ pub mod dadd_daddu { // SPECIAL rs rt rd 0 DADD // 13 13 2 let instructions: Vec = vec![0b000000_01101_01101_00010_00000_101100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; // Assume register $t5 contains 18,134,889,837,812,767,690, which is an integer // that takes up 64 bits. @@ -1182,7 +1182,7 @@ pub mod dadd_daddu { // SPECIAL rs rt rd 0 DADDU // 16 17 18 let instructions: Vec = vec![0b000000_10000_10001_10010_00000_101101]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[16] = 1_069_193_590_294; // $s0 datapath.registers.gpr[17] = 34_359_738_368; // $s1 @@ -1210,7 +1210,7 @@ pub mod dsub_dsubu { // $s4 $s3 $s5 DSUB // 18 17 19 let instructions: Vec = vec![0b000000_10010_10001_10011_00000_101110]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; // Assume registers $s3 and $s4 contain numbers larger than 32 bits, // but smaller than 64 bits. @@ -1240,7 +1240,7 @@ pub mod dsub_dsubu { // $s4 $s3 $s5 DSUB // 18 17 19 let instructions: Vec = vec![0b000000_10010_10001_10011_00000_101110]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; // Assume registers $s4 is the minimum possible integer and $s4 is 1. datapath.registers.gpr[18] = 0; // $s4 @@ -1263,7 +1263,7 @@ pub mod dsub_dsubu { // SPECIAL rs rt rd 0 DSUBU // 16 17 18 let instructions: Vec = vec![0b000000_10000_10001_10010_00000_101111]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[16] = 92_975_612_771_919; // $s0 datapath.registers.gpr[17] = 13_810_775_572_047; // $s1 @@ -1290,7 +1290,7 @@ pub mod dmul_dmulu { // SPECIAL $t8 $t9 $a0 DMUL SOP34 // 24 25 4 let instructions: Vec = vec![0b000000_11000_11001_00100_00010_011100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; // Assume register $t8 contains a number larger than 32 bits, // but smaller than 64 bits. @@ -1315,7 +1315,7 @@ pub mod dmul_dmulu { // SPECIAL $t7 $t6 $s7 DMUL SOP34 // 15 14 23 let instructions: Vec = vec![0b000000_01111_01110_10111_00010_011100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; // Assume register $t7 contains a number larger than 32 bits, // but smaller than 64 bits. @@ -1340,7 +1340,7 @@ pub mod dmul_dmulu { // SPECIAL $s4 $s3 $s2 DMUL SOP34 // 20 19 18 let instructions: Vec = vec![0b000000_10100_10011_10010_00010_011100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; // Assume registers $s4 and $s3 contain numbers larger than 32 bits, // but smaller than 64 bits. @@ -1369,7 +1369,7 @@ pub mod dmul_dmulu { // SPECIAL $s0 $s1 $s2 DMULU SOP35 // 16 17 18 let instructions: Vec = vec![0b000000_10000_10001_10010_00010_011101]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[16] = 17_592_186_044_416; // $s0 datapath.registers.gpr[17] = 1_000; // $s1 @@ -1397,7 +1397,7 @@ pub mod ddiv_ddivu { // 17 18 16 let instructions: Vec = vec![0b000000_10001_10010_10000_00010_011110]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; // Assume register $s1 contains a number larger than 32 bits, // but smaller than 64 bits. @@ -1425,7 +1425,7 @@ pub mod ddiv_ddivu { // 6 5 7 let instructions: Vec = vec![0b000000_00110_00101_00111_00010_011110]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; // Assume register $a2 contains a number larger than 32 bits, // but smaller than 64 bits. @@ -1453,7 +1453,7 @@ pub mod ddiv_ddivu { // 16 17 18 let instructions: Vec = vec![0b000000_10000_10001_10010_00010_011111]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[16] = 10_213_202_487_240; // $s0 datapath.registers.gpr[17] = 11; // $s1 @@ -1479,7 +1479,7 @@ pub mod dahi_dati { // op rs rt immediate // REGIMM $a0 DAHI 1 let instructions: Vec = vec![0b000001_00100_00110_0000000000000001]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[4] = 0xABCD; // $a0 @@ -1501,7 +1501,7 @@ pub mod dahi_dati { // op rs rt immediate // REGIMM $a1 DATI 1 let instructions: Vec = vec![0b000001_00101_11110_0000000000000001]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[5] = 0xABCD; // $a1 @@ -1523,7 +1523,7 @@ pub mod load_word { // lw $t0 $s0 offset = 0 let instructions: Vec = vec![0b100011_01000_10000_0000000000000000]; - datapath.initialize(instructions.clone())?; + datapath.initialize_legacy(instructions.clone())?; datapath.execute_instruction(); assert_eq!(datapath.registers.gpr[16], instructions[0] as u64); Ok(()) @@ -1537,7 +1537,7 @@ pub mod load_word { // lw $t0 $s0 offset = 4 let instructions: Vec = vec![0b100011_01000_10000_0000000000000100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; // place data at address datapath.memory.store_word(0b100, 0x10000)?; @@ -1556,7 +1556,7 @@ pub mod load_word { // lw $t0 $s0 offset = 0 let instructions: Vec = vec![0b100011_01000_10000_0000000000000000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; // place data at address datapath.memory.store_word(0b100, 0x10000)?; @@ -1575,7 +1575,7 @@ pub mod load_word { // lw $t0 $s0 offset = 0 let instructions: Vec = vec![0b100011_01000_10000_0000000000000100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; // place data at address datapath.memory.store_word(0b1000, 0x10000)?; @@ -1594,7 +1594,7 @@ pub mod load_word { // lw $t0 $s0 offset = 0 let instructions: Vec = vec![0b100011_01000_10000_1111111111111100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; // place data at address datapath.memory.store_word(0b1000, 0x10000)?; @@ -1615,7 +1615,7 @@ pub mod load_upper_imm { // lui $t0 $s0 offset = 42 let instructions: Vec = vec![0b001111_01000_10000_0010101010101010]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.execute_instruction(); let t = datapath.registers[GpRegisterType::S0]; @@ -1629,7 +1629,7 @@ pub mod load_upper_imm { // lui $t0 $s0 offset = 42 let instructions: Vec = vec![0b001111_01000_10000_1010101010101010]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.execute_instruction(); let t = datapath.registers[GpRegisterType::S0]; @@ -1645,7 +1645,7 @@ pub mod store_word { // sw $t0 $s0 offset = 0 let instructions: Vec = vec![0b101011_01000_10000_0000000000000000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.execute_instruction(); let t = datapath.memory.load_word(0)?; @@ -1659,7 +1659,7 @@ pub mod store_word { // sw $t0 $s0 offset = 4 let instructions: Vec = vec![0b101011_01000_10000_0000000000000100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[8] = 0; datapath.registers.gpr[16] = 0xff; @@ -1676,7 +1676,7 @@ pub mod store_word { // sw $t0 $s0 offset = 4 let instructions: Vec = vec![0b101011_01000_10000_0000000000000100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[8] = 4; datapath.registers.gpr[16] = 0xff; @@ -1693,7 +1693,7 @@ pub mod store_word { // sw $t0 $s0 offset = -4 let instructions: Vec = vec![0b101011_01000_10000_1111111111111100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[8] = 12; datapath.registers.gpr[16] = 0xff; @@ -1719,7 +1719,7 @@ pub mod coprocessor { // COP1 fmt ft fs fd function // s $f0 $f1 $f2 ADD let instructions: Vec = vec![0b010001_10000_00000_00001_00010_000000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[0] = f32::to_bits(0.25f32) as u64; datapath.coprocessor.fpr[1] = f32::to_bits(0.5f32) as u64; @@ -1742,7 +1742,7 @@ pub mod coprocessor { // COP1 fmt ft fs fd function // d $f0 $f1 $f2 ADD let instructions: Vec = vec![0b010001_10001_00000_00001_00010_000000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[0] = f64::to_bits(123.125); datapath.coprocessor.fpr[1] = f64::to_bits(0.5); @@ -1766,7 +1766,7 @@ pub mod coprocessor { // COP1 fmt ft fs fd function // s $f0 $f1 $f2 SUB let instructions: Vec = vec![0b010001_10000_00000_00001_00010_000001]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[0] = f32::to_bits(5.625f32) as u64; datapath.coprocessor.fpr[1] = f32::to_bits(3.125f32) as u64; @@ -1788,7 +1788,7 @@ pub mod coprocessor { // COP1 fmt ft fs fd function // d $f0 $f1 $f2 SUB let instructions: Vec = vec![0b010001_10001_00000_00001_00010_000001]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[0] = f64::to_bits(438.125); datapath.coprocessor.fpr[1] = f64::to_bits(98765.5); @@ -1810,7 +1810,7 @@ pub mod coprocessor { // COP1 fmt ft fs fd function // s $f4 $f5 $f9 MUL let instructions: Vec = vec![0b010001_10000_00100_00101_01001_000010]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[5] = f32::to_bits(24.5f32) as u64; datapath.coprocessor.fpr[4] = f32::to_bits(0.5f32) as u64; @@ -1832,7 +1832,7 @@ pub mod coprocessor { // COP1 fmt ft fs fd function // d $f9 $f6 $f4 MUL let instructions: Vec = vec![0b010001_10001_01001_00110_00100_000010]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[6] = f64::to_bits(-150.0625); datapath.coprocessor.fpr[9] = f64::to_bits(9.5); @@ -1854,7 +1854,7 @@ pub mod coprocessor { // COP1 fmt ft fs fd function // s $f17 $f16 $f15 DIV let instructions: Vec = vec![0b010001_10000_10001_10000_01111_000011]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[16] = f32::to_bits(901f32) as u64; datapath.coprocessor.fpr[17] = f32::to_bits(2f32) as u64; @@ -1879,7 +1879,7 @@ pub mod coprocessor { // COP1 fmt ft fs fd function // d $f20 $f10 $f1 DIV let instructions: Vec = vec![0b010001_10001_10100_01010_00001_000011]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[10] = f64::to_bits(95405.375); datapath.coprocessor.fpr[20] = f64::to_bits(2.0); @@ -1901,7 +1901,7 @@ pub mod coprocessor { // SWC1 base ft offset // $s1 $f3 0 let instructions: Vec = vec![0b111001_10001_00011_0000000000000000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[17] = 1028; // $s1 datapath.coprocessor.fpr[3] = f32::to_bits(1.0625f32) as u64; @@ -1927,7 +1927,7 @@ pub mod coprocessor { // SWC1 base ft offset // $s0 $f5 32 let instructions: Vec = vec![0b111001_10000_00101_0000000000100000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[16] = 2000; // $s0 datapath.coprocessor.fpr[5] = f32::to_bits(3.5f32) as u64; @@ -1957,7 +1957,7 @@ pub mod coprocessor { // SWC1 base ft offset // $s2 $f0 0 let instructions: Vec = vec![0b111001_10010_00000_0000000000000000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[18] = 1000; // $s2 datapath.coprocessor.fpr[0] = f64::to_bits(9853114.625); @@ -1982,7 +1982,7 @@ pub mod coprocessor { // LWC1 base ft offset // $t0 $f10 0 let instructions: Vec = vec![0b110001_01000_01010_0000000000000000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[8] = 500; // $t0 @@ -2013,7 +2013,7 @@ pub mod coprocessor { // LWC1 base ft offset // $t1 $f11 200 let instructions: Vec = vec![0b110001_01001_01011_0000000011001000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[9] = 1000; // $t1 @@ -2044,7 +2044,7 @@ pub mod coprocessor { // COP1 fmt ft fs cc __cond // s $f2 $f1 0 EQ let instructions: Vec = vec![0b010001_10000_00010_00001_000_00_110010]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[1] = f32::to_bits(15.5f32) as u64; datapath.coprocessor.fpr[2] = f32::to_bits(15.5f32) as u64; @@ -2067,7 +2067,7 @@ pub mod coprocessor { // COP1 fmt ft fs cc __cond // s $f3 $f14 0 EQ let instructions: Vec = vec![0b010001_10000_00011_01110_000_00_110010]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[14] = f32::to_bits(20.125f32) as u64; datapath.coprocessor.fpr[3] = f32::to_bits(100f32) as u64; @@ -2090,7 +2090,7 @@ pub mod coprocessor { // COP1 fmt ft fs cc __cond // d $f9 $f5 0 EQ let instructions: Vec = vec![0b010001_10001_01001_00101_000_00_110010]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[5] = f64::to_bits(12951.625); datapath.coprocessor.fpr[9] = f64::to_bits(12951.625); @@ -2113,7 +2113,7 @@ pub mod coprocessor { // COP1 fmt ft fs cc __cond // d $f19 $f15 0 EQ let instructions: Vec = vec![0b010001_10001_10011_01111_000_00_110010]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[15] = f64::to_bits(6016.25); datapath.coprocessor.fpr[19] = f64::to_bits(820.43); @@ -2136,7 +2136,7 @@ pub mod coprocessor { // COP1 fmt ft fs cc __cond // s $f0 $f19 0 LT let instructions: Vec = vec![0b010001_10000_00000_10011_000_00_111100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[19] = f32::to_bits(2.875f32) as u64; datapath.coprocessor.fpr[0] = f32::to_bits(70.6f32) as u64; @@ -2159,7 +2159,7 @@ pub mod coprocessor { // COP1 fmt ft fs cc __cond // s $f31 $f30 0 LT let instructions: Vec = vec![0b010001_10000_11111_11110_000_00_111100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[30] = f32::to_bits(90.7f32) as u64; datapath.coprocessor.fpr[31] = f32::to_bits(-87.44f32) as u64; @@ -2182,7 +2182,7 @@ pub mod coprocessor { // COP1 fmt ft fs cc __cond // d $f29 $f12 0 LT let instructions: Vec = vec![0b010001_10001_11101_01100_000_00_111100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[12] = f64::to_bits(4.0); datapath.coprocessor.fpr[29] = f64::to_bits(30000.6); @@ -2205,7 +2205,7 @@ pub mod coprocessor { // COP1 fmt ft fs cc __cond // d $f5 $f4 0 LT let instructions: Vec = vec![0b010001_10001_00101_00100_000_00_111100]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[4] = f64::to_bits(413.420); datapath.coprocessor.fpr[5] = f64::to_bits(-6600.9); @@ -2228,7 +2228,7 @@ pub mod coprocessor { // COP1 fmt ft fs cc __cond // s $f1 $f0 0 LE let instructions: Vec = vec![0b010001_10000_00001_00000_000_00_111110]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[0] = f32::to_bits(171.937f32) as u64; datapath.coprocessor.fpr[1] = f32::to_bits(9930.829f32) as u64; @@ -2251,7 +2251,7 @@ pub mod coprocessor { // COP1 fmt ft fs cc __cond // s $f3 $f2 0 LE let instructions: Vec = vec![0b010001_10000_00011_00010_000_00_111110]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[2] = f32::to_bits(6.5f32) as u64; datapath.coprocessor.fpr[3] = f32::to_bits(6.5f32) as u64; @@ -2274,7 +2274,7 @@ pub mod coprocessor { // COP1 fmt ft fs cc __cond // s $f5 $f4 0 LE let instructions: Vec = vec![0b010001_10000_00101_00100_000_00_111110]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[4] = f32::to_bits(5742.006f32) as u64; datapath.coprocessor.fpr[5] = f32::to_bits(1336.568f32) as u64; @@ -2297,7 +2297,7 @@ pub mod coprocessor { // COP1 fmt ft fs cc __cond // d $f7 $f6 0 LE let instructions: Vec = vec![0b010001_10001_00111_00110_000_00_111110]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[6] = f64::to_bits(3483.70216); datapath.coprocessor.fpr[7] = f64::to_bits(7201.56625); @@ -2320,7 +2320,7 @@ pub mod coprocessor { // COP1 fmt ft fs cc __cond // d $f9 $f8 0 LE let instructions: Vec = vec![0b010001_10001_01001_01000_000_00_111110]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[8] = f64::to_bits(77.4009); datapath.coprocessor.fpr[9] = f64::to_bits(77.4009); @@ -2343,7 +2343,7 @@ pub mod coprocessor { // COP1 fmt ft fs cc __cond // d $f11 $f10 0 LE let instructions: Vec = vec![0b010001_10001_01011_01010_000_00_111110]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[10] = f64::to_bits(9190.43309); datapath.coprocessor.fpr[11] = f64::to_bits(2869.57622); @@ -2366,7 +2366,7 @@ pub mod coprocessor { // COP1 fmt ft fs cc __cond // s $f13 $f12 0 NGT let instructions: Vec = vec![0b010001_10000_01101_01100_000_00_111111]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[12] = f32::to_bits(2469.465f32) as u64; datapath.coprocessor.fpr[13] = f32::to_bits(3505.57f32) as u64; @@ -2389,7 +2389,7 @@ pub mod coprocessor { // COP1 fmt ft fs cc __cond // s $f15 $f14 0 NGT let instructions: Vec = vec![0b010001_10000_01111_01110_000_00_111111]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[14] = f32::to_bits(7099.472f32) as u64; datapath.coprocessor.fpr[15] = f32::to_bits(87.198f32) as u64; @@ -2412,7 +2412,7 @@ pub mod coprocessor { // COP1 fmt ft fs cc __cond // d $f17 $f16 0 NGT let instructions: Vec = vec![0b010001_10001_10001_10000_000_00_111111]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[16] = f64::to_bits(7726.4794015); datapath.coprocessor.fpr[17] = f64::to_bits(9345.7753943); @@ -2435,7 +2435,7 @@ pub mod coprocessor { // COP1 fmt ft fs cc __cond // d $f19 $f18 0 NGT let instructions: Vec = vec![0b010001_10001_10011_10010_000_00_111111]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[18] = f64::to_bits(4688.2854359); datapath.coprocessor.fpr[19] = f64::to_bits(819.7956308); @@ -2458,7 +2458,7 @@ pub mod coprocessor { // COP1 fmt ft fs cc __cond // s $f21 $f20 0 NGE let instructions: Vec = vec![0b010001_10000_10101_10100_000_00_111101]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[20] = f32::to_bits(3090.244f32) as u64; datapath.coprocessor.fpr[21] = f32::to_bits(7396.444f32) as u64; @@ -2481,7 +2481,7 @@ pub mod coprocessor { // COP1 fmt ft fs cc __cond // s $f23 $f22 0 NGE let instructions: Vec = vec![0b010001_10000_10111_10110_000_00_111101]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[22] = f32::to_bits(6269.823f32) as u64; datapath.coprocessor.fpr[23] = f32::to_bits(3089.393f32) as u64; @@ -2504,7 +2504,7 @@ pub mod coprocessor { // COP1 fmt ft fs cc __cond // d $f25 $f24 0 NGE let instructions: Vec = vec![0b010001_10001_11001_11000_000_00_111101]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[24] = f64::to_bits(819.7956308); datapath.coprocessor.fpr[25] = f64::to_bits(4688.2854359); @@ -2527,7 +2527,7 @@ pub mod coprocessor { // COP1 fmt ft fs cc __cond // d $f27 $f26 0 NGE let instructions: Vec = vec![0b010001_10001_11011_11010_000_00_111101]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[26] = f64::to_bits(9776.3465875); datapath.coprocessor.fpr[27] = f64::to_bits(1549.8268716); @@ -2557,7 +2557,7 @@ pub mod coprocessor { // 0 -1 (which becomes -4) 0b010001_01000_000_0_1_1111111111111110, ]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[5] = f64::to_bits(12951.625); datapath.coprocessor.fpr[9] = f64::to_bits(12951.625); @@ -2588,7 +2588,7 @@ pub mod coprocessor { // 0 -1 (which becomes -4) 0b010001_01000_000_0_1_1111111111111110, ]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[5] = f64::to_bits(12952.625); datapath.coprocessor.fpr[9] = f64::to_bits(12951.625); @@ -2619,7 +2619,7 @@ pub mod coprocessor { // 0 -1 (which becomes -4) 0b010001_01000_000_0_0_1111111111111110, ]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[4] = f32::to_bits(5742.006f32) as u64; datapath.coprocessor.fpr[5] = f32::to_bits(1336.568f32) as u64; @@ -2650,7 +2650,7 @@ pub mod coprocessor { // 0 -1 (which becomes -4) 0b010001_01000_000_0_0_1111111111111110, ]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[4] = f32::to_bits(742.006f32) as u64; datapath.coprocessor.fpr[5] = f32::to_bits(1336.568f32) as u64; @@ -2674,7 +2674,7 @@ pub mod coprocessor { // COP1 sub rt fs 0 // MT $s0 $f0 let instructions: Vec = vec![0b010001_00100_10000_00000_00000000000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[16] = 25; @@ -2696,7 +2696,7 @@ pub mod coprocessor { // COP1 sub rt fs 0 // MT $s1 $f1 let instructions: Vec = vec![0b010001_00100_10001_00001_00000000000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[17] = 0x1234_5678_ABCD_BEEF; @@ -2718,7 +2718,7 @@ pub mod coprocessor { // COP1 sub rt fs 0 // DMT $t0 $f30 let instructions: Vec = vec![0b010001_00101_01000_11110_00000000000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[8] = 0xDEAD_BEEF_FEED_DEED; @@ -2740,7 +2740,7 @@ pub mod coprocessor { // COP1 sub rt fs 0 // MF $s5 $f18 let instructions: Vec = vec![0b010001_00000_10101_10010_00000000000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[18] = 123; @@ -2762,7 +2762,7 @@ pub mod coprocessor { // COP1 sub rt fs 0 // MF $s6 $f19 let instructions: Vec = vec![0b010001_00000_10110_10011_00000000000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[19] = 0xABBA_BABB_3ABA_4444; @@ -2784,7 +2784,7 @@ pub mod coprocessor { // COP1 sub rt fs 0 // MF $s7 $f20 let instructions: Vec = vec![0b010001_00000_10111_10100_00000000000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[20] = 0xBADA_BEEF_BADA_B00E; @@ -2806,7 +2806,7 @@ pub mod coprocessor { // COP1 sub rt fs 0 // DMF $t8 $f21 let instructions: Vec = vec![0b010001_00001_11000_10101_00000000000]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.coprocessor.fpr[21] = 0xADDA_DADD_1BAA_CAFE; @@ -2826,7 +2826,7 @@ pub mod jump_tests { // J let instructions: Vec = vec![0b000010_00_00000000_00000000_00000010]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.execute_instruction(); assert_eq!(datapath.registers.pc, 8); @@ -2839,7 +2839,7 @@ pub mod jump_tests { // J let instructions: Vec = vec![0x0800_0fff]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.execute_instruction(); assert_eq!(datapath.registers.pc, 0x3ffc); @@ -2853,7 +2853,7 @@ pub mod jump_tests { // J low_26 let instructions: Vec = vec![0x0800_0000 | 0x03ff_ffff]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.execute_instruction(); assert_eq!(datapath.registers.pc, 0x0fff_fffc); @@ -2870,7 +2870,7 @@ pub mod jump_and_link_tests { // J let instructions: Vec = vec![0b000011_00_00000000_00000000_00000010]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.execute_instruction(); assert_eq!(datapath.registers.pc, 8); @@ -2885,7 +2885,7 @@ pub mod jump_and_link_tests { // J let instructions: Vec = vec![0x0c00_0fff]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.execute_instruction(); assert_eq!(datapath.registers.pc, 0x3ffc); @@ -2901,7 +2901,7 @@ pub mod jump_and_link_tests { // J low_26 let instructions: Vec = vec![0x0c00_0000 | 0x03ff_ffff]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.execute_instruction(); assert_eq!(datapath.registers.pc, 0x0fff_fffc); @@ -2919,7 +2919,7 @@ pub mod jr_and_jalr_tests { // JR $r8 // Special $r8 $zero $zero JALR let instructions: Vec = vec![0b000000_01000_00000_00000_00000_001001]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[0b01000] = 24; datapath.execute_instruction(); @@ -2935,7 +2935,7 @@ pub mod jr_and_jalr_tests { // JALR $r8 // Special $r8 $zero $ra JALR let instructions: Vec = vec![0, 0, 0b000000_01000_00000_11111_00000_001001]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.pc = 8; let initial_pc = datapath.registers.pc; datapath.registers.gpr[0b01000] = 24; @@ -2955,7 +2955,7 @@ pub mod beq_tests { // beq let instructions: Vec = vec![0b000100_01000_10000_0000000000000001]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; let initial_pc = datapath.registers.pc; datapath.execute_instruction(); @@ -2973,7 +2973,7 @@ pub mod beq_tests { 0b000100_01000_10000_0000000000000001, 0b000100_01000_10000_0000000000000001, ]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[0b01000] = 1234; datapath.registers.gpr[0b10000] = 4321; @@ -2997,7 +2997,7 @@ pub mod beq_tests { 0, // 0x0c 0b000100_01000_10000_1111111111111011, // 0x10, Branch to 0x00 ]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[0b01000] = 1234; datapath.registers.gpr[0b10000] = 1234; @@ -3046,7 +3046,7 @@ pub mod bne_tests { let instructions: Vec = vec![0b000101_01000_10000_0000000000000001]; datapath.registers.gpr[0b01000] = 1234; datapath.registers.gpr[0b10000] = 1234; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.execute_instruction(); let expt_result = 4; // PC + 4, PC starts at 0 with the bne instruction at address 0, no branch acures assert_eq!(datapath.registers.pc, expt_result); @@ -3074,7 +3074,7 @@ pub mod bne_tests { 0, // 0x1c 0b000101_01000_10000_1111111111111001, // 0x20, bne r8, r16, -24, (branch -28 relative to next addres), branch to 0x08 ]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; datapath.registers.gpr[0b01000] = 1234; datapath.registers.gpr[0b10000] = 4321; @@ -3133,7 +3133,7 @@ pub mod syscall { // SPECIAL (code) SYSCALL 0b000000_00000000000000000000_001100, ]; - datapath.initialize(instructions)?; + datapath.initialize_legacy(instructions)?; assert!(!datapath.is_halted()); datapath.registers.gpr[9] = 5; // $t1 diff --git a/src/tests/integration/core_parser/arithmetic.rs b/src/tests/integration/core_parser/arithmetic.rs index be7583455..bf09ce6f0 100644 --- a/src/tests/integration/core_parser/arithmetic.rs +++ b/src/tests/integration/core_parser/arithmetic.rs @@ -9,7 +9,7 @@ fn basic_addu() -> Result<(), String> { let instructions = String::from("addu r20, r19, r18"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[18] = 6849841; datapath.registers.gpr[19] = 99816512; @@ -33,7 +33,7 @@ sll $s1, $s1, 3"#, ); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; while !datapath.is_halted() { datapath.execute_instruction(); @@ -54,7 +54,7 @@ move $s5, $s4"#, ); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; while !datapath.is_halted() { datapath.execute_instruction(); @@ -72,7 +72,7 @@ fn basic_nop() -> Result<(), String> { let instructions = String::from(r#"nop"#); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; let mut expected_registers = datapath.registers; expected_registers.pc = 4; diff --git a/src/tests/integration/core_parser/basic_immediate.rs b/src/tests/integration/core_parser/basic_immediate.rs index e7653d7c1..46ca3a88e 100644 --- a/src/tests/integration/core_parser/basic_immediate.rs +++ b/src/tests/integration/core_parser/basic_immediate.rs @@ -11,7 +11,7 @@ fn basic_addi() -> Result<(), String> { let instructions = String::from("addi r11, r15, 2"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[15] = 100; @@ -31,7 +31,7 @@ fn basic_addiu() -> Result<(), String> { let instructions = String::from("addiu r14, r17, 5"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[17] = 500; @@ -51,7 +51,7 @@ fn basic_subi() -> Result<(), String> { let instructions = String::from("subi r11, r15, 2"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[15] = 100; @@ -71,7 +71,7 @@ fn basic_muli() -> Result<(), String> { let instructions = String::from("muli r11, r15, 2"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[15] = 100; @@ -91,7 +91,7 @@ fn basic_divi() -> Result<(), String> { let instructions = String::from("divi r11, r15, 2"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[15] = 100; @@ -111,7 +111,7 @@ fn basic_ori() -> Result<(), String> { let instructions = String::from("ori r11, r15, 2"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[15] = 100; @@ -131,7 +131,7 @@ fn basic_andi() -> Result<(), String> { let instructions = String::from("andi r11, r15, 4"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[15] = 100; @@ -151,7 +151,7 @@ fn basic_li() -> Result<(), String> { let instructions = String::from("li r15, 56"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; while !datapath.is_halted() { datapath.execute_instruction(); @@ -170,7 +170,7 @@ fn basic_lui() -> Result<(), String> { let instructions = String::from("lui r20, 65530"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; while !datapath.is_halted() { datapath.execute_instruction(); @@ -190,7 +190,7 @@ fn basic_aui() -> Result<(), String> { let instructions = String::from("aui r15, r18, 4612"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[18] = 0x0000_0000_0030_ABCD; diff --git a/src/tests/integration/core_parser/basic_operations.rs b/src/tests/integration/core_parser/basic_operations.rs index fd2150e3b..4ea6f6728 100644 --- a/src/tests/integration/core_parser/basic_operations.rs +++ b/src/tests/integration/core_parser/basic_operations.rs @@ -9,7 +9,7 @@ fn basic_add() -> Result<(), String> { let instructions = String::from("add r11, r7, r8"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[7] = 51; datapath.registers.gpr[8] = 5; @@ -30,7 +30,7 @@ fn basic_sub() -> Result<(), String> { let instructions = String::from("sub r12, r7, r8"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[7] = 51; datapath.registers.gpr[8] = 5; @@ -51,7 +51,7 @@ fn basic_mul() -> Result<(), String> { let instructions = String::from("mul r13, r7, r8"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[7] = 51; datapath.registers.gpr[8] = 5; @@ -72,7 +72,7 @@ fn basic_div() -> Result<(), String> { let instructions = String::from("div r14, r7, r8"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[7] = 51; datapath.registers.gpr[8] = 5; @@ -93,7 +93,7 @@ fn basic_or() -> Result<(), String> { let instructions = String::from("or r15, r7, r8"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[7] = 51; datapath.registers.gpr[8] = 5; @@ -114,7 +114,7 @@ fn basic_and() -> Result<(), String> { let instructions = String::from("and r16, r7, r8"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[7] = 51; datapath.registers.gpr[8] = 5; diff --git a/src/tests/integration/core_parser/branch_jump.rs b/src/tests/integration/core_parser/branch_jump.rs index 72d55ab65..0cbbcedd5 100644 --- a/src/tests/integration/core_parser/branch_jump.rs +++ b/src/tests/integration/core_parser/branch_jump.rs @@ -17,7 +17,7 @@ j loop"#, ); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; // Execute the ori instruction. datapath.execute_instruction(); @@ -45,7 +45,7 @@ jr r15"#, ); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; // Execute 2 instructions. for _ in 0..2 { @@ -70,7 +70,7 @@ function: ori $t0, $zero, 5831"#, ); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; while !datapath.is_halted() { datapath.execute_instruction(); @@ -96,7 +96,7 @@ function: ori $t1, $zero, 9548"#, ); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; // Execute 3 instructions. for _ in 0..3 { @@ -145,7 +145,7 @@ change10: daddiu $s2, $s2, 10"#, ); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; while !datapath.is_halted() { datapath.execute_instruction(); @@ -186,7 +186,7 @@ changez: daddiu $s2, $s2, 20"#, ); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; while !datapath.is_halted() { datapath.execute_instruction(); @@ -218,7 +218,7 @@ bne $s0, $s2, loop"#, ); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; let mut iterations = 0; diff --git a/src/tests/integration/core_parser/conditions.rs b/src/tests/integration/core_parser/conditions.rs index 91d957f12..774cafe66 100644 --- a/src/tests/integration/core_parser/conditions.rs +++ b/src/tests/integration/core_parser/conditions.rs @@ -27,7 +27,7 @@ akin! { let instructions = String::from("*instruction_name r*destination_register, r5, r6"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[5] = *true_value1; datapath.registers.gpr[6] = *true_value2; @@ -46,7 +46,7 @@ akin! { let instructions = String::from("*instruction_name r*destination_register, r5, r6"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[5] = *false_value1; datapath.registers.gpr[6] = *false_value2; diff --git a/src/tests/integration/core_parser/coprocessor_move.rs b/src/tests/integration/core_parser/coprocessor_move.rs index 38de80480..bcff12b7f 100644 --- a/src/tests/integration/core_parser/coprocessor_move.rs +++ b/src/tests/integration/core_parser/coprocessor_move.rs @@ -8,7 +8,7 @@ fn basic_mtc1() -> Result<(), String> { let instructions = String::from("mtc1 $t2, $f5"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[10] = 658461658; // $t2 @@ -26,7 +26,7 @@ fn truncate_32_bit_mtc1() -> Result<(), String> { let instructions = String::from("mtc1 $t3, $f6"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[11] = 0x0000_02F2_AC71_AC41; // $t3 @@ -44,7 +44,7 @@ fn basic_mfc1() -> Result<(), String> { let instructions = String::from("mfc1 $t3, $f5"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.coprocessor.fpr[5] = 657861659; @@ -62,7 +62,7 @@ fn truncate_32_bit_mfc1() -> Result<(), String> { let instructions = String::from("mfc1 $t4, $f6"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.coprocessor.fpr[6] = 0x0003_7F80_E5E7_D785; @@ -80,7 +80,7 @@ fn basic_dmtc1() -> Result<(), String> { let instructions = String::from("dmtc1 $t3, $f6"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[11] = 0x0120_02F2_AC71_AC41; // $t3 @@ -98,7 +98,7 @@ fn basic_dmfc1() -> Result<(), String> { let instructions = String::from("dmfc1 $t4, $f6"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.coprocessor.fpr[6] = 0x0003_7F90_E5E7_D785; diff --git a/src/tests/integration/core_parser/double_arithmetic.rs b/src/tests/integration/core_parser/double_arithmetic.rs index 83ee30fdd..9c2c46e2e 100644 --- a/src/tests/integration/core_parser/double_arithmetic.rs +++ b/src/tests/integration/core_parser/double_arithmetic.rs @@ -17,7 +17,7 @@ akin! { let instructions = String::from(*instruction); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[16] = *value1; datapath.registers.gpr[17] = *value2; @@ -46,7 +46,7 @@ akin! { let instructions = String::from(*instruction); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[25] = *value1; datapath.registers.gpr[26] = *value2; diff --git a/src/tests/integration/core_parser/double_immediate.rs b/src/tests/integration/core_parser/double_immediate.rs index 4bd27b211..531f3795e 100644 --- a/src/tests/integration/core_parser/double_immediate.rs +++ b/src/tests/integration/core_parser/double_immediate.rs @@ -8,7 +8,7 @@ fn basic_dahi() -> Result<(), String> { let instructions = String::from("dahi r3, 123"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[3] = 0; @@ -29,7 +29,7 @@ fn dahi_sign_extend() -> Result<(), String> { let instructions = String::from("dahi r5, 43158"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[5] = 0; @@ -50,7 +50,7 @@ fn basic_dati() -> Result<(), String> { let instructions = String::from("dati r10, 4321"); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[10] = 0; @@ -78,7 +78,7 @@ akin! { let instructions = String::from(*instruction); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[20] = *rs_value; @@ -104,7 +104,7 @@ akin! { let instructions = String::from(*instruction); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.registers.gpr[20] = *rs_value; diff --git a/src/tests/integration/core_parser/fibonacci.rs b/src/tests/integration/core_parser/fibonacci.rs index de64e4399..f380aeaee 100644 --- a/src/tests/integration/core_parser/fibonacci.rs +++ b/src/tests/integration/core_parser/fibonacci.rs @@ -75,7 +75,7 @@ fn recursive_fibonacci() -> Result<(), String> { ); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; while !datapath.is_halted() { datapath.execute_instruction(); diff --git a/src/tests/integration/core_parser/floating_point_arithmetic.rs b/src/tests/integration/core_parser/floating_point_arithmetic.rs index c88473c28..7f3466d48 100644 --- a/src/tests/integration/core_parser/floating_point_arithmetic.rs +++ b/src/tests/integration/core_parser/floating_point_arithmetic.rs @@ -19,7 +19,7 @@ akin! { let instructions = String::from(*instruction); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.coprocessor.fpr[15] = *value1; datapath.coprocessor.fpr[16] = *value2; @@ -50,7 +50,7 @@ akin! { let instructions = String::from(*instruction); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.coprocessor.fpr[15] = *value1; datapath.coprocessor.fpr[16] = *value2; diff --git a/src/tests/integration/core_parser/floating_point_branch.rs b/src/tests/integration/core_parser/floating_point_branch.rs index 59db68d78..fb74fd44f 100644 --- a/src/tests/integration/core_parser/floating_point_branch.rs +++ b/src/tests/integration/core_parser/floating_point_branch.rs @@ -31,7 +31,7 @@ bc1t loop"#, ); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; while !datapath.is_halted() { datapath.execute_instruction(); @@ -74,7 +74,7 @@ bc1f loop"#, ); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; while !datapath.is_halted() { datapath.execute_instruction(); diff --git a/src/tests/integration/core_parser/floating_point_comparison.rs b/src/tests/integration/core_parser/floating_point_comparison.rs index 6b663a17d..45e9ed632 100644 --- a/src/tests/integration/core_parser/floating_point_comparison.rs +++ b/src/tests/integration/core_parser/floating_point_comparison.rs @@ -17,7 +17,7 @@ akin! { let instructions = String::from(*instruction); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.coprocessor.fpr[15] = *value1; datapath.coprocessor.fpr[16] = *value2; @@ -46,7 +46,7 @@ akin! { let instructions = String::from(*instruction); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.coprocessor.fpr[15] = *value1; datapath.coprocessor.fpr[16] = *value2; diff --git a/src/tests/integration/core_parser/mod.rs b/src/tests/integration/core_parser/mod.rs index 1951eeb01..79b7166a5 100644 --- a/src/tests/integration/core_parser/mod.rs +++ b/src/tests/integration/core_parser/mod.rs @@ -31,7 +31,7 @@ add $s1, $s0, $s0"#, // Parse instructions and load into emulation core memory. let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; // Execute 2 instructions. for _ in 0..2 { @@ -70,7 +70,7 @@ dati r1, 43982"#, // Parse instructions and load into emulation core memory. let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; // Execute 4 instructions. for _ in 0..4 { @@ -97,7 +97,7 @@ dmuli r8, r7, 2"#, ); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; while !datapath.is_halted() { datapath.execute_instruction(); diff --git a/src/tests/integration/core_parser/store_load_word.rs b/src/tests/integration/core_parser/store_load_word.rs index 68e4473e3..00e7811ec 100644 --- a/src/tests/integration/core_parser/store_load_word.rs +++ b/src/tests/integration/core_parser/store_load_word.rs @@ -13,7 +13,7 @@ sw r25, 0(r14)"#, ); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; while !datapath.is_halted() { datapath.execute_instruction(); @@ -34,7 +34,7 @@ lw r25, 0(r14)"#, ); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.memory.memory[403] = 36; @@ -62,7 +62,7 @@ sw $s2, secret_number"#, ); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; while !datapath.is_halted() { datapath.execute_instruction(); @@ -89,7 +89,7 @@ swc1 $f25, 0($s0)"#, ); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; while !datapath.is_halted() { datapath.execute_instruction(); @@ -110,7 +110,7 @@ lwc1 $f12, 0($t4)"#, ); let (_, instruction_bits) = parser(instructions); - datapath.initialize(instruction_bits)?; + datapath.initialize_legacy(instruction_bits)?; datapath.memory.memory[403] = 36;