ModelicaStandardLibrary icon indicating copy to clipboard operation
ModelicaStandardLibrary copied to clipboard

Use of parameter without value in Spice3.Internal.MOS2

Open perost opened this issue 6 months ago • 5 comments

Modelica.Electrical.Spice3.Internal.MOS2 contains these parameter declarations:

final parameter Spice3.Internal.Mos2.Mos2ModelLineParams p=
      Spice3.Internal.Mos2.mos2RenameParametersRevised(modelcard) annotation(Evaluate=true);

final parameter Spice3.Internal.Mos2.Mos2ModelLineParams p1=
      Spice3.Internal.Mos2.mos2ModelLineParamsInitEquationsRevised(p, m_type);

p is initialized by a call to mos2RenameParametersRevised, which does not assign a value to p.m_bulkCapFactorIsGiven (nor does that parameter have a start value). p is then used as argument to mos2ModelLineParamsInitEquationsRevised, which at the end of the function has an if-statement using m_bulkCapFactorIsGiven in the condition.

Unless I'm missing something this looks like p.m_bulkCapFactorIsGiven will always be used uninitialized in this model. This model is only used by Spice3.Semiconductors.M_NMOS2 and Spice3.Semiconductors.M_PMOS2, neither of which seems to be part of any example models (or anything else).

perost avatar Jun 23 '25 13:06 perost

One possibility is that:

  • m_bulkCapFactorIsGiven should have a start-value of 0 similarly as m_bulkCapFactor;
  • mos2RenameParametersRevised should use similar logic for it as preceding declarations (as in mos1RenameParameters)

However, CJ has a default of zero - whereas CBS has a default of -1e40.

HansOlsson avatar Jun 23 '25 14:06 HansOlsson

How should I fix the problem in the gui? From the discussion I can't follow.

Apologies to not to follow

kmerbcn avatar Jun 23 '25 14:06 kmerbcn

@kmerbcn the problem is not with the GUI, it is with the component model in the Modelica Standard Library. We need to fix that upstream.

Apparently, the diode model can potentially consider a bulk capacitance factor or not. Do you know how this is handled in the original Spice model?

casella avatar Jun 24 '25 13:06 casella

It is a voltage depending formula relating other spice parameters.

kmerbcn avatar Jun 24 '25 18:06 kmerbcn

Hello Francesco

Is this the right place to contribute for the standard modelica library?

kmerbcn avatar Jun 24 '25 19:06 kmerbcn