From 5bdd8664724f08b27d6e575aedbfb6ccbc79b482 Mon Sep 17 00:00:00 2001 From: Anton Lydike Date: Sat, 17 Apr 2021 23:08:09 +0200 Subject: [PATCH] implemented instruction j, added cpu cycle counter --- riscemu/CPU.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/riscemu/CPU.py b/riscemu/CPU.py index 7cb475b..efbec9a 100644 --- a/riscemu/CPU.py +++ b/riscemu/CPU.py @@ -17,6 +17,7 @@ class CPU: def __init__(self, conf: RunConfig): from . import MMU self.pc = 0 + self.cycle = 0 self.exit = False self.exit_code = 0 self.conf = conf @@ -42,6 +43,7 @@ class CPU: ins = None try: while not self.exit: + self.cycle += 1 ins = self.mmu.read_ins(self.pc) self.pc += 1 self.__run_instruction(ins) @@ -140,6 +142,7 @@ class CPU: ) def instruction_sub(self, ins: 'LoadedInstruction'): + INS_NOT_IMPLEMENTED(ins) def instruction_lui(self, ins: 'LoadedInstruction'): @@ -227,7 +230,9 @@ class CPU: self.pc = dest def instruction_j(self, ins: 'LoadedInstruction'): - INS_NOT_IMPLEMENTED(ins) + ASSERT_LEN(ins.args, 1) + addr = ins.get_imm(0) + self.pc = addr def instruction_jr(self, ins: 'LoadedInstruction'): INS_NOT_IMPLEMENTED(ins)