Created Use an existing spice text file for a subcircuit (markdown)

StefanSchippers 2024-01-08 16:16:36 +01:00
parent 987e83eaaf
commit c317fdd025
1 changed files with 51 additions and 0 deletions

@ -0,0 +1,51 @@
If you have for example the following definition in a file, say `symbol_include.cir`:
```
* example of a subcircuit contained in a file
.subckt symbol_include Z VCC VSS
+ A B C W=10 L=1
...
...
.ends
```
You can use this file to get the spice netlist port order:
In the following testbench:
![1](https://github.com/StefanSchippers/xschem/assets/69359491/17ef7c28-9167-4507-8898-26e01dbe989a)
the symbol is defined as follows:
![2](https://github.com/StefanSchippers/xschem/assets/69359491/db2f6c2b-3a4f-4a1b-bb76-861d13c6b964)
When netlisting the testbench the port order (the @pinlist in the `format` string)
of the `x1` instance call will match the order in the file `symbol_include.cir`:
```
** sch_path: /home/schippes/.xschem/xschem_library/symbol_include/tb_symbol_include.sch
**.subckt tb_symbol_include XZ XVSS XVCC XC XB XA
*.opin XZ
*.ipin XVSS
*.ipin XVCC
*.ipin XC
*.ipin XB
*.ipin XA
x1 XZ XVCC XVSS XA XB XC symbol_include
**.ends
* expanding symbol: symbol_include.sym # of pins=6
** sym_path: /home/schippes/.xschem/xschem_library/symbol_include/symbol_include.sym
.include symbol_include.cir
.end
```
A final note, the `spice_sym_def` does not necessarily need to use a .include line. You can directly define the subcircuit:
```
spice_sym_def="
.subckt symbol_include Z VCC VSS
+ A B C
...
...
.ends
"
```