Tim Edwards
06/23/2024, 4:33 PMsky130_ef_ip__analog_switches
which is a library of analog switches. It is all self-contained, so it has an "xschem" directory, and all the schematics in that directory include components from the same directory.
If I want to use those switches in another project, then I create a directory called "dependencies" in that project, and under "dependencies" I clone the sky130_ef_ip__analog_switches
repository. Then I can include a switch symbol by navigating to the repository and choosing a switch symbol. However, that symbol is linked to a schematic, and that schematic may refer to other symbols in the same directory. If so, then xschem cannot find those symbols. But it can find the schematic linked to the symbol, so it seems to understand that a schematic should be in the same location as its corresponding symbol, but doesn't understand that symbols instanced in the schematic might also come from the same directory as the schematic.
It appears that xschem has some built-in concept of "cwd" because if I don't put the current directory into the XSCHEM_LIBRARY_PATH (either as an absolute path from root or as .
), then xschem will still find symbols in the directory where I start up. It doesn't seem like too much of a stretch to ask that the built-in concept of "cwd" should change to the directory where a schematic is being read, so that local files referenced by that schematic will be discovered automatically.
Hopefully I explained that in an understandable way. . .tnt
06/23/2024, 4:40 PMcurdirname
which is the directory name of the current schematic, but it's sometimes buggy when generating the spice netlist because it messes with curdirname
. But yeah, I'd love some way to have symbol references relative to the path of the schematic they are being referenced from.Luke Harold Miles
06/23/2024, 5:51 PMLuke Harold Miles
06/23/2024, 5:52 PMtnt
06/23/2024, 6:05 PMLuis Henrique Rodovalho
06/23/2024, 6:11 PMStefan Schippers
06/26/2024, 6:40 AMlast_loaded_symbol
β¦ load corresponding schematic (searching in the full list of paths if search_schematic
xschemrc boolean variable is set or looking up the symbol schematic
attribute if set or looking in the same directory of the symbol)
β¦ generate netlist of schematic
β’ end for
note that as new schematics are loaded new symbols might be loaded, appended to the list and last_loaded_symbol
will be incremented.Stefan Schippers
06/26/2024, 6:51 AMschematic
attribute in symbols can be used to change the schematic to be used, and this schematic
can also be set at instance level to have different schematics used for the symbol in different instantiations. Since all files in xschem are ASCII text files it is trivially easy to change these attributes in the whole project with simple scripts like awk / sed.
https://xschem.sourceforge.io/stefan/xschem_man/tutorial_xschem_libraries.htmlLeo Moser
06/27/2024, 9:34 AMproject
βββ testbench.sch
βββ schematic.sch
βββ schematic.sym
When I start xschem and place schematic
inside testbench
, the absolute path to schematic.sym
is written to the file.
This is not great as it is not portable, and most users are not even aware of this. Many of the Chipalooza submissions had absolute paths in their schematics.
To be portable one would need to add project
to the XSCHEM_LIBRARY_PATH
. Then schematic
inside testbench
would refer to schematic.sym
and not to the absolute path.
This is also not perfect because you have to set XSCHEM_LIBRARY_PATH
every time you want to edit a schematic. You can create a Makefile that does that for you, but then you are less flexible when creating new schematics. If you forget to set XSCHEM_LIBRARY_PATH
when invoking xschem and then place some symbols, there would be absolute paths again. What is the correct solution here? Adding an xschemrc to project
with the content append XSCHEM_LIBRARY_PATH :[file dirname [info script]]
? This should always append project
to XSCHEM_LIBRARY_PATH
, no matter from where it is sourced, right? This would solve the issue, but if your project has subfolders, you can only ever start xschem from project
, otherwise the paths would not be correct. Maybe that's just the price one has to pay?
This should also work well with standalone IPs: you just need to source the xschemrc of the IP to add it to the XSCHEM_LIBRARY_PATH
.
I think the current handling of files in the same directory is not optimal. It helps users to get started designing their circuits without setting XSCHEM_LIBRARY_PATH
, but in its current implementation it's more trouble than it's worth, I think π€οΈ
I appreciate your feedback and thank you so much for your work on xschem ποΈ
LeoStefan Schippers
06/27/2024, 6:23 PMappend XSCHEM_LIBRARY_PATH :[file dirname [info script]]
will append the directory containing the xschemrc. If you have subfolder
inside this project
directory it is OK, objects inside subfolder/
will have a reference subfolder/component.sym
, this is a relative path so design is portable. If you want to include other folders that are not children of project/
you really should add these folders to your xschemrc.
You can organize your project in many different ways, please read this manual page about xschem path management.
You don't need to setup XSCHEM_LIBRARY_PATH
every time you create a new schematic, you have to create a xschemrc
file (which sets also XSCHEM_LIBRARY_PATH
of course) once when you create a new project. We have done this for any project in Cadence. Often designers don't realize this because there is a CAD/EDA team working behind the scenes that does all this maintenance work.
A project might be organized like this (for xschem schematics and symbols):
β’ .../project
β¦ testbench
β¦ analog
β¦ digital
β¦ io
β¦ ... (whatever else)...
β¦ ...
Then you have the base symbols xschem needs (pins, net labels, ideal spice devices etc):
β’ .../share/xschem/xschem_library
β¦ devices
And then the pdk data (example for sky130A):
β’ .../share/pdk/sky130A/libs.tech/xschem
β¦ sky130_fd_pr
(the silicon device symbols, MOSFETs, diodes, capacitors, resistors, ...)
β¦ sky130_stdcells
(the digital standard cell gates)
A good setup for this is to add 3 directories (the absolute paths on the host) to `XSCHEM_LIBRARY_PATH`:
β’ .../project
β’ .../share/xschem/xschem_library
β’ .../share/pdk/sky130A/libs.tech/xschem
A schematic.sch
from the analog
subfolder will have a reference in the schematic as analog/schematic.sch
A schematic top.sch
under project/
will have reference top.sch
(no subfolders)
A pfet_01v8.sym
will have reference: sky130_fd_pr/pfet_01v8.sym
A voltage source will have reference: devices/vsource.sym
.
This happens because the XSCHEM_LIBRARY_PATH dirs are defined one level above the directory containing the .sym/.sch files. Xschem adds the last level directory to the reference. If you provide to XSCHEM_LIBRARY_PATH the last level directories then the components will be referenced by their names only.Leo Moser
06/28/2024, 9:17 AMAll professional tools require to setup a library configuration before starting a project, like the cds.lib in Cadence. If you don't do that you won't be able to open / instantiate objects at all (you will not see anything in the library manager).Exactly, so maybe we should require the same for xschem (you always have to specify your project in
XSCHEM_LIBRARY_PATH
) if that means we gain portability.
If you insert a symbol from a directory that is not known to xschem the full absolute path will be used. This makes the design unportable, but at the very least will make it work on the system you are working on.True, but I do not think that it's worth it. Most designers never realise that they should have specified their project path in
XSCHEM_LIBRARY_PATH
and that they are using absolute paths.
When an instantiated object is inside a directory known by xschem the path prefix is removed from the symbol reference. This will make the design portable on a different system (after setting up the project xschemrc file on the new system that tells xschem where the design is located).That is not quite true, maybe I'm doing something wrong. For me, this is only the case if you are on the system on which the schematic was created (the absolute path must be valid). But if you are on a different system, the abolute paths are no longer valid, setting up the xschemrc does not fix the absolute paths then. --- For this reason I think if no
XSCHEM_LIBRARY_PATH
is set up for the project, then instead of writing absolute paths, relative paths should be written, as if the directory of the currently open schematic is appended to XSCHEM_LIBRARY_PATH
.
Doing it this way, it will also "just work" if you haven't set up XSCHEM_LIBRARY_PATH
for your project, but it is portable and can be referenced by others as a dependency by appending the project to XSCHEM_LIBRARY_PATH
.
Of course, this breaks down when you have something like "testbench -> schematic 1 -> schematic 2", but then you know at least that you need to properly specify the project path in XSCHEM_LIBRARY_PATH
, as it should have been done in the first place.
What do you think of this idea?
Thanks!Yuan Mei
06/28/2024, 6:39 PMXSCHEM_LIBRARY_PATH
is set up for the project, then instead of writing absolute paths, relative paths should be written, as if the directory of the currently open schematic is appended to XSCHEM_LIBRARY_PATH
.
> Doing it this way, it will also "just work" if you haven't set up XSCHEM_LIBRARY_PATH
for your project, but it is portable and can be referenced by others as a dependency by appending the project to XSCHEM_LIBRARY_PATH
.
I'm very supportive of this idea. I didn't know the XSCHEM_LIBRARY_PATH
mechanism. Just made a symlink from the PDK supplied xschemrc to ~/.xschemrc
. So, with several people on a design team, we all have to be conscious of relative paths and modify the .sch file text to remove absolute paths if necessary. We exactly encountered the problem of having a lot of absolute paths that made the design reuse very difficult, although we kept the relative directory structures well in the project.Stefan Schippers
06/30/2024, 7:05 AMThat is not quite true, maybe I'm doing something wrong. For me, this is only the case if you are on the system on which the schematic was created (the absolute path must be valid). But if you are on a different system, the abolute paths are no longer valid, setting up the xschemrc does not fix the absolute paths then.This happens if the original design already has absolute paths inside it. This is an unportable design no matter what you do afterward. You need to specify the project directory locations in XSCHEM_LIBRARY_PATH, reopen the schematics and save. This time the absolute paths will be removed.
Stefan Schippers
06/30/2024, 7:10 AMXSCHEM_LIBRARY_PATH
> is set up for the project, then instead of writing absolute paths,
> relative paths should be written, as if the directory of the currently
> open schematic is appended to XSCHEM_LIBRARY_PATH
.
There is a fundamental problem in this approach.
Consider the following hierarchy:
β’ top.sch
(located in directory X)
β¦ inv.sym
β¦ adc.sym --> adc.sch
(located in directory Y)
βͺοΈ inv.sym
Where should xschem look for inv.sym?
Using the path of the enclosing schematic was done in xschem some time ago. This generated an endless series of problems and erratic behavior, and has been removed. Project locations should be specified in a deterministic way as a list of paths to search for.Leo Moser
06/30/2024, 7:39 AMThis happens if the original design already has absolute paths inside it. This is an unportable design no matter what you do afterward.
You need to specify the project directory locations in XSCHEM_LIBRARY_PATH, reopen the schematics and save. This time the absolute paths will be removed.Yes, that's exactly our problem. Users will create schematics that are unportable, because they don't know any better.
Leo Moser
06/30/2024, 7:41 AMThere is a fundamental problem in this approach.
Consider the following hierarchy:
β’(located in directory X)top.sch
β¦inv.sym
β¦(located in directory Y)adc.sym --> adc.sch
βͺοΈinv.sym
Where should xschem look for inv.sym?
Using the path of the enclosing schematic was done in xschem some time ago. This generated an endless series of problems and erratic behavior, and has been removed. Project locations should be specified in a deterministic way as a list of paths to search for.Yes, that's the problem I meant with "testbench -> schematic 1 -> schematic 2". It works fine as long as you have a flat hierarchy. I was trying to suggest this mechanism as a replacement for absolute paths, since it works for simple designs. Maybe a better approach would be to add
cwd
to XSCHEM_LIBRARY_PATH
this would work for larger hierarchical designs, as long as one opens xschem from the root of the project.
Maybe we don't even need a replacement for absolute paths.Leo Moser
06/30/2024, 7:42 AMProject locations should be specified in a deterministic way as a list of paths to search for.Exactly. Maybe xschem should simply always expect the user to set
XSCHEM_LIBRARY_PATH
properly.Leo Moser
07/09/2024, 6:17 AMStefan Schippers
07/15/2024, 6:38 AMxschemrc
editing si to place an xschemrc
file inside the project root directory, the whole project is located in this directory or in subdirectories below this one, and xschemrc
has this setting:
append XSCHEM_LIBRARY_PATH :[file dirname [info script]]
This way you can call xschem on the project from any location using:
xschem --rcfile /path/to/project/xschemrc
If the project includes symbols from directories outside the project root directory then these directories should be added to XSCHEM_LIBRARY_PATH
to have a portable schematic (no absolute path references).Leo Moser
07/15/2024, 7:23 AMtnt
07/15/2024, 9:01 AMtnt
07/15/2024, 9:02 AMXSCHEM_LIBRARY_PATH
for the local project symbols and that's it.
Certainly not change user preferences. And also not set things like PDK device symbols or default xschem library symbols since those will be different for different users.Stefan Schippers
07/16/2024, 5:22 AM~/.xschem/xschemrc
is not read, only the system .../share/xschem/xschemrc
file is read. (by default this file is 100% commented, so it does nothing)
> Like I'd like the project xchemrc to ONLY append some items to XSCHEM_LIBRARY_PATH
for the local project symbols and that's it.
> Certainly not change user preferences. And also not set things like PDK device symbols or default xschem library symbols since those will be different
> for different users.
You can do something like this in your project dir:
source $USER_CONF_DIR/xschemrc
append XSCHEM_LIBRARY_PATH :.....
append XSCHEM_LIBRARY_PATH :.....
Leo Moser
07/16/2024, 6:27 AMIf no matching filename is found the reference is taken as is, so it will be searched for in current directory, like in UnixAnd this is exactly what I suggest to remove, because then the design will contain absolute paths and won't be portable. As long as this mechanism exists, users will use it π οΈ
tnt
07/16/2024, 10:46 AMpwd
, it shouldn't be added as an absolute path, it should be added without that pwd
prefix.Leo Moser
07/16/2024, 3:06 PMStefan Schippers
07/19/2024, 1:18 PMcommit 8b5ed3f32ed77b67044b7097376e845be518cdc2 (HEAD -> master, origin/master, origin/HEAD)
Author: stefan schippers <stefan.schippers@gmail.com>
Date: Fri Jul 19 15:13:38 2024 +0200
symbols picked up from CWD are saved in parent design without absolute paths even if the CWD is not in XSCHEM_LIBRARY_PATH list of places.
So if you start xschem in a directory 1234/
where top.sch
includes symbol xxx.sym
(all these file under 1234/
) the design will not have absolute paths:
v {xschem version=3.4.5 file_version=1.2
}
G {}
K {}
V {}
S {}
E {}
C {xxx.sym} 30 -90 0 0 {name=x1}
Leo Moser
07/19/2024, 5:54 PM