2012-04-13 01:08:20 +00:00
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
2006-08-26 11:35:28 +00:00
|
|
|
//*************************************************************************
|
|
|
|
// DESCRIPTION: Verilator: Common headers
|
|
|
|
//
|
2019-11-08 03:33:59 +00:00
|
|
|
// Code available from: https://verilator.org
|
2006-08-26 11:35:28 +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
|
2006-08-26 11:35:28 +00:00
|
|
|
//
|
|
|
|
//*************************************************************************
|
2019-10-05 00:17:11 +00:00
|
|
|
|
2006-08-26 11:35:28 +00:00
|
|
|
#ifndef _V3GLOBAL_H_
|
|
|
|
#define _V3GLOBAL_H_ 1
|
|
|
|
|
2006-12-18 19:20:45 +00:00
|
|
|
#include "config_build.h"
|
2018-06-28 22:55:36 +00:00
|
|
|
#ifndef HAVE_CONFIG_BUILD
|
2018-07-02 13:11:20 +00:00
|
|
|
# error "Something failed during ./configure as config_build.h is incomplete. Perhaps you used autoreconf, don't."
|
2018-06-28 22:55:36 +00:00
|
|
|
#endif
|
|
|
|
|
2006-12-18 19:20:45 +00:00
|
|
|
#include "verilatedos.h"
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
|
|
#include "V3Error.h"
|
2014-11-22 16:48:39 +00:00
|
|
|
#include "V3FileLine.h"
|
2006-08-26 11:35:28 +00:00
|
|
|
#include "V3Options.h"
|
2011-11-30 03:09:50 +00:00
|
|
|
|
2018-10-14 17:43:24 +00:00
|
|
|
#include <string>
|
|
|
|
|
2011-11-30 03:09:50 +00:00
|
|
|
class AstNetlist;
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
|
|
//======================================================================
|
|
|
|
// Statics
|
|
|
|
|
|
|
|
|
|
|
|
//######################################################################
|
2015-05-15 01:46:07 +00:00
|
|
|
|
|
|
|
class VWidthMinUsage {
|
|
|
|
public:
|
|
|
|
enum en {
|
2019-05-19 20:13:13 +00:00
|
|
|
LINT_WIDTH,
|
|
|
|
MATCHES_WIDTH,
|
|
|
|
VERILOG_WIDTH
|
2015-05-15 01:46:07 +00:00
|
|
|
};
|
|
|
|
enum en m_e;
|
2018-08-25 13:52:45 +00:00
|
|
|
inline VWidthMinUsage() : m_e(LINT_WIDTH) {}
|
2015-10-04 02:33:06 +00:00
|
|
|
// cppcheck-suppress noExplicitConstructor
|
2018-08-25 13:52:45 +00:00
|
|
|
inline VWidthMinUsage(en _e) : m_e(_e) {}
|
|
|
|
explicit inline VWidthMinUsage(int _e) : m_e(static_cast<en>(_e)) {}
|
|
|
|
operator en() const { return m_e; }
|
2020-02-02 15:34:29 +00:00
|
|
|
};
|
|
|
|
inline bool operator==(const VWidthMinUsage& lhs, const VWidthMinUsage& rhs) {
|
|
|
|
return lhs.m_e == rhs.m_e;
|
|
|
|
}
|
|
|
|
inline bool operator==(const VWidthMinUsage& lhs, VWidthMinUsage::en rhs) {
|
|
|
|
return lhs.m_e == rhs;
|
|
|
|
}
|
|
|
|
inline bool operator==(VWidthMinUsage::en lhs, const VWidthMinUsage& rhs) {
|
|
|
|
return lhs == rhs.m_e;
|
|
|
|
}
|
2015-05-15 01:46:07 +00:00
|
|
|
|
|
|
|
//######################################################################
|
|
|
|
// V3Global - The top level class for the entire program
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
|
|
class V3Global {
|
|
|
|
// Globals
|
2020-03-02 02:39:23 +00:00
|
|
|
AstNetlist* m_rootp; // Root of entire netlist
|
|
|
|
VWidthMinUsage m_widthMinUsage; // What AstNode::widthMin() is used for
|
2012-02-02 01:20:43 +00:00
|
|
|
|
2020-03-02 02:39:23 +00:00
|
|
|
int m_debugFileNumber; // Number to append to debug files created
|
|
|
|
bool m_assertDTypesResolved; // Tree should have dtypep()'s
|
|
|
|
bool m_constRemoveXs; // Const needs to strip any Xs
|
|
|
|
bool m_needTraceDumper; // Need __Vm_dumperp in symbols
|
|
|
|
bool m_needHInlines; // Need __Inlines file
|
|
|
|
bool m_needHeavy; // Need verilated_heavy.h include
|
|
|
|
bool m_dpi; // Need __Dpi include files
|
2007-11-30 22:38:21 +00:00
|
|
|
|
2006-08-26 11:35:28 +00:00
|
|
|
public:
|
2007-11-30 22:38:21 +00:00
|
|
|
// Options
|
2019-05-19 20:13:13 +00:00
|
|
|
V3Options opt; // All options; let user see them directly
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
|
|
public:
|
2017-11-01 22:51:41 +00:00
|
|
|
// CONSTRUCTORS
|
2006-08-26 11:35:28 +00:00
|
|
|
V3Global() {
|
2019-05-19 20:13:13 +00:00
|
|
|
m_debugFileNumber = 0;
|
|
|
|
m_widthMinUsage = VWidthMinUsage::LINT_WIDTH;
|
|
|
|
m_assertDTypesResolved = false;
|
|
|
|
m_constRemoveXs = false;
|
2020-03-02 02:39:23 +00:00
|
|
|
m_needTraceDumper = false;
|
2019-05-19 20:13:13 +00:00
|
|
|
m_needHInlines = false;
|
|
|
|
m_needHeavy = false;
|
|
|
|
m_dpi = false;
|
|
|
|
m_rootp = NULL; // created by makeInitNetlist() so static constructors run first
|
2006-08-26 11:35:28 +00:00
|
|
|
}
|
2011-11-30 03:09:50 +00:00
|
|
|
AstNetlist* makeNetlist();
|
2012-05-30 02:59:17 +00:00
|
|
|
void boot() { UASSERT(!m_rootp,"call once"); m_rootp = makeNetlist(); }
|
2011-11-30 03:09:50 +00:00
|
|
|
void clear();
|
2006-08-26 11:35:28 +00:00
|
|
|
// ACCESSORS (general)
|
|
|
|
AstNetlist* rootp() const { return m_rootp; }
|
2015-05-15 01:46:07 +00:00
|
|
|
VWidthMinUsage widthMinUsage() const { return m_widthMinUsage; }
|
2011-11-30 03:36:51 +00:00
|
|
|
bool assertDTypesResolved() const { return m_assertDTypesResolved; }
|
2006-08-26 11:35:28 +00:00
|
|
|
|
|
|
|
// METHODS
|
|
|
|
void readFiles();
|
2011-11-30 03:09:50 +00:00
|
|
|
void checkTree();
|
2017-09-18 02:52:57 +00:00
|
|
|
static void dumpCheckGlobalTree(const string& stagename, int newNumber=0, bool doDump=true);
|
2011-11-30 03:36:51 +00:00
|
|
|
void assertDTypesResolved(bool flag) { m_assertDTypesResolved = flag; }
|
2015-05-15 01:46:07 +00:00
|
|
|
void widthMinUsage(const VWidthMinUsage& flag) { m_widthMinUsage = flag; }
|
2014-06-10 02:27:04 +00:00
|
|
|
bool constRemoveXs() const { return m_constRemoveXs; }
|
|
|
|
void constRemoveXs(bool flag) { m_constRemoveXs = flag; }
|
2006-08-26 11:35:28 +00:00
|
|
|
string debugFilename(const string& nameComment, int newNumber=0) {
|
2019-05-19 20:13:13 +00:00
|
|
|
++m_debugFileNumber;
|
|
|
|
if (newNumber) m_debugFileNumber = newNumber;
|
|
|
|
char digits[100]; sprintf(digits, "%03d", m_debugFileNumber);
|
|
|
|
return opt.makeDir()+"/"+opt.prefix()+"_"+digits+"_"+nameComment;
|
2006-08-26 11:35:28 +00:00
|
|
|
}
|
2020-03-02 02:39:23 +00:00
|
|
|
bool needTraceDumper() const { return m_needTraceDumper; }
|
|
|
|
void needTraceDumper(bool flag) { m_needTraceDumper = flag; }
|
2007-11-30 22:38:21 +00:00
|
|
|
bool needHInlines() const { return m_needHInlines; }
|
2020-03-02 02:39:23 +00:00
|
|
|
void needHInlines(bool flag) { m_needHInlines = flag; }
|
2010-01-17 20:10:37 +00:00
|
|
|
bool needHeavy() const { return m_needHeavy; }
|
2020-03-02 02:39:23 +00:00
|
|
|
void needHeavy(bool flag) { m_needHeavy = flag; }
|
2009-12-03 11:55:29 +00:00
|
|
|
bool dpi() const { return m_dpi; }
|
|
|
|
void dpi(bool flag) { m_dpi = flag; }
|
2006-08-26 11:35:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern V3Global v3Global;
|
|
|
|
|
|
|
|
//######################################################################
|
|
|
|
|
2019-05-13 23:47:52 +00:00
|
|
|
#endif // guard
|