Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

one of the xschem provided example circuits does not load #1

Closed
StefanSchippers opened this issue Mar 11, 2024 · 12 comments
Closed

one of the xschem provided example circuits does not load #1

StefanSchippers opened this issue Mar 11, 2024 · 12 comments

Comments

@StefanSchippers
Copy link

if I try to load this:
https://xschem-viewer.com/?file=https://github.com/StefanSchippers/xschem/blob/master/xschem_library/examples/mos_power_ampli.sch
get the following error:
Error loading https://github.com/StefanSchippers/xschem/blob/master/xschem_library/examples/mos_power_ampli.sch: SyntaxError: Expected "\"" or "\\\\" but "[" found.

expected is this:
1

@StefanSchippers
Copy link
Author

The following simpler example does not cause errors but only wires are rendered:
https://xschem-viewer.com/?file=https://github.com/StefanSchippers/xschem/blob/master/xschem_library/examples/osc.sch
1

expected is this:
2

@urish
Copy link
Member

urish commented Mar 11, 2024

Thanks for reporting!

I believe I fixed the first issue.

As for the second issue, it happens because the viewer can't find the referenced files in the same folder (e.g. lab_pin.sym or capa.sym). I'm not sure what the lookup algorithm for files would be?

Currently, we have a list of known prefixes, and we map them for URLs where to look for files. This works well for all of the examples from the sky130 PDK that I've tried so far:

const libraryLoader = new LibraryLoader([
{
path: 'devices/',
url: 'https://raw.githubusercontent.com/StefanSchippers/xschem/master/xschem_library/',
},
{
path: 'stdcells/',
url: 'https://raw.githubusercontent.com/StefanSchippers/xschem_sky130/main/',
},
{
path: 'sky130_tests/',
url: 'https://raw.githubusercontent.com/StefanSchippers/xschem_sky130/main/',
},
{
path: 'sky130_fd_pr/',
url: 'https://raw.githubusercontent.com/StefanSchippers/xschem_sky130/main/',
},
{
path: 'sky130_stdcells/',
url: 'https://raw.githubusercontent.com/StefanSchippers/xschem_sky130/main/',
},
{
path: 'mips_cpu/',
url: 'https://raw.githubusercontent.com/StefanSchippers/xschem_sky130/main/',
},
]);

@StefanSchippers
Copy link
Author

StefanSchippers commented Mar 11, 2024

Hi, most xschem schematics have some basic symbols (like a voltage source, vsource.sym) or net labels (lab_wire.sym or lab_pin.sym) or circuit in/out pins (ipin.sym, opin.sym, iopin.sym) , ideal resistors (res.sym), ideal capacitors (capa.sym) and so on.
These symbols are referenced either directly ( component lines like C {lab_pin.sym) .... or with a devices/ prefix (C {devices/lab_pin.sym} ... ). I suggest you look up these in this directory, which is a standard component of xschem. You can either keep a local copy of it or get it pulled from the repository, it is not going to change much over time, its pretty stable.

In some xschem user setups the library search path goes down to the devices/ directory (first component line example) or one level above (like in sky130 setups, second component line example).

@urish
Copy link
Member

urish commented Mar 11, 2024

Thanks for explaining! So now the second issue is also fixed - if the component path doesn't include any "/", and we can't find the file in the same directory as the schematic, we look for them under devices/ as a fallback.

Good point regarding pulling the devices - at some point we might cache the devices them at build time, to speed up the loading time of the viewer.

@urish urish closed this as completed Mar 11, 2024
@StefanSchippers
Copy link
Author

Nice work! if you have some doubts about the xschem file format or anything related just let me know!

@urish
Copy link
Member

urish commented Mar 11, 2024

Thanks! I was actually wondering about graphs. I see they are represented as a box with a graph flag, e.g.

B 2 1400 -440 1660 -260 {flags=graph
y1=0
y2=170
divy=4
subdivy=1
x1=0.0247231
x2=0.0249981
divx=8
subdivx=4
dataset=0
unitx=m



color="8 7"
node="tcleval(\\"Xm1 power;vpp $\{path\}outi - i(v.$\{path\}vu) *\\"
\\"Average;vpp $\{path\}outi - i(v.$\{path\}vu) * 200u ravg()\\")"
jpeg_quality=30
xlabmag=1.4}

but I couldn't find any documentation on what the other properties means and what options are available.

@StefanSchippers
Copy link
Author

StefanSchippers commented Mar 11, 2024

Graphs are used to view simulation results. They are just rectangles on layer 2, some attributes specify it is a graph (the flags attribute, the X/Y range to display (x1, x2, y1, y2) the number of grid divisions (with axis labels) and subdivisions for X and Y (divx, subdivx, divy, subdivy) unit multipliers (unitx, unity), the simulation nodes to display (node="...") and the colors (if specified, color="...") there are some other attributes to specify the quality in pdf/svg exports (simulation data can contain 100000 points, I can not dump these as vector graphics, so graphs are rasterized).
My suggestion is to skip these rectangles altogether. (so if you see flags=graph --> skip) at least in the initial development. You need simulation data anyway to get anything useful displayed. Xschem also has an option to hide completely these boxes if no data is loaded.

There is another box container that holds image data, just simple png images with data encoded as a text base64 attribute (image_data=".....") . These can be rendered easily ina browser, I think. these have these flags:

flags=image,unscaled
alpha=0.7
image_data=iVBORw...long_string_of_base64_encoded_text_sdhkldshfgdghdg

the unscaled optional modifier tells the image is placed scaled one to one in the xschem schematic and user can not scale it.
Otherwise it is just like other rectangles and can be resized/stretched at will.

Image containers are supposed to be used to place company logos and other small pictures. Do not expect any good performance by embedding a 16k UUUHD image !

Thes containers are compatible additions to the core xschem objects. if I load a schematic with graphs and images with an older xschem version it will just show empty grey rectangles , ignoring the attributes defined therein.

In some cases I have placed an image of a schematic found may be in a datasheet or in a book with a low alpha value so it will be transparent, then set attribute lock=true (so it can not be moved / selected) and used the background to draw the xschem schematic on top of it.

@StefanSchippers
Copy link
Author

Also as a suggestion I think you can at least temporarily skip the @#*:net_name and @#*:pinnumber attributes, these are documented here (search for "PREDEFINED SYMBOL VALUES" ) and are very rarely used.

@urish
Copy link
Member

urish commented Mar 11, 2024

Now it makes sense! Well, we just show grey rectangles instead of graphs. Do you think it's better just to hide them?

Also as a suggestion I think you can at least temporarily skip the @#:net_name and @#:pinnumber attributes

skip as in just replace them with an empty string?

@StefanSchippers
Copy link
Author

StefanSchippers commented Mar 11, 2024

Yes , If no data is displayed its better to skip.
1
see xschem menu on the bottom

@StefanSchippers
Copy link
Author

skip as in just replace them with an empty string?

Yes, so you have less junk. These are really low priority, so keep a comment in thecode for future improvements.
I see there are some issues with rotated / mirrored symbols so this has higher priority. my opinion of course.

@urish
Copy link
Member

urish commented Mar 11, 2024

Alright, graphs hidden. Feel free to open a new issue for anything you find about rotated / mirrored symbols

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants