diff options
| author | Aleksa Vuckovic <aleksa@vuckovic.cc> | 2025-04-13 15:22:11 +0200 |
|---|---|---|
| committer | Aleksa Vuckovic <aleksa@vuckovic.cc> | 2025-04-13 15:22:11 +0200 |
| commit | 9dc01a04044b5f882bb15567818fa2a51af68691 (patch) | |
| tree | a27be590e75b3b1580fc27119207bc6f721a5f9b /src/instruction/instruction.rs | |
Diffstat (limited to 'src/instruction/instruction.rs')
| -rw-r--r-- | src/instruction/instruction.rs | 15 |
1 files changed, 15 insertions, 0 deletions
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<u32>, + pub opcode31_27: Option<u32>, +} + +pub trait Instruction: Debug { + fn opcode(&self) -> Opcode; + fn execute(&self, instruction: u32, cpu: &mut State) -> Result<(), Box<dyn Error>>; +} |
