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
|
|
|
//
|
|
|
|
//*************************************************************************
|
|
|
|
//
|
2019-01-04 00:17:22 +00:00
|
|
|
// Copyright 2003-2019 by Wilson Snyder. This program is free software; you can
|
2007-11-30 22:38:21 +00:00
|
|
|
// 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.
|
2007-11-30 22:38:21 +00:00
|
|
|
//
|
|
|
|
// Verilator is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
//*************************************************************************
|
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
|
|
|
|
void emitInt();
|
|
|
|
|
|
|
|
// VISITORS
|
2016-11-27 13:11:38 +00:00
|
|
|
virtual void visit(AstBasicDType* nodep) {
|
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
|
|
|
}
|
2019-12-01 16:52:48 +00:00
|
|
|
virtual void visit(AstAssocArrayDType* nodep) {
|
|
|
|
v3Global.needHeavy(true);
|
|
|
|
iterateChildren(nodep);
|
|
|
|
}
|
2019-12-01 17:35:49 +00:00
|
|
|
virtual void visit(AstQueueDType* nodep) {
|
|
|
|
v3Global.needHeavy(true);
|
|
|
|
iterateChildren(nodep);
|
|
|
|
}
|
2019-02-15 23:33:52 +00:00
|
|
|
virtual void visit(AstValuePlusArgs* nodep) {
|
|
|
|
v3Global.needHeavy(true);
|
|
|
|
iterateChildren(nodep);
|
|
|
|
}
|
2019-12-10 00:17:52 +00:00
|
|
|
virtual void visit(AstAtoN* nodep) {
|
|
|
|
v3Global.needHeavy(true);
|
|
|
|
iterateChildren(nodep);
|
|
|
|
}
|
|
|
|
virtual void visit(AstCompareNN* nodep) {
|
|
|
|
v3Global.needHeavy(true);
|
|
|
|
iterateChildren(nodep);
|
|
|
|
}
|
2007-11-30 22:38:21 +00:00
|
|
|
|
|
|
|
// Default
|
2016-11-27 13:11:38 +00:00
|
|
|
virtual void visit(AstNode* nodep) {
|
2018-05-11 00:55:37 +00:00
|
|
|
iterateChildren(nodep);
|
2007-11-30 22:38:21 +00:00
|
|
|
}
|
|
|
|
//---------------------------------------
|
|
|
|
// ACCESSORS
|
|
|
|
public:
|
2015-10-04 02:33:06 +00:00
|
|
|
explicit EmitCInlines(AstNetlist* nodep) {
|
2018-05-11 00:55:37 +00:00
|
|
|
iterate(nodep);
|
2018-10-27 14:03:28 +00:00
|
|
|
if (v3Global.needHInlines()) {
|
|
|
|
emitInt();
|
|
|
|
}
|
2007-11-30 22:38:21 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void EmitCInlines::emitInt() {
|
|
|
|
string filename = v3Global.opt.makeDir()+"/"+topClassName()+"__Inlines.h";
|
|
|
|
newCFile(filename, false/*slow*/, false/*source*/);
|
|
|
|
V3OutCFile hf (filename);
|
|
|
|
m_ofp = &hf;
|
|
|
|
|
|
|
|
ofp()->putsHeader();
|
|
|
|
puts("#ifndef _"+topClassName()+"__Inlines_H_\n");
|
|
|
|
puts("#define _"+topClassName()+"__Inlines_H_\n");
|
|
|
|
puts("\n");
|
|
|
|
|
|
|
|
puts("#include \"verilated.h\"\n");
|
|
|
|
|
|
|
|
puts("\n//======================\n\n");
|
|
|
|
|
2017-09-19 01:36:18 +00:00
|
|
|
// Placeholder - v3Global.needHInlines(true) currently not used
|
2007-11-30 22:38:21 +00:00
|
|
|
|
|
|
|
puts("//======================\n\n");
|
2019-05-19 20:13:13 +00:00
|
|
|
puts("#endif // guard\n");
|
2007-11-30 22:38:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//######################################################################
|
|
|
|
// EmitC class functions
|
|
|
|
|
|
|
|
void V3EmitC::emitcInlines() {
|
|
|
|
UINFO(2,__FUNCTION__<<": "<<endl);
|
|
|
|
EmitCInlines syms (v3Global.rootp());
|
|
|
|
}
|