Commit Graph

5201 Commits

Author SHA1 Message Date
h_vogt 1ffb957e6c inpcom.c, inp_fix_subckt_multiplier(), cleanup, using strchr() 2017-04-12 21:48:13 +02:00
rlar 2f1219811e src/spicelib/devices/*/*set.c, XXXunsetup(), reset local node variables unconditionally
and use a more robust test for local node numbers.

That is, transform this pattern :
  if (here->Node && ...) {
     CKTdltNNum(ckt, here->Node);
     here->Node = 0;
  }
into this :
  if (here->Node > 0 && ...)
     CKTdltNNum(ckt, here->Node);
  here->Node = 0;

The change of "!= 0" ==> "> 0" accounts for rare cases where "Node"
   might have been set to -1, (meaning "unconnected")
The unconditional execution of the zero assignment is for those cases
  where "Node" might have been assigned to some external or other local Node.
If so, the variable would not be set to zero, confusing the "guarding" if's
  in the corresponding XXXsetup() routine.

The Pattern to follow is:
  1) unset and delete *all* local Nodes in XXXunsetup()
  2) allocate all of them again in a re-invocation of XXXsetup(),
       exactly the same way as in the very first invocation.
2017-04-12 21:34:05 +02:00
rlar 00c743c37d src/spicelib/devices/*/*def*.h, declare external node variables const
for almost all other external nodes (notable exception "txl")
src/spicelib/devices/*/*def*.h, declare external node variables const

1) The compiler shall emit an error message if we still mess around
     with external node numbers.
2) To mark which elements of the instance struct are meant to be set
     externally when parsing the netlist

These "external" node variables are exclusively set via the
  overlay struct GENinstance, member GENnode[]

We shall not mess around with these "external" node variables
  because it would get rather difficult to avoid bugs considering
  re-invocation of the XXXsetup() routine.
This gets interesting for devices with optional ports,
  which get copied around depending on the amount of connected ports.
2017-04-12 21:34:02 +02:00
rlar 0e9576cb34 src/spicelib/devices/*/*set.c, missing CKTdltNNum() invocations, complex cases
All locally created nodes (CKTmk..() invocations in XXXsetup())
  must be deleted in XXXunsetup()

Otherwise CKTmk..() invocations during a following CKTsetup()
  will re-emit still used node numbers,
  thus accidentally shorting nodes.

This patch fixes the complex cases,
  which are external node variables (ports of the instance),
  which might be moved over to other external node variables
  to cope with optional port connections.
This is fixed by copying the node numbers to local shadow variables
  to avoid messing with the external nodes.
Otherwise a following CKTsetup() might again meddle with the external
  node variables, at least causing considerable confusion, probably causing
  hard to find bugs.
2017-04-12 21:34:00 +02:00
rlar c0921250b7 src/spicelib/devices/*/*set.c, missing CKTdltNNum() invocations, medium cases
All locally created nodes (CKTmk..() invocations in XXXsetup())
  must be deleted in XXXunsetup()

Otherwise CKTmk..() invocations during a following CKTsetup()
  will re-emit still used node numbers,
  thus accidentally shorting nodes.

This patch fixes a little bit more complex cases,
  which are local node variables which will start with value 0
  and eventually be set with the result of a CKTmk..() invocations,
  but might as well receive a node number from another node variable.
Here CKTdltNNum() must not be invoked if the node number is merely
  a copy from another node variable.
2017-04-12 21:33:59 +02:00
rlar 1fd14fa2ee src/spicelib/devices/*/*set.c, missing CKTdltNNum() invocations, simple cases
All locally created nodes (CKTmk..() invocations in XXXsetup())
  must be deleted in XXXunsetup()

Otherwise CKTmk..() invocations during a following CKTsetup()
  will re-emit still used node numbers,
  thus accidentally shorting nodes.

This patch fixes the simple cases,
  which are local node variables which will start with value 0
  and eventually be set with the result of a CKTmk..() invocation.
More complex cases evolve, if such a local variable might receive
  a node number which origins from another node, or the netlist itself.
2017-04-12 21:33:58 +02:00
rlar 0c86adf9af src/spicelib/devices/*/*set.c, XXXunsetup(), sort CKTdltNNum() invocations
Invoke CKTdltNNum() in reverse order of local node creation in XXXsetup()

This fixes a bug at least in mesa and hfet1,
  where already destroyed node variables have still been accessed
  in the guarding 'if' of a later CKTdltNNum() stanza.
Invoking them in revers order easily prevents such bugs,
  and improves readability.
2017-04-12 21:33:50 +02:00
rlar 7afb798a6f check for illegal DEVsetup() DEVunsetup() patterns.
Consider the following silent contracts:
1)
 CKTsetup() invocations must be separated by a CKTunsetup() invocation
 But CKTsetup() has an internal flag,
   which will prevent re-invocation of DEVsetup()
 But DEVsetup() will be called during sensitivity analysis,
   bypassing this precaution. It is fatal if this will
   cause another node allocation (CKTmk..()).
   This commit tries to detect such cases.
   (Note: many DEVsetup routines (all ?) have their CKTmk..() invocations
      guarded to avoid reallocation of local nodes,
      see commit f7f454c0a1
        bug fix, fix the guard for device generated internal nodes (via CKTmkVolt())
   )
   FIXME:
     DEVsetup() is seriously obfuscated by these guards.
     If would be far better, if the sensitivity analysis
       wouldn't sidestep into DEVsetup()
     consider a device local variant of the CKTisSetup flag
2)
 DEVunsetup() must delete all, each and every,
   local allocated node in DEVsetup()
 Otherwise CKTmk..() invocations in a following CKTsetup() will
   return duplicate node numbers, effectively shorting device nodes.
 This commit tries to detect incomplete CKTdltNNum() invocations.
3)
  DEVunsetup() must not delete a netlist node.
  This can easily happen in those devices which have optional ports,
    which have code in DEVsetup() which copies node numbers to
    local node variables.
  This commit tries to detect such errors.
2017-04-12 21:32:51 +02:00
h_vogt 69b235531e sharedspice.c, introduce csh variable "sharedmode"
to reflect whether running as shared library
2017-04-12 21:22:22 +02:00
h_vogt 0bf381e01d cpitf.c, for Windows, introduce csh variable "win_console"
to reflect whether this .exe is a "console" build
2017-04-12 21:11:13 +02:00
h_vogt 670880086f cpitf.c, MS Visual Studio, introduce csh variable "pg_config"
reflecting .exe compilation for
  32/64 bit
  with/without NGDEBUG
2017-04-12 21:01:57 +02:00
h_vogt d7a1899210 runcoms.c, rawfile.c, include filename in the 'ASCII/binary raw file' printout 2017-04-12 20:45:51 +02:00
rlar 926ba4baaf xspice/icm/analog/file_source/cfunc.mod, use CALLBACK
to free() locally allocated memory and fclose() a local filestream
2017-04-12 20:14:47 +02:00
rlar 58874cc65e xspice, implement "CALLBACK"
Allow to register a callback function in the cfunc.mod files,
  which will be invoked in MIFdestroy.
Usefull to "free" memory which has been allocated locally in a cfunc.mod file.
2017-04-12 20:02:35 +02:00
mhx 5f0f54761a xspice, analog/file_source, bug fix
The source code did not consider the possibility
  of more than one "tran" analysis invocations.

see "Bewildering problem with filesource block while sweeping"
https://sourceforge.net/p/ngspice/discussion/133842/thread/52949e23/
2017-04-12 20:01:14 +02:00
rlar 4872580221 mifsetup.c, MIFunsetup(), #3/3 now invoke CKTdltNNum() 2017-04-12 18:41:07 +02:00
rlar 9154f83c37 mifsetup.c, MIFunsetup(), #2/3 copy paste from MIFsetup() 2017-04-12 18:38:26 +02:00
rlar c68a0313bd mifsetup.c, MIFunsetup(), #1/3 delete broken code 2017-04-12 18:38:25 +02:00
dwarning 48262e5c0a extend safe operation area check (SOA) to polarity check for mosfets by additional parameters 2017-04-11 21:31:54 +02:00
rlar 46ab21dca9 inpcom.c, is_a_modelname(), don't accept "1E2" 2017-04-09 20:19:35 +02:00
h_vogt 847a09fd37 inpcom.c, get_number_terminals(), ignore "save" and "print" when CIDER 2017-04-09 18:33:12 +02:00
h_vogt e5d70d0821 gnuplot.c, bug fix, allow gnuplot with MINGW 2017-04-09 17:53:40 +02:00
rlar ccfcc056ad inpcom.c, bug fix, allow leading '_' in parameter identifiers 2017-04-09 15:38:15 +02:00
rlar c6896cf338 accept .para shortcut for .param 2017-04-09 15:37:46 +02:00
rlar 900bed550d string.c, #6/6, use skip_ws() and skip_back_ws() 2017-04-09 15:35:44 +02:00
rlar 0da47c644b string.c, #5/6, cleanup 2017-04-09 15:35:41 +02:00
rlar 5b23b54769 string.c, #4/6, cleanup token fetching 2017-04-09 15:35:38 +02:00
rlar c6a3438408 string.c, #3/6, cleanup 'return' 2017-04-09 15:35:35 +02:00
rlar ed13e8a15a string.c, #2/7, drop 'register' 2017-04-09 15:35:32 +02:00
rlar d48bec757c string.c, #1/6, whitespace 2017-04-09 15:35:29 +02:00
rlar fb1c6fc123 ifparm, #16/16, isrc.c, non grouped alias entry, change "c" from IP to IOPPR 2017-04-09 15:29:44 +02:00
rlar 762314b893 ifparm, #15/16, ind.c, missing IF_AC|IF_PRINCIPAL in alias entry, use IOPAPR 2017-04-09 15:29:43 +02:00
rlar d32a32bdc8 ifparm, #14/16, res.c, missing IF_ORQUERY|IF_REDUNDANT, introduce IOPQOR 2017-04-09 15:29:42 +02:00
rlar cefb65507f ifparm, #13/16, res.c, missing IF_SETQUERY in an alias entry, introduce IOPQR 2017-04-09 15:29:41 +02:00
rlar 8d3acddc7b ifparm, #12/16, res.c, missing IF_PRINCIPAL in an alias entry, introduce IOPPR 2017-04-09 15:29:40 +02:00
rlar 614eebe944 ifparm, #11/16, res.c, missing IF_CHKQUERY for some alias entries, introduce IOPZR 2017-04-09 15:29:40 +02:00
rlar ff00855397 ifparm, #10/16, jfet2.c, missing IF_REDUNDANT for some aliases, introduce PARAMR 2017-04-09 15:29:39 +02:00
rlar cee466b35e ifparm, #9/16, mes.c, "m" is an alias of "area", use IOPUR 2017-04-09 15:29:38 +02:00
rlar f0e2b43940 ifparm, #8/16, excess IF_REDUNDANT for some aliases, use IOP 2017-04-09 15:29:37 +02:00
rlar 102a6b7c77 ifparm, #7/16, missing IF_UNINTERESTING for some aliases, introduce IOPUR 2017-04-09 15:29:36 +02:00
rlar 4fc33eb656 ifparm, #6/16, missing IF_NONSENSE for some aliases, introduce IOPXR 2017-04-09 15:29:35 +02:00
rlar b56c2a2504 ifparm, #5/16, missing IF_AC for some aliases, introduce IOPAR 2017-04-09 15:29:34 +02:00
rlar eac26d741c ifparm, #4/16, missing IF_REDUNDANT for some aliases, introduce IOPAPR 2017-04-09 15:29:33 +02:00
rlar 445860f79a ifparm, #3/16, missing IF_REDUNDANT for some aliases, use IOPR 2017-04-09 15:29:32 +02:00
dwarning 115b52a899 ifparm, #2/16, missing IF_REDUNDANT, duplicates and descriptions 2017-04-09 15:29:30 +02:00
dwarning e0fcdc7457 ifparm, #1/16, missing IF_REDUNDANT for vth0/vtho in bsim models 2017-04-09 15:23:15 +02:00
rlar 1e6b809af8 introduce command "check_ifparm" to check consistency of the device IFparm sets
For developing purpose only, and bound to HAVE_TSEARCH, HAVE_TDESTROY

IFparm descriptors must obey certain contracts,
  1) aliases must be grouped together with their associated main descriptor,
       and all must have flag IF_REDUNDANT set
  2) there shall be no duplicated .id fields except for aliases.
  3) aliased entries shall have consistent .dataType fields

check_ifparm will traverse all IFparm sets and report violations
2017-04-09 14:40:51 +02:00
h_vogt cf9dbff890 inpcom.c, cleanup, use strchr() 2017-04-09 14:14:45 +02:00
rlar 2df8f433f8 inp.c, inp_parse_temper(), rewrite, using search_idenifier and find_assignment
try to make it more robust with regard to
  '!=' '<=' '=='         don't misinterpret as '='
  "atemperaticvariable"  don't misinterpret as 'temper'
  multiple temper in one expression
2017-04-09 14:14:36 +02:00
rlar 511389ad10 inpcom.c, introduce find_back_assignment() 2017-04-09 14:14:06 +02:00