Beispiel #1
0
 bool canSimulate(AstNode *nodep) {
     SimulateVisitor simvis;
     AstNode* clonep = nodep->cloneTree(true);
     simvis.mainCheckTree(clonep);
     pushDeletep(clonep); clonep = NULL;
     return simvis.optimizable();
 }
Beispiel #2
0
    bool simulateTree(AstNode *nodep, const V3Number *loopValue, AstNode *dtypep, V3Number &outNum) {
	AstNode* clone = nodep->cloneTree(true);
	if (!clone) {
	    nodep->v3fatalSrc("Failed to clone tree");
	    return false;
	}
	if (loopValue) {
	    m_varValuep = new AstConst (nodep->fileline(), *loopValue);
	    // Iteration requires a back, so put under temporary node
	    AstBegin* tempp = new AstBegin (nodep->fileline(), "[EditWrapper]", clone);
	    m_varModeReplace = true;
	    tempp->stmtsp()->iterateAndNext(*this);
	    m_varModeReplace = false;
	    clone = tempp->stmtsp()->unlinkFrBackWithNext();
	    tempp->deleteTree();
	    tempp = NULL;
	    pushDeletep(m_varValuep); m_varValuep = NULL;
	}
	SimulateVisitor simvis;
	simvis.mainParamEmulate(clone);
	if (!simvis.optimizable()) {
	    UINFO(3, "Unable to simulate" << endl);
	    if (debug()>=9) nodep->dumpTree(cout,"- _simtree: ");
	    return false;
	}
	// Fetch the result
	V3Number* res = simvis.fetchNumberNull(clone);
	if (!res) {
	    UINFO(3, "No number returned from simulation" << endl);
	    return false;
	}
	// Patch up datatype
	if (dtypep) {
	    AstConst new_con (clone->fileline(), *res);
	    new_con.dtypeFrom(dtypep);
	    outNum = new_con.num();
	    return true;
	}
	outNum = *res;
	return true;
    }
Beispiel #3
0
    bool canSimulate(AstNode *nodep) {
	SimulateVisitor simvis;
	AstNode* clone = nodep->cloneTree(true);
	simvis.mainCheckTree(clone);
	return simvis.optimizable();
    }