From 9dc01a04044b5f882bb15567818fa2a51af68691 Mon Sep 17 00:00:00 2001 From: Aleksa Vuckovic Date: Sun, 13 Apr 2025 15:22:11 +0200 Subject: Initial commit --- src/instruction/instruction.rs | 15 +++++++++++++++ src/instruction/mod.rs | 1 + 2 files changed, 16 insertions(+) create mode 100644 src/instruction/instruction.rs create mode 100644 src/instruction/mod.rs (limited to 'src/instruction') diff --git a/src/instruction/instruction.rs b/src/instruction/instruction.rs new file mode 100644 index 0000000..2779023 --- /dev/null +++ b/src/instruction/instruction.rs @@ -0,0 +1,15 @@ +use crate::rv32_cpu::rv32_cpu::State; +use std::error::Error; +use std::fmt::Debug; + +#[derive(Debug, Clone, Hash, PartialEq, Eq)] +pub struct Opcode { + pub opcode6_2: u32, + pub opcode14_12: Option, + pub opcode31_27: Option, +} + +pub trait Instruction: Debug { + fn opcode(&self) -> Opcode; + fn execute(&self, instruction: u32, cpu: &mut State) -> Result<(), Box>; +} diff --git a/src/instruction/mod.rs b/src/instruction/mod.rs new file mode 100644 index 0000000..bf06da5 --- /dev/null +++ b/src/instruction/mod.rs @@ -0,0 +1 @@ +pub mod instruction; \ No newline at end of file -- cgit v1.2.3