summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pysc-v/InstructionSets/RV32I.py30
1 files changed, 15 insertions, 15 deletions
diff --git a/pysc-v/InstructionSets/RV32I.py b/pysc-v/InstructionSets/RV32I.py
index 5992869..bbe88c3 100644
--- a/pysc-v/InstructionSets/RV32I.py
+++ b/pysc-v/InstructionSets/RV32I.py
@@ -80,7 +80,7 @@ class B(Instruction):
imm_1_4 = (self.imm & 0b0000000011110)>>1
imm_5_10 = (self.imm & 0b0011111100000)>>5
return c_uint32(
- (im_12 << 30) +\
+ (imm_12 << 30) +\
(imm_5_10 << 25) +\
(self.rs2 << 20) +\
(self.rs1 << 15) +\
@@ -102,7 +102,7 @@ class U(Instruction):
# immediate
imm_12_32 = (imm & 0xFFFFF000)>>12
return c_uint32(
- (self.imm_12_32 << 12) +\
+ (imm_12_32 << 12) +\
(self.rd << 7) +\
self.opcode
)
@@ -116,15 +116,15 @@ class J(Instruction):
def compile(self):
# NOTE: Jumps are also weird
- imm_12_19 = 0x0FF000
- imm_11 = 0x000800
- imm_1_10 = 0x0007FE
- imm_20 = 0x100000
+ imm_20 = (self.imm & 0x100000)>>20
+ imm_12_19 = (self.imm & 0x0FF000)>>12
+ imm_11 = (self.imm & 0x000800)>>8
+ imm_1_10 = (self.imm & 0x0007FE)>>1
return c_uint32(
- (self.imm_20 << 31) +\
- (self.imm_1_10 << 21) +\
- (self.imm_11 << 20) +\
- (self.imm_12_19 << 12) +\
+ (imm_20 << 31) +\
+ (imm_1_10 << 21) +\
+ (imm_11 << 20) +\
+ (imm_12_19 << 12) +\
(self.rd << 7) +\
self.opcode
)
@@ -229,19 +229,19 @@ class lb(I):
@RV32I.instruction
class sb(S):
name = "sb"
- opcode = 0b010001
+ opcode = 0b0100011
funct3 = 0b000
@RV32I.instruction
class sh(S):
name = "sh"
- opcode = 0b010001
+ opcode = 0b0100011
funct3 = 0b001
@RV32I.instruction
class sw(S):
name = "sw"
- opcode = 0b010001
+ opcode = 0b0100011
funct3 = 0b010
@RV32I.instruction
@@ -393,14 +393,14 @@ class sra(R):
funct7 = 0b0100000
@RV32I.instruction
-class or(R):
+class _or(R):
name = "or"
opcode = 0b0110011
funct3 = 0b110
funct7 = 0b0000000
@RV32I.instruction
-class and(R):
+class _and(R):
name = "and"
opcode = 0b0110011
funct3 = 0b111