StefanSchippers / xschem

A schematic editor for VLSI/Asic/Analog custom designs, netlist backends for VHDL, Spice and Verilog. The tool is focused on hierarchy and parametric designs, to maximize circuit reuse.
Other
297 stars 21 forks source link

instance value substitution in `spice_sym_def` #218

Closed rroohhh closed 10 hours ago

rroohhh commented 3 weeks ago

Hi, It seems to me that currently using instance values (like in format) is not supported in spice_sym_def. I would like to be able to do something like this in my symbol:

type=subcircuit
format="@name @@A @@B @symname"
spice_sym_def=".include @symname_@corner.txt"
template="name=x1 corner=0"

To change the spice_sym_def depending on a corner property set on a instance.

If implementing this is not desired, is there some other way to achieve this?

StefanSchippers commented 3 weeks ago

replace spice_sym_def with device_model and change symbol type from subcircuit to primitive.

type=primitive
format=...
template=...
device_model=".include @symname\\_@corner\\.txt"

note the double backslashes, they represent a single escape inside the quoted string. The first escape is needed to tell xschem the first parameter is @symname and not @symname_, the second escape tells the second parameter is @corner and not @corner.txt

inside spice_sym_def no @ substitution is done. I think I will add this feature in a next commit.

rroohhh commented 2 weeks ago

Thank you for your quick response, I finally found the time to try this and using device_model is working great. I also tested spice_sym_def together with your latest changes from fa4d4a0970fe2e46ee5c13bea034655b31196582 There I noticed the substitution is working fine for parameters specified on the instance, but I could not get @symref to get substituted. With device_model I used that in combination with tcleval to obtain pathes relativ to the symbol file location, for example like this:

type=primitive
format="@name @@GND @@DIR @@A1 @@A2 @@A3 @@A4 @@A5 @@A6 @@A7 @@A8 @@B8 @@B7 @@B6 @@B5 @@B4 @@B3 @@B2 @@B1 @@OEN 74LVC8T245_PW"
template="name=x1 corner=0 LVC8T245_A_IO=LVC8T245_IO_12 LVC8T245_B_IO=LVC8T245_IO_12 LVC8T245_IN=LVC8T245_IN_12"
device_model="tcleval(.include [set myDir [file dirname "@symref\\"]]/74LVC8T245_PW.spice
.include $myDir/74LVC8T245_PW/corner_@corner\\/models.spice
.include $myDir/74LVC8T245_PW/corner_@corner\\/LVC8T245_A_IO_@LVC8T245_A_IO\\.spice
.include $myDir/74LVC8T245_PW/corner_@corner\\/LVC8T245_B_IO_@LVC8T245_B_IO\\.spice
.include $myDir/74LVC8T245_PW/corner_@corner\\/LVC8T245_IN_@LVC8T245_IN\\.spice)"

Is there a different intended way to achieve this?

StefanSchippers commented 2 weeks ago

I made another commit to process @symref (return full path of symbol, like /a/b/c/inv.sym) as well as @symname (return only name of symbol with no .sym extension) in spice_sym_def attributes. Please test if you have a chance to do it.