summaryrefslogtreecommitdiff
path: root/src/rv32i
diff options
context:
space:
mode:
authorAleksa Vuckovic <aleksa@vuckovic.cc>2025-04-13 15:22:11 +0200
committerAleksa Vuckovic <aleksa@vuckovic.cc>2025-04-13 15:22:11 +0200
commit9dc01a04044b5f882bb15567818fa2a51af68691 (patch)
treea27be590e75b3b1580fc27119207bc6f721a5f9b /src/rv32i
Initial commitHEADmaster
Diffstat (limited to 'src/rv32i')
-rw-r--r--src/rv32i/mod.rs2
-rw-r--r--src/rv32i/rv32i.rs14
-rw-r--r--src/rv32i/slti.rs18
3 files changed, 34 insertions, 0 deletions
diff --git a/src/rv32i/mod.rs b/src/rv32i/mod.rs
new file mode 100644
index 0000000..2fb36ce
--- /dev/null
+++ b/src/rv32i/mod.rs
@@ -0,0 +1,2 @@
+pub mod rv32i;
+pub mod slti; \ No newline at end of file
diff --git a/src/rv32i/rv32i.rs b/src/rv32i/rv32i.rs
new file mode 100644
index 0000000..88826b2
--- /dev/null
+++ b/src/rv32i/rv32i.rs
@@ -0,0 +1,14 @@
+use crate::rv32_cpu::rv32_cpu::Rv32Cpu;
+use crate::extension::extension::Extension;
+use super::slti::Slti;
+use crate::instruction::instruction::Instruction;
+
+pub struct Rv32i {
+}
+
+impl Extension for Rv32i {
+ fn add_instructions(cpu: &mut Rv32Cpu) -> &mut Rv32Cpu {
+ cpu.add_decode(Slti.opcode(), Box::new(Slti));
+ cpu
+ }
+} \ No newline at end of file
diff --git a/src/rv32i/slti.rs b/src/rv32i/slti.rs
new file mode 100644
index 0000000..09d166c
--- /dev/null
+++ b/src/rv32i/slti.rs
@@ -0,0 +1,18 @@
+use crate::rv32_cpu::rv32_cpu::State;
+use crate::instruction::instruction::{Instruction, Opcode};
+
+#[derive(Debug)]
+pub struct Slti;
+
+impl Instruction for Slti {
+ fn opcode(&self) -> Opcode {
+ Opcode {
+ opcode6_2: 0b00100,
+ opcode14_12: Some(0b001),
+ opcode31_27: Some(0b00000),
+ }
+ }
+ fn execute(&self, instruction: u32, state: &mut State) -> Result<(), Box<dyn std::error::Error>> {
+ Ok(())
+ }
+}