question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[SKiDL BUG] svg skin not compatible with netlistsvg

See original GitHub issue

skin.svg file has no correct format for netlistsvg.

netlistsvg error:

/usr/local/lib/node_modules/netlistsvg/built/Skin.js:11
                return e[1]['s:pid'].startsWith(prefix);
                                     ^

TypeError: Cannot read property 'startsWith' of undefined
    at /usr/local/lib/node_modules/netlistsvg/built/Skin.js:11:38
    at arrayFilter (/usr/local/lib/node_modules/netlistsvg/node_modules/lodash/lodash.js:596:11)
    at Function.filter (/usr/local/lib/node_modules/netlistsvg/node_modules/lodash/lodash.js:9241:14)
    at Object.getPortsWithPrefix (/usr/local/lib/node_modules/netlistsvg/built/Skin.js:9:23)
    at Cell.buildElkChild (/usr/local/lib/node_modules/netlistsvg/built/Cell.js:213:36)
    at /usr/local/lib/node_modules/netlistsvg/built/elkGraph.js:12:18
    at Array.map (<anonymous>)
    at Object.buildElkGraph (/usr/local/lib/node_modules/netlistsvg/built/elkGraph.js:11:33)
    at Object.render (/usr/local/lib/node_modules/netlistsvg/built/index.js:43:29)
    at render (/usr/local/lib/node_modules/netlistsvg/bin/netlistsvg.js:23:9)
    at parseFiles (/usr/local/lib/node_modules/netlistsvg/bin/netlistsvg.js:57:9)
    at fs.readFile (/usr/local/lib/node_modules/netlistsvg/bin/netlistsvg.js:41:17)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)

I think s:pid should be in the same root <g> tag i.e.

<g s:type="PMOS_GSD_1_" s:width="112.5" s:height="132.0" transform="translate(60.0,72.0)">
			<s:alias val="PMOS_GSD_1_" />
			<path d="M 27.0 0.0 L 15.0 -4.5 L 15.0 4.5 L 27.0 0.0" style="stroke-width:1.0"
				class="$cell_id symbol pen_fill" />
			<circle cx="19.5" cy="0.0" r="33.0" style="stroke-width:3.0" class="$cell_id symbol " />
			<path d="M 3.0 0.0 L -30.0 0.0" style="stroke-width:1.0" class="$cell_id symbol " />
			<path d="M 3.0 -22.5 L 3.0 22.5" style="stroke-width:3.0" class="$cell_id symbol " />
			<path d="M 9.0 21.0 L 30.0 21.0" style="stroke-width:1.0" class="$cell_id symbol " />
			<path d="M 9.0 15.0 L 9.0 27.0" style="stroke-width:3.0" class="$cell_id symbol " />
			<path d="M 9.0 -6.0 L 9.0 6.0" style="stroke-width:3.0" class="$cell_id symbol " />
			<path d="M 9.0 -21.0 L 30.0 -21.0" style="stroke-width:1.0" class="$cell_id symbol " />
			<path d="M 9.0 -27.0 L 9.0 -15.0" style="stroke-width:3.0" class="$cell_id symbol " />
			<path d="M 30.0 -30.0 L 30.0 -21.0" style="stroke-width:1.0" class="$cell_id symbol " />
			<path d="M 30.0 30.0 L 30.0 0.0 L 9.0 0.0" style="stroke-width:1.0" class="$cell_id symbol " />
			<path d="M -60.0 0.0 L -30.0 0.0" style="stroke-width:1.0" class="$cell_id symbol" />
			<text class='pin_num_text' text-anchor='end' x='-30.0' y='0.0'
				transform='rotate(0 -30.0 0.0) translate(-6.0 -2.25)' style='font-size:15.0px'> 1 </text>
			<path d="M 30.0 60.0 L 30.0 30.0" style="stroke-width:1.0" class="$cell_id symbol" />
			<text class='pin_num_text' text-anchor='end' x='30.0' y='30.0'
				transform='rotate(-90 30.0 30.0) translate(-6.0 -2.25)' style='font-size:15.0px'> 2 </text>
			<path d="M 30.0 -72.0 L 30.0 -30.0" style="stroke-width:1.0" class="$cell_id symbol" />
			<text class='pin_num_text' text-anchor='start' x='30.0' y='-30.0'
				transform='rotate(-90 30.0 -30.0) translate(6.0 -2.25)' style='font-size:15.0px'> 3 </text>
			<text class='part_ref_text' text-anchor='start' x='60.0' y='-15.0'
				transform='rotate(0 60.0 -15.0) translate(0.0 7.5)' style='font-size:15.0px' s:attribute="ref"> X
			</text>
			<text class='part_name_text' text-anchor='start' x='60.0' y='15.0'
				transform='rotate(0 60.0 15.0) translate(0.0 7.5)' style='font-size:15.0px' s:attribute="value"> X
			</text>
			<g s:x="0.0" s:y="0" s:pid="1" s:position="left"/>
			<g s:x="30.0" s:y="60" s:pid="2" s:position="bottom"/>
			<g s:x="30.0" s:y="-72" s:pid="3" s:position="top"/>
	</g>

not working because extra <g transform…:

<g s:type="PMOS_GSD_1_" s:width="112.5" s:height="132.0" >
<s:alias val="PMOS_GSD_1_"/>
<g transform="translate(60.0,72.0)">
<path d="M 27.0 0.0 L 15.0 -4.5 L 15.0 4.5 L 27.0 0.0" style="stroke-width:1.0" class="$cell_id symbol pen_fill" />
<circle cx="19.5" cy="0.0" r="33.0" style="stroke-width:3.0" class="$cell_id symbol " />
<path d="M 3.0 0.0 L -30.0 0.0" style="stroke-width:1.0" class="$cell_id symbol " />
<path d="M 3.0 -22.5 L 3.0 22.5" style="stroke-width:3.0" class="$cell_id symbol " />
<path d="M 9.0 21.0 L 30.0 21.0" style="stroke-width:1.0" class="$cell_id symbol " />
<path d="M 9.0 15.0 L 9.0 27.0" style="stroke-width:3.0" class="$cell_id symbol " />
<path d="M 9.0 -6.0 L 9.0 6.0" style="stroke-width:3.0" class="$cell_id symbol " />
<path d="M 9.0 -21.0 L 30.0 -21.0" style="stroke-width:1.0" class="$cell_id symbol " />
<path d="M 9.0 -27.0 L 9.0 -15.0" style="stroke-width:3.0" class="$cell_id symbol " />
<path d="M 30.0 -30.0 L 30.0 -21.0" style="stroke-width:1.0" class="$cell_id symbol " />
<path d="M 30.0 30.0 L 30.0 0.0 L 9.0 0.0" style="stroke-width:1.0" class="$cell_id symbol " />
<path d="M -60.0 0.0 L -30.0 0.0" style="stroke-width:1.0" class="$cell_id symbol"/>
<text class='pin_num_text' text-anchor='end' x='-30.0' y='0.0' transform='rotate(0 -30.0 0.0) translate(-6.0 -2.25)' style='font-size:15.0px'  > 1 </text>
<path d="M 30.0 60.0 L 30.0 30.0" style="stroke-width:1.0" class="$cell_id symbol"/>
<text class='pin_num_text' text-anchor='end' x='30.0' y='30.0' transform='rotate(-90 30.0 30.0) translate(-6.0 -2.25)' style='font-size:15.0px'  > 2 </text>
<path d="M 30.0 -72.0 L 30.0 -30.0" style="stroke-width:1.0" class="$cell_id symbol"/>
<text class='pin_num_text' text-anchor='start' x='30.0' y='-30.0' transform='rotate(-90 30.0 -30.0) translate(6.0 -2.25)' style='font-size:15.0px'  > 3 </text>
<text class='part_ref_text' text-anchor='start' x='60.0' y='-15.0' transform='rotate(0 60.0 -15.0) translate(0.0 7.5)' style='font-size:15.0px' s:attribute="ref" > X </text>
<text class='part_name_text' text-anchor='start' x='60.0' y='15.0' transform='rotate(0 60.0 15.0) translate(0.0 7.5)' style='font-size:15.0px' s:attribute="value" > X </text>
</g>
<g s:x="0.0" s:y="72.0" s:pid="1" s:position="left"/>
<g s:x="90.0" s:y="132.0" s:pid="2" s:position="bottom"/>
<g s:x="90.0" s:y="0.0" s:pid="3" s:position="top"/>
</g>

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
xesscorpcommented, Jul 11, 2021

I had a real hard time getting your example (or any example) to work because of my installation of node and npm. An old version of netlistsvg is installed when you use npm install netlistsvg. When you use npm install github:nturley/netlistsvg to install the newest version locally, skidl still defaults to using the global (but out-of-date) version of netlistsvg. When I tried to update the global version with npm install github:nturley/netlistsvg -g, Ubuntu wouldn’t allow it because of directory permissions (even when using sudo).

So I completely removed node and npm and reinstalled the latest versions. Then all my examples began working as well as this version of your example:

from skidl import *

mosfet = Part("pspice","MPMOS")
mosfet.symtx = "HL"  # Had a problem using "R" rotations.
#pmos = Part("DeviceSteffen","PMOS_GSD")  # I don't have this library.
pmos = Part("pspice","MPMOS")  # I substituted this part.
n01=Net("n01")
mosfet[1] += mosfet[2]
n01 += mosfet[3]
pmos[3] += mosfet[3]

generate_svg()

So I think you shouldn’t need your work-around if you get the latest version of netlistsvg installed correctly.

One problem did arise when the second PMOS transistor in your example was rotated to the right: the elkjs module threw an exception. The exception didn’t happen if I rotated the transistor to the left or applied any other type of transformation. I haven’t yet found the cause of this error.

If you think your problems might also be caused by an out-of-date installation of node, npm, or netlistsvg, then here are the steps I used to re-install on Ubuntu:

cd ~
sudo apt remove node npm nodejs

sudo rm -rf /usr/local/bin/npm 
sudo rm -rf /usr/local/share/man/man1/node* 
sudo rm -rf /usr/local/lib/dtrace/node.d
rm -rf ~/.npm
rm -rf ~/.node-gyp
sudo rm -rf /opt/local/bin/node
sudo rm -rf /opt/local/include/node
sudo rm -rf /opt/local/lib/node_modules
sudo rm -rf /usr/local/lib/node*
sudo rm -rf /usr/local/include/node*
sudo rm -rf /usr/local/bin/node*

curl -sL https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh -o install_nvm.sh
bash install_nvm.sh

nvm install stable
nvm use stable
npm install nturley/netlistsvg

If you’re sure you have the newest version of netlistsvg, then we’ll have to keep looking for a solution. But I got exactly the same error running your example as you did when I was using an older version of netlistsvg.

0reactions
devbismecommented, Sep 9, 2021

I finally got back to this and verified that your fix works for all my test cases and also solves the problem with the rotated transistor. I’ve checked the changes into the development branch. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

NetlistSVG — pcbdl documentation - Google
netlistsvg is used by pcbdl to render a graphical output of the schematics. It uses the “analog skin” to get something similar to...
Read more >
everything.schedule.xml - GitHub
</abstract> <description><p>Carry bugs are fairly common, and usually too small to have big impact, or so they are considered. This one was no...
Read more >
Bookmarks
GitHub - xesscorp/skidl: SKiDL is a module that extends Python with the ability to design electronic circuits. https://greenteapress.com/wp/modsimpy/ · Home - ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found