It looks like you're new here. If you want to get involved, click one of these buttons!
I'm new here so first: thanks for KLayout!
I've been using a work flow that's essentially:
The annoying thing is that it can't be automatic because the extracted parameters to the top level LVS extracted subcircuit periodically changes which means I have to hand edit (or check) the instantiation each time rather than just running ngspice.
So my suggestion is that klayout sort the ports of subcircuits alphabetically - either every extracted sub circuit, or just top level one (that is not referenced by other subcircuits in the output file).
Alternately you could keep the parameter order from the spice deck you were running LVS against (that would make it easier to switch backwards and forwards between extracted spice and reference designs) - this is probably more complex to implement, alphabetically would be OK
Comments
You mean parameters or ports?
Ports are not necessarily named in the extracted netlist - if you name the nets by labels, that can be done, but if the nets are not named the nets are numbered arbitrarily and ports can change order. There is no way to ensure a specific port order in the general case. LVS is port order agnostic and that is what the extracted netlist is made for.
The right way to think that is back annotation. The LVS will give you the correspondence between extracted netlist and schematic netlist through the cross reference information. So it is basically possible to create a netlist that is identical to schematic in most respects, but there is a caveat: the hierarchy may be different - i.e. some circuits may be flat in the extracted netlist, so the correspondence can only be established between circuits that are present and matched in both netlists.
If it is just about top level circuit pins, it's easier, because if you use "make_top_level_pins", it will only create pins from named nets.
You can monkey-patch the Netlist class to provide an alternative "make_top_level_pins" which sorts by name. Put this into your LVS script somewhere at the beginning:
In your LVS deck, use this method then to generate top level pins sorted by net names:
You can use this call instead of "make_top_level_pins".
Note: puts this method call before "compare" - otherwise your cross references will be wrong.
Matthias