Skip to content
Snippets Groups Projects
Commit ef9bc4c2 authored by Martin Högstedt's avatar Martin Högstedt
Browse files

more progress on the asm instructions on mia

parent 0fc247d2
No related branches found
No related tags found
1 merge request!13We know have asm instructions, can step forward and backward between clock cycle and asm instructions
...@@ -79,6 +79,16 @@ class Processor: ...@@ -79,6 +79,16 @@ class Processor:
""" """
raise NotImplemented raise NotImplemented
def run_asm_instruction(self, num_instructions = 1) -> None:
"""
Runs assembler instructions on the processors 'num_instructions' times.
Default argument is one, but it is possible to specify any number of instructions.
This should be implemented per processor and thus we raise NotImplemented.
"""
raise NotImplemented
def run_continuously(self): def run_continuously(self):
""" """
Runs the processor until it halts. Runs the processor until it halts.
......
...@@ -460,7 +460,7 @@ class GUI(QMainWindow): ...@@ -460,7 +460,7 @@ class GUI(QMainWindow):
def stepToolBarButtonClick(self): def stepToolBarButtonClick(self):
""" """
Runs the cpu a specified number of times according to the jump value box. Runs the cpu a specified number of clock cycles according to the jump value box.
""" """
# Don't do steps if cpu is running # Don't do steps if cpu is running
...@@ -475,6 +475,23 @@ class GUI(QMainWindow): ...@@ -475,6 +475,23 @@ class GUI(QMainWindow):
self.threadpool.start(simultaion_thread) self.threadpool.start(simultaion_thread)
self.updateCpuListeners() self.updateCpuListeners()
def stepAsmToolBarButtonClick(self):
"""
Runs the cpu a specified number of asm instructions according to the jump value box.
"""
# Don't do steps if cpu is running
if self.cpu_running:
return
steps = self.asm_jump_value_box.value()
self.cpu_running = True
self.setDisabledWhenRunning(True)
self.cpu.unstop()
simultaion_thread = RunThread(self.cpu, self.halted_signal, False, steps)
self.threadpool.start(simultaion_thread)
self.updateCpuListeners()
def runToolBarButtonClick(self) -> None: def runToolBarButtonClick(self) -> None:
""" """
Runs the cpu until it is stopped by user input, breakpoint or similar. Runs the cpu until it is stopped by user input, breakpoint or similar.
...@@ -860,7 +877,7 @@ class GUI(QMainWindow): ...@@ -860,7 +877,7 @@ class GUI(QMainWindow):
Undos as many processor cycles as the number entered in the box. Undos as many processor cycles as the number entered in the box.
""" """
try: try:
steps = self.jump_value_box.value() steps = self.asm_jump_value_box.value()
self.cpu.load_cycle(max(self.cpu.get_clock() - steps, 0)) self.cpu.load_cycle(max(self.cpu.get_clock() - steps, 0))
self.updateCpuListeners() self.updateCpuListeners()
except (ValueError, IndexError): except (ValueError, IndexError):
......
...@@ -4,6 +4,7 @@ from qtpy.QtCore import QRunnable ...@@ -4,6 +4,7 @@ from qtpy.QtCore import QRunnable
class RunThread(QRunnable): class RunThread(QRunnable):
""" """
This class is used to run the cpu on a seperate thread. This class is used to run the cpu on a seperate thread.
This allows the user to interact with the GUI will th cpu is running. This allows the user to interact with the GUI will th cpu is running.
When the cpu halts this thread will emit to it's given signal When the cpu halts this thread will emit to it's given signal
the GUI can then handel what should happend after execution on its own. the GUI can then handel what should happend after execution on its own.
...@@ -25,3 +26,8 @@ class RunThread(QRunnable): ...@@ -25,3 +26,8 @@ class RunThread(QRunnable):
self.cpu.do_tick() self.cpu.do_tick()
self.signal.emit(self.steps) self.signal.emit(self.steps)
def run_asm(self):
self.cpu.run_asm(self.steps)
self.signal.emit(self.steps)
...@@ -303,9 +303,26 @@ class MIA_CPU(Processor): ...@@ -303,9 +303,26 @@ class MIA_CPU(Processor):
"""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."""
op_code = self.get_module("IR").op ir = self.get_module("IR")
op_code = ir.op
return self.get_module("K1").get_label(int(op_code)) 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.
Default argument is one, but it is possible to specify any number of instructions.
"""
while True:
if num_instructions <= 0:
return
if self.is_new_instruction():
num_instructions -= 1
self.do_tick()
def should_halt(self) -> bool: def should_halt(self) -> bool:
micro_memory_state = self.micro_memory.get_state() micro_memory_state = self.micro_memory.get_state()
return micro_memory_state["halt"] return micro_memory_state["halt"]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment