diff --git a/src/simudator/core/module.py b/src/simudator/core/module.py index b84284952a8c0177ddf4756f874401a89d745fa4..b4eaec3b21680f7fe7e1e81a01e602cf50c9581e 100644 --- a/src/simudator/core/module.py +++ b/src/simudator/core/module.py @@ -1,4 +1,5 @@ from __future__ import annotations + from os import error from simudator.core.signal import Signal diff --git a/src/simudator/gui/module_graphics_item/integer_memory_graphic.py b/src/simudator/gui/module_graphics_item/integer_memory_graphic.py index c746c082c3fcc3e33d16b20949415b833cdfcf07..262d7a5766208c33f7306c9876e380539c046155 100644 --- a/src/simudator/gui/module_graphics_item/integer_memory_graphic.py +++ b/src/simudator/gui/module_graphics_item/integer_memory_graphic.py @@ -1,3 +1,5 @@ +import sys +import traceback from enum import Enum from qtpy.QtWidgets import QButtonGroup, QHBoxLayout, QHeaderView, QRadioButton @@ -8,6 +10,8 @@ from simudator.gui.module_graphics_item.memory_graphic import ( MemoryWindow, ) +sys.setrecursionlimit(100) + class Base(Enum): NONE = 0 @@ -53,7 +57,7 @@ class IntegerMemoryWindow(MemoryWindow): self.layout.addWidget(self._memory_table) # Create base buttons, they are exclusive by default - # so need a seperate QButtonGroup since these four + # so need a separate QButtonGroup since these four # have nothing to do with the edit/view buttons self.dec_signed_button = QRadioButton("Decimal Signed") self.dec_unsigned_button = QRadioButton("Decimal Unsigned") @@ -140,7 +144,10 @@ class IntegerMemoryTable(MemoryTable): self._base = Base.DECIMAL_UNSIGNED self._bit_length = bit_length super().__init__(memory_module, column_size) - + print(traceback.format_exc()) + print(memory_module) + print(memory_module.get_parameter()) + raise ValueError self.update() # Signal used to detect when the user has edited a cell # This code can only be called after the initial self.update(). @@ -208,6 +215,9 @@ class IntegerMemoryTable(MemoryTable): # and format each value is in try: + print(value) + print(min_value) + print(max_value) if self._base == Base.BINARY: value = int(value, 2) elif self._base == Base.HEXADECIMAL: diff --git a/src/simudator/processor/mia/modules/micro_memory.py b/src/simudator/processor/mia/modules/micro_memory.py index 5995909ed6befcdbe0f8e821d4b519216bee40e8..e9aa9e464a92e5e06a84832815ca0892bb00ea20 100644 --- a/src/simudator/processor/mia/modules/micro_memory.py +++ b/src/simudator/processor/mia/modules/micro_memory.py @@ -26,8 +26,6 @@ class MicroMemory(Module): "l_flag_val", "memory", "halt", - "adress_padding", - "value_padding", ) MEMORY_ADDRESS_PADDING = 2 @@ -51,8 +49,6 @@ class MicroMemory(Module): o_flag: Signal, l_flag: Signal, name: str = "uM", - adress_padding: int = 2, - value_padding: int = 7, ) -> None: """ Parameters @@ -127,10 +123,6 @@ class MicroMemory(Module): self.memory = [0 for _ in range(128)] self.halt = False # Used for signalling a HALT - # paddings to ensure saving to file has the correct format - self.adress_padding = adress_padding - self.value_padding = value_padding - def update_logic(self) -> None: """ Update the micro controller with a new instruction index. @@ -297,6 +289,16 @@ class MicroMemory(Module): state["memory"] = self.memory[:] return state + def get_parameter(self) -> dict: + parameter = super().get_parameter() + + # Bit length is not used internally within this module. + # The only way the micro memory memory can receive input + # is from the user, and the user is not able to insert values that + # are larger than 25 bits + parameter["bit_length"] = 25 + return parameter + def set_state(self, state: dict) -> None: super().set_state(state) self.memory = state["memory"] @@ -316,7 +318,7 @@ class MicroMemory(Module): self.c_flag_val = 0 self.o_flag_val = 0 self.l_flag_val = 0 - self.memory = [0 for i in range(128)] + self.memory = [0 for _ in range(128)] self.halt = False # Used for signalling a HALT def load_from_str(self, state_string) -> None: