Skip to content

Commit

Permalink
Corrected tool vlog2Spice to use the same name-rewriting method
Browse files Browse the repository at this point in the history
used by vlog2Cel and vlog2Def when translating verilog backslash-
escaped names into something that is SPICE compatible.
  • Loading branch information
RTimothyEdwards committed Aug 17, 2019
1 parent 09aad04 commit 3c8b04d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/netgen_lvs.sh
Expand Up @@ -81,7 +81,7 @@ endif
# netlists. All netlists must be more recent than the project ".def" file.

if ( ! -f ${synthdir}/${rootname}.spc || \
( -M ${synthdir}/${rootname}.spc < -M ${synthdir}/${rootname}.blif )) then
( -M ${synthdir}/${rootname}.spc < -M ${synthdir}/${rootname}.rtl.v )) then
echo "LVS failure: No schematic netlist found." |& tee -a ${synthlog}
echo "Premature exit." |& tee -a ${synthlog}
echo "Synthesis flow stopped due to error condition." >> ${synthlog}
Expand Down
22 changes: 22 additions & 0 deletions src/vlog2Spice.c
Expand Up @@ -109,6 +109,24 @@ int main (int argc, char *argv[])
return result;
}

/*--------------------------------------------------------------*/
/* Verilog backslash notation, which is the most absurd syntax */
/* in the known universe, is fundamentally incompatible with */
/* SPICE. The ad-hoc solution used by qflow is to replace */
/* the trailing space with another backslash such that the */
/* name is SPICE-compatible and the original syntax can be */
/* recovered when needed. */
/*--------------------------------------------------------------*/

void backslash_fix(char *netname)
{
char *sptr;

if (*netname == '\\')
if ((sptr = strchr(netname, ' ')) != NULL)
*sptr = '\\';
}

/*--------------------------------------------------------------*/
/* write_output --- Write the SPICE netlist output */
/* */
Expand Down Expand Up @@ -466,6 +484,7 @@ int write_output(struct cellrec *topcell, LinkedStringPtr spicelibs,
if (*portname == ',') portname++;
ssave = *epos;
*epos = '\0';
backslash_fix(portname);
fprintf(outfile, "%s", portname);
*epos = ssave;
}
Expand All @@ -476,6 +495,7 @@ int write_output(struct cellrec *topcell, LinkedStringPtr spicelibs,

if (wb.start < 0) {
/* portname is not a bus */
backslash_fix(portname);
fprintf(outfile, "%s", portname);
}
else {
Expand All @@ -487,6 +507,7 @@ int write_output(struct cellrec *topcell, LinkedStringPtr spicelibs,
/* portname is a partial or full bus */
dptr = strrchr(portname, '[');
if (dptr) *dptr = '\0';
backslash_fix(portname);
if (flags & DO_DELIMITER)
fprintf(outfile, "%s<%d>", portname, lidx);
else
Expand All @@ -496,6 +517,7 @@ int write_output(struct cellrec *topcell, LinkedStringPtr spicelibs,
}
}
else {
backslash_fix(port->net);
fprintf(outfile, "%s", port->net);
}

Expand Down

0 comments on commit 3c8b04d

Please sign in to comment.