From e75f5661e2b59126614ada8018766c3a8ca23289 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Tue, 9 Feb 2021 09:12:22 -0500 Subject: [PATCH 1/2] Added a zero-value current source to the zero-valued devices handled by the pre-matching method. The current source is treated like the others except that it forms an open circuit rather than a short. --- VERSION | 2 +- base/flatten.c | 29 +++++++++++++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/VERSION b/VERSION index 82850f9..d642333 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.5.165 +1.5.166 diff --git a/base/flatten.c b/base/flatten.c index b6c8a26..9bc3f0b 100644 --- a/base/flatten.c +++ b/base/flatten.c @@ -1660,7 +1660,8 @@ PrematchLists(char *name1, int file1, char *name2, int file2) while (ecomp != NULL) { if ((ecomp->num1 != ecomp->num2) && (ecomp->cell1 != NULL) && ((ecomp->cell1->class == CLASS_RES) || - (ecomp->cell1->class == CLASS_VSOURCE))) { + (ecomp->cell1->class == CLASS_VSOURCE) || + (ecomp->cell1->class == CLASS_ISOURCE))) { int node1 = -1, node2 = -1; lob = NULL; for (ob1 = tc1->cell; ob1; ) { @@ -1709,11 +1710,16 @@ PrematchLists(char *name1, int file1, char *name2, int file2) tsub1->name, tc1->name); - /* merge node of endpoints */ - for (ob2 = tc1->cell; ob2; ob2 = ob2->next) { - if (ob2->node == node2) - ob2->node = node1; - } + /* A current source is an open, while a */ + /* resistor or voltage source is a short. */ + + if (ecomp->cell1->class != CLASS_ISOURCE) { + /* merge node of endpoints */ + for (ob2 = tc1->cell; ob2; ob2 = ob2->next) { + if (ob2->node == node2) + ob2->node = node1; + } + } /* snip, snip. Excise this device */ if (lob == NULL) { @@ -1765,7 +1771,8 @@ PrematchLists(char *name1, int file1, char *name2, int file2) if ((ecomp->num1 != ecomp->num2) && (ecomp->cell2 != NULL) && ((ecomp->cell2->class == CLASS_RES) || - (ecomp->cell2->class == CLASS_VSOURCE))) { + (ecomp->cell2->class == CLASS_VSOURCE) || + (ecomp->cell2->class == CLASS_ISOURCE))) { int node1 = -1, node2 = -1; lob = NULL; for (ob2 = tc2->cell; ob2; ) { @@ -1815,9 +1822,11 @@ PrematchLists(char *name1, int file1, char *name2, int file2) tc2->name); /* merge node of endpoints */ - for (ob1 = tc2->cell; ob1; ob1 = ob1->next) { - if (ob1->node == node2) - ob1->node = node1; + if (ecomp->cell2->class != CLASS_ISOURCE) { + for (ob1 = tc2->cell; ob1; ob1 = ob1->next) { + if (ob1->node == node2) + ob1->node = node1; + } } /* snip, snip. Excise this device */ From 19471275dfd6a8df336612c219d2fa91051003d6 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Tue, 9 Feb 2021 09:30:27 -0500 Subject: [PATCH 2/2] Added handling of control blocks (.CONTROL ... .ENDC) in ngspice- format files to the SPICE parser, so that netgen can be run directly on a testbench file and not generate errors due to statements in the control block. --- base/spice.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/base/spice.c b/base/spice.c index 0209ded..9f46fdc 100644 --- a/base/spice.c +++ b/base/spice.c @@ -865,6 +865,17 @@ skip_ends: } } + /* Ignore anything in a .CONTROL ... .ENDC block */ + else if (matchnocase(nexttok, ".CONTROL")) { + while (1) { + SpiceSkipNewLine(); + SkipTok(NULL); + if (EndParseFile()) break; + if (matchnocase(nexttok, ".ENDC")) + break; + } + } + // Blackbox (library) mode---parse only subcircuits and models; // ignore all components.