From b6e8133a4df71bc4c751550e2b66651c2f33ad78 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Sat, 19 May 2018 07:52:07 -0400 Subject: [PATCH] When tracing, use scalars on single bit arrays to appease vcddiff. --- Changes | 2 ++ src/V3EmitC.cpp | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Changes b/Changes index d4f9ad955..76461b227 100644 --- a/Changes +++ b/Changes @@ -6,6 +6,8 @@ The contributors that suggested a given feature are shown in []. Thanks! **** Report interface ports connected to wrong interface, bug1294. [Todd Strader] +**** When tracing, use scalars on single bit arrays to appease vcddiff. + **** Fix parsing "output signed" in V2K port list, msg2540. [James Jung] **** Fix parsing error on bad missing #, bug1308. [Dan Kirkham] diff --git a/src/V3EmitC.cpp b/src/V3EmitC.cpp index e0586e991..2fe788869 100644 --- a/src/V3EmitC.cpp +++ b/src/V3EmitC.cpp @@ -2405,14 +2405,20 @@ class EmitCTrace : EmitCStmts { string full = ((m_funcp->funcType() == AstCFuncType::TRACE_FULL || m_funcp->funcType() == AstCFuncType::TRACE_FULL_SUB) ? "full":"chg"); + bool emitWidth = false; if (nodep->dtypep()->basicp()->isDouble()) { puts("vcdp->"+full+"Double"); } else if (nodep->isWide() || emitTraceIsScBv(nodep) || emitTraceIsScBigUint(nodep)) { puts("vcdp->"+full+"Array"); + emitWidth = true; } else if (nodep->isQuad()) { puts("vcdp->"+full+"Quad "); - } else if (nodep->declp()->bitRange().ranged()) { + emitWidth = true; + } else if (nodep->declp()->bitRange().ranged() + // 1 element smaller to use Bit dump + && nodep->declp()->bitRange().elements() != 1) { puts("vcdp->"+full+"Bus "); + emitWidth = true; } else { puts("vcdp->"+full+"Bit "); } @@ -2420,8 +2426,7 @@ class EmitCTrace : EmitCStmts { + ((arrayindex<0) ? 0 : (arrayindex*nodep->declp()->widthWords())))); puts(","); emitTraceValue(nodep, arrayindex); - if (!nodep->dtypep()->basicp()->isDouble() // When float/double no longer have widths this can go - && (nodep->declp()->bitRange().ranged() || emitTraceIsScBv(nodep) || emitTraceIsScBigUint(nodep))) { + if (emitWidth) { puts(","+cvtToStr(nodep->declp()->widthMin())); } puts(");\n");