diff --git a/Changes b/Changes index 4d38b3a6d..9dced9b36 100644 --- a/Changes +++ b/Changes @@ -7,8 +7,14 @@ 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 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] + * 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;} }; diff --git a/src/V3EmitC.cpp b/src/V3EmitC.cpp index a7eb1eec0..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"); @@ -1797,9 +1802,6 @@ void EmitCImp::emitImp(AstNodeModule* modp) { // 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"); 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/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) { 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) { 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);