2012-04-13 01:08:20 +00:00
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
2007-11-30 22:38:21 +00:00
|
|
|
//*************************************************************************
|
|
|
|
// DESCRIPTION: Verilator: Emit C++ for tree
|
|
|
|
//
|
2019-11-08 03:33:59 +00:00
|
|
|
// Code available from: https://verilator.org
|
2007-11-30 22:38:21 +00:00
|
|
|
//
|
|
|
|
//*************************************************************************
|
|
|
|
//
|
2020-03-21 15:24:24 +00:00
|
|
|
// Copyright 2003-2020 by Wilson Snyder. This program is free software; you
|
|
|
|
// can redistribute it and/or modify it under the terms of either the GNU
|
2009-05-04 21:07:57 +00:00
|
|
|
// Lesser General Public License Version 3 or the Perl Artistic License
|
|
|
|
// Version 2.0.
|
2020-03-21 15:24:24 +00:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
2007-11-30 22:38:21 +00:00
|
|
|
//
|
|
|
|
//*************************************************************************
|
2019-10-05 00:17:11 +00:00
|
|
|
|
2007-11-30 22:38:21 +00:00
|
|
|
#include "config_build.h"
|
|
|
|
#include "verilatedos.h"
|
|
|
|
|
|
|
|
#include "V3Global.h"
|
|
|
|
#include "V3EmitC.h"
|
|
|
|
#include "V3EmitCBase.h"
|
|
|
|
#include "V3Stats.h"
|
|
|
|
|
2018-10-14 17:43:24 +00:00
|
|
|
#include <cmath>
|
|
|
|
#include <cstdarg>
|
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
|
|
|
|
2007-11-30 22:38:21 +00:00
|
|
|
//######################################################################
|
|
|
|
|
|
|
|
class EmitCInlines : EmitCBaseVisitor {
|
|
|
|
// STATE
|
|
|
|
|
|
|
|
// METHODS
|
|
|
|
|
|
|
|
// VISITORS
|
2020-01-21 22:35:56 +00:00
|
|
|
virtual void visit(AstBasicDType* nodep) VL_OVERRIDE {
|
2018-10-27 14:03:28 +00:00
|
|
|
if (nodep->keyword() == AstBasicDTypeKwd::STRING) {
|
|
|
|
// Request #include <string> via verilated_heavy.h when we create symbol file
|
|
|
|
v3Global.needHeavy(true);
|
|
|
|
}
|
2010-01-17 20:10:37 +00:00
|
|
|
}
|
2020-01-21 22:35:56 +00:00
|
|
|
virtual void visit(AstAssocArrayDType* nodep) VL_OVERRIDE {
|
2019-12-01 16:52:48 +00:00
|
|
|
v3Global.needHeavy(true);
|
|
|
|
iterateChildren(nodep);
|
|
|
|
}
|
2020-04-05 13:30:23 +00:00
|
|
|
virtual void visit(AstClass* nodep) VL_OVERRIDE {
|
|
|
|
v3Global.needC11(true);
|
|
|
|
v3Global.needHeavy(true);
|
|
|
|
iterateChildren(nodep);
|
|
|
|
}
|
2020-03-07 15:24:27 +00:00
|
|
|
virtual void visit(AstDynArrayDType* nodep) VL_OVERRIDE {
|
|
|
|
v3Global.needHeavy(true);
|
|
|
|
iterateChildren(nodep);
|
|
|
|
}
|
2020-01-21 22:35:56 +00:00
|
|
|
virtual void visit(AstQueueDType* nodep) VL_OVERRIDE {
|
2019-12-01 17:35:49 +00:00
|
|
|
v3Global.needHeavy(true);
|
|
|
|
iterateChildren(nodep);
|
|
|
|
}
|
2020-01-21 22:35:56 +00:00
|
|
|
virtual void visit(AstNodeReadWriteMem* nodep) VL_OVERRIDE {
|
2020-01-14 12:01:17 +00:00
|
|
|
v3Global.needHeavy(true);
|
|
|
|
iterateChildren(nodep);
|
|
|
|
}
|
2020-01-21 22:35:56 +00:00
|
|
|
virtual void visit(AstValuePlusArgs* nodep) VL_OVERRIDE {
|
2019-02-15 23:33:52 +00:00
|
|
|
v3Global.needHeavy(true);
|
2020-03-06 03:33:31 +00:00
|
|
|
iterateChildren(nodep);
|
|
|
|
}
|
2020-04-12 22:57:12 +00:00
|
|
|
virtual void visit(AstCNew* nodep) VL_OVERRIDE {
|
2020-03-06 03:33:31 +00:00
|
|
|
if (v3Global.opt.savable()) v3error("Unsupported: --savable with dynamic new");
|
2019-02-15 23:33:52 +00:00
|
|
|
iterateChildren(nodep);
|
|
|
|
}
|
2020-01-21 22:35:56 +00:00
|
|
|
virtual void visit(AstAtoN* nodep) VL_OVERRIDE {
|
2019-12-10 00:17:52 +00:00
|
|
|
v3Global.needHeavy(true);
|
|
|
|
iterateChildren(nodep);
|
|
|
|
}
|
2020-03-02 02:39:23 +00:00
|
|
|
virtual void visit(AstDumpCtl* nodep) VL_OVERRIDE {
|
|
|
|
if (v3Global.opt.trace()) v3Global.needTraceDumper(true);
|
|
|
|
v3Global.needHeavy(true);
|
|
|
|
iterateChildren(nodep);
|
|
|
|
}
|
2020-01-21 22:35:56 +00:00
|
|
|
virtual void visit(AstPutcN* nodep) VL_OVERRIDE {
|
2019-12-15 13:09:52 +00:00
|
|
|
v3Global.needHeavy(true);
|
|
|
|
iterateChildren(nodep);
|
|
|
|
}
|
2020-01-21 22:35:56 +00:00
|
|
|
virtual void visit(AstGetcN* nodep) VL_OVERRIDE {
|
2019-12-15 13:09:52 +00:00
|
|
|
v3Global.needHeavy(true);
|
|
|
|
iterateChildren(nodep);
|
|
|
|
}
|
2020-01-26 21:38:22 +00:00
|
|
|
virtual void visit(AstGetcRefN* nodep) VL_OVERRIDE {
|
|
|
|
v3Global.needHeavy(true);
|
|
|
|
iterateChildren(nodep);
|
|
|
|
}
|
2020-01-21 22:35:56 +00:00
|
|
|
virtual void visit(AstSubstrN* nodep) VL_OVERRIDE {
|
2019-12-15 13:09:52 +00:00
|
|
|
v3Global.needHeavy(true);
|
|
|
|
iterateChildren(nodep);
|
|
|
|
}
|
2020-01-21 22:35:56 +00:00
|
|
|
virtual void visit(AstCompareNN* nodep) VL_OVERRIDE {
|
2019-12-10 00:17:52 +00:00
|
|
|
v3Global.needHeavy(true);
|
|
|
|
iterateChildren(nodep);
|
2020-05-14 22:03:00 +00:00
|
|
|
}
|
|
|
|
virtual void visit(AstFOpen* nodep) VL_OVERRIDE {
|
|
|
|
v3Global.needHeavy(true);
|
|
|
|
iterateChildren(nodep);
|
|
|
|
}
|
|
|
|
virtual void visit(AstFOpenMcd* nodep) VL_OVERRIDE {
|
|
|
|
v3Global.needHeavy(true);
|
|
|
|
iterateChildren(nodep);
|
2019-12-10 00:17:52 +00:00
|
|
|
}
|
2007-11-30 22:38:21 +00:00
|
|
|
|
|
|
|
//---------------------------------------
|
2020-04-04 12:31:14 +00:00
|
|
|
virtual void visit(AstNode* nodep) VL_OVERRIDE { iterateChildren(nodep); }
|
|
|
|
|
2007-11-30 22:38:21 +00:00
|
|
|
public:
|
2020-05-16 11:53:27 +00:00
|
|
|
explicit EmitCInlines(AstNetlist* nodep) { iterate(nodep); }
|
2007-11-30 22:38:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//######################################################################
|
|
|
|
// EmitC class functions
|
|
|
|
|
|
|
|
void V3EmitC::emitcInlines() {
|
2020-04-05 00:08:58 +00:00
|
|
|
UINFO(2, __FUNCTION__ << ": " << endl);
|
|
|
|
EmitCInlines(v3Global.rootp());
|
2007-11-30 22:38:21 +00:00
|
|
|
}
|