Skip to content

Commit

Permalink
Merge branch 'fix/svg-control' into 'main'
Browse files Browse the repository at this point in the history
add control signal arrows

See merge request es/lehre/rechnerarchitektur/architecture-simulator!30
  • Loading branch information
mikuhn committed Dec 15, 2023
2 parents 27119f3 + 2cb4f3f commit 7bc9623
Show file tree
Hide file tree
Showing 3 changed files with 236 additions and 33 deletions.
24 changes: 23 additions & 1 deletion architecture_simulator/gui/toy_svg_directives.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,51 @@ def __init__(self):
self.text_alu_out = SvgWriteDirective()
# Control unit signal paths and texts to highlight.
self.path_control_unit_write_ram = SvgFillDirectiveControlUnit()
self.path_control_unit_write_ram_2 = SvgFillDirectiveControlUnit()
self.text_write_ram = SvgFillDirectiveControlUnit()
self.text_write_ram_2 = SvgFillDirectiveControlUnit()
self.path_control_unit_inc_pc = SvgFillDirectiveControlUnit()
self.path_control_unit_inc_pc_2 = SvgFillDirectiveControlUnit()
self.text_inc_pc = SvgFillDirectiveControlUnit()
self.path_control_unit_set_pc = SvgFillDirectiveControlUnit()
self.path_control_unit_set_pc_2 = SvgFillDirectiveControlUnit()
self.text_set_pc = SvgFillDirectiveControlUnit()
self.path_control_unit_addr_ir = SvgFillDirectiveControlUnit()
self.path_control_unit_addr_ir_2 = SvgFillDirectiveControlUnit()
self.text_addr_ir = SvgFillDirectiveControlUnit()
self.text_addr_ir_2 = SvgFillDirectiveControlUnit()
self.path_control_unit_set_ir = SvgFillDirectiveControlUnit()
self.path_control_unit_set_ir_2 = SvgFillDirectiveControlUnit()
self.text_set_ir = SvgFillDirectiveControlUnit()
self.text_set_ir_2 = SvgFillDirectiveControlUnit()
self.path_control_unit_set_accu = SvgFillDirectiveControlUnit()
self.path_control_unit_set_accu_2 = SvgFillDirectiveControlUnit()
self.text_set_accu = SvgFillDirectiveControlUnit()
self.text_set_accu_2 = SvgFillDirectiveControlUnit()
self.path_control_unit_alucin = SvgFillDirectiveControlUnit()
self.path_control_unit_alucin_2 = SvgFillDirectiveControlUnit()
self.text_alucin = SvgFillDirectiveControlUnit()
self.text_alucin_2 = SvgFillDirectiveControlUnit()
self.path_control_unit_alumode = SvgFillDirectiveControlUnit()
self.path_control_unit_alumode_2 = SvgFillDirectiveControlUnit()
self.text_alumode = SvgFillDirectiveControlUnit()
self.text_alumode_2 = SvgFillDirectiveControlUnit()
self.path_control_unit_alu3 = SvgFillDirectiveControlUnit()
self.path_control_unit_alu3_2 = SvgFillDirectiveControlUnit()
self.text_alu3 = SvgFillDirectiveControlUnit()
self.text_alu3_2 = SvgFillDirectiveControlUnit()
self.path_control_unit_alu2 = SvgFillDirectiveControlUnit()
self.path_control_unit_alu2_2 = SvgFillDirectiveControlUnit()
self.text_alu2 = SvgFillDirectiveControlUnit()
self.text_alu2_2 = SvgFillDirectiveControlUnit()
self.path_control_unit_alu1 = SvgFillDirectiveControlUnit()
self.path_control_unit_alu1_2 = SvgFillDirectiveControlUnit()
self.text_alu1 = SvgFillDirectiveControlUnit()
self.text_alu1_2 = SvgFillDirectiveControlUnit()
self.path_control_unit_alu0 = SvgFillDirectiveControlUnit()
self.path_control_unit_alu0_2 = SvgFillDirectiveControlUnit()
self.text_alu0 = SvgFillDirectiveControlUnit()
self.text_alu0_2 = SvgFillDirectiveControlUnit()

def export(self) -> list[tuple[str, str, Any]]:
"""Exports all SvgDirectives into a format that the front end understands.
Expand Down Expand Up @@ -174,4 +196,4 @@ class SvgFillDirectiveControlUnit(SvgFillDirective):
"""SVG Fill Directive for the control unit signals."""

def __init__(self):
super().__init__(color_on="#ED6B03", color_off="#000000")
super().__init__(color_on="#ed0202", color_off="#000000")
17 changes: 17 additions & 0 deletions architecture_simulator/gui/webgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,23 @@ def get_toy_svg_update_values(sim: ToySimulation) -> list[tuple[str, str, Any]]:
assert isinstance(control_unit_text, SvgFillDirectiveControlUnit)
control_unit_path.do_highlight = value
control_unit_text.do_highlight = value

try:
control_unit_path_2 = getattr(
result, "path_control_unit_" + name + "_2"
)
except AttributeError:
pass
else:
control_unit_path_2.do_highlight = value

try:
control_unit_text_2 = getattr(result, "text_" + name + "_2")
except AttributeError:
pass
else:
control_unit_text_2.do_highlight = value

return result.export()


Expand Down
Loading

0 comments on commit 7bc9623

Please sign in to comment.