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

started on pipeline, pivotet to fixing comments and documentation

parent 58f2a69c
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 #131305 passed
...@@ -71,6 +71,11 @@ class Processor: ...@@ -71,6 +71,11 @@ class Processor:
module = self.update_queue.pop(0) module = self.update_queue.pop(0)
module.update_logic() module.update_logic()
def get_current_instrution(self):
"""
Return the current instruction. Useful for pipeline diagram.
"""
raise NotImplemented
def run_continuously(self): def run_continuously(self):
""" """
......
...@@ -32,6 +32,7 @@ from simudator.gui.orientation import Orientation ...@@ -32,6 +32,7 @@ from simudator.gui.orientation import Orientation
from simudator.gui.port_graphics_item import PortGraphicsItem from simudator.gui.port_graphics_item import PortGraphicsItem
from simudator.gui.run_continuously_thread import RunThread from simudator.gui.run_continuously_thread import RunThread
from simudator.gui.signal_graphics_item import SignalGraphicsItem from simudator.gui.signal_graphics_item import SignalGraphicsItem
from simudator.gui.pipeline import PipeLine
class View(QGraphicsView): class View(QGraphicsView):
...@@ -82,7 +83,9 @@ class View(QGraphicsView): ...@@ -82,7 +83,9 @@ class View(QGraphicsView):
class GUI(QMainWindow): class GUI(QMainWindow):
""" """
This is the main class for the GUI. It handles creating the widnow for Main gui class. Handles gui windows, toolbar and visualizes modules.
This is the main class for the GUI. It handles creating the window for
the gui, aswell as the toolbar for controlling the simultaion. the gui, aswell as the toolbar for controlling the simultaion.
It takes a processor and visualizes its modules as boxes with the signals as lines It takes a processor and visualizes its modules as boxes with the signals as lines
between them. Graphics items for the modules and signals need to be created between them. Graphics items for the modules and signals need to be created
...@@ -119,6 +122,11 @@ class GUI(QMainWindow): ...@@ -119,6 +122,11 @@ class GUI(QMainWindow):
# Using the cpu's internal status directly could case problems # Using the cpu's internal status directly could case problems
self.cpu_running = False self.cpu_running = False
self.pipeline = PipeLine()
self.pipeline.setRowCount(5)
self.pipeline.setColumnCount(5)
self.pipeline.show()
# Set Style, THESE ARE TEST AND DONT WORK # Set Style, THESE ARE TEST AND DONT WORK
app = QApplication.instance() app = QApplication.instance()
app.setStyleSheet("Qwidget.QMainWindow { background-color: yellow }") app.setStyleSheet("Qwidget.QMainWindow { background-color: yellow }")
...@@ -129,6 +137,9 @@ class GUI(QMainWindow): ...@@ -129,6 +137,9 @@ class GUI(QMainWindow):
def createToolBar(self) -> None: def createToolBar(self) -> None:
""" """
Creates the toolbar containing file, layout and toolbar buttons.
Creates the toolbar containing the file, layout and toolbar Creates the toolbar containing the file, layout and toolbar
buttons with their respective sub buttons. buttons with their respective sub buttons.
""" """
...@@ -260,6 +271,8 @@ class GUI(QMainWindow): ...@@ -260,6 +271,8 @@ class GUI(QMainWindow):
def connectModuleActions(self, action_signals: []) -> None: def connectModuleActions(self, action_signals: []) -> None:
""" """
Connects modules with actions thorught ids (strings). Useful for breakpoints.
This function takes a list of tuples with an This function takes a list of tuples with an
action id (which is a predefined string) and a signal. action id (which is a predefined string) and a signal.
It then connects the signal to a function depending on the action id. It then connects the signal to a function depending on the action id.
...@@ -288,6 +301,7 @@ class GUI(QMainWindow): ...@@ -288,6 +301,7 @@ class GUI(QMainWindow):
def updateCpuListeners(self) -> None: def updateCpuListeners(self) -> None:
""" """
Updates the graphics items in the scene and the clock. Updates the graphics items in the scene and the clock.
Used after the cpu has run or when the user has edited somehting. Used after the cpu has run or when the user has edited somehting.
""" """
self.cpu_graphics_scene.updateGraphicsItems() self.cpu_graphics_scene.updateGraphicsItems()
...@@ -309,6 +323,7 @@ class GUI(QMainWindow): ...@@ -309,6 +323,7 @@ class GUI(QMainWindow):
if self.breakpoint_window is not None: if self.breakpoint_window is not None:
self.breakpoint_window.update() self.breakpoint_window.update()
""" """
@Slot is used to explicitly mark a python method as a Qt slot @Slot is used to explicitly mark a python method as a Qt slot
and specify a C++ signature for it, which is used most commonly and specify a C++ signature for it, which is used most commonly
...@@ -318,8 +333,9 @@ class GUI(QMainWindow): ...@@ -318,8 +333,9 @@ class GUI(QMainWindow):
@Slot(str, str, str) @Slot(str, str, str)
def editModuleState(self, module_name, state, value) -> None: def editModuleState(self, module_name, state, value) -> None:
""" """
Tries to change the value of module to value given by user Tries to change the value of module to value given by user.
through the dialog opened by editModuleStateDialog.
Does this through the dialog opened by editModuleStateDialog.
""" """
try: try:
parsed_value = ast.literal_eval(value) parsed_value = ast.literal_eval(value)
...@@ -335,8 +351,9 @@ class GUI(QMainWindow): ...@@ -335,8 +351,9 @@ class GUI(QMainWindow):
@Slot(str, str, str) @Slot(str, str, str)
def editMemoryContent(self, module_name: str, adress: str, value: str) -> None: def editMemoryContent(self, module_name: str, adress: str, value: str) -> None:
""" """
Tries to change the value at adress to value given by user Tries to change the value at adress to value given by user.
through the dialog opened by editModuleStateDialog.
Does this through the dialog opened by editModuleStateDialog.
""" """
try: try:
parsed_adress = int(adress, 16) parsed_adress = int(adress, 16)
...@@ -357,8 +374,7 @@ class GUI(QMainWindow): ...@@ -357,8 +374,7 @@ class GUI(QMainWindow):
@Slot(str, str, str) @Slot(str, str, str)
def addStateBreakpoint(self, module_name: str, state: str, value: str) -> None: def addStateBreakpoint(self, module_name: str, state: str, value: str) -> None:
""" """
Tries to add a breakpoint to the module through the dialog Tries to add a breakpoint to the module through the dialog opened by stateBreakpointDialog.
opened by stateBreakpointDialog.
""" """
try: try:
parsed_value = ast.literal_eval(value) parsed_value = ast.literal_eval(value)
...@@ -370,8 +386,7 @@ class GUI(QMainWindow): ...@@ -370,8 +386,7 @@ class GUI(QMainWindow):
@Slot(str, str) @Slot(str, str)
def addLambdaBreakpoint(self, lambda_name, kwargs_str) -> None: def addLambdaBreakpoint(self, lambda_name, kwargs_str) -> None:
""" """
Tries to add a breakpoint to the module through the dialog Tries to add a breakpoint to the module through the dialog opened by lambdaBreakpointDialog.
opened by lambdaBreakpointDialog.
""" """
try: try:
lambda_kwargs = {} lambda_kwargs = {}
...@@ -386,8 +401,7 @@ class GUI(QMainWindow): ...@@ -386,8 +401,7 @@ class GUI(QMainWindow):
@Slot(str, str, str) @Slot(str, str, str)
def addMemoryBreakpoint(self, module_name: str, adress: str, value: str) -> None: def addMemoryBreakpoint(self, module_name: str, adress: str, value: str) -> None:
""" """
Tries to add a breakpoint to the module through the dialog Tries to add a breakpoint to the module through the dialog opened by memoryBreakpointDialog.
opened by memoryBreakpointDialog.
""" """
try: try:
parsed_adress = int(adress) parsed_adress = int(adress)
...@@ -399,8 +413,7 @@ class GUI(QMainWindow): ...@@ -399,8 +413,7 @@ class GUI(QMainWindow):
def setDisabledWhenRunning(self, is_disable): def setDisabledWhenRunning(self, is_disable):
""" """
This function greys out buttons for actions Greys out buttons for actions that can't be done while cpu is running.
that can't be done while cpu is running.
""" """
self.load_action.setDisabled(is_disable) self.load_action.setDisabled(is_disable)
self.save_action.setDisabled(is_disable) self.save_action.setDisabled(is_disable)
...@@ -445,8 +458,7 @@ class GUI(QMainWindow): ...@@ -445,8 +458,7 @@ class GUI(QMainWindow):
@Slot(int) @Slot(int)
def cpuHaltedFunction(self, steps: int) -> None: def cpuHaltedFunction(self, steps: int) -> None:
""" """
Called from other thread when cpu has halted. Called from other thread when cpu has halted. Will inform the user and update visuals.
Will inform the user and update visuals.
""" """
# If a breakpoint halted the program inform thr user # If a breakpoint halted the program inform thr user
...@@ -468,10 +480,11 @@ class GUI(QMainWindow): ...@@ -468,10 +480,11 @@ class GUI(QMainWindow):
self.cpu.stop() self.cpu.stop()
self.updateCpuListeners() self.updateCpuListeners()
# TODO: What is the difference between folderSaveDialog and folderLoadDialog?
def folderSaveDialog(self) -> str: def folderSaveDialog(self) -> str:
""" """
Opens a file explorer in a new window. Returns the Opens a file explorer in a new window. Returns the absolute path to the selected file.
absolute path to the selected file.
""" """
dialog = QFileDialog() dialog = QFileDialog()
dialog.setFileMode(QFileDialog.AnyFile) dialog.setFileMode(QFileDialog.AnyFile)
...@@ -482,8 +495,7 @@ class GUI(QMainWindow): ...@@ -482,8 +495,7 @@ class GUI(QMainWindow):
def folderLoadDialog(self) -> str: def folderLoadDialog(self) -> str:
""" """
Opens a file explorer in a new window. Returns the Opens a file explorer in a new window. Returns the absolute path to the selected file.
absolute path to the selected file.
""" """
dialog = QFileDialog() dialog = QFileDialog()
dialog.setFileMode(QFileDialog.AnyFile) dialog.setFileMode(QFileDialog.AnyFile)
...@@ -562,9 +574,9 @@ class GUI(QMainWindow): ...@@ -562,9 +574,9 @@ class GUI(QMainWindow):
def saveLayoutToolBarButtonClick(self) -> None: def saveLayoutToolBarButtonClick(self) -> None:
""" """
Saves the layout of all the modules in a (somewhat) Saves the layout of all the modules in a (somewhat) human readable format.
human readable format.
Erases the previous content of the file before saving This also erases the previous content of the file before saving
the data. the data.
""" """
path = self.folderSaveDialog() path = self.folderSaveDialog()
...@@ -605,8 +617,7 @@ class GUI(QMainWindow): ...@@ -605,8 +617,7 @@ class GUI(QMainWindow):
def loadDefaultLayoutToolBarButtonClick(self) -> None: def loadDefaultLayoutToolBarButtonClick(self) -> None:
""" """
Places all the module_graphic objects in a diagonal going Places all the module_graphic objects in a diagonal going down to the right.
down to the right.
""" """
counter = 0 counter = 0
for key in self.cpu_graphics_scene.module_graphics_items: for key in self.cpu_graphics_scene.module_graphics_items:
...@@ -621,6 +632,7 @@ class GUI(QMainWindow): ...@@ -621,6 +632,7 @@ class GUI(QMainWindow):
def loadLayoutFromFile(self, file) -> None: def loadLayoutFromFile(self, file) -> None:
""" """
Loads a layout for the current cpu from the selected file. Loads a layout for the current cpu from the selected file.
If at anypoint this funciton would error, the default layout If at anypoint this funciton would error, the default layout
is loaded instead. is loaded instead.
""" """
...@@ -666,8 +678,7 @@ class GUI(QMainWindow): ...@@ -666,8 +678,7 @@ class GUI(QMainWindow):
visibility: bool, visibility: bool,
) -> None: ) -> None:
""" """
Changes the graphical signal to have the positions given Changes the graphical signal to have the positions given as argument.
as argument.
""" """
qpoints = [] qpoints = []
# Turn points -> QPointF # Turn points -> QPointF
...@@ -686,8 +697,7 @@ class GUI(QMainWindow): ...@@ -686,8 +697,7 @@ class GUI(QMainWindow):
graphics_module_y: float, graphics_module_y: float,
) -> None: ) -> None:
""" """
Changes the positions of graphical modules to the ones given Changes the positions of graphical modules to the ones given as argument.
as argument.
""" """
graphics_module.setX(graphics_module_x) graphics_module.setX(graphics_module_x)
graphics_module.setY(graphics_module_y) graphics_module.setY(graphics_module_y)
...@@ -708,8 +718,8 @@ class GUI(QMainWindow): ...@@ -708,8 +718,8 @@ class GUI(QMainWindow):
def saveStateMenuButtonClick(self) -> None: def saveStateMenuButtonClick(self) -> None:
""" """
Save state of cpu to file. Save state of cpu to file.
Erases the previous content of the file before saving
the data. This erases the previous content of the file before saving the data.
""" """
# Not safe to save while running # Not safe to save while running
...@@ -753,7 +763,9 @@ class GUI(QMainWindow): ...@@ -753,7 +763,9 @@ class GUI(QMainWindow):
def loadLayoutToolBarButtonClick(self) -> None: def loadLayoutToolBarButtonClick(self) -> None:
""" """
Loads a given layout from a selected file. If the layout was Loads a given layout from a selected file.
If the layout was
unable to load, an error message will pop up informing the user unable to load, an error message will pop up informing the user
and the default layout will be loaded. and the default layout will be loaded.
""" """
......
from qtpy.QtWidgets import QTableWidget
class PipeLine(QTableWidget):
"""
Documentation
"""
def __init__(self):
super().__init__()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment