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

stepping over asm instructions now works

parent af4a5d7b
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
Pipeline #131557 failed
......@@ -310,14 +310,14 @@ class GUI(QMainWindow):
backward_arrow_icon = self.style().standardIcon(QStyle.SP_MediaSeekBackward)
self.undo_asm_action = QAction(backward_arrow_icon, "Undo Asm", self)
self.undo_asm_action.setStatusTip("Undo the last assembler instruction")
self.undo_asm_action.triggered.connect(self.undoToolBarButtonClick)
self.undo_asm_action.triggered.connect(self.undoAsmToolBarButtonClick)
toolbar.addAction(self.undo_asm_action)
# Add step button on toolbar
forward_arrow_icon = self.style().standardIcon(QStyle.SP_MediaSeekForward)
self.step_asm_action = QAction(forward_arrow_icon, "Step Asm", self)
self.step_asm_action.setStatusTip("Run one assembler instruction")
self.step_asm_action.triggered.connect(self.stepToolBarButtonClick)
self.step_asm_action.triggered.connect(self.stepAsmToolBarButtonClick)
toolbar.addAction(self.step_asm_action)
# Add box for jump value
......@@ -502,7 +502,7 @@ class GUI(QMainWindow):
steps = self.jump_value_box.value()
self.cpu_running = True
self.setDisabledWhenRunning(True)
simulation_thread = RunThread(self.cpu, self.cpu_tick_signal, self.update_delay, False, steps)
simulation_thread = RunThread(self.cpu, self.cpu_tick_signal, self.update_delay, False, False, steps)
self.threadpool.start(simulation_thread)
def stepAsmToolBarButtonClick(self):
......@@ -517,8 +517,7 @@ class GUI(QMainWindow):
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)
simultaion_thread = RunThread(self.cpu, self.cpu_tick_signal, self.update_delay, False, True, steps)
self.threadpool.start(simultaion_thread)
self.updateCpuListeners()
......
......@@ -8,40 +8,54 @@ class RunThread(QRunnable):
a seperate thread. This allows the user to interact with the GUI while the
simulation is running.
After each cpu tick, this thread will emit to its given QT signal so that
After each CPU tick, this thread will emit to its given QT signal so that
the GUI can update itself and possibly inform the user of when the execution
has halted.
"""
def __init__(self, cpu, signal, delay: float, run_continuously=True, steps=0):
def __init__(self, cpu, signal, delay: float, run_continuously=True,
is_asm_instruciton=False, steps=0):
super().__init__()
self.cpu = cpu
self.signal = signal
self.run_continuously = run_continuously
self.steps = steps
self.delay = delay
self.is_asm_instruciton = is_asm_instruciton
def run(self):
if self.run_continuously:
self.cpu.unstop()
while not self.cpu.is_stopped:
self.cpu.do_tick()
self.signal.emit(1)
time.sleep(self.delay)
if self.is_asm_instruciton:
else:
for _ in range(self.steps):
while self.steps > 0:
self.cpu.do_tick()
# We only care about asm instructions
if self.cpu.is_new_instruction():
self.steps -= 1
self.signal.emit(1)
time.sleep(self.delay)
if self.cpu.is_stopped:
break
# Signal end of execution as having run 0 ticks
self.signal.emit(0)
def run_asm(self):
self.cpu.run_asm(self.steps)
else:
if self.run_continuously:
self.cpu.unstop()
while not self.cpu.is_stopped:
self.cpu.do_tick()
self.signal.emit(1)
time.sleep(self.delay)
else:
for _ in range(self.steps):
self.cpu.do_tick()
self.signal.emit(1)
time.sleep(self.delay)
if self.cpu.is_stopped:
break
# Signal end of execution as having run 0 ticks
self.signal.emit(0)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment