Hi, can I create a symbol in XSCHEM for .*spice no...
# xschem
a
Hi, can I create a symbol in XSCHEM for .*spice not for .sch?
s
@Ahmed Reda yes you can , draw a symbol with the required input / output pins, then add the following attributes to the symbol (press 'q' key in the symbol window drawing area with nothing selected):
Copy code
type=subcircuit
spice_sym_def=".include /path/to/file.spice"
format="@name @pinlist @symname"
template="name=x1"
the
spice_sym_def
attribute tells xschem to write the corresponding line into the netlist. This will include the specified .spice file. This is a recend xschem addition, so use a recent xschem version. the produced netlist of below example will be:
Copy code
** sch_path: /home/schippes/.xschem/xschem_library/test_spice_include.sch
**.subckt test_spice_include
x2 AA BB ZZ spice_include
**.ends

* expanding   symbol:  spice_include.sym # of pins=3
** sym_path: /home/schippes/.xschem/xschem_library/spice_include.sym
.include /path/to/file.spice
.end
1.png
You can also create a symbol and an empty schematic, the schematic only contains the I/O pins, then press 'q' in the empty schematic and add the spice netlist of the subcircuit. This is a more portable solution since everything is included in the xschem files:
In this case the fllowing netlist will be produced:
Copy code
** sch_path: /home/schippes/.xschem/xschem_library/test_spice_include.sch
**.subckt test_spice_include
x2 AA BB ZZ spice_include
**.ends

* expanding   symbol:  spice_include.sym # of pins=3
** sym_path: /home/schippes/.xschem/xschem_library/spice_include.sym
** sch_path: /home/schippes/.xschem/xschem_library/spice_include.sch
.subckt spice_include A B Z
*.ipin A
*.ipin B
*.opin Z
**** begin user architecture code
m2 Z A VCCPIN VCCPIN cmosp w=wpa l=lpa ad='wpa *4.6u' as='wpa *4.6u' pd='wpa *2+9.2u' ps='wpa *2+9.2u'
+ m=1
m1 Z B VCCPIN VCCPIN cmosp w=wpb l=lpb ad='wpb *4.6u' as='wpb *4.6u' pd='wpb *2+9.2u' ps='wpb *2+9.2u'
+ m=1
m3 Z A net1 VSSPIN cmosn w=wna l=lna ad='wna *4.3u' as='wna *4.3u' pd='wna *2+8.6u' ps='wna *2+8.6u'
+ m=1
m4 net1 B VSSPIN VSSPIN cmosn w=wnb l=lnb ad='wnb *4.3u' as='wnb *4.3u' pd='wnb *2+8.6u' ps='wnb *2+8.6u'
+ m=1

**** end user architecture code
.ends

.end
a
Thanks @Stefan Schippers. I would like to double check with you the following steps. 1-add the following attributes to the symbol when pressing 'q' key in the symbol window.
type=primitive
format="@name @pinlist @symname"
template="name=X1"
2-In the test bench, I add the following attribute
.include /path/to/path/sar.spice
Those steps make the testbench works fine. are they reasonable steps? because when I used
Copy code
type=subcircuit
spice_sym_def=".include sar.spice"
format="@name @pinlist @symname"
template="name=x1"
in the symbol window ,then use it in a testbench and press neltist in the testbench window, a samll window apprears that sar.sch is required.
s
yes also using 'primitive' type and including the definition in the parent testbench is a valid option. The spice_sym_def did not work to you because your xschem version is not the most up to date.
1
a
Thanks @Stefan Schippers