refactor 2 electric boogaloo
This commit is contained in:
Generated
+20
-14
@@ -231,6 +231,10 @@ dependencies = [
|
|||||||
"zbus 5.7.1",
|
"zbus 5.7.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "assembler"
|
||||||
|
version = "0.2.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-broadcast"
|
name = "async-broadcast"
|
||||||
version = "0.7.2"
|
version = "0.7.2"
|
||||||
@@ -656,6 +660,10 @@ dependencies = [
|
|||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "common"
|
||||||
|
version = "0.2.0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "concurrent-queue"
|
name = "concurrent-queue"
|
||||||
version = "2.5.0"
|
version = "2.5.0"
|
||||||
@@ -755,15 +763,6 @@ version = "1.2.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f"
|
checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "damn_simple_architecture"
|
|
||||||
version = "0.1.0"
|
|
||||||
dependencies = [
|
|
||||||
"eframe",
|
|
||||||
"egui",
|
|
||||||
"rfd",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "digest"
|
name = "digest"
|
||||||
version = "0.10.7"
|
version = "0.10.7"
|
||||||
@@ -972,6 +971,16 @@ dependencies = [
|
|||||||
"bytemuck",
|
"bytemuck",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "emulator"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"common",
|
||||||
|
"eframe",
|
||||||
|
"egui",
|
||||||
|
"rfd",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "endi"
|
name = "endi"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
@@ -2643,12 +2652,9 @@ checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "slab"
|
name = "slab"
|
||||||
version = "0.4.9"
|
version = "0.4.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67"
|
checksum = "04dc19736151f35336d325007ac991178d504a119863a2fcb3758cdb5e52c50d"
|
||||||
dependencies = [
|
|
||||||
"autocfg",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "slotmap"
|
name = "slotmap"
|
||||||
|
|||||||
+6
-12
@@ -1,13 +1,7 @@
|
|||||||
[package]
|
[workspace]
|
||||||
name = "damn_simple_architecture"
|
members = ["emulator", "common", "assembler"]
|
||||||
version = "0.1.0"
|
|
||||||
|
[workspace.package]
|
||||||
|
version = "0.2.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
authors = ["zxq5", "nullndvoid"]
|
||||||
[lib]
|
|
||||||
name = "dsa_rs"
|
|
||||||
path = "src/lib.rs"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
eframe = "0.31.1"
|
|
||||||
egui = "0.31.1"
|
|
||||||
rfd = "0.15.3"
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
[package]
|
||||||
|
name = "assembler"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
authors.workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
pub fn add(left: u64, right: u64) -> u64 {
|
||||||
|
left + right
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn it_works() {
|
||||||
|
let result = add(2, 2);
|
||||||
|
assert_eq!(result, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
[package]
|
||||||
|
name = "common"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
authors.workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::common::{instructions::encode::Encode, prelude::*};
|
use crate::{instructions::encode::Encode, prelude::*};
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum Interrupt {
|
pub enum Interrupt {
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
//! Various types of arguments that instructions can take, alongside encoding and decoding logic.
|
//! Various types of arguments that instructions can take, alongside encoding and decoding logic.
|
||||||
|
|
||||||
use crate::common::instructions::Encode;
|
use crate::{
|
||||||
use crate::common::prelude::*;
|
instructions::{RegisterParseError, encode::Encode},
|
||||||
|
prelude::Register,
|
||||||
|
};
|
||||||
|
|
||||||
/// A list of errors that can be returned when decoding instruction arguments.
|
/// A list of errors that can be returned when decoding instruction arguments.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::common::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
/// Not to be used directly, just call [`Instruction::encode`].
|
/// Not to be used directly, just call [`Instruction::encode`].
|
||||||
pub trait Encode {
|
pub trait Encode {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::common::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_encode_nop() {
|
fn test_encode_nop() {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
//! All the errors that may be returned from [`instructions`].
|
//! All the errors that may be returned from [`instructions`].
|
||||||
|
|
||||||
use crate::common::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
/// Error type for parsing register numbers.
|
/// Error type for parsing register numbers.
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#![allow(clippy::unwrap_used)]
|
#![allow(clippy::unwrap_used)]
|
||||||
use crate::common::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_opcode_nop() {
|
fn test_opcode_nop() {
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
#![deny(
|
||||||
|
clippy::unwrap_used,
|
||||||
|
clippy::nursery,
|
||||||
|
clippy::perf,
|
||||||
|
clippy::pedantic,
|
||||||
|
clippy::complexity
|
||||||
|
)]
|
||||||
|
#![allow(
|
||||||
|
clippy::cast_possible_truncation,
|
||||||
|
clippy::missing_panics_doc,
|
||||||
|
clippy::missing_errors_doc,
|
||||||
|
clippy::match_wildcard_for_single_variants
|
||||||
|
)]
|
||||||
|
|
||||||
|
pub mod instructions;
|
||||||
|
|
||||||
|
pub mod prelude {
|
||||||
|
//! A collection of types you should definitely import when working with this crate.
|
||||||
|
pub use super::instructions::{
|
||||||
|
Address, Instruction, InstructionType, Interrupt, Register, args::*, errors::*,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
[package]
|
||||||
|
name = "emulator"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
name = "dsa_rs"
|
||||||
|
path = "src/lib.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
common = { path = "../common" }
|
||||||
|
eframe = "0.31.1"
|
||||||
|
egui = "0.31.1"
|
||||||
|
rfd = "0.15.3"
|
||||||
@@ -7,14 +7,13 @@ use std::{
|
|||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::emulator::system::{
|
||||||
common::instructions::{Instruction, Register},
|
model::{Command, Running, State},
|
||||||
emulator::system::{
|
processor::Processor,
|
||||||
model::{Command, Running, State},
|
|
||||||
processor::Processor,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use common::instructions::{Instruction, Register};
|
||||||
|
|
||||||
pub fn run_emulator(
|
pub fn run_emulator(
|
||||||
cmd_rx: &Receiver<Command>,
|
cmd_rx: &Receiver<Command>,
|
||||||
state_tx: &Sender<State>,
|
state_tx: &Sender<State>,
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::common::prelude::*;
|
use common::prelude::*;
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
|
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
|
||||||
pub enum Running {
|
pub enum Running {
|
||||||
+7
-6
@@ -3,14 +3,13 @@ use std::{
|
|||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::emulator::system::{
|
||||||
common::instructions::{Instruction, Interrupt, Register, errors::InstructionDecodeError},
|
memory::MemoryUnit,
|
||||||
emulator::system::{
|
model::{IODevice, RegFile},
|
||||||
memory::MemoryUnit,
|
|
||||||
model::{IODevice, RegFile},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use common::instructions::{Instruction, Interrupt, Register, errors::InstructionDecodeError};
|
||||||
|
|
||||||
pub struct Processor {
|
pub struct Processor {
|
||||||
pub memory: Box<dyn MemoryUnit>,
|
pub memory: Box<dyn MemoryUnit>,
|
||||||
pub registers: RegFile,
|
pub registers: RegFile,
|
||||||
@@ -356,6 +355,8 @@ impl Executable for Instruction {
|
|||||||
Self::Halt => {
|
Self::Halt => {
|
||||||
cpu.halted = true;
|
cpu.halted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_ => todo!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-6
@@ -1,10 +1,9 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::{
|
use crate::emulator::system::memory::*;
|
||||||
common::instructions::{
|
|
||||||
args::{ITypeArgs, RTypeArgs},
|
use common::instructions::{
|
||||||
*,
|
args::{ITypeArgs, RTypeArgs},
|
||||||
},
|
*,
|
||||||
emulator::system::memory::*,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
fn create_test_processor() -> Processor {
|
fn create_test_processor() -> Processor {
|
||||||
@@ -1,13 +1,12 @@
|
|||||||
use std::sync::mpsc::Sender;
|
use std::sync::mpsc::Sender;
|
||||||
|
|
||||||
use crate::{
|
use crate::emulator::{
|
||||||
common::instructions::Register,
|
system::model::{Command, Running, State},
|
||||||
emulator::{
|
ui::interface::Component,
|
||||||
system::model::{Command, Running, State},
|
|
||||||
ui::interface::Component,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use common::instructions::Register;
|
||||||
|
|
||||||
pub struct ControlPanel {
|
pub struct ControlPanel {
|
||||||
visible: bool,
|
visible: bool,
|
||||||
sender: Sender<Command>,
|
sender: Sender<Command>,
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
use crate::{
|
use crate::emulator::{system::model::State, ui::interface::Component};
|
||||||
common::instructions::Register,
|
|
||||||
emulator::{system::model::State, ui::interface::Component},
|
use common::instructions::Register;
|
||||||
};
|
|
||||||
|
|
||||||
pub struct StackInspector {
|
pub struct StackInspector {
|
||||||
visible: bool,
|
visible: bool,
|
||||||
@@ -12,5 +12,4 @@
|
|||||||
clippy::match_wildcard_for_single_variants
|
clippy::match_wildcard_for_single_variants
|
||||||
)]
|
)]
|
||||||
|
|
||||||
pub mod common;
|
|
||||||
pub mod emulator;
|
pub mod emulator;
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
pub mod instructions;
|
|
||||||
|
|
||||||
pub mod prelude {
|
|
||||||
//! A collection of types you should definitely import when working with this crate.
|
|
||||||
pub use super::instructions::{
|
|
||||||
Address, Instruction, InstructionType, Interrupt, Register, args::*, errors::*,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user