diff --git a/Changes b/Changes index 14e4a42aa..7993f6fe5 100644 --- a/Changes +++ b/Changes @@ -7,6 +7,8 @@ indicates the contributor was also the author of the fix; Thanks! *** Add --pins-bv option to use sc_bv for all ports. [Brian Small] +*** Add SYSTEMPERL_INCLUDE envvar to assist RPM builds. [Chitlesh Goorah] + **** Report errors when duplicate labels are used, bug72. [Vasu Kandadi] **** Fix the SC_MODULE name() to not include __PVT__. [Bob Fredieu] diff --git a/bin/verilator b/bin/verilator index 6fe20bd73..5eb6fb6d4 100755 --- a/bin/verilator +++ b/bin/verilator @@ -953,10 +953,18 @@ building the SystemC model. =item SYSTEMPERL -Specifies the directory containing the Verilog-Perl distribution kit. This -is used to find the Verilog-Perl library and include files. If not +Specifies the directory containing the SystemPerl distribution kit. This +is used to find the SystemPerl library and include files. If not specified, it will come from a default optionally specified at configure -time (before Verilator was compiled). +time (before Verilator was compiled). See also SYSTEMPERL_INCLUDE. + +=item SYSTEMPERL_INCLUDE + +Specifies the directory containing the Verilog-Perl include .cpp files, +from the src/ directory of the SystemPerl kit. If not specified, it will +be computed from the SYSTEMPERL environment variable if it is set, and if +SYSTEMPERL is not set SYSTEMPERL_INCLUDE will come from a default +optionally specified at configure time (before Verilator was compiled). =item VCS_HOME diff --git a/include/verilated.mk.in b/include/verilated.mk.in index a4e38a8b2..268806a3f 100644 --- a/include/verilated.mk.in +++ b/include/verilated.mk.in @@ -89,8 +89,8 @@ endif ##### SystemPerl builds ifeq ($(VM_SP),1) - CPPFLAGS += -I$(SYSTEMPERL)/src -DSYSTEMPERL - VPATH += $(SYSTEMPERL)/src + CPPFLAGS += -I$(SYSTEMPERL_INCLUDE) -DSYSTEMPERL + VPATH += $(SYSTEMPERL_INCLUDE) LIBS += -lm -lstdc++ VK_CLASSES_SP = $(addsuffix .sp, $(VM_CLASSES)) @@ -110,8 +110,8 @@ endif ifeq ($(VM_SC),1) LIBS += -lm -lstdc++ ifeq ($(VM_TRACE),1) - CPPFLAGS += -I$(SYSTEMPERL)/src - VPATH += $(SYSTEMPERL)/src + CPPFLAGS += -I$(SYSTEMPERL_INCLUDE) + VPATH += $(SYSTEMPERL_INCLUDE) endif endif @@ -121,8 +121,8 @@ endif ifeq ($(VM_PCLI),1) LIBS += -lm -lstdc++ ifeq ($(VM_TRACE),1) - CPPFLAGS += -I$(SYSTEMPERL)/src - VPATH += $(SYSTEMPERL)/src + CPPFLAGS += -I$(SYSTEMPERL_INCLUDE) + VPATH += $(SYSTEMPERL_INCLUDE) endif endif diff --git a/readme.texi b/readme.texi index 3c6dfdd62..7281163e9 100644 --- a/readme.texi +++ b/readme.texi @@ -116,8 +116,9 @@ If you will be using SystemC, download and install Verilog-Perl, If you will be using SystemC, download and install System-Perl, @url{http://search.cpan.org/search?module=SystemC::Netlist}. Note you'll need to set a @samp{SYSTEMPERL} environment variable to point -to the downloaded kit (not the installed files.) Also, make sure to -do a @code{make sc_patch}. +to the downloaded kit. Optionally also set @samp{SYSTEMPERL_INCLUDE} +to point to the installed headers. Also, make sure to do a @code{make +sc_patch}. @item @code{cd} to the Verilator directory containing this README. @@ -128,8 +129,8 @@ Type @samp{./configure} to configure Verilator for your system. If you are configuring Verilator to be part of a RPM or other distribution package system, you may want to use the --enable-defenv configure flag. This will take the current value of VERILATOR_ROOT, -SYSTEMC, SYSTEMC_ARCH, and SYSTEMPERL and build them as defaults into -the executable. +SYSTEMC, SYSTEMC_ARCH, SYSTEMPERL, and SYSTEMPERL_INCLUDE and build +them as defaults into the executable. @item Type @samp{make} to compile Verilator. diff --git a/src/Makefile_obj.in b/src/Makefile_obj.in index e0e542e74..64d454d32 100644 --- a/src/Makefile_obj.in +++ b/src/Makefile_obj.in @@ -81,12 +81,19 @@ CPPFLAGS += -W -Wall -Wno-unused-parameter -Wno-char-subscripts -Werror #CPPFLAGS += -pedantic-errors endif +ifneq ($(SYSTEMPERL),) # Intuit SYSTEMPERL_INCLUDE as it's new + SYSTEMPERL_INCLUDE ?= $(SYSTEMPERL)/src +#else if set, leave as-is. +#else if SYSTEMPERL="" don't set _INCLUDE so source will figure it out +endif + # Allow RPM builds to specify hardcoded data directories # To do this: ifeq ($(CFG_WITH_DEFENV),yes) CPPFLAGS += -DDEFENV_SYSTEMC=\"$(SYSTEMC)\" CPPFLAGS += -DDEFENV_SYSTEMC_ARCH=\"$(SYSTEMC_ARCH)\" CPPFLAGS += -DDEFENV_SYSTEMPERL=\"$(SYSTEMPERL)\" + CPPFLAGS += -DDEFENV_SYSTEMPERL_INCLUDE=\"$(SYSTEMPERL_INCLUDE)\" ifeq ($(VERILATOR_ROOT),) # Use what we're given, or intuit CPPFLAGS += -DDEFENV_VERILATOR_ROOT=\"$(pkgdatadir)\" else @@ -280,4 +287,3 @@ DEPS := $(wildcard *.d) ifneq ($(DEPS),) include $(DEPS) endif - diff --git a/src/V3EmitMk.cpp b/src/V3EmitMk.cpp index f4ffd0d0a..05af41c40 100644 --- a/src/V3EmitMk.cpp +++ b/src/V3EmitMk.cpp @@ -87,6 +87,7 @@ public: of.puts("PERL = "+V3Options::getenvPERL()+"\n"); of.puts("VERILATOR_ROOT = "+V3Options::getenvVERILATOR_ROOT()+"\n"); of.puts("SYSTEMPERL = "+V3Options::getenvSYSTEMPERL()+"\n"); + of.puts("SYSTEMPERL_INCLUDE = "+V3Options::getenvSYSTEMPERL_INCLUDE()+"\n"); of.puts("\n# Switches...\n"); of.puts(string("VM_SP = ")+(v3Global.opt.systemPerl()?"1":"0")+"\n"); diff --git a/src/V3Options.cpp b/src/V3Options.cpp index a2dd94876..c6f2645c2 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -327,8 +327,7 @@ string V3Options::getenvSYSTEMC() { setenvStr("SYSTEMC", var, "Hardcoded at build time"); } // Only correct or check it if we really need the value - if ((v3Global.opt.systemPerl() || v3Global.opt.systemC()) - && !v3Global.opt.lintOnly()) { + if (v3Global.opt.usingSystemCLibs()) { if (var == "") { v3fatal("Need $SYSTEMC in environment\n" "Probably System-C isn't installed, see http://www.systemc.org\n"); @@ -356,13 +355,21 @@ string V3Options::getenvSYSTEMC_ARCH() { } string V3Options::getenvSYSTEMPERL() { + // Must be careful to set SYSTEMPERL_INCLUDE first else we'd setenv + // SYSTEMPERL which would override a DEFENVed SYSTEMPERL_INCLUDE. + V3Options::getenvSYSTEMPERL_INCLUDE(); + return V3Options::getenvSYSTEMPERLGuts(); +} + +string V3Options::getenvSYSTEMPERLGuts() { + // Get SYSTEMPERL when SYSTEMPERL_INCLUDE has already been tested string var = getenvStr("SYSTEMPERL",""); if (var == "" && string(DEFENV_SYSTEMPERL) != "") { var = DEFENV_SYSTEMPERL; - setenvStr("SYSTEMC_PERL", var, "Hardcoded at build time"); + setenvStr("SYSTEMPERL", var, "Hardcoded at build time"); } // Only correct or check it if we really need the value - if ((v3Global.opt.systemPerl() || v3Global.opt.trace()) && !v3Global.opt.lintOnly()) { + if (v3Global.opt.usingSystemPerlLibs()) { if (var == "") { string testdir = V3Options::getenvW() + "/hw/utils/perltools/SystemC"; // Hack for internal testing if (V3Options::fileStatDir(testdir)) { @@ -370,13 +377,35 @@ string V3Options::getenvSYSTEMPERL() { setenvStr ("SYSTEMPERL", var, "From W"); } } + // Test for correctness in SYSTEMPERL_INCLUDE + } + return var; +} + +string V3Options::getenvSYSTEMPERL_INCLUDE() { + string var = getenvStr("SYSTEMPERL_INCLUDE",""); + if (var == "" && string(DEFENV_SYSTEMPERL_INCLUDE) != "") { + // Note if SYSTEMPERL is DEFENVed, then SYSTEMPERL_INCLUDE is also DEFENVed + // So we don't need to sweat testing SYSTEMPERL also + var = DEFENV_SYSTEMPERL_INCLUDE; + setenvStr("SYSTEMPERL_INCLUDE", var, "Hardcoded at build time"); + } + // Only correct or check it if we really need the value + if (v3Global.opt.usingSystemPerlLibs()) { + if (var == "") { + string sp = V3Options::getenvSYSTEMPERLGuts(); + var = sp+"/src"; + setenvStr ("SYSTEMPERL_INCLUDE", var, "From $SYSTEMPERL/src"); + } + // We warn about $SYSTEMPERL instead of _INCLUDE since that's more likely + // what users will want to set. if (var == "") { v3fatal("Need $SYSTEMPERL in environment for --sp or --trace\n" "Probably System-Perl isn't installed, see http://www.veripool.org/systemperl\n"); } if (var != "" - && !V3Options::fileStatNormal(var+"/src/systemperl.h")) { - v3fatal("$SYSTEMPERL environment var doesn't seem to point to System-Perl kit\n"); + && !V3Options::fileStatNormal(var+"/systemperl.h")) { + v3fatal("Neither $SYSTEMPERL nor $SYSTEMPERL_INCLUDE environment vars to point to System-Perl kit: "<