diff --git a/pymint/mintcompiler.py b/pymint/mintcompiler.py index f6cf143..73297be 100644 --- a/pymint/mintcompiler.py +++ b/pymint/mintcompiler.py @@ -7,6 +7,7 @@ from pymint.antlrgen.mintParser import mintParser from pymint.mintdevice import MINTDevice from pymint.mintlayer import MINTLayerType +from parchmint.device import ValveType class MINTCompiler(mintListener): @@ -33,9 +34,7 @@ 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") @@ -47,9 +46,7 @@ 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), @@ -62,9 +59,7 @@ 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), @@ -78,9 +73,7 @@ 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), @@ -141,9 +134,7 @@ 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: @@ -153,9 +144,7 @@ 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(), @@ -200,9 +189,7 @@ 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] @@ -210,9 +197,7 @@ 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: @@ -233,9 +218,7 @@ 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: @@ -326,9 +309,7 @@ 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: @@ -356,9 +337,7 @@ 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): @@ -373,9 +352,7 @@ 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: @@ -384,12 +361,8 @@ def exitValveStat(self, ctx: mintParser.ValveStatContext): valve_name = ctx.ufname()[0].getText() # type: ignore if not (self._current_layer is not None and self._current_layer.ID is not None): raise AssertionError - valve_component = self.current_device.create_mint_component( - valve_name, - entity, - self.current_params, - [self._current_layer.ID], - ) + + # Get the connection information connection_name = ctx.ufname()[1].getText() # type: ignore valve_connection = self.current_device.device.get_connection(connection_name) if valve_connection is None: @@ -399,22 +372,25 @@ def exitValveStat(self, ctx: mintParser.ValveStatContext): ) ) - self.current_device.device.map_valve(valve_component, valve_connection) + self.current_device.create_valve( + name=valve_name, + technology=entity, + params=self.current_params, + layer_ids=[self._current_layer.ID], + connection=valve_connection, + valve_type=ValveType.NORMALLY_OPEN, + ) 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/pyproject.toml b/pyproject.toml index bf5a18b..e4db87a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,3 +43,9 @@ docs = ["sphinx"] [build-system] requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" + +[tool.pytest.ini_options] +minversion = "6.0" +testpaths = [ + "./tests/" +] \ No newline at end of file