From 2396181bc5ebb33590ed7ad921f110d810f7364b Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 19 Jan 2012 20:30:41 -0500 Subject: [PATCH] Add SYSTEMC_INCLUDE and SYSTEMC_LIBDIR --- Changes | 4 ++++ bin/verilator | 37 ++++++++++++++++++++--------- include/verilated.mk.in | 6 ++--- readme.pod | 16 +++++-------- readme.texi | 16 ++++++------- src/Makefile_obj.in | 2 ++ src/V3EmitMk.cpp | 6 ++++- src/V3Options.cpp | 52 +++++++++++++++++++++++++++++++++++------ src/V3Options.h | 2 ++ src/Verilator.cpp | 2 ++ src/config_build.h.in | 6 +++++ test_regress/driver.pl | 8 +++++-- test_sc/Makefile | 5 ++-- test_sc/Makefile_obj | 2 +- test_sp/Makefile_obj | 2 +- 15 files changed, 120 insertions(+), 46 deletions(-) diff --git a/Changes b/Changes index 8417a7d81..e43339098 100644 --- a/Changes +++ b/Changes @@ -6,6 +6,10 @@ indicates the contributor was also the author of the fix; Thanks! * Verilator 3.831**** +** Support SystemC 2.3.0 prerelease. This requires setting the new + SYSTEMC_INCLUDE and SYSTEMC_LIBDIR variables in place of now + deprecated SYSTEMC and SYSTEMC_ARCH. [Iztok Jeras] + **** Suppress VARHIDDEN on dpi import arguments. [Ruben Diez] **** Support "generate for (genvar i=0; ...". [David Kravitz] diff --git a/bin/verilator b/bin/verilator index 04b7251f0..9c657837f 100755 --- a/bin/verilator +++ b/bin/verilator @@ -1103,8 +1103,8 @@ We then can compile it And link with SystemC. Note your path to the libraries may vary, depending on the operating system. - export SYSTEMC=/path/to/where/systemc/was/built/or/installed - g++ -L$SYSTEMC/lib-linux ../sc_main.o Vour__ALL*.o verilated.o \ + export SYSTEMC_LIBDIR=/path/to/where/libsystemc.a/exists + g++ -L$SYSTEMC_LIBDIR ../sc_main.o Vour__ALL*.o verilated.o \ -o Vour -lsystemc And now we run it @@ -1240,24 +1240,39 @@ or ccache; see the documentation for those programs. =item SYSTEMC -Required for SystemC output mode. If set, specifies the directory -containing the SystemC distribution. This is used to find the SystemC -include files. If not specified, it will come from a default optionally -specified at configure time (before Verilator was compiled). +Deprecated. Used only if SYSTEMC_INCLUDE or SYSTEMC_LIBDIR is not set. If +set, specifies the directory containing the SystemC distribution. If not +specified, it will come from a default optionally specified at configure +time (before Verilator was compiled). =item SYSTEMC_ARCH -Specifies the architecture name used by the SystemC kit. This is the part -after the dash in the lib-{...} directory name created by a 'make' in the -SystemC distribution. If not set, Verilator will try to intuit the proper -setting, or use the default optionally specified at configure time (before -Verilator was compiled). . +Deprecated. Used only if SYSTEMC_LIBDIR is not set. Specifies the +architecture name used by the SystemC kit. This is the part after the dash +in the lib-{...} directory name created by a 'make' in the SystemC +distribution. If not set, Verilator will try to intuit the proper setting, +or use the default optionally specified at configure time (before Verilator +was compiled). =item SYSTEMC_CXX_FLAGS Specifies additional flags that are required to be passed to GCC when building the SystemC model. +=item SYSTEMC_INCLUDE + +If set, specifies the directory containing the systemc.h header file. If +not specified, it will come from a default optionally specified at +configure time (before Verilator was compiled), or computed from +SYSTEMC/include. + +=item SYSTEMC_LIBDIR + +If set, specifies the directory containing the libsystemc.a library. If not +specified, it will come from a default optionally specified at configure +time (before Verilator was compiled), or compted from +SYSTEMC/lib-SYSTEMC_ARCH. + =item SYSTEMPERL Specifies the directory containing the SystemPerl distribution kit. This diff --git a/include/verilated.mk.in b/include/verilated.mk.in index ca752d6fc..9ab4ff49f 100644 --- a/include/verilated.mk.in +++ b/include/verilated.mk.in @@ -93,10 +93,10 @@ VM_SUPPORT += $(VM_SUPPORT_FAST) $(VM_SUPPORT_SLOW) ##### SystemC or SystemPerl builds ifeq ($(VM_SP_OR_SC),1) - CPPFLAGS += $(SYSTEMC_CXX_FLAGS) -I$(SYSTEMC)/include - LDFLAGS += $(SYSTEMC_CXX_FLAGS) -L$(SYSTEMC)/lib-$(VM_SC_TARGET_ARCH) + CPPFLAGS += $(SYSTEMC_CXX_FLAGS) -I$(SYSTEMC_INCLUDE) + LDFLAGS += $(SYSTEMC_CXX_FLAGS) -L$(SYSTEMC_LIBDIR) SC_LIBS = -lsystemc - ifneq ($(wildcard $(SYSTEMC)/lib-$(VM_SC_TARGET_ARCH)/*numeric_bit*),) + ifneq ($(wildcard $(SYSTEMC_LIBDIR)/*numeric_bit*),) # Systemc 1.2.1beta SC_LIBS += -lnumeric_bit -lqt endif diff --git a/readme.pod b/readme.pod index 39e84b15f..b19f065ee 100644 --- a/readme.pod +++ b/readme.pod @@ -72,14 +72,10 @@ Download the latest package from that site, and decompress. If you will be using SystemC (vs straight C++ output), download SystemC 2.0.1 from L. Follow their installation -instructions. You will need to set the SYSTEMC environment variable to -point to this download. Also, setenv SYSTEMC_ARCH to the architecture name -you used with SystemC, generally 'linux' or 'cygwin'. - -Verilator assumes you did a make in the SystemC kit directory and SYSTEMC -points to that directory. There must be appropriate files in -C<$SYSTEMC/include> and C<$SYSTEMC/lib-linux> for SystemC compilation to -work. +instructions. You will need to set SYSTEMC_INCLUDE to point to the +include directory with systemc.h in it, and SYSTEMC_LIBDIR to points +to the directory with libsystemc.a in it. (Older installations may +set SYSTEMC and SYSTEMC_ARCH instead.) =item @@ -101,8 +97,8 @@ C to the Verilator directory containing this README. You now have to decide how you're going to eventually install the kit. -Note Verilator builds the current value of VERILATOR_ROOT, SYSTEMC, -SYSTEMC_ARCH, SYSTEMPERL, and SYSTEMPERL_INCLUDE as defaults into the +Note Verilator builds the current value of VERILATOR_ROOT, SYSTEMC_INCLUDE, +SYSTEMC_LIBDIR, SYSTEMPERL, and SYSTEMPERL_INCLUDE as defaults into the executable, so try to have them correct before configuring. =over 4 diff --git a/readme.texi b/readme.texi index 9b4c97e10..17d1f70fb 100644 --- a/readme.texi +++ b/readme.texi @@ -106,11 +106,11 @@ Unix system. @enumerate @item If you will be using SystemC (vs straight C++ output), download -SystemC 2.0.1 from @url{http://www.systemc.org}. Follow their -installation instructions. As described in the System-Perl README, -you will need to set SYSTEMC and/or SYSTEMC_KIT to point to this -download. Also, set SYSTEMC_ARCH to the architecture name you used -with SystemC, generally 'linux' or 'cygwin'. +SystemC from @url{http://www.systemc.org}. Follow their installation +instructions. You will need to set SYSTEMC_INCLUDE to point to the +include directory with systemc.h in it, and SYSTEMC_LIBDIR to points +to the directory with libsystemc.a in it. (Older installations may +set SYSTEMC and SYSTEMC_ARCH instead.) @item If you will be using SystemC, download and install Verilog-Perl, @@ -132,8 +132,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, SYSTEMPERL, and SYSTEMPERL_INCLUDE and build -them as defaults into the executable. +SYSTEMC_INCLUDE, SYSTEMC_LIBDIR, SYSTEMPERL, and SYSTEMPERL_INCLUDE +and build them as defaults into the executable. @item Type @samp{make} to compile Verilator. @@ -176,7 +176,7 @@ $VERILATOR_ROOT/bin/verilator, which will find the path to all needed files. Verilator assumes you did a make in the SystemC kit directory. If not, you will need -to populate @samp{$SYSTEMC/include} and @samp{$SYSTEMC/lib-linux} appropriately. +to populate @samp{$SYSTEMC_INCLUDE} and @samp{$SYSTEMC_LIBDIR} appropriately. If you will be modifying Verilator, you will probably want a second stable copy of this kit for others to use while you experiment. diff --git a/src/Makefile_obj.in b/src/Makefile_obj.in index 57dfea21f..023e2f0ac 100644 --- a/src/Makefile_obj.in +++ b/src/Makefile_obj.in @@ -111,6 +111,8 @@ endif ifeq ($(CFG_WITH_DEFENV),yes) CPPFLAGS += -DDEFENV_SYSTEMC=\"$(SYSTEMC)\" CPPFLAGS += -DDEFENV_SYSTEMC_ARCH=\"$(SYSTEMC_ARCH)\" + CPPFLAGS += -DDEFENV_SYSTEMC_INCLUDE=\"$(SYSTEMC_INCLUDE)\" + CPPFLAGS += -DDEFENV_SYSTEMC_LIBDIR=\"$(SYSTEMC_LIBDIR)\" CPPFLAGS += -DDEFENV_SYSTEMPERL=\"$(SYSTEMPERL)\" CPPFLAGS += -DDEFENV_SYSTEMPERL_INCLUDE=\"$(SYSTEMPERL_INCLUDE)\" ifeq ($(VERILATOR_ROOT),) # Use what we're given, or intuit diff --git a/src/V3EmitMk.cpp b/src/V3EmitMk.cpp index 1ff29871a..f5d537670 100644 --- a/src/V3EmitMk.cpp +++ b/src/V3EmitMk.cpp @@ -137,6 +137,10 @@ public: of.puts("SYSTEMPERL = "+V3Options::getenvSYSTEMPERL()+"\n"); of.puts("# Path to SystemPerl kit includes (from $SYSTEMPERL_INCLUDE)\n"); of.puts("SYSTEMPERL_INCLUDE = "+V3Options::getenvSYSTEMPERL_INCLUDE()+"\n"); + of.puts("# SystemC include directory with systemc.h (from $SYSTEMC_INCLUDE)\n"); + of.puts(string("SYSTEMC_INCLUDE ?= ")+V3Options::getenvSYSTEMC_INCLUDE()+"\n"); + of.puts("# SystemC library directory with libsystemc.a (from $SYSTEMC_LIBDIR)\n"); + of.puts(string("SYSTEMC_LIBDIR ?= ")+V3Options::getenvSYSTEMC_LIBDIR()+"\n"); of.puts("\n### Switches...\n"); of.puts("# SystemPerl output mode? 0/1 (from --sp)\n"); @@ -147,7 +151,7 @@ public: of.puts(string("VM_SP_OR_SC = ")+(v3Global.opt.systemC()?"1":"0")+"\n"); of.puts("# Deprecated\n"); of.puts(string("VM_PCLI = ")+(v3Global.opt.systemC()?"0":"1")+"\n"); - of.puts("# SystemC architecture to find link library path (from $SYSTEMC_ARCH)\n"); + of.puts("# Deprecated: SystemC architecture to find link library path (from $SYSTEMC_ARCH)\n"); of.puts(string("VM_SC_TARGET_ARCH = ")+V3Options::getenvSYSTEMC_ARCH()+"\n"); of.puts("\n### Vars...\n"); diff --git a/src/V3Options.cpp b/src/V3Options.cpp index a1dfc8d2b..19faf65cc 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -414,13 +414,6 @@ string V3Options::getenvSYSTEMC() { var = DEFENV_SYSTEMC; setenvStr("SYSTEMC", var, "Hardcoded at build time"); } - // Only correct or check it if we really need the value - if (v3Global.opt.usingSystemCLibs()) { - if (var == "") { - v3fatal("Need $SYSTEMC in environment\n" - "Probably System-C isn't installed, see http://www.systemc.org\n"); - } - } return var; } @@ -451,6 +444,47 @@ string V3Options::getenvSYSTEMC_ARCH() { return var; } +string V3Options::getenvSYSTEMC_INCLUDE() { + string var = getenvStr("SYSTEMC_INCLUDE",""); + if (var == "" && string(DEFENV_SYSTEMC_INCLUDE) != "") { + var = DEFENV_SYSTEMC_INCLUDE; + setenvStr("SYSTEMC_INCLUDE", var, "Hardcoded at build time"); + } + if (var == "") { + 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; +} + +string V3Options::getenvSYSTEMC_LIBDIR() { + string var = getenvStr("SYSTEMC_LIBDIR",""); + if (var == "" && string(DEFENV_SYSTEMC_LIBDIR) != "") { + var = DEFENV_SYSTEMC_LIBDIR; + setenvStr("SYSTEMC_LIBDIR", var, "Hardcoded at build time"); + } + if (var == "") { + string sc = getenvSYSTEMC(); + 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; +} + string V3Options::getenvSYSTEMPERL() { // Must be careful to set SYSTEMPERL_INCLUDE first else we'd setenv // SYSTEMPERL which would override a DEFENVed SYSTEMPERL_INCLUDE. @@ -1096,6 +1130,8 @@ void V3Options::showVersion(bool verbose) { cout << " Compiled in defaults if not in environment:\n"; cout << " SYSTEMC = " << DEFENV_SYSTEMC<compile_vlt_flags(%param); - if ($self->sc_or_sp && !defined $ENV{SYSTEMC}) { + if ($self->sc_or_sp && !defined $ENV{SYSTEMC} && !defined $ENV{SYSTEMC_INCLUDE}) { $self->skip("Test requires SystemC; ignore error since not installed\n"); return 1; } @@ -1495,7 +1495,11 @@ Run using Verilator. =item SYSTEMC -Root directory name of SystemC kit. +Root directory name of SystemC kit. Only used if SYSTEMC_INCLUDE not set. + +=item SYSTEMC_INCLUDE + +Directory name with systemc.h in it. =item VERILATOR_GHDL diff --git a/test_sc/Makefile b/test_sc/Makefile index d2d625098..837e468fb 100644 --- a/test_sc/Makefile +++ b/test_sc/Makefile @@ -22,9 +22,10 @@ export VERILATOR_ROOT include $(VERILATOR_ROOT)/include/verilated.mk DEBUG_ON = --debug +SYSTEMC_TESTING ?= $(SYSTEMC)$(SYSTEMC_INCLUDE) ###################################################################### -ifneq ($(SYSTEMC),) +ifneq ($(SYSTEMC_TESTING),) test_default: precopy prep preproc compile run test_debug: precopy prep_dbg preproc compile run else @@ -59,7 +60,7 @@ obj_dir: nosc: @echo - @echo %Skip: SYSTEMC not in environment + @echo %Skip: SYSTEMC_INCLUDE not in environment @echo ###################################################################### diff --git a/test_sc/Makefile_obj b/test_sc/Makefile_obj index 2c27310f5..a95d93a47 100644 --- a/test_sc/Makefile_obj +++ b/test_sc/Makefile_obj @@ -25,7 +25,7 @@ LDFLAGS += $(SYSTEMC_CXX_FLAGS) ####################################################################### # Linking final exe -- presumes have a sim_main.cpp -SC_LIB = $(SYSTEMC)/lib-$(VM_SC_TARGET_ARCH)/libsystemc.a +SC_LIB = $(SYSTEMC_LIBDIR)/libsystemc.a simx: sc_main.o $(VK_GLOBAL_OBJS) \ $(VM_PREFIX)__ALL.a $(SC_LIB) diff --git a/test_sp/Makefile_obj b/test_sp/Makefile_obj index 17d974ab8..a2b796fed 100644 --- a/test_sp/Makefile_obj +++ b/test_sp/Makefile_obj @@ -28,7 +28,7 @@ LDFLAGS += $(SYSTEMC_CXX_FLAGS) ####################################################################### # Linking final exe -- presumes have a sim_main.cpp -SC_LIB = $(SYSTEMC)/lib-$(VM_SC_TARGET_ARCH)/libsystemc.a +SC_LIB = $(SYSTEMC_LIBDIR)/libsystemc.a simx: sc_main.o $(VK_GLOBAL_OBJS) \ $(VM_PREFIX)__ALL.a $(SC_LIB)