diff options
author | Ekaitz Zarraga <ekaitz@elenq.tech> | 2021-07-23 20:49:14 +0200 |
---|---|---|
committer | Ekaitz Zarraga <ekaitz@elenq.tech> | 2021-07-23 20:49:14 +0200 |
commit | 681036ddc3891904f13c84197cd90e2472cb3e1c (patch) | |
tree | 080b9580c14274698d1848e7640cba0cc47a53a6 /pyscv/InstructionSets/instructions.py | |
parent | 309d36182ef32a1bc5bff84f39e9e81db0ddb9a6 (diff) |
Diffstat (limited to 'pyscv/InstructionSets/instructions.py')
-rw-r--r-- | pyscv/InstructionSets/instructions.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/pyscv/InstructionSets/instructions.py b/pyscv/InstructionSets/instructions.py new file mode 100644 index 0000000..00a3146 --- /dev/null +++ b/pyscv/InstructionSets/instructions.py @@ -0,0 +1,36 @@ +from ctypes import c_uint32 + + +class Instruction: + size = 4 # Instruction size in bytes + + def __init__(self): + pass + + def compile(self): + # return the binstream of the instruction in a c_uint32 + pass + + def execute(self, pc): + # executes the instruction and returns the next program counter + return + +class InstructionSet: + + def __init__(self, init=None): + self.instructions = dict() + + def instruction(self, ins): + if ins.name not in self.instructions: + self.instructions[ins.name] = ins + return ins + + # NOTE: We don't need to treat pseudoinstructions in an special way yet, + # but we separate the decorator for clarity + pseudoinstruction = instruction + + +if __name__ == "__main__": + # TODO This is the interface i'd love to have + addins = add("x5","x2","zero") + j("labelName") |