~kicad/+git/ngspice-mirror-sourceforge:fix-CKTunsetup-4

Last commit made on 2017-03-18
Get this branch:
git clone -b fix-CKTunsetup-4 https://git.launchpad.net/~kicad/+git/ngspice-mirror-sourceforge
Members of KiCad can upload to this branch. Log in for directions.

Branch merges

Branch information

Name:
fix-CKTunsetup-4
Repository:
lp:~kicad/+git/ngspice-mirror-sourceforge

Recent commits

ef5f883... by rlar <rlar>

xspice/icm/analog/file_source/cfunc.mod, use CALLBACK to free and fclose

974c192... by rlar <rlar>

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.

e7333c3... by Marcel Hendrix

Fixed file_source. See the example.cir,

It exercises most parameters and supports ALTER.
Fixme, the data file is opened, but never closed!

6ee5b55... by rlar <rlar>

mifsetup.c, MIFunsetup(), #3/3 now invoke CKTdltNNum()

620a7da... by rlar <rlar>

mifsetup.c, MIFunsetup(), #2/3 copy paste from MIFsetup()

5ad2cfa... by rlar <rlar>

mifsetup.c, MIFunsetup(), #1/3 delete broken code

a0af890... by rlar <rlar>

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.

3020969... by rlar <rlar>

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.

f6668cd... by rlar <rlar>

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.

28a4780... by rlar <rlar>

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.