diff --git a/pymint/mintcompiler.py b/pymint/mintcompiler.py index 73297be..ee4272c 100644 --- a/pymint/mintcompiler.py +++ b/pymint/mintcompiler.py @@ -2,12 +2,12 @@ from typing import Dict, Optional from parchmint import Layer, Target +from parchmint.device import ValveType from pymint.antlrgen.mintListener import mintListener from pymint.antlrgen.mintParser import mintParser from pymint.mintdevice import MINTDevice from pymint.mintlayer import MINTLayerType -from parchmint.device import ValveType class MINTCompiler(mintListener): @@ -34,7 +34,9 @@ def exitNetlist(self, ctx: mintParser.NetlistContext): def enterHeader(self, ctx: mintParser.HeaderContext): if self.current_device is None: - raise Exception("Error Initializing the device. Could not find the current device") + raise Exception( + "Error Initializing the device. Could not find the current device" + ) if ctx.device_name is None: raise Exception("Could not find Device Name") @@ -46,7 +48,9 @@ def exitLayerBlock(self, ctx: mintParser.LayerBlockContext): def enterFlowBlock(self, ctx: mintParser.FlowBlockContext): if self.current_device is None: - raise Exception("Error Initializing the device. Could not find the current device") + raise Exception( + "Error Initializing the device. Could not find the current device" + ) layer = self.current_device.create_mint_layer( str(self.current_layer_id), str(self.flow_layer_count), @@ -59,7 +63,9 @@ def enterFlowBlock(self, ctx: mintParser.FlowBlockContext): def enterControlBlock(self, ctx: mintParser.ControlBlockContext): if self.current_device is None: - raise Exception("Error Initializing the device. Could not find the current device") + raise Exception( + "Error Initializing the device. Could not find the current device" + ) layer = self.current_device.create_mint_layer( str(self.current_layer_id), @@ -73,7 +79,9 @@ def enterControlBlock(self, ctx: mintParser.ControlBlockContext): def enterIntegrationBlock(self, ctx: mintParser.IntegrationBlockContext): if self.current_device is None: - raise Exception("Error Initializing the device. Could not find the current device") + raise Exception( + "Error Initializing the device. Could not find the current device" + ) layer = self.current_device.create_mint_layer( str(self.current_layer_id), @@ -134,7 +142,9 @@ def enterControlStat(self, ctx: mintParser.ControlStatContext): def exitPrimitiveStat(self, ctx: mintParser.PrimitiveStatContext): if self.current_device is None: - raise Exception("Error Initializing the device. Could not find the current device") + raise Exception( + "Error Initializing the device. Could not find the current device" + ) entity = self.current_entity if entity is None: @@ -144,7 +154,9 @@ def exitPrimitiveStat(self, ctx: mintParser.PrimitiveStatContext): for ufname in ctx.ufnames().ufname(): # type: ignore if self._current_layer is None: raise Exception("Current layer is set to None") - if not (self._current_layer is not None and self._current_layer.ID is not None): + if not ( + self._current_layer is not None and self._current_layer.ID is not None + ): raise AssertionError self.current_device.create_mint_component( ufname.getText(), @@ -189,7 +201,9 @@ def exitBankGenStat(self, ctx: mintParser.BankGenStatContext): component_name = name + "_" + str(i) if self._current_layer is None: raise Exception("Current Layer not Set") - if not (self._current_layer is not None and self._current_layer.ID is not None): + if not ( + self._current_layer is not None and self._current_layer.ID is not None + ): raise AssertionError self.current_device.create_mint_component( component_name, entity, self.current_params, [self._current_layer.ID] @@ -197,7 +211,9 @@ def exitBankGenStat(self, ctx: mintParser.BankGenStatContext): def exitGridDeclStat(self, ctx: mintParser.GridDeclStatContext): if self.current_device is None: - raise Exception("Error Initializing the device. Could not find the current device") + raise Exception( + "Error Initializing the device. Could not find the current device" + ) entity = self.current_entity if entity is None: @@ -218,7 +234,9 @@ def exitGridDeclStat(self, ctx: mintParser.GridDeclStatContext): def exitChannelStat(self, ctx: mintParser.ChannelStatContext): if self.current_device is None: - raise Exception("Error Initializing the device. Could not find the current device") + raise Exception( + "Error Initializing the device. Could not find the current device" + ) entity = self.current_entity if entity is None: @@ -309,7 +327,9 @@ def exitNetStat(self, ctx: mintParser.NetStatContext): def exitSpanStat(self, ctx: mintParser.SpanStatContext): if self.current_device is None: - raise Exception("Error Initializing the device. Could not find the current device") + raise Exception( + "Error Initializing the device. Could not find the current device" + ) entity = self.current_entity if entity is None: @@ -337,7 +357,9 @@ def exitSpanStat(self, ctx: mintParser.SpanStatContext): def exitNodeStat(self, ctx: mintParser.NodeStatContext): entity = "NODE" if self.current_device is None: - raise Exception("Error Initializing the device. Could not find the current device") + raise Exception( + "Error Initializing the device. Could not find the current device" + ) # Loop for each of the components that need to be created with this param if not (self._current_layer is not None and self._current_layer.ID is not None): @@ -352,7 +374,9 @@ def exitNodeStat(self, ctx: mintParser.NodeStatContext): def exitValveStat(self, ctx: mintParser.ValveStatContext): if self.current_device is None: - raise Exception("Error Initializing the device. Could not find the current device") + raise Exception( + "Error Initializing the device. Could not find the current device" + ) entity = self.current_entity if entity is None: @@ -383,14 +407,18 @@ def exitValveStat(self, ctx: mintParser.ValveStatContext): def enterViaStat(self, ctx: mintParser.ViaStatContext): if self.current_device is None: - raise Exception("Error Initializing the device. Could not find the current device") + raise Exception( + "Error Initializing the device. Could not find the current device" + ) for ufname in ctx.ufnames().ufname(): self.current_device.add_via(ufname.getText(), []) def enterTerminalStat(self, ctx: mintParser.TerminalStatContext): if self.current_device is None: - raise Exception("Error Initializing the device. Could not find the current device") + raise Exception( + "Error Initializing the device. Could not find the current device" + ) terminal_name = ctx.ufname().getText() pin_number = int(ctx.INT.getText()) diff --git a/pymint/mintwriter.py b/pymint/mintwriter.py index 1e17f3e..252b713 100644 --- a/pymint/mintwriter.py +++ b/pymint/mintwriter.py @@ -33,7 +33,9 @@ def to_component_MINT(component: Component) -> str: Returns: str: MINT string fragment """ - return "{} {} {};".format(component.entity, component.ID, to_params_MINT(component.params)) + return "{} {} {};".format( + component.entity, component.ID, to_params_MINT(component.params) + ) def to_valve_MINT(component: Component, connection: Connection) -> str: @@ -48,7 +50,9 @@ def to_valve_MINT(component: Component, connection: Connection) -> str: Returns: str: MINT string fragment """ - return "{} {} on {} {};".format(component.entity, component.ID, connection.ID, to_params_MINT(component.params)) + return "{} {} on {} {};".format( + component.entity, component.ID, connection.ID, to_params_MINT(component.params) + ) def to_connection_MINT(connection: Connection) -> str: