开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

.include vs .lib directives


 

Hello guys,
I'd like to ask how ngspice, under the hood of Kicad, actually manages library files.?
?
From ngspice manual, there are two ways to include .models or .subckt, namely using .include vs .lib directive.
?
.include <filename> literally includes the content of <filename> where the directive is located (e.g. within a .cir netlist). It works, let's say, just like the #include pre-processing directive in C language.
?
.lib instead actually includes only parts from library referenced in the file where the .lib directive is. The manual says that. lib directive has the following format: .lib <filename> libname. The latter should be the name of a "section" within the <filename> library file.
?
If the above is correct, what are the "markers" of sections within the library files ?
?
Thanks.
?


 

开云体育

Try opening a library file in a text editor (but be careful with Notepad - it sometimes plays tricks) and look through it. I think you will see plainly the section markers.

On 2025-02-26 19:22, Carlo wrote:
Hello guys,
I'd like to ask how ngspice, under the hood of Kicad, actually manages library files.?
?
From ngspice manual, there are two ways to include .models or .subckt, namely using .include vs .lib directive.
?
.include <filename> literally includes the content of <filename> where the directive is located (e.g. within a .cir netlist). It works, let's say, just like the #include pre-processing directive in C language.
?
.lib instead actually includes only parts from library referenced in the file where the .lib directive is. The manual says that. lib directive has the following format: .lib <filename> libname. The latter should be the name of a "section" within the <filename> library file.
?
If the above is correct, what are the "markers" of sections within the library files ?
?
Thanks.
?
--
OOO - Own Opinions only If something is true: * as far as we know - it's science *for certain - it's mathematics *unquestionably - it's religion

Virus-free.


 

开云体育

On 26/02/2025 20:22, Carlo wrote:
If the above is correct, what are the "markers" of sections within the library files ?
.subckt <name> 1 2 3
..
..
.ends <name>

The above.

--
Regards,
Tony


 

On Wed, Feb 26, 2025 at 01:35 PM, Tony Casey wrote:
.subckt <name> 1 2 3
..
..
.ends <name>
From ngspice-44 manual section 2.10:
The .LIB statement allows including library descriptions into the input file. Inside the *.lib
file a library libname will be selected. The statements of each library inside the *.lib file are
enclosed in .LIB libname <...> .ENDL statements.
From above I believe the "markers" are .LIB and .ENDL statements within the library file itself. I'll do a test using them within a my library.
?
Carlo.
?


 

开云体育

On 27/02/2025 08:38, Carlo wrote:
On Wed, Feb 26, 2025 at 01:35 PM, Tony Casey wrote:
.subckt <name> 1 2 3
..
..
.ends <name>
From ngspice-44 manual section 2.10:
The .LIB statement allows including library descriptions into the input file. Inside the *.lib
file a library libname will be selected. The statements of each library inside the *.lib file are
enclosed in .LIB libname <...> .ENDL statements.
From above I believe the "markers" are .LIB and .ENDL statements within the library file itself. I'll do a test using them within a my library.
That would make .subckt models non-portable between different SPICE simulators.

--
Regards,
Tony


 
Edited

On Thu, Feb 27, 2025 at 12:28 AM, Tony Casey wrote:
That would make .subckt models non-portable between different SPICE simulators.
Of course, the solution is not modify the library itself (no .LIB <libname> .ENDL within it) but use "set ngbehavior=lt" command into .spiceinit configuration file for ngspice.
?
Carlo.