Configure now enables SystemC if it is installed as a system headers.

This commit is contained in:
Wilson Snyder 2020-05-28 18:51:46 -04:00
parent 773ed97504
commit 279f21bb5b
9 changed files with 58 additions and 22 deletions

View File

@ -8,6 +8,9 @@ The contributors that suggested a given feature are shown in []. Thanks!
** OPT_FAST is now -Os by default. See the BENCHMARKING & OPTIMIZATION part
of the manual if you experience issues with compilation speed.
*** Configure now enables SystemC if it is installed as a system headers,
e.g. with 'apt-get install systemc-dev'.
*** Add --waiver-output flag that writes a verilator config file (.vlt) with
waivers to the warnings emitted during a Verilator run.

View File

@ -442,6 +442,20 @@ AC_CHECK_MEMBER([struct stat.st_mtim.tv_nsec],
[AC_DEFINE([HAVE_STAT_NSEC],[1],[Defined if struct stat has st_mtim.tv_nsec])],
[], [#include <sys/stat.h>])
# HAVE_SYSTEMC
# - If found the default search path has it, so support is always enabled.
# - If not found or not system-wide, user can set SYSTEMC_INCLUDE.
# AC_CHECK_HEADERS seems to not locate on Travis-CI but include does work.
AC_MSG_CHECKING([whether SystemC is found (in system path)])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#include <systemc.h>
]],[])],
[_my_result=yes
AC_DEFINE([HAVE_SYSTEMC_H],[1],[Defined if have systemc.h])],
[_my_result=no])
AC_MSG_RESULT($_my_result)
AC_SUBST(HAVE_SYSTEMC_H)
# Checks for system services
# Other install directories

View File

@ -37,8 +37,8 @@ endif
# If you build your own rules from scratch, note you need to include
# SystemC as follows (Vtop.mk file includes verilated.mk with these
# already).
# CPPFLAGS += $(SYSTEMC_CXX_FLAGS) -I$(SYSTEMC_INCLUDE)
# LDFLAGS += $(SYSTEMC_CXX_FLAGS) -L$(SYSTEMC_LIBDIR)
# CPPFLAGS += $(SYSTEMC_CXX_FLAGS) $(addprefix -I, $(SYSTEMC_INCLUDE))
# LDFLAGS += $(SYSTEMC_CXX_FLAGS) $(addprefix -L, $(SYSTEMC_LIBDIR))
# See the benchmarking section of bin/verilator.
# Support class optimizations. This includes the tracing and symbol table.

View File

@ -105,8 +105,8 @@ OPT_GLOBAL = -Os
##### SystemC builds
ifeq ($(VM_SC),1)
CPPFLAGS += $(SYSTEMC_CXX_FLAGS) -I$(SYSTEMC_INCLUDE)
LDFLAGS += $(SYSTEMC_CXX_FLAGS) -L$(SYSTEMC_LIBDIR)
CPPFLAGS += $(SYSTEMC_CXX_FLAGS) $(addprefix -I, $(SYSTEMC_INCLUDE))
LDFLAGS += $(SYSTEMC_CXX_FLAGS) $(addprefix -L, $(SYSTEMC_LIBDIR))
SC_LIBS = -lsystemc
ifneq ($(wildcard $(SYSTEMC_LIBDIR)/*numeric_bit*),)
# Systemc 1.2.1beta

View File

@ -160,6 +160,13 @@ public:
of.puts("# SystemC library directory with libsystemc.a (from $SYSTEMC_LIBDIR)\n");
of.puts(string("SYSTEMC_LIBDIR ?= ") + V3Options::getenvSYSTEMC_LIBDIR() + "\n");
// Only check it if we really need the value
if (v3Global.opt.usingSystemCLibs() && !V3Options::systemCFound()) {
v3fatal("Need $SYSTEMC_INCLUDE in environment or when Verilator configured,\n"
"and need $SYSTEMC_LIBDIR in environment or when Verilator configured\n"
"Probably System-C isn't installed, see http://www.systemc.org\n");
}
of.puts("\n### Switches...\n");
of.puts("# SystemC output mode? 0/1 (from --sc)\n");
of.puts(string("VM_SC = ") + ((v3Global.opt.systemC()) ? "1" : "0") + "\n");
@ -234,7 +241,7 @@ public:
of.puts("\n### Link rules... (from --exe)\n");
of.puts(v3Global.opt.exeName()
+ ": $(VK_USER_OBJS) $(VK_GLOBAL_OBJS) $(VM_PREFIX)__ALL.a\n");
of.puts("\t$(LINK) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) -o $@ $(LIBS) $(SC_LIBS)\n");
of.puts("\t$(LINK) $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS) $(LIBS) $(SC_LIBS) -o $@\n");
of.puts("\n");
}

View File

@ -540,13 +540,6 @@ string V3Options::getenvSYSTEMC_INCLUDE() {
string sc = getenvSYSTEMC();
if (sc != "") var = sc + "/include";
}
// Only correct or check it if we really need the value
if (v3Global.opt.usingSystemCLibs()) {
if (var == "") {
v3fatal("Need $SYSTEMC_INCLUDE in environment or when Verilator configured\n"
"Probably System-C isn't installed, see http://www.systemc.org\n");
}
}
return var;
}
@ -561,13 +554,6 @@ string V3Options::getenvSYSTEMC_LIBDIR() {
string arch = getenvSYSTEMC_ARCH();
if (sc != "" && arch != "") var = sc + "/lib-" + arch;
}
// Only correct or check it if we really need the value
if (v3Global.opt.usingSystemCLibs()) {
if (var == "") {
v3fatal("Need $SYSTEMC_LIBDIR in environment or when Verilator configured\n"
"Probably System-C isn't installed, see http://www.systemc.org\n");
}
}
return var;
}
@ -581,6 +567,19 @@ string V3Options::getenvVERILATOR_ROOT() {
return var;
}
bool V3Options::systemCSystemWide() {
#ifdef HAVE_SYSTEMC_H
return true;
#else
return false;
#endif
}
bool V3Options::systemCFound() {
return (systemCSystemWide()
|| (!getenvSYSTEMC_INCLUDE().empty() && !getenvSYSTEMC_LIBDIR().empty()));
}
//######################################################################
// V3 Options notification methods
@ -1514,6 +1513,7 @@ void V3Options::showVersion(bool verbose) {
cout << " SYSTEMC_INCLUDE = " << DEFENV_SYSTEMC_INCLUDE << endl;
cout << " SYSTEMC_LIBDIR = " << DEFENV_SYSTEMC_LIBDIR << endl;
cout << " VERILATOR_ROOT = " << DEFENV_VERILATOR_ROOT << endl;
cout << " SystemC system-wide = " << cvtToStr(systemCSystemWide()) << endl;
cout << endl;
cout << "Environment:\n";
@ -1526,6 +1526,10 @@ void V3Options::showVersion(bool verbose) {
cout << " VERILATOR_ROOT = " << V3Os::getenvStr("VERILATOR_ROOT", "") << endl;
// wrapper uses this:
cout << " VERILATOR_BIN = " << V3Os::getenvStr("VERILATOR_BIN", "") << endl;
cout << endl;
cout << "Features (based on environment or compiled-in support):\n";
cout << " SystemC found = " << cvtToStr(systemCFound()) << endl;
}
//======================================================================

View File

@ -596,6 +596,8 @@ public:
static string getenvSYSTEMC_INCLUDE();
static string getenvSYSTEMC_LIBDIR();
static string getenvVERILATOR_ROOT();
static bool systemCSystemWide();
static bool systemCFound(); // SystemC installed, or environment points to it
// METHODS (file utilities using these options)
string fileExists(const string& filename);

View File

@ -77,6 +77,10 @@ using std::make_pair;
// Define if struct stat has st_mtim.tv_nsec (from configure)
#undef HAVE_STAT_NSEC
// Define if SystemC found
// - If defined, the default search path has it, so support is always enabled.
// - If undef, not system-wide, user can set SYSTEMC_INCLUDE.
#undef HAVE_SYSTEMC_H
//**********************************************************************
//**** OS and compiler specifics

View File

@ -1413,8 +1413,9 @@ sub sc {
}
sub have_sc {
#my $self = shift;
return 1 if (defined $ENV{SYSTEMC} || defined $ENV{SYSTEMC_INCLUDE});
my $self = (ref $_[0]? shift : $Self);
return 1 if (defined $ENV{SYSTEMC} || defined $ENV{SYSTEMC_INCLUDE} || $ENV{CFG_HAVE_SYSTEMC});
return 1 if $self->verilator_version =~ /systemc found *= *1/i;
return 0;
}
@ -2030,8 +2031,9 @@ sub _read_inputs_vhdl {
our $_Verilator_Version;
sub verilator_version {
# Returns verbose version, line 1 contains actual version
if (!defined $_Verilator_Version) {
my @args = ("perl", "$ENV{VERILATOR_ROOT}/bin/verilator", "--version");
my @args = ("perl", "$ENV{VERILATOR_ROOT}/bin/verilator", "-V");
my $args = join(' ',@args);
$_Verilator_Version = `$args`;
$_Verilator_Version or die "can't fork: $! ".join(' ',@args);