Skip to content
Snippets Groups Projects
Commit 5e890e8f authored by Martin's avatar Martin
Browse files

fixed broken gui by replacing get_state with get_gui_state where needed

parent 6e517c6b
No related branches found
No related tags found
1 merge request!43Fixed ALU bugs of edit state and add breakpoint
Pipeline #133425 failed
......@@ -71,7 +71,7 @@ class Register(Module):
return state
def get_gui_state(self) -> dict[str, Any]:
state = self.get_state()
state = {"name": self.name, "value": self._value}
return state
def set_state(self, state: dict[str, Any]) -> None:
......
......@@ -248,6 +248,6 @@ class IntegerMemoryTable(MemoryTable):
# -7 + 16 % 16 = 9 = 1001 = -7
value = (value + max_value) % max_value
index = row * 4 + col
index = row * self._column_size + col
state['memory'][index] = value
self._memory.set_state(state)
......@@ -191,12 +191,12 @@ class MemoryTable(QTableWidget):
return
def _on_cell_changed(self, row, col):
state = self._memory.get_state()
state = self._memory.get_gui_state()
item = self.item(row, col)
value = item.text()
if value == "":
return
index = row * 4 + col
index = row * self._column_size + col
state['memory'][index] = value
self._memory.set_state(state)
......
......@@ -57,7 +57,7 @@ class ModuleGraphicsItem(QGraphicsObject, QGraphicsItem):
# Get information about module
# Get inputs/outputs is not always implemented so might not show all ports
self.state = module.get_state()
self.state = module.get_gui_state()
self.input_signals = module.get_input_signals()
self.output_signals = module.get_output_signals()
......
......@@ -38,7 +38,7 @@ class RegisterGraphicsItem(ModuleGraphicsItem):
)
def update(self):
state = self.module.get_state()
state = self.module.get_gui_state()
full_text = f"{state['name']}: {state['value']}"
self.text.setText(full_text)
......@@ -52,6 +52,6 @@ class IntegerRegisterGraphicsItem(RegisterGraphicsItem):
def update(self):
parameter = self.module.get_parameter()
hex_length = math.ceil(parameter["bit_length"] / 4)
state = self.module.get_state()
state = self.module.get_gui_state()
full_text = f"{state['name']}: {state['value']:0{hex_length}x}"
self.text.setText(full_text)
......@@ -35,7 +35,7 @@ class MicroMemoryGraphicsItem(MiaMemoryGraphicsItem):
def update(self):
# get instruction field
uM_state = self.module.get_state()
uM_state = self.module.get_gui_state()
instr = uM_state["curr_instr"]
......
......@@ -10,7 +10,7 @@ class PcGraphicsItem(IntegerRegisterGraphicsItem):
"""
def update(self):
self.state = self.module.get_state()
self.state = self.module.get_gui_state()
name = self.state["name"]
value = self.state["value"]
......
......@@ -11,9 +11,9 @@ class uPcGraphicsItem(IntegerRegisterGraphicsItem):
"""
def update(self):
self.state = self.module.get_state()
name = self.state["name"]
value = self.state["value"]
self.gui_state = self.module.get_gui_state()
name = self.gui_state["name"]
value = self.gui_state["value"]
full_text = f"{name}: {value:02x}"
......@@ -27,12 +27,16 @@ class uPcGraphicsItem(IntegerRegisterGraphicsItem):
)
# Draw from K1 port
from_k1 = PortGraphicsItem(self.module.signals["in_k1"], Orientation.UP, parent=self)
from_k1 = PortGraphicsItem(
self.module.signals["in_k1"], Orientation.UP, parent=self
)
from_k1.setPos(width * 2 / 8, 0)
self.ports.append(from_k1)
# Draw from K2 port
from_k2 = PortGraphicsItem(self.module.signals["in_k2"], Orientation.UP, parent=self)
from_k2 = PortGraphicsItem(
self.module.signals["in_k2"], Orientation.UP, parent=self
)
from_k2.setPos(width * 6 / 8, 0)
self.ports.append(from_k2)
......
......@@ -158,6 +158,11 @@ class LC(Module):
state["decrement_by_one"] = self._decrement_by_one
return state
def get_gui_state(self) -> dict[str, Any]:
state = super().get_gui_state()
state["value"] = self._value
return state
def get_parameter(self) -> dict[str, Any]:
"""Return a dictionary of the parameters of the loop counter,
i.e. the bit length of the counter.
......
......@@ -284,8 +284,10 @@ class MicroMemory(Module):
return state
def get_gui_state(self) -> dict[str, Any]:
state = super().get_state()
state = super().get_gui_state()
state["memory"] = self._memory[:]
state["halt"] = self._halt
state["curr_instr"] = self._curr_instr
return state
def set_state(self, state: dict) -> None:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment