diff --git a/base/netcmp.c b/base/netcmp.c index 496d9af..55f70ff 100644 --- a/base/netcmp.c +++ b/base/netcmp.c @@ -6393,9 +6393,13 @@ struct nlist *addproxies(struct hashlist *p, void *clientdata) /* circuit pair has been matched with automorphisms, */ /* then some pins may be matched arbitrarily. */ /* */ -/* Return 1 on success, 0 on failure. */ /* If "dolist" is 1, append the list representing the */ /* output (if any) to variable tcl_out, if it exists. */ +/* */ +/* Return codes: */ +/* 2: Neither cell had pins, so matching is unnecessary */ +/* 1: Exact match */ +/* 0: Inexact match resolved by proxy pin insertion */ /*------------------------------------------------------*/ int MatchPins(struct nlist *tc1, struct nlist *tc2, int dolist) @@ -6432,7 +6436,7 @@ int MatchPins(struct nlist *tc1, struct nlist *tc2, int dolist) if (haspins == 0) { // Neither cell has any ports, so this is probably a top-level // cell and there is nothing to do. - return 1; + return 2; } cover = (char *)CALLOC(numnodes, sizeof(char)); diff --git a/tcltk/tclnetgen.c b/tcltk/tclnetgen.c index 242aee6..94d04fd 100644 --- a/tcltk/tclnetgen.c +++ b/tcltk/tclnetgen.c @@ -2910,15 +2910,26 @@ _netcmp_equate(ClientData clientData, Circuit1 = tp1; Circuit2 = tp2; } - if (MatchPins(tp1, tp2, dolist)) { + + // Check for and remove duplicate pins. Normally this is called + // from "compare", but since "equate pins" may be called outside + // of and before "compare", pin uniqueness needs to be ensured. + + UniquePins(tp1->name, tp1->file); + UniquePins(tp2->name, tp2->file); + + result = MatchPins(tp1, tp2, dolist); + if (result == 2) { + Fprintf(stdout, "Cells have no pins; pin matching not needed.\n"); + } + else if (result > 0) { Fprintf(stdout, "Cell pin lists are equivalent.\n"); - Tcl_SetObjResult(interp, Tcl_NewBooleanObj(1)); } else { Fprintf(stdout, "Cell pin lists for %s and %s altered to match.\n", name1, name2); - Tcl_SetObjResult(interp, Tcl_NewBooleanObj(0)); } + Tcl_SetObjResult(interp, Tcl_NewIntObj(result)); if (ElementClasses == NULL) { /* Recover temporarily set global variables (see above) */ Circuit1 = SaveC1;