I built libngspice-kicad with ngSpice 30 (latest stable version)


#1

I noticed that the old version of ngSpice is being used with the kicad_5.0.2 package from the repository (that does not support VDMOS models).

So, I made a new version of the package libngspice-kicad with ngSpice 30. I used the original source package and just replaced the source code of ngSpice, incremented the version numbers and added new entry in the changelog.

libngspice-kicad_0.2-30_amd64.deb (1.9 MB)
libngspice-kicad_0.2-30_amd64.deb.sha512sum (166 Bytes)

I also built again the kicad_5.0.2 package. The kicad_5.0.2 from the repository is working with the new library, however I am not sure if it’s correct to use it with the newer ngspice library.

Download from Google Drive (download all at once link):

Packages are built on Ubuntu 16.04.5 LTS.

First, I built and installed the new version of the ngspice library (version 30):

$ sudo dpkg -i libngspice-kicad_0.2-30_amd64.deb 
$ sudo dpkg -i libngspice-kicad-doc_0.2-30_amd64.deb 

Then, I installed most of the packages from the repository (except kicad - note the sign “-” after the “kicad”):

$ sudo apt-get install kicad-doc-en kicad-footprints kicad-packages3d kicad-symbols kicad-templates kicad-

Then, I built and installed my version of the kicad.

$ sudo dpkg -i kicad_5.0.2-stable-201811280958+bee76a0~70~ubuntu16.04.1_amd64.deb

Here is the list of installed “kicad” packages on my system:

valentin@computer:~$ apt list --installed | grep kicad

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

kicad/xenial,now 5.0.2-stable-201811280958+bee76a0~70~ubuntu16.04.1 amd64 [installed]
kicad-doc-en/xenial,xenial,now 5.0.2-stable-201812071423+1518~17~ubuntu16.04.1 all [installed]
kicad-footprints/xenial,xenial,now 5.0.2-stable-201812071423+5bf695a~9~ubuntu16.04.1 all [installed]
kicad-packages3d/xenial,xenial,now 5.0.2-stable-201812071618+c24f4c5~7~ubuntu16.04.1 all [installed]
kicad-symbols/xenial,xenial,now 5.0.2-stable-201812071435+84cd7f9~6~ubuntu16.04.1 all [installed]
kicad-templates/xenial,xenial,now 5.0.2-stable-201812071430+31b13f2~8~ubuntu16.04.1 all [installed]
libngspice-kicad/now 0.2-30 amd64 [installed,local]
libngspice-kicad-doc/now 0.2-30 amd64 [installed,local]
valentin@computer:~$ 

I did not rebuilt all the packages, because I think there is no need to do it.

I did not installed kicad-dbg_5.0.2 and kicad-demo_5.0.2, because they are not critical.

Checksums:

ba4752f70ee89e85ec7adbab8bb7d1542c90bdff7b60720ca66a8a491f8e4f7174ccc1795d971a22f807ef903af532fb843edb65080ec9c76250b1d796b42026  ./libngspice-kicad_0.2-30_amd64.deb
feb484a5348732bb48ee49e9ed133601bb0316d64757ecf44d19e48c677a332a31b01849bc548f781292db1f15f407a782ba7b7638dd2c570d84f7eb305642db  ./libngspice-kicad-doc_0.2-30_amd64.deb
bb3dce4860e7633b0bc6dc11fd6b8ce9a028935bef2ed2ec9862e2775c0036340bf3d45895be35c5c889a8f677c13f38567f7cdbc725bda4650d8aa2b6d45ce8  ./kicad_5.0.2-stable-201811280958+bee76a0~70~ubuntu16.04.1_amd64.deb
aa0a2ee8e7b6ba029dbbe7359c4cd7826b78959a95d241534af5abe1f7c35650c8ad3ffc4198af21b5b50d2acccdf2e1310fd66e4c91b5229894a2034f985925  ./kicad-dbg_5.0.2-stable-201811280958+bee76a0~70~ubuntu16.04.1_amd64.deb
cc567cae7619cd741aa38c4f89fbc5569d0a51e02e2f97c5df9d0dfc1c79d4506aa0d007fa3233cf6e13b770eb24ef5c73648224a6d54222e587c7c2d5d9eef9  ./kicad-demo_5.0.2-stable-201811280958+bee76a0~70~ubuntu16.04.1_all.deb

I tested it and it works with some subcircuits. But with other subcircuits KiCad crashes (segmentation fault).

Example of subcircuit that induces crash:

.SUBCKT Transistor 1 2 3

M5 1 2 3 Si4842DY

.model Si4842DY VDMOS(Rg=3 Rd=2.4m Rs=1.8m Vto=2 Kp=98 Cgdmax=1n Cgdmin=.13n Cgs=1.7n Cjo=.5n Is=50p Rb=3m mfg=Siliconix Vds=30 Ron=6m Qg=25n)

.ENDS Transistor

Example of subcircuit that does not induce crash (but is wrong and the program return error message):

.SUBCKT Transistor 1 2 3

V5 1 2 3 Si4842DY

.model Si4842DY VDMOS(Rg=3 Rd=2.4m Rs=1.8m Vto=2 Kp=98 Cgdmax=1n Cgdmin=.13n Cgs=1.7n Cjo=.5n Is=50p Rb=3m mfg=Siliconix Vds=30 Ron=6m Qg=25n)

.ENDS Transistor

The error message is:

Error on line 0 :
v.xm1.v5 vds vgs 3 3 si4842dy
unknown parameter (3) 

Archive of the project (if you want to test it).

When I use transistors defined as MOSFET (without subcircuit) it works. For example:

.model Si4842DY VDMOS(Rg=3 Rd=2.4m Rs=1.8m Vto=2 Kp=98 Cgdmax=1n Cgdmin=.13n Cgs=1.7n Cjo=.5n Is=50p Rb=3m mfg=Siliconix Vds=30 Ron=6m Qg=25n)


#2

Crashing with a VMOS subcircuit is a bug in ngspice. We have to find a fix.


#3

I noticed that the crash is happening if the VDMOS model is definded inside a subcircuit.

For example, when I define it like this it works and does not crash:

.model Si4842DY VDMOS(Rg=3 Rd=2.4m Rs=1.8m Vto=2 Kp=98 Cgdmax=1n Cgdmin=.13n Cgs=1.7n Cjo=.5n Is=50p Rb=3m mfg=Siliconix Vds=30 Ron=6m Qg=25n)

.SUBCKT MyTransistor 1 2 3

M5 1 2 3 Si4842DY

.ENDS MyTransistor

When I move the model inside like this it crashes:

.SUBCKT MyTransistor 1 2 3

.model Si4842DY VDMOS(Rg=3 Rd=2.4m Rs=1.8m Vto=2 Kp=98 Cgdmax=1n Cgdmin=.13n Cgs=1.7n Cjo=.5n Is=50p Rb=3m mfg=Siliconix Vds=30 Ron=6m Qg=25n)

M5 1 2 3 Si4842DY

.ENDS MyTransistor

This way it also crashes:

.SUBCKT MyTransistor 1 2 3

M5 1 2 3 Si4842DY

.model Si4842DY VDMOS(Rg=3 Rd=2.4m Rs=1.8m Vto=2 Kp=98 Cgdmax=1n Cgdmin=.13n Cgs=1.7n Cjo=.5n Is=50p Rb=3m mfg=Siliconix Vds=30 Ron=6m Qg=25n)

.ENDS MyTransistor

It also crashes when I try to use this model as “M” (mosfet):

.model Si4842DY NMOS(Rg=3 Rd=2.4m Rs=1.8m Vto=2 Kp=98 Cgdmax=1n Cgdmin=.13n Cgs=1.7n Cjo=.5n Is=50p Rb=3m Vds=30 Ron=6m Qg=25n)

With this model KiCad crashes:

*SRC=2N7002;2N7002;MOSFETs N;Enh;60.0V 0.115A 7.50ohms  Diodes Inc. -
.MODEL 2N7002  NMOS( LEVEL=1 VTO=2.50 KP=32.0m  GAMMA=3.10
+ PHI=.75  LAMBDA=39.9u RD=1.05 RS=1.05
+ IS=57.5f  PB=0.800 MJ=0.460 CBD=98.8p 
+ CBS=119p  CGSO=60.0n CGDO=50.0n CGBO=390n  )

With this model works:

.model 2N7002 VDMOS(Rg=3 Vto=1.6 Rd=0 Rs=.75 Rb=.14 Kp=.17 mtriode=1.25 Cgdmax=80p Cgdmin=12p Cgs=50p Cjo=50p Is=.04p mfg=Fairchild Vds=60 Ron=2 Qg=1.5n)


#4

Many thanks for your detailed analysis. We will have a look at ngspice.

The model 2N7002 NMOS … does not work because an NMOS Level1 requires four terminals drain, gate, source, and bulk. Your instance line

M5 1 2 3 Si4842DY

or maybe

M5 1 2 3 2N7002

does have only three terminals.

In addition an NMOS model will not accept most of the VDMOS model parameters. It is made for integrated MOS transistors on an IC (and some 4-terminal discretes).


Simulate LM358 Spice model import
#5

It crashes when I use this model only when I use 3 pin symbol (Device:Q_NMOS_DGS). When I use the 4 pin symbol it works like I expect it.

*SRC=2N7002;2N7002;MOSFETs N;Enh;60.0V 0.115A 7.50ohms  Diodes Inc. -
.MODEL 2N7002  NMOS( LEVEL=1 VTO=2.50 KP=32.0m  GAMMA=3.10
+ PHI=.75  LAMBDA=39.9u RD=1.05 RS=1.05
+ IS=57.5f  PB=0.800 MJ=0.460 CBD=98.8p 
+ CBS=119p  CGSO=60.0n CGDO=50.0n CGBO=390n  )

When it crashes I read this in the console:

valentin@computer:~$ LD_LIBRARY_PATH=/tmp/pkg/usr/lib kicad
kicad: ../../../../src/maths/sparse/spbuild.c:270: spGetElement: Assertion `IS_SPARSE( Matrix ) && Row >= 0 && Col >= 0' failed.
Aborted (core dumped)
valentin@computer:~$ 

I removed the libngspice-kicad package and built again the ngspice with changed PACKAGE_NAME (to make the libngspice-kicad compatible with the ngspice Ubuntu package).

I did not noticed any change in behaviour when I removed the directory usr/lib/libngspiceforkicad (previously called usr/lib/ngspice).

Do you think that the files in this directory should be included in the libngspice-kicad package?

Also, the newest version of ngspice (when built with configure --with-ngshared ) is making a binary called cmpp. Is this file should be included in the libngspice-kicad package?

The same file is provided by the ngspice package, so if I include it to the libngspice-kicad this would make the packages incompatible (conflicting) with each other.

valentin@computer:/var/cache/apt/archives$ dpkg-deb -c ngspice_26-1build1_amd64.deb | grep cmpp
-rwxr-xr-x root/root     84368 2016-02-07 13:08 ./usr/bin/cmpp
-rw-r--r-- root/root       828 2016-02-07 13:08 ./usr/share/man/man1/cmpp.1.gz
valentin@computer:/var/cache/apt/archives$ 

I noticed that it does not crash when the .model inside the .SUBCKT is NMOS transistor:

.SUBCKT MyTransistor 1 2 3

*SRC=2N7002;2N7002;MOSFETs N;Enh;60.0V 0.115A 7.50ohms  Diodes Inc. -
.MODEL 2N7002  NMOS( LEVEL=1 VTO=2.50 KP=32.0m  GAMMA=3.10
+ PHI=.75  LAMBDA=39.9u RD=1.05 RS=1.05
+ IS=57.5f  PB=0.800 MJ=0.460 CBD=98.8p 
+ CBS=119p  CGSO=60.0n CGDO=50.0n CGBO=390n  )

M5 1 2 3 3 2N7002

.ENDS MyTransistor

But it crashes if I miss the forth terminal of the NMOS transistor (M5 1 2 3 2N7002 instead of M5 1 2 3 3 2N7002).


#6

Programs like LTspice have custom code, where if it detects a netlist line with a prefix of M (for MOSFET) and it counts 3 terminals, it will copy the 3rd node to the 4th node. The result is that all 3-terminal MOSFETs get automatically converted to 4-terminal in the netlist. This is true regardless of the type of MOSFET model (NMOS, VDMOS, etc.). However, if you use a subcircuit, the prefix is now an X and this special handling doesn’t happen anymore. It’s then up to the subcircuit author to handle connection of the 4th terminal, just like how you did in the last example. A similar thing in LTspice happens with Q devices (BJTs), where the 4th terminal (substrate node) automatically gets connected to node zero (global ground) whenever a 3-terminal BJT is detected.

It appears KiCad does not include special handling like these when generating the netlist. Is that something that should be requested as a feature to prevent issues like these? One alternative to adding automatic detection like this is the ability to allow the “Alternate Node Sequence” feature to allow for more terminals than what the symbol supports. For example, if you had a 3-terminal symbol with 1=G, 2=S, and 3=D, then you could punch in an alternate sequence of 3,1,2,2 to copy the source node into the body node. The downside is the user would still need to be aware that this needs to be done for proper operation.


#7

The bug in ngspice has already been identified. We need to do more tests before the patch will be uploaded to the ngspice pre-master branch.

We will add a fourth terminal to the VDMOS model that is a thermal node, to simulate the temperature behavior of the device, including external heat sinks.


#8

I just tested it and it works just like you described it.

It works when I enter “Alternate Node Sequence” 1 2 3 3 and crashes if I don’t.


#9

I understand. My suggestion was to have it fixed in the netlist generation (KiCad) instead of (or in addition to) the netlist interpretation (ngspice). This is in case someone wants to export the netlist into another SPICE or simulation program. Whatever, just throwing the idea out there.


#10

Huh? I guess I screwed up earlier. I was having troubling getting the 4th terminal to copy like that. I assumed it wouldn’t let me use more terminals than the symbol itself has. I must’ve screwed something up, because it definitely works when I try it again, just like it works for you above. OK, well that’s a decent workaround that can be used in the meantime.


#11

I made a new package of the ngSpice library used by KiCad (libngspice-kicad_0.2-30.2_amd64.deb).

I used the latest source code “ngspice-30-2” from here. The recent bug fixes (discussed in this thread) are not included - I don’t know in which fork are included.

Made some changes to include the .cm files and make it not conflicting with the original ngspice package.

Also, I built again the kicad package (kicad_5.0.2-stable-201811280958+bee76a0~70~ubuntu16.04.1_amd64.deb) to make sure it will work with the new library. The filename is the same as the old one.

In the new libngspice-kicad package the files with extension .cm are located in /usr/lib/x86_64-linux-gnu/ngspice-kicad/ngspice/. The cmpp binary is moved to /usr/share/ngspice-kicad/ngspice/bin (to make possible installation of the original ngspice package without conflict). The man page is located in /usr/share/ngspice-kicad/ngspice/man/man1/

Download all files from Google Drive.

List of the files:

$ dpkg-query -L libngspice-kicad 
/.
/usr
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/ngspice-kicad
/usr/lib/x86_64-linux-gnu/ngspice-kicad/ngspice
/usr/lib/x86_64-linux-gnu/ngspice-kicad/ngspice/spice2poly.cm
/usr/lib/x86_64-linux-gnu/ngspice-kicad/ngspice/xtradev.cm
/usr/lib/x86_64-linux-gnu/ngspice-kicad/ngspice/table.cm
/usr/lib/x86_64-linux-gnu/ngspice-kicad/ngspice/analog.cm
/usr/lib/x86_64-linux-gnu/ngspice-kicad/ngspice/digital.cm
/usr/lib/x86_64-linux-gnu/ngspice-kicad/ngspice/xtraevt.cm
/usr/lib/x86_64-linux-gnu/libngspice.so.0.0.0
/usr/lib/x86_64-linux-gnu/libngspice.la
/usr/share
/usr/share/doc
/usr/share/doc/libngspice-kicad
/usr/share/doc/libngspice-kicad/copyright
/usr/share/doc/libngspice-kicad/README.tcl.gz
/usr/share/doc/libngspice-kicad/changelog.Debian.gz
/usr/share/doc/libngspice-kicad/README.adms
/usr/share/ngspice-kicad
/usr/share/ngspice-kicad/ngspice
/usr/share/ngspice-kicad/ngspice/include
/usr/share/ngspice-kicad/ngspice/include/ngspice
/usr/share/ngspice-kicad/ngspice/include/ngspice/sen2defs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/tfdefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/bool.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/matldefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/dstring.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/wstdio.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/carddefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/ipcproto.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/trandefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/fftext.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/memory.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/cmproto.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/outpdefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/noisedef.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/mifproto.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/multi_line.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/cmtypes.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/ipctiein.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/dopdefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/tskdefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/graph.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/dvec.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/devdefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/numglobs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/fteinput.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/FastNorm3.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/stringskip.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/onedev.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/profile.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/enhtypes.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/swec.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/const.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/compatmode.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/miftypes.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/cidersupt.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/mif.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/ftedev.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/trcvdefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/pnode.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/sensgen.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/1-f-code.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/evtudn.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/numgen.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/meshdefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/methdefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/randnumb.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/missing_math.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/wallace.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/fteext.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/fteinp.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/enh.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/numenum.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/jobdefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/cmconstants.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/sim.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/opdefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/tclspice.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/acdefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/inpmacs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/inpdefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/spmatrix.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/defines.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/stringutil.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/evtshared.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/iferrmsg.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/onemesh.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/domndefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/sharedspice.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/mifcmdat.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/plot.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/macros.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/ngspice.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/optdefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/typedefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/cktdefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/material.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/gendefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/pzdefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/hash.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/evttypes.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/complex.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/mobdefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/inpptree.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/numcards.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/elctdefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/suffix.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/meshext.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/ciderinp.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/mifdefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/config.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/cm.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/ftedebug.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/ftedefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/cluster.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/twomesh.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/evtproto.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/wordlist.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/optndefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/bdrydefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/dllitf.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/smpdefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/sensdefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/cpdefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/cpstd.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/gendev.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/dgen.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/grid.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/contdefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/twodev.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/mifparse.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/numconst.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/ipc.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/hlpdefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/fteparse.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/modldefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/distodef.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/cpextern.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/ftedbgra.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/lsort.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/evt.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/fteoptdefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/ifsim.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/pssdefs.h
/usr/share/ngspice-kicad/ngspice/include/ngspice/sperror.h
/usr/share/ngspice-kicad/ngspice/man
/usr/share/ngspice-kicad/ngspice/man/man1
/usr/share/ngspice-kicad/ngspice/man/man1/cmpp.1
/usr/share/ngspice-kicad/ngspice/dlmain.c
/usr/share/ngspice-kicad/ngspice/scripts
/usr/share/ngspice-kicad/ngspice/scripts/setplot
/usr/share/ngspice-kicad/ngspice/scripts/spinit
/usr/share/ngspice-kicad/ngspice/scripts/devaxis
/usr/share/ngspice-kicad/ngspice/scripts/devload
/usr/share/ngspice-kicad/ngspice/scripts/spectrum
/usr/share/ngspice-kicad/ngspice/scripts/ciderinit
/usr/share/ngspice-kicad/ngspice/bin
/usr/share/ngspice-kicad/ngspice/bin/cmpp
/usr/lib/x86_64-linux-gnu/libngspice.so
/usr/lib/x86_64-linux-gnu/libngspice.so.0

Modified files from the “debian” directory in the source:

debian/libngspice-kicad.install

usr/lib/*/ngspice-kicad/libngspice* /usr/lib/x86_64-linux-gnu
usr/lib/*/ngspice-kicad/ngspice/*
usr/share/ngspice-kicad/ngspice/*
usr/bin/cmpp usr/share/ngspice-kicad/ngspice/bin
usr/share/man/man1/cmpp.1 usr/share/ngspice-kicad/ngspice/man/man1

debian/changelog

(Added new version number and description).

debian/rules (the line with “dh_auto_configure” is changed)

#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# This has to be exported to make some magic below work.
export DH_OPTIONS
PKG=ngspice

%:
    dh $@ --sourcedirectory=${PKG} --parallel  --with autotools-dev


override_dh_auto_configure:#
    (cd ngspice; ./autogen.sh)
    dh_auto_configure $@ -- --libdir=/usr/lib/x86_64-linux-gnu/ngspice-kicad --datarootdir=/usr/share/ngspice-kicad --includedir=/usr/share/ngspice-kicad/ngspice/include --with-ngshared --enable-xspice --enable-cider --enable-openmp --with-tcl=/usr/lib

override_dh_auto_test:
#Nop

If you had installed KiCad from the repository ( ppa:js-reynaud/kicad-5) you can remove the kicad and libngspice-kicad packages without removing the dependencies:

$ sudo dpkg -r --force-depends  kicad
$ sudo dpkg -r --force-depends  libngspice-kicad

And install the packages I built (from the current directory):

$ sudo dpkg -i libngspice-kicad_0.2-30.2_amd64.deb
$ sudo dpkg -i  kicad_5.0.2-stable-201811280958+bee76a0~70~ubuntu16.04.1_amd64.deb

I did not tested what will happen if you try to install the new packages before removing the old ones, probably it will work.

My system is:

$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="16.04.5 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.5 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial