diff --git a/mia_layout b/mia_layout index 101be585e8d128145708a4e4143db2a12c90bc8d..389240da584aad71d3c3d98738e2e62a8b958cb1 100644 --- a/mia_layout +++ b/mia_layout @@ -1 +1 @@ -[{"Bus": [687.0, 298.0], "uPC": [1175.0, 371.0], "SuPC": [1034.0, 373.0], "PC": [862.0, 452.0], "AR": [476.0, 408.0], "ASR": [483.0, 460.0], "HR": [862.0, 497.0], "uM": [985.0, 695.0], "ALU": [451.0, 292.0], "GRx": [186.0, 628.0], "IR": [757.0, 293.0], "Z-Flag": [186.0, 579.0], "N-Flag": [186.0, 532.0], "C-Flag": [186.0, 484.0], "O-Flag": [186.0, 435.0], "L-Flag": [186.0, 387.0], "LC": [209.0, 341.0], "PM": [427.0, 504.0], "K1": [955.0, 457.0], "K2": [1137.0, 457.0]}, {"0": [0.0, 180.0, 1, true], "1": [10.0, 0.0, 3, true], "2": [10.0, 80.0, 3, true], "3": [0.0, 231.0, 1, true], "4": [0.0, 255.0, 1, true], "5": [10.0, 160.0, 3, true], "6": [10.0, 180.0, 3, true], "7": [0.0, 38.0, 1, true], "8": [0.0, 146.0, 1, true], "9": [10.0, 210.0, 3, true], "10": [10.0, 233.0, 3, true], "11": [0.0, 415.0, 1, true], "12": [0.0, 435.0, 1, true], "13": [17.0, 0.0, 0, true], "14": [61.0, 15.0, 3, true], "15": [0.0, 7.0, 1, true], "16": [0.0, 34.0, 1, true], "17": [69.0, 32.0, 3, true], "18": [69.0, 5.0, 3, true], "19": [0.0, 6.0, 1, true], "20": [0.0, 26.0, 1, true], "21": [69.0, 36.0, 3, true], "22": [0.0, 11.0, 1, true], "23": [34.5, 0.0, 0, true], "24": [61.0, 18.0, 3, true], "25": [0.0, 24.0, 1, true], "26": [0.0, 11.0, 1, true], "27": [0.0, 34.0, 1, true], "28": [0.0, 25.0, 1, true], "29": [0.0, 26.0, 1, true], "30": [120.0, 44.0, 3, true], "31": [59.0, 60.0, 2, true], "32": [187.0, 85.0, 3, true], "33": [187.0, 105.0, 3, true], "34": [150.0, 25.0, 3, true], "35": [150.0, 49.0, 3, true], "36": [0.0, 18.0, 1, true], "37": [123.0, 0.0, 0, true], "38": [17.0, 0.0, 0, true], "39": [37.5, 200.0, 2, true], "40": [38.0, 0.0, 0, true], "41": [132.0, 0.0, 0, true], "42": [37.5, 200.0, 2, true]}, {"0": [[[679.0, 478.0], [640.0, 478.0], [640.0, 478.0], [552.0, 478.0]], true], "1": [[[679.0, 529.0], [632.0, 529.0], [632.0, 529.0], [585.0, 529.0]], true], "2": [[[679.0, 553.0], [616.0, 553.0], [616.0, 553.0], [585.0, 553.0]], true], "3": [[[705.0, 458.0], [782.0, 458.0], [782.0, 458.0], [854.0, 458.0]], true], "4": [[[705.0, 478.0], [842.0, 478.0], [842.0, 478.0], [854.0, 478.0]], true], "5": [[[679.0, 336.0], [623.0, 336.0], [623.0, 336.0], [579.0, 336.0]], true], "6": [[[679.0, 444.0], [671.0, 444.0], [671.0, 444.0], [553.0, 444.0]], true], "7": [[[705.0, 508.0], [842.0, 508.0], [842.0, 508.0], [854.0, 508.0]], true], "8": [[[705.0, 531.0], [854.0, 531.0], [854.0, 531.0], [854.0, 531.0]], true], "9": [[[679.0, 713.0], [643.5, 713.0], [643.5, 713.0], [381.0, 713.0]], true], "10": [[[679.0, 733.0], [643.5, 733.0], [643.5, 733.0], [381.0, 733.0]], true], "11": [[[1192.0, 363.0], [1192.0, 363.0], [1192.0, 338.0], [972.0, 338.0], [972.0, 449.0], [972.0, 449.0]], true], "12": [[[1244.0, 386.0], [1268.0, 386.0], [1268.0, 449.0], [1269.0, 449.0]], true], "13": [[[1167.0, 378.0], [1121.0, 378.0], [1121.0, 378.0], [1111.0, 378.0]], true], "14": [[[1167.0, 405.0], [1112.0, 405.0], [1112.0, 405.0], [1111.0, 405.0]], true], "15": [[[468.0, 419.0], [407.0, 419.0], [407.0, 318.0], [443.0, 318.0]], true], "16": [[[510.5, 400.0], [510.0, 400.0], [510.0, 360.0], [510.0, 360.0]], true], "17": [[[475.0, 484.0], [419.0, 484.0], [419.0, 522.0], [419.0, 522.0]], true], "18": [[[1078.0, 449.0], [1137.0, 449.0], [1137.0, 449.0], [1175.0, 449.0]], true]}] +[{"Bus": [815.0, 332.0], "uPC": [999.0, 243.0], "SuPC": [1132.0, 242.0], "PC": [885.0, 491.0], "AR": [561.0, 494.0], "ASR": [596.0, 271.0], "HR": [563.0, 564.0], "uM": [355.0, 621.0], "ALU": [543.0, 380.0], "GRx": [407.0, 727.0], "IR": [651.0, 159.0], "Z-Flag": [853.0, 780.0], "N-Flag": [933.0, 780.0], "C-Flag": [1012.0, 780.0], "O-Flag": [1092.0, 780.0], "L-Flag": [1173.0, 780.0], "LC": [1197.0, 737.0], "PM": [354.0, 308.0], "K1": [979.0, 321.0], "K2": [978.0, 538.0]}, {"0": [0.0, 23.0, 1, true], "1": [10.0, 0.0, 3, true], "2": [3.0, 0.0, 0, true], "3": [0.0, 80.0, 1, true], "4": [0.0, 100.0, 1, true], "5": [10.0, 168.0, 3, true], "6": [10.0, 191.0, 3, true], "7": [0.0, 287.0, 1, true], "8": [0.0, 210.0, 1, true], "9": [0.0, 242.0, 1, true], "10": [0.0, 264.0, 1, true], "11": [0.0, 480.0, 1, true], "12": [0.0, 500.0, 1, true], "13": [0.0, 6.0, 1, true], "14": [23.0, 0.0, 0, true], "15": [61.0, 35.0, 3, true], "16": [61.0, 6.0, 3, true], "17": [0.0, 7.0, 1, true], "18": [0.0, 36.0, 1, true], "19": [0.0, 9.0, 1, true], "20": [0.0, 32.0, 1, true], "21": [25.0, 40.0, 2, true], "22": [69.0, 35.0, 3, true], "23": [41.0, 0.0, 0, true], "24": [61.0, 28.0, 3, true], "25": [0.0, 29.0, 1, true], "26": [69.0, 10.0, 3, true], "27": [69.0, 32.0, 3, true], "28": [0.0, 25.0, 1, true], "29": [90.0, 0.0, 0, true], "30": [30.0, 0.0, 0, true], "31": [60.0, 60.0, 2, true], "32": [187.0, 85.0, 3, true], "33": [187.0, 105.0, 3, true], "34": [0.0, 23.0, 1, true], "35": [0.0, 60.0, 1, true], "36": [180.0, 23.0, 3, true], "37": [23.0, 0.0, 0, true], "38": [180.0, 50.0, 3, true], "39": [150.0, 15.0, 3, true], "40": [150.0, 33.0, 3, true], "41": [99.0, 0.0, 0, true], "42": [150.0, 25.0, 3, true], "43": [7.0, 0.0, 0, true], "44": [37.5, 200.0, 2, true], "45": [150.0, 25.0, 3, true], "46": [0.0, 22.0, 1, true], "47": [37.5, 200.0, 2, true]}, {"0": [[[807.0, 355.0], [758.0, 355.0], [758.0, 299.0], [665.0, 299.0]], true], "1": [[[833.0, 332.0], [1087.0, 332.0], [1087.0, 201.0], [737.0, 201.0]], false], "2": [[[818.0, 324.0], [703.0, 324.0], [703.0, 235.0], [721.0, 235.0]], false], "3": [[[807.0, 412.0], [719.0, 412.0], [719.0, 323.0], [512.0, 323.0]], true], "4": [[[807.0, 432.0], [710.0, 432.0], [710.0, 341.0], [512.0, 341.0]], true], "5": [[[833.0, 500.0], [862.0, 500.0], [862.0, 500.0], [877.0, 500.0]], true], "6": [[[833.0, 523.0], [853.0, 523.0], [853.0, 523.0], [877.0, 523.0]], true], "7": [[[807.0, 619.0], [531.0, 619.0], [531.0, 372.0], [573.0, 372.0]], true], "8": [[[807.0, 542.0], [743.0, 542.0], [743.0, 542.0], [586.0, 542.0]], true], "9": [[[807.0, 574.0], [701.0, 574.0], [701.0, 574.0], [640.0, 574.0]], true], "10": [[[807.0, 596.0], [726.0, 596.0], [726.0, 596.0], [640.0, 596.0]], true], "11": [[[807.0, 812.0], [643.5, 812.0], [643.5, 812.0], [602.0, 812.0]], true], "12": [[[807.0, 832.0], [643.5, 832.0], [643.5, 832.0], [602.0, 832.0]], true], "13": [[[991.0, 249.0], [986.0, 249.0], [986.0, 313.0], [986.0, 313.0]], true], "14": [[[1022.0, 235.0], [965.0, 235.0], [965.0, 560.0], [970.0, 560.0]], true], "15": [[[1068.0, 278.0], [1082.0, 278.0], [1082.0, 278.0], [1124.0, 278.0]], true], "16": [[[1068.0, 249.0], [1085.0, 249.0], [1085.0, 249.0], [1124.0, 249.0]], true], "17": [[[638.0, 529.0], [685.0, 529.0], [685.0, 372.0], [633.0, 372.0]], true], "18": [[[602.0, 486.0], [644.0, 486.0], [644.0, 448.0], [603.0, 448.0]], true], "19": [[[588.0, 300.0], [549.0, 300.0], [549.0, 300.0], [453.0, 300.0]], true], "20": [[[630.0, 159.0], [1612.75, 159.0], [1612.75, 529.0], [1016.5, 529.0]], false], "21": [[[630.0, 186.0], [1662.75, 186.0], [1662.75, 746.0], [1015.5, 746.0]], false], "22": [[[1137.0, 346.0], [1175.0, 346.0], [1175.0, 563.0], [1136.0, 563.0]], true]}] diff --git a/mia_layout_backup b/mia_layout_backup new file mode 100644 index 0000000000000000000000000000000000000000..389240da584aad71d3c3d98738e2e62a8b958cb1 --- /dev/null +++ b/mia_layout_backup @@ -0,0 +1 @@ +[{"Bus": [815.0, 332.0], "uPC": [999.0, 243.0], "SuPC": [1132.0, 242.0], "PC": [885.0, 491.0], "AR": [561.0, 494.0], "ASR": [596.0, 271.0], "HR": [563.0, 564.0], "uM": [355.0, 621.0], "ALU": [543.0, 380.0], "GRx": [407.0, 727.0], "IR": [651.0, 159.0], "Z-Flag": [853.0, 780.0], "N-Flag": [933.0, 780.0], "C-Flag": [1012.0, 780.0], "O-Flag": [1092.0, 780.0], "L-Flag": [1173.0, 780.0], "LC": [1197.0, 737.0], "PM": [354.0, 308.0], "K1": [979.0, 321.0], "K2": [978.0, 538.0]}, {"0": [0.0, 23.0, 1, true], "1": [10.0, 0.0, 3, true], "2": [3.0, 0.0, 0, true], "3": [0.0, 80.0, 1, true], "4": [0.0, 100.0, 1, true], "5": [10.0, 168.0, 3, true], "6": [10.0, 191.0, 3, true], "7": [0.0, 287.0, 1, true], "8": [0.0, 210.0, 1, true], "9": [0.0, 242.0, 1, true], "10": [0.0, 264.0, 1, true], "11": [0.0, 480.0, 1, true], "12": [0.0, 500.0, 1, true], "13": [0.0, 6.0, 1, true], "14": [23.0, 0.0, 0, true], "15": [61.0, 35.0, 3, true], "16": [61.0, 6.0, 3, true], "17": [0.0, 7.0, 1, true], "18": [0.0, 36.0, 1, true], "19": [0.0, 9.0, 1, true], "20": [0.0, 32.0, 1, true], "21": [25.0, 40.0, 2, true], "22": [69.0, 35.0, 3, true], "23": [41.0, 0.0, 0, true], "24": [61.0, 28.0, 3, true], "25": [0.0, 29.0, 1, true], "26": [69.0, 10.0, 3, true], "27": [69.0, 32.0, 3, true], "28": [0.0, 25.0, 1, true], "29": [90.0, 0.0, 0, true], "30": [30.0, 0.0, 0, true], "31": [60.0, 60.0, 2, true], "32": [187.0, 85.0, 3, true], "33": [187.0, 105.0, 3, true], "34": [0.0, 23.0, 1, true], "35": [0.0, 60.0, 1, true], "36": [180.0, 23.0, 3, true], "37": [23.0, 0.0, 0, true], "38": [180.0, 50.0, 3, true], "39": [150.0, 15.0, 3, true], "40": [150.0, 33.0, 3, true], "41": [99.0, 0.0, 0, true], "42": [150.0, 25.0, 3, true], "43": [7.0, 0.0, 0, true], "44": [37.5, 200.0, 2, true], "45": [150.0, 25.0, 3, true], "46": [0.0, 22.0, 1, true], "47": [37.5, 200.0, 2, true]}, {"0": [[[807.0, 355.0], [758.0, 355.0], [758.0, 299.0], [665.0, 299.0]], true], "1": [[[833.0, 332.0], [1087.0, 332.0], [1087.0, 201.0], [737.0, 201.0]], false], "2": [[[818.0, 324.0], [703.0, 324.0], [703.0, 235.0], [721.0, 235.0]], false], "3": [[[807.0, 412.0], [719.0, 412.0], [719.0, 323.0], [512.0, 323.0]], true], "4": [[[807.0, 432.0], [710.0, 432.0], [710.0, 341.0], [512.0, 341.0]], true], "5": [[[833.0, 500.0], [862.0, 500.0], [862.0, 500.0], [877.0, 500.0]], true], "6": [[[833.0, 523.0], [853.0, 523.0], [853.0, 523.0], [877.0, 523.0]], true], "7": [[[807.0, 619.0], [531.0, 619.0], [531.0, 372.0], [573.0, 372.0]], true], "8": [[[807.0, 542.0], [743.0, 542.0], [743.0, 542.0], [586.0, 542.0]], true], "9": [[[807.0, 574.0], [701.0, 574.0], [701.0, 574.0], [640.0, 574.0]], true], "10": [[[807.0, 596.0], [726.0, 596.0], [726.0, 596.0], [640.0, 596.0]], true], "11": [[[807.0, 812.0], [643.5, 812.0], [643.5, 812.0], [602.0, 812.0]], true], "12": [[[807.0, 832.0], [643.5, 832.0], [643.5, 832.0], [602.0, 832.0]], true], "13": [[[991.0, 249.0], [986.0, 249.0], [986.0, 313.0], [986.0, 313.0]], true], "14": [[[1022.0, 235.0], [965.0, 235.0], [965.0, 560.0], [970.0, 560.0]], true], "15": [[[1068.0, 278.0], [1082.0, 278.0], [1082.0, 278.0], [1124.0, 278.0]], true], "16": [[[1068.0, 249.0], [1085.0, 249.0], [1085.0, 249.0], [1124.0, 249.0]], true], "17": [[[638.0, 529.0], [685.0, 529.0], [685.0, 372.0], [633.0, 372.0]], true], "18": [[[602.0, 486.0], [644.0, 486.0], [644.0, 448.0], [603.0, 448.0]], true], "19": [[[588.0, 300.0], [549.0, 300.0], [549.0, 300.0], [453.0, 300.0]], true], "20": [[[630.0, 159.0], [1612.75, 159.0], [1612.75, 529.0], [1016.5, 529.0]], false], "21": [[[630.0, 186.0], [1662.75, 186.0], [1662.75, 746.0], [1015.5, 746.0]], false], "22": [[[1137.0, 346.0], [1175.0, 346.0], [1175.0, 563.0], [1136.0, 563.0]], true]}] diff --git a/src/simudator/core/processor.py b/src/simudator/core/processor.py index 709195328f73a4890ef6992ffb456442adcec2ea..b5269963bf81cb413f066bbb946b9344be6ba106 100644 --- a/src/simudator/core/processor.py +++ b/src/simudator/core/processor.py @@ -36,6 +36,10 @@ class Processor: self.max_line_len = 170 self.line_seperator = "-" self.is_stopped = False + # TODO: keeping track of what pieces of info not to show + # show not be done at the processor level. + # Maybe implemenet a 'get_pretty_print_state' at module + # level? self.ignore_keys = [ "bit_length", "mask", "increment", "read_from_bus", "read_from_uADR", "decrement_by_one", "bus_id" @@ -69,12 +73,15 @@ class Processor: def run_continuously(self): + """ + Runs the processor until it halts. + """ while not self.should_halt() and not self.is_stopped: self.do_tick() # Print all reached breakpoints then exit the loop self.breakpoint_reached = False - for bp_id, bp in self.breakpoints.items(): + for _, bp in self.breakpoints.items(): #TODO: Can make this more efficient by only checking enabled breakpoints if bp.is_break() and bp.is_enabled: self.breakpoint_reached = True @@ -470,8 +477,8 @@ class Processor: if not self.breakpoints: print("There are no breakpoints.") else: - for id, bp in self.breakpoints.items(): - print(f"BP {id}: {bp}") + for bp_id, bp in self.breakpoints.items(): + print(f"BP {bp_id}: {bp}") def add_memory_breakpoint(self, module_name:str, adress: int, value: Any) -> None: diff --git a/src/simudator/gui/breakpoint_window.py b/src/simudator/gui/breakpoint_window.py index bf713be52d56593502b42f2706a231868a7b6737..82530cf9cf06fb9584aed20272876ab39b616e6f 100644 --- a/src/simudator/gui/breakpoint_window.py +++ b/src/simudator/gui/breakpoint_window.py @@ -69,7 +69,7 @@ class BreakpointWindow(QWidget): """ Removes all list items from the breakpoint list. """ - for row in range(self.breakpoint_list.count()): + for _ in range(self.breakpoint_list.count()): self.breakpoint_list.takeItem(0) def toggleEnabledClicked(self) -> None: diff --git a/src/simudator/gui/cpu_graphics_scene.py b/src/simudator/gui/cpu_graphics_scene.py index 489456086359b06812a9227a5eaffdcea7cc7732..e00332fe5dc84700c68ba92cc590df4e36fb549c 100644 --- a/src/simudator/gui/cpu_graphics_scene.py +++ b/src/simudator/gui/cpu_graphics_scene.py @@ -39,6 +39,11 @@ class CpuGraphicsScene(QGraphicsScene): self.placeModuleGraphicsItemDefault(graphics_item) def placeModuleGraphicsItemDefault(self, graphics_item: ModuleGraphicsItem) -> None: + """ + Places a module graphics items at a position where the x value + is equal to the y value. Used to place all graphics items in a + diagonal. + """ placement = len(self.module_graphics_items)*self.MODULE_SPACEING graphics_item.setPos(placement, placement) self.addItem(graphics_item) @@ -48,6 +53,9 @@ class CpuGraphicsScene(QGraphicsScene): pos_x: int, pos_y: int ) -> None: + """ + Changes the postions of an existing modules graphics item. + """ graphics_item.setPos(pos_x*self.MODULE_SPACEING, pos_y*self.MODULE_SPACEING) @@ -103,6 +111,9 @@ class CpuGraphicsScene(QGraphicsScene): super().mousePressEvent(event) def load_layout_from_file(self, file_path: str) -> None: + """ + Loads a layout for a processor from a saved filed. + """ file = open(file_path) graphics_item_name = None diff --git a/src/simudator/gui/gui.py b/src/simudator/gui/gui.py index 112d349e299c0dd1143d1bef30c49358b466b5fe..54c220dfc035f7d7ecce84cc854cbe3e9a73228d 100644 --- a/src/simudator/gui/gui.py +++ b/src/simudator/gui/gui.py @@ -370,6 +370,10 @@ class GUI(QMainWindow): """ @pyqtSlot(str, str, str) def editModuleState(self, module_name, state, value) -> None: + """ + Tries to change the value of module to value given by user + through the dialog opened by editModuleStateDialog. + """ try: parsed_value = ast.literal_eval(value) except SyntaxError as e: @@ -383,6 +387,10 @@ class GUI(QMainWindow): @pyqtSlot(str, str, str) def editMemoryContent(self, module_name: str, adress: str, value: str) -> None: + """ + Tries to change the value at adress to value given by user + through the dialog opened by editModuleStateDialog. + """ try: parsed_adress = int(adress, 16) parsed_value = ast.literal_eval(value) @@ -402,6 +410,10 @@ class GUI(QMainWindow): @pyqtSlot(str, str, str) def addStateBreakpoint(self, module_name: str, state: str, value: str) -> None: + """ + Tries to add a breakpoint to the module through the dialog + opened by stateBreakpointDialog. + """ try: parsed_value = ast.literal_eval(value) self.cpu.add_state_breakpoint(module_name, state, parsed_value) @@ -411,6 +423,10 @@ class GUI(QMainWindow): @pyqtSlot(str, str) def addLambdaBreakpoint(self, lambda_name, kwargs_str) -> None: + """ + Tries to add a breakpoint to the module through the dialog + opened by lambdaBreakpointDialog. + """ try: lambda_kwargs = {} for kwarg in kwargs_str.split(' '): @@ -423,6 +439,10 @@ class GUI(QMainWindow): @pyqtSlot(str, str, str) def addMemoryBreakpoint(self, module_name: str, adress: str, value: str) -> None: + """ + Tries to add a breakpoint to the module through the dialog + opened by memoryBreakpointDialog. + """ try: parsed_adress = int(adress, 16) parsed_value = ast.literal_eval(value) @@ -600,8 +620,8 @@ class GUI(QMainWindow): def saveLayoutToolBarButtonClick(self) -> None: """ - Saves the layout of all the modules in a human readable - (and editable) format. + Saves the layout of all the modules in a (somewhat) + human readable format. Erases the previous content of the file before saving the data. """ diff --git a/src/simudator/gui/module_graphics_item/module_graphics_item.py b/src/simudator/gui/module_graphics_item/module_graphics_item.py index aa7e750d03552b946c13975be01483a5716a8881..35863feeebe01658c3592fb17164da8876b70ee0 100644 --- a/src/simudator/gui/module_graphics_item/module_graphics_item.py +++ b/src/simudator/gui/module_graphics_item/module_graphics_item.py @@ -97,7 +97,7 @@ class ModuleGraphicsItem(QGraphicsObject, QGraphicsItem): height = max(inputs_height, outputs_height, members_height) - width = longest_line_len * self.CHAR_LEN * 2 + 2 * self.WIDTH_MARGIN + width = longest_line_len * self.CHAR_LEN * 2 + 2 * self.WIDTH_MARGIN # Shadow self.shadow = QGraphicsRectItem(0, 0, width, height, self) @@ -279,11 +279,5 @@ class ModuleGraphicsItem(QGraphicsObject, QGraphicsItem): name = self.name return f"{name}:\nx: {x_pos} y: {y_pos}\n" - def get_pos(self): - return self.pos() - - def get_scene_pos(self): - return self.scenePos() - def getName(self) -> str: return self.name diff --git a/src/simudator/processor/mia/alu.py b/src/simudator/processor/mia/alu.py index 4c99aaf03568b80251ffbe1aebb383e0e68b078d..15e090010d61c70c77ca7a30de21d64966749939 100644 --- a/src/simudator/processor/mia/alu.py +++ b/src/simudator/processor/mia/alu.py @@ -323,7 +323,6 @@ class ALU(Module): # Convert shifted to int value = self.bin_to_int(new_binary_number) - print(carry) self.update_flags(None, None, new_binary_number, carry) return value