From d5e9e7cd2b74979866dfc8a10b4876630b04b543 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Tue, 19 Apr 2011 19:02:03 -0500 Subject: [PATCH 1/6] Remove dead code --- src/V3Width.cpp | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 4673b6cb6..b0ab5a2b9 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -390,47 +390,20 @@ private: // Just a quick check as after V3Param these nodes instead are AstSel's AstNode* selp = V3Width::widthSelNoIterEdit(nodep); if (selp!=nodep) { nodep=NULL; selp->iterate(*this,vup); return; } nodep->v3fatalSrc("AstSelBit should disappear after widthSel"); - if (vup->c()->prelim()) { - nodep->lhsp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p()); // from - nodep->rhsp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p()); // bit - } } virtual void visit(AstSelExtract* nodep, AstNUser* vup) { // Just a quick check as after V3Param these nodes instead are AstSel's AstNode* selp = V3Width::widthSelNoIterEdit(nodep); if (selp!=nodep) { nodep=NULL; selp->iterate(*this,vup); return; } nodep->v3fatalSrc("AstSelExtract should disappear after widthSel"); - if (vup->c()->prelim()) { - nodep->fromp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p()); - nodep->msbp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p()); - nodep->lsbp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p()); - } } virtual void visit(AstSelPlus* nodep, AstNUser* vup) { AstNode* selp = V3Width::widthSelNoIterEdit(nodep); if (selp!=nodep) { nodep=NULL; selp->iterate(*this,vup); return; } nodep->v3fatalSrc("AstSelPlus should disappear after widthSel"); - if (vup->c()->prelim()) { - nodep->fromp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p()); - nodep->bitp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p()); - nodep->widthp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p()); - if (AstConst* constp = nodep->widthp()->castConst()) { - int width = constp->toSInt(); - nodep->width(width,width); - } - } } virtual void visit(AstSelMinus* nodep, AstNUser* vup) { AstNode* selp = V3Width::widthSelNoIterEdit(nodep); if (selp!=nodep) { nodep=NULL; selp->iterate(*this,vup); return; } nodep->v3fatalSrc("AstSelMinus should disappear after widthSel"); - if (vup->c()->prelim()) { - nodep->fromp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p()); - nodep->bitp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p()); - nodep->widthp()->iterateAndNext(*this,WidthVP(ANYSIZE,0,BOTH).p()); - if (AstConst* constp = nodep->widthp()->castConst()) { - int width = constp->toSInt(); - nodep->width(width,width); - } - } } virtual void visit(AstExtend* nodep, AstNUser* vup) { From 250394f72ba33b447f47e9bb55e011b4474dd926 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 9 May 2011 23:49:17 -0400 Subject: [PATCH 2/6] Fix compiler warnings on SPARC, bug288 --- Changes | 2 ++ src/V3AstNodes.h | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index 4d38b3a6d..9e2e16d38 100644 --- a/Changes +++ b/Changes @@ -9,6 +9,8 @@ indicates the contributor was also the author of the fix; Thanks! **** Fix CDCRSTLOGIC report showing endpoint flops without resets. +**** Fix compiler warnings on SPARC, bug288. [Ahmed El-Mahmoudy] + * Verilator 3.812 2011/04/06 *** Add --trace-max-width and --trace-max-array, bug319. [Alex Solomatnikov] diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index b2260f8b6..235fe93b8 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -3184,9 +3184,9 @@ struct AstBufIf1 : public AstNodeBiop { ASTNODE_NODE_FUNCS(BufIf1, BUFIF1) virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs) { out.opBufIf1(lhs,rhs); } virtual string emitVerilog() { return "bufif(%r,%l)"; } - virtual string emitC() { V3ERROR_NA; return false;} // Lclean || Rclean + virtual string emitC() { V3ERROR_NA; return "";} // Lclean || Rclean virtual string emitSimpleOperator() { V3ERROR_NA; return false;} // Lclean || Rclean - virtual bool cleanOut() {V3ERROR_NA; return false;} // Lclean || Rclean + virtual bool cleanOut() {V3ERROR_NA; return "";} // Lclean || Rclean virtual bool cleanLhs() {return false;} virtual bool cleanRhs() {return false;} virtual bool sizeMattersLhs() {return false;} virtual bool sizeMattersRhs() {return false;} }; From df4bc950fe2f022bbe7559bbeb7529dbd17432e5 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 9 May 2011 23:58:38 -0400 Subject: [PATCH 3/6] Cleanup trailing whitespace --- src/verilog.y | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/verilog.y b/src/verilog.y index 49a4c5658..c8c24b39c 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -833,7 +833,7 @@ port: // ==IEEE: port | portDirNetE /*implicit*/ portSig variable_dimensionListE sigAttrListE '=' constExpr { $$=$2; /*VARDTYPE-same*/ AstVar* vp=VARDONEP($$,$3,$4); $$->addNextNull(vp); vp->valuep($6); } ; - + portDirNetE: // IEEE: part of port, optional net type and/or direction /* empty */ { } // // Per spec, if direction given default the nettype. @@ -842,12 +842,12 @@ portDirNetE: // IEEE: part of port, optional net type and/or direction | port_direction net_type { VARDECL(PORT); VARDTYPE(NULL/*default_nettype*/); } // net_type calls VARNET | net_type { } // net_type calls VARNET ; - + port_declNetE: // IEEE: part of port_declaration, optional net type /* empty */ { } | net_type { } // net_type calls VARNET ; - + portSig: id/*port*/ { $$ = new AstPort($1,PINNUMINC(),*$1); } | idSVKwd { $$ = new AstPort($1,PINNUMINC(),*$1); } @@ -2838,7 +2838,7 @@ junkToSemiList: junkToSemi { } /* ignored */ | junkToSemiList junkToSemi { } /* ignored */ ; - + junkToSemi: BISONPRE_NOT(';',yENDSPECIFY,yENDMODULE) { } | error {} @@ -3109,7 +3109,7 @@ vltOffFront: int V3ParseImp::bisonParse() { if (PARSEP->debugBison()>=9) yydebug = 1; - return yyparse(); + return yyparse(); } const char* V3ParseImp::tokenName(int token) { From 4af0af93bf4fafc934020c9de98b2eb10327d96b Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 12 May 2011 06:32:29 -0400 Subject: [PATCH 4/6] Fix DPI undeclared svBitVecVal compile error, bug346. --- Changes | 2 ++ src/V3EmitC.cpp | 9 ++++++--- src/V3EmitCSyms.cpp | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Changes b/Changes index 9e2e16d38..1dd472ad8 100644 --- a/Changes +++ b/Changes @@ -7,6 +7,8 @@ indicates the contributor was also the author of the fix; Thanks! **** Fix error on enum references to other packages, bug339. [Alex Solomatnikov] +**** Fix DPI undeclared svBitVecVal compile error, bug346. [Chandan Egbert] + **** Fix CDCRSTLOGIC report showing endpoint flops without resets. **** Fix compiler warnings on SPARC, bug288. [Ahmed El-Mahmoudy] diff --git a/src/V3EmitC.cpp b/src/V3EmitC.cpp index a7eb1eec0..3c325dd1c 100644 --- a/src/V3EmitC.cpp +++ b/src/V3EmitC.cpp @@ -1792,14 +1792,17 @@ void EmitCImp::emitImp(AstNodeModule* modp) { puts("//############################################################\n"); puts("#sp implementation\n"); } + if (v3Global.dpi()) { + // do this before including our main .h file so that any references to + // types defined in svdpi.h are available + puts("#include \""+ topClassName() +"__Dpi.h\"\n"); + puts("\n"); + } ofp()->printf("#include \"%-20s // For This\n", (modClassName(modp)+".h\"").c_str()); // Us puts("#include \""+ symClassName() +".h\"\n"); - if (v3Global.dpi()) { - puts("#include \""+ topClassName() +"__Dpi.h\"\n"); - } if (optSystemPerl() && (splitFilenum() || !m_fast)) { puts("\n"); diff --git a/src/V3EmitCSyms.cpp b/src/V3EmitCSyms.cpp index fe966a993..997c0f8f9 100644 --- a/src/V3EmitCSyms.cpp +++ b/src/V3EmitCSyms.cpp @@ -519,6 +519,8 @@ void EmitCSyms::emitDpiHdr() { puts("// Manually include this file where DPI .c import functions are declared to insure\n"); puts("// the C functions match the expectations of the DPI imports.\n"); puts("\n"); + puts("#include \"svdpi.h\"\n"); + puts("\n"); puts("#ifdef __cplusplus\n"); puts("extern \"C\" {\n"); puts("#endif\n"); From 9558e14479d4d291b68a9d08eb55997ddb6bbaca Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 12 May 2011 06:59:13 -0400 Subject: [PATCH 5/6] Fix DPI undeclared svBitVecVal compile error, bug346. Additional change. --- src/V3EmitC.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/V3EmitC.cpp b/src/V3EmitC.cpp index 3c325dd1c..19cee0ea9 100644 --- a/src/V3EmitC.cpp +++ b/src/V3EmitC.cpp @@ -1619,7 +1619,12 @@ void EmitCImp::emitInt(AstNodeModule* modp) { if (v3Global.needHInlines()) { // Set by V3EmitCInlines; should have been called before us puts("#include \""+topClassName()+"__Inlines.h\"\n"); } - // No __Dpi.h needed, we've shimmed it all into the interface + if (v3Global.dpi()) { + // do this before including our main .h file so that any references to + // types defined in svdpi.h are available + puts("#include \""+ topClassName() +"__Dpi.h\"\n"); + puts("\n"); + } // Declare foreign instances up front to make C++ happy puts("class "+symClassName()+";\n"); @@ -1792,12 +1797,6 @@ void EmitCImp::emitImp(AstNodeModule* modp) { puts("//############################################################\n"); puts("#sp implementation\n"); } - if (v3Global.dpi()) { - // do this before including our main .h file so that any references to - // types defined in svdpi.h are available - puts("#include \""+ topClassName() +"__Dpi.h\"\n"); - puts("\n"); - } ofp()->printf("#include \"%-20s // For This\n", (modClassName(modp)+".h\"").c_str()); From fb856790688bf2f4a2c87b6736677287290557d8 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 12 May 2011 07:35:28 -0400 Subject: [PATCH 6/6] Fix DPI bit vector compile errors, bug347. --- Changes | 2 ++ src/V3Task.cpp | 8 +++++--- test_regress/t/t_dpi_export.v | 2 ++ test_regress/t/t_dpi_export_c.cpp | 3 +++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Changes b/Changes index 1dd472ad8..9dced9b36 100644 --- a/Changes +++ b/Changes @@ -9,6 +9,8 @@ indicates the contributor was also the author of the fix; Thanks! **** Fix DPI undeclared svBitVecVal compile error, bug346. [Chandan Egbert] +**** Fix DPI bit vector compile errors, bug347. [Chandan Egbert] + **** Fix CDCRSTLOGIC report showing endpoint flops without resets. **** Fix compiler warnings on SPARC, bug288. [Ahmed El-Mahmoudy] diff --git a/src/V3Task.cpp b/src/V3Task.cpp index 7e4ae71d0..8b55882d4 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -605,7 +605,7 @@ private: return new AstCStmt(portp->fileline(), stmt); } - AstNode* createAssignDpiToInternal(AstVarScope* portvscp, const string& frName) { + AstNode* createAssignDpiToInternal(AstVarScope* portvscp, const string& frName, bool cvt) { // Create assignment from DPI temporary into internal format AstVar* portp = portvscp->varp(); string stmt; @@ -614,6 +614,8 @@ private: stmt += "VL_CVT_VP_Q("; ket += ")"; } + if (!cvt + && portp->basicp() && portp->basicp()->isBitLogic() && portp->widthMin() != 1) stmt += "*"; // it's a svBitVecVal stmt += frName; stmt += ket; // Use a AstCMath, as we want V3Clean to mask off bits that don't make sense. @@ -680,7 +682,7 @@ private: argnodesp = argnodesp->addNextNull(refp); if (portp->isInput()) { - dpip->addStmtsp(createAssignDpiToInternal(outvscp, portp->name())); + dpip->addStmtsp(createAssignDpiToInternal(outvscp, portp->name(), false)); } } } @@ -795,7 +797,7 @@ private: if (AstVar* portp = stmtp->castVar()) { if (portp->isIO() && (portp->isOutput() || portp->isFuncReturn())) { AstVarScope* portvscp = portp->user2p()->castNode()->castVarScope(); // Remembered when we created it earlier - cfuncp->addStmtsp(createAssignDpiToInternal(portvscp,portp->name()+"__Vcvt")); + cfuncp->addStmtsp(createAssignDpiToInternal(portvscp,portp->name()+"__Vcvt",true)); } } } diff --git a/test_regress/t/t_dpi_export.v b/test_regress/t/t_dpi_export.v index 87968f057..1601771de 100644 --- a/test_regress/t/t_dpi_export.v +++ b/test_regress/t/t_dpi_export.v @@ -23,6 +23,7 @@ module t; function int dpix_int123(); dpix_int123 = 32'h123; endfunction export "DPI-C" function dpix_f_bit; + export "DPI-C" function dpix_f_bit15; export "DPI-C" function dpix_f_int; export "DPI-C" function dpix_f_byte; export "DPI-C" function dpix_f_shortint; @@ -30,6 +31,7 @@ module t; export "DPI-C" function dpix_f_chandle; function bit dpix_f_bit (bit i); dpix_f_bit = ~i; endfunction + function bit [14:0] dpix_f_bit15 (bit [14:0] i); dpix_f_bit15 = ~i; endfunction function int dpix_f_int (int i); dpix_f_int = ~i; endfunction function byte dpix_f_byte (byte i); dpix_f_byte = ~i; endfunction function shortint dpix_f_shortint(shortint i); dpix_f_shortint = ~i; endfunction diff --git a/test_regress/t/t_dpi_export_c.cpp b/test_regress/t/t_dpi_export_c.cpp index e6d16f344..c6f8b6eab 100644 --- a/test_regress/t/t_dpi_export_c.cpp +++ b/test_regress/t/t_dpi_export_c.cpp @@ -123,8 +123,11 @@ int dpix_run_tests() { CHECK_RESULT (int, o, 0x458UL); #endif + svBitVecVal vec10[1] = {0x10}; + CHECK_RESULT (int, dpix_f_bit(1), 0x0); CHECK_RESULT (int, dpix_f_bit(0), 0x1); + CHECK_RESULT (int, dpix_f_bit15(vec10) & 0x7fUL, 0x6f); // Simulators disagree over the next three's sign extension unless we mask the upper bits CHECK_RESULT (int, dpix_f_int(1) & 0xffffffffUL, 0xfffffffeUL); CHECK_RESULT (int, dpix_f_byte(1) & 0xffUL, 0xfe);