diff --git a/src/simudator/core/processor.py b/src/simudator/core/processor.py index 543e578af369779931865c95988d799214f194c5..6e76bb221191f56e5d29618fce3a2d50cb15a36d 100644 --- a/src/simudator/core/processor.py +++ b/src/simudator/core/processor.py @@ -253,9 +253,13 @@ class Processor: try: module_states = self.module_history[cycle_index] + print(cycle_index) except IndexError: + print(cycle_index) + print(321) raise IndexError + for module_name, module_state in module_states.items(): self.modules[module_name].set_state(module_state) diff --git a/src/simudator/processor/mia/mia.py b/src/simudator/processor/mia/mia.py index 632248c87c7aee629a2847d377638e23ce769618..22fcefb151cba9c6430da8119d40a8c2b9e2b1a3 100644 --- a/src/simudator/processor/mia/mia.py +++ b/src/simudator/processor/mia/mia.py @@ -294,21 +294,22 @@ class MIA_CPU(Processor): self.new_instruction = True self.current_instruction = self.get_current_instrution() self.assembly_cycles.append(self.get_clock()) - self.finished_assembly_instructions += 1 else: self.new_instruction = False def get_current_instrution(self) -> str: - """Returns a string containing the label for the current instruction. + """ + Returns a string containing the label for the current instruction. - If the label doesnt exist, the string is empty.""" + If the label doesnt exist, the string is empty. + """ ir = self.get_module("IR") op_code = ir.op return self.get_module("K1").get_label(int(op_code)) def run_asm_instruction(self, num_instructions = 1) -> None: """ - Runs assembler instructions on Mia 'num_instructions' times. + Runs 'num_instructions' assembler instructions on Mia. Default argument is one, but it is possible to specify any number of instructions. """ @@ -336,15 +337,18 @@ class MIA_CPU(Processor): index = len(self.assembly_cycles) index -= num_instructions + index -= 1 # We cant undo more instructions than we have performed. if index < 0: raise IndexError clockcycle = self.assembly_cycles[index] - self.assembly_cycles = self.assembly_cycles[:index] + print("Cycle: ", clockcycle) + print("Steps : ", num_instructions) self.load_cycle(clockcycle) + self.assembly_cycles = self.assembly_cycles[:index+1] def should_halt(self) -> bool: