add support to map DIYLC pin indices to spice

This commit is contained in:
Branislav Stojkovic
2019-03-09 16:47:18 +01:00
parent 54ff518438
commit 8ccdd84a6f
4 changed files with 35 additions and 8 deletions
@@ -0,0 +1,6 @@
package org.diylc.netlist;
public interface ISpiceMapper {
int mapToSpiceNode(int index);
}
@@ -72,7 +72,7 @@ public class SpiceAnalyzer extends NetlistAnalyzer implements INetlistAnalyzer {
StringBuilder sb = new StringBuilder();
List<Group> groups = netlist.getSortedGroups();
int unconnectedIndex = groups.size() + 1;
int unconnectedIndex = groups.size();
int maxLen = 0;
for (IDIYComponent<?> c : allComponents) {
@@ -83,16 +83,33 @@ public class SpiceAnalyzer extends NetlistAnalyzer implements INetlistAnalyzer {
for (IDIYComponent<?> c : allComponents) {
sb.append(fill(c.getName(), (int) (Math.ceil(maxLen / 5.0) * 5)));
sb.append(" ");
int[] nodeIndices = new int[c.getControlPointCount()];
// find node indices for each control point
for (int i = 0; i < c.getControlPointCount(); i++) {
int index = find(new Node(c, i), groups);
if (index < 0)
index = unconnectedIndex++;
else
index++;
sb.append(fill(Integer.toString(index), 5));
int pointIndex = i;
int nodeIndex = find(new Node(c, pointIndex), groups);
if (nodeIndex < 0)
nodeIndex = unconnectedIndex++;
// 1-based convention
nodeIndex++;
// remap if needed
if (c instanceof ISpiceMapper)
pointIndex = ((ISpiceMapper)c).mapToSpiceNode(pointIndex);
nodeIndices[pointIndex] = nodeIndex;
}
// output to spice
for (int i = 0; i < c.getControlPointCount(); i++) {
sb.append(fill(Integer.toString(nodeIndices[i]), 5));
sb.append(" ");
}
sb.append(c.getValueForDisplay());
sb.append(c.getValue());
sb.append("<br>");
}
Binary file not shown.
+4
View File
@@ -2582,6 +2582,10 @@
<changeType>NEW_FEATURE</changeType>
<description>Ability to tag components and building blocks as favorites</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Generate SPICE-compatible netlist (still in beta stage)</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>When in "Highlight Connected Area" mode, the status bar shows useful information making it harder to forget what the mode does</description>