diff --git a/src/V3Ast.h b/src/V3Ast.h index 6ae97f107..36448ff51 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -140,8 +140,9 @@ public: : m_e(static_cast(_e)) {} // Need () or GCC 4.8 false warning operator en() const { return m_e; } VAccess invert() const { return (m_e == WRITE) ? VAccess(READ) : VAccess(WRITE); } - bool isRead() const { return m_e == READ; } - bool isWrite() const { return m_e == WRITE; } + bool isReadOnly() const { return m_e == READ; } // False if/when support READWRITE + bool isWrite() const { return m_e == WRITE; } // Need audit if/when support READWRITE + bool isWriteOnly() const { return m_e == WRITE; } // False if/when support READWRITE }; inline bool operator==(const VAccess& lhs, const VAccess& rhs) { return lhs.m_e == rhs.m_e; } inline bool operator==(const VAccess& lhs, VAccess::en rhs) { return lhs.m_e == rhs; } diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 34b3af025..e3038b17c 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -2360,7 +2360,7 @@ public: } } virtual int instrCount() const override { - return widthInstrs() * (access().isWrite() ? 1 : instrCountLd()); + return widthInstrs() * (access().isWriteOnly() ? 1 : instrCountLd()); } virtual string emitVerilog() override { V3ERROR_NA_RETURN(""); } virtual string emitC() override { V3ERROR_NA_RETURN(""); } diff --git a/src/V3Cast.cpp b/src/V3Cast.cpp index 1f0fb7d86..2a8173978 100644 --- a/src/V3Cast.cpp +++ b/src/V3Cast.cpp @@ -154,7 +154,7 @@ private: } } virtual void visit(AstVarRef* nodep) override { - if (nodep->access().isRead() && !VN_IS(nodep->backp(), CCast) + if (nodep->access().isReadOnly() && !VN_IS(nodep->backp(), CCast) && VN_IS(nodep->backp(), NodeMath) && !VN_IS(nodep->backp(), ArraySel) && nodep->backp()->width() && castSize(nodep) != castSize(nodep->varp())) { // Cast vars to IData first, else below has upper bits wrongly set diff --git a/src/V3Const.cpp b/src/V3Const.cpp index bfadcab72..6ef289e86 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -1605,7 +1605,7 @@ private: // if (debug()) valuep->dumpTree(cout, " visitvaref: "); iterateAndNextNull(nodep->varp()->valuep()); // May change nodep->varp()->valuep() AstNode* valuep = nodep->varp()->valuep(); - if (!nodep->access().isWrite() + if (nodep->access().isReadOnly() && ((!m_params // Can reduce constant wires into equations && m_doNConst && v3Global.opt.oConst() diff --git a/src/V3Gate.cpp b/src/V3Gate.cpp index 3bf82c08c..92fb406f8 100644 --- a/src/V3Gate.cpp +++ b/src/V3Gate.cpp @@ -842,7 +842,7 @@ private: // It's possible we substitute into something that will be reduced more later, // however, as we never delete the top Always/initial statement, all should be well. m_didReplace = true; - UASSERT_OBJ(!nodep->access().isWrite(), nodep, + UASSERT_OBJ(nodep->access().isReadOnly(), nodep, "Can't replace lvalue assignments with const var"); AstNode* substp = m_replaceTreep->cloneTree(false); UASSERT_OBJ( diff --git a/src/V3Simulate.h b/src/V3Simulate.h index b8baebd4d..84bf595ef 100644 --- a/src/V3Simulate.h +++ b/src/V3Simulate.h @@ -433,7 +433,7 @@ private: } } if (!m_checkOnly && optimizable()) { // simulating - UASSERT_OBJ(!nodep->access().isWrite(), nodep, + UASSERT_OBJ(nodep->access().isReadOnly(), nodep, "LHS varref should be handled in AstAssign visitor."); { // Return simulation value - copy by reference instead of value for speed diff --git a/src/V3Subst.cpp b/src/V3Subst.cpp index 636d39986..33f554067 100644 --- a/src/V3Subst.cpp +++ b/src/V3Subst.cpp @@ -306,7 +306,7 @@ private: iterate(nodep->rhsp()); AstVarRef* varrefp = VN_CAST(nodep->lhsp(), VarRef); AstConst* constp = VN_CAST(nodep->rhsp(), Const); - if (varrefp && isSubstVar(varrefp->varp()) && !varrefp->access().isWrite() && constp) { + if (varrefp && isSubstVar(varrefp->varp()) && varrefp->access().isReadOnly() && constp) { // Nicely formed lvalues handled in NodeAssign // Other lvalues handled as unknown mess in AstVarRef int word = constp->toUInt(); diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index 3b983055b..b517e5bdc 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -845,7 +845,7 @@ private: virtual void visit(AstVarRef* nodep) override { if (m_tracep) { UASSERT_OBJ(nodep->varScopep(), nodep, "No var scope?"); - UASSERT_OBJ(!nodep->access().isWrite(), nodep, "Lvalue in trace? Should be const."); + UASSERT_OBJ(nodep->access().isReadOnly(), nodep, "Lvalue in trace? Should be const."); V3GraphVertex* varVtxp = nodep->varScopep()->user1u().toGraphVertex(); if (!varVtxp) { varVtxp = new TraceVarVertex(&m_graph, nodep->varScopep()); diff --git a/src/V3WidthSel.cpp b/src/V3WidthSel.cpp index 8e3b09316..c3232066d 100644 --- a/src/V3WidthSel.cpp +++ b/src/V3WidthSel.cpp @@ -280,10 +280,10 @@ private: "Unsupported: String array operation on non-variable"); } AstNode* newp; - if (varrefp && varrefp->access().isWrite()) { - newp = new AstGetcRefN(nodep->fileline(), fromp, rhsp); - } else { + if (varrefp && varrefp->access().isReadOnly()) { newp = new AstGetcN(nodep->fileline(), fromp, rhsp); + } else { + newp = new AstGetcRefN(nodep->fileline(), fromp, rhsp); } UINFO(6, " new " << newp << endl); nodep->replaceWith(newp);