diff --git a/include/verilated.h b/include/verilated.h index c627e43bf..3857524f5 100644 --- a/include/verilated.h +++ b/include/verilated.h @@ -68,6 +68,13 @@ public: //========================================================================= // Declare nets +#ifndef VL_ST_SIG +# define VL_ST_SIG8(name, msb,lsb) CData name ///< Declare signal, 1-8 bits +# define VL_ST_SIG16(name, msb,lsb) SData name ///< Declare signal, 9-16 bits +# define VL_ST_SIG64(name, msb,lsb) QData name ///< Declare signal, 33-64 bits +# define VL_ST_SIG(name, msb,lsb) IData name ///< Declare signal, 17-32 bits +# define VL_ST_SIGW(name,msb,lsb,words) WData name[words] ///< Declare signal, 65+ bits +#endif #ifndef VL_SIG # define VL_SIG8(name, msb,lsb) CData name ///< Declare signal, 1-8 bits # define VL_SIG16(name, msb,lsb) SData name ///< Declare signal, 9-16 bits diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index e6673eae0..045b052ef 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -2762,6 +2762,7 @@ private: bool m_formCallTree:1; // Make a global function to call entire tree of functions bool m_slow:1; // Slow routine, called once or just at init time bool m_funcPublic:1; // From user public task/function + bool m_isStatic:1; // Function is declared static (no this) public: AstCFunc(FileLine* fl, const string& name, AstScope* scopep, const string& rtnType="") : AstNode(fl) { @@ -2775,6 +2776,7 @@ public: m_formCallTree = false; m_slow = false; m_funcPublic = false; + m_isStatic = false; } virtual ~AstCFunc() {} virtual AstType type() const { return AstType::CFUNC;} @@ -2804,6 +2806,8 @@ public: string argTypes() const { return m_argTypes; } void funcType(AstCFuncType flag) { m_funcType = flag; } AstCFuncType funcType() const { return m_funcType; } + bool isStatic() const { return m_isStatic; } + void isStatic(bool flag) { m_isStatic = flag; } // // If adding node accessors, see below AstNode* argsp() const { return op1p()->castNode(); } diff --git a/src/V3EmitC.cpp b/src/V3EmitC.cpp index 984511e6d..edc2e5231 100644 --- a/src/V3EmitC.cpp +++ b/src/V3EmitC.cpp @@ -733,16 +733,17 @@ void EmitCStmts::emitVarDecl(AstVar* nodep, const string& prefixIfImp) { // For example three VL_SIG8's needs alignment 1 but size 3. ofp()->putAlign(nodep->isStatic(), nodep->widthAlignBytes(), nodep->arrayElements()*nodep->widthAlignBytes()); if (nodep->isStatic() && prefixIfImp=="") puts("static "); + if (nodep->isStatic()) puts("VL_ST_"); else puts("VL_"); if (nodep->widthMin() <= 8) { - puts("VL_SIG8("); + puts("SIG8("); } else if (nodep->widthMin() <= 16) { - puts("VL_SIG16("); + puts("SIG16("); } else if (nodep->isQuad()) { - puts("VL_SIG64("); + puts("SIG64("); } else if (!nodep->isWide()) { - puts("VL_SIG("); + puts("SIG("); } else { - puts("VL_SIGW("); + puts("SIGW("); } if (prefixIfImp!="") { puts(prefixIfImp); puts("::"); } puts(nodep->name()); @@ -1298,6 +1299,7 @@ void EmitCImp::emitIntFuncDecls(AstModule* modp) { for (vector<AstCFunc*>::iterator it = funcsp.begin(); it != funcsp.end(); ++it) { AstCFunc* funcp = *it; ofp()->putsPrivate(funcp->declPrivate()); + if (funcp->isStatic()) puts("static "); puts(funcp->rtnTypeVoid()); puts("\t"); puts(funcp->name()); puts("("+cFuncArgs(funcp)+");\n"); }