aboutsummaryrefslogtreecommitdiff
path: root/src/isa/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/isa/mod.rs')
-rw-r--r--src/isa/mod.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/isa/mod.rs b/src/isa/mod.rs
index 5e9a7dc..ac8ce45 100644
--- a/src/isa/mod.rs
+++ b/src/isa/mod.rs
@@ -1,6 +1,7 @@
pub mod opcodes;
+pub mod funct3;
-enum Register {
+pub enum Register {
X0 = 0,
X1 = 1,
X2 = 2,
@@ -15,6 +16,12 @@ enum Register {
X11 = 11,
}
+impl Register {
+ pub fn as_num(self) -> usize {
+ self as usize
+ }
+}
+
pub struct Instruction {
word: u32,
}
@@ -29,4 +36,8 @@ impl Instruction {
pub fn opcode(&self) -> u32 {
self.word & 0x7F
}
+
+ pub fn funct3(&self) -> u32 {
+ (self.word >> 12) & 0x3
+ }
}