Skip to content

Missing parameter declarations in 'X' prefix mos device declaration #401

Open

Description

@das-dias

Spice/Parser.py:Element.init, ln 460

       number_of_positionals = prefix_data.number_of_positionals_min
       if number_of_positionals and stop_location is not None: # model is optional
            self._parameters, stop_location = self._line.read_words(stop_location, number_of_positionals)
        if prefix_data.multi_devices and stop_location is not None:
            remaining, stop_location = self._line.split_words(stop_location, until='=')
            self._parameters.extend(remaining)

Line 462 replaces the detected model positional parameter after the nodes of element 'X'.

After that, no additional positional parameters are read, and a declaration like:

XMM12<0>__4 MM12<0>__4:d MM12<0>__4:g MM12<0>__4:s MM14:b nch_18_mac L=xxx
+ W=xxx AD=xxxx AS=xxxx PD=xxxx PS=xxxx ...
+ ...
+ ...
+ spomt1=xxxx spmb=xxxx spomb=x spomb1=xxxx _ccoflag=0
+ _rcoflag=x _rgflag=x

ends up failing to be parsed.

Activity

  1. das-dias commented on Jun 11, 2025

    @das-dias
    Author

    I managed to fix some of the issues using the following changes:

            number_of_positionals = prefix_data.number_of_positionals_min
            if number_of_positionals and stop_location is not None: # model is optional
                additional, stop_location = self._line.read_words(stop_location, number_of_positionals)
                self._parameters.extend(additional)
            if prefix_data.multi_devices and stop_location is not None:
                remaining, stop_location = self._line.split_words(stop_location, until='=')
                self._parameters.extend(remaining)
            # Fix missing parameters in X mosfet device model declarations
            if prefix_data.has_variable_number_of_pins and stop_location is not None:
                remaining, stop_location = self._line.split_words(stop_location, until='\n\r')
                self._parameters.extend(remaining)

    This code prevents the model parameter from being overwritten, and also reads the remainder of the parameters for the device declaration with 'X' prefix.

    However when exporting the circuit, all positional parameters appear before nodes and model declaration, which is an issue.

    Edit 2)

    After further reading and debugging, I managed to solve the issue by not updating the positional parameters, but the optionals using the has_optionals flag of the PrefixData Class:

    self.has_variable_number_of_pins = prefix in ('Q', 'X') # NPinElement, Q has 3 to 4 pins
    self.has_optionals = prefix in ('Q', 'X')

    This way we can read out the parameters and correctly export the netlist back to a spice file with nodes and parameters in correct order.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions