Add mockup for runtime copy

This commit is contained in:
Stefan Wallentowitz 2020-05-24 21:07:20 +02:00
parent eda46e3949
commit f95879a50a
11 changed files with 130 additions and 6 deletions

View File

@ -88,6 +88,7 @@ datarootdir = @datarootdir@
# Compile options
CFG_WITH_CCWARN = @CFG_WITH_CCWARN@
CFG_WITH_DEFENV = @CFG_WITH_DEFENV@
CFG_COPY_RUNTIME_DEFAULT = @CFG_COPY_RUNTIME_DEFAULT@
CFG_WITH_LONGTESTS = @CFG_WITH_LONGTESTS@
CFG_WITH_THREADED = @CFG_WITH_THREADED@
PACKAGE_VERSION = @PACKAGE_VERSION@

View File

@ -282,6 +282,7 @@ detailed descriptions in L</"VERILATION ARGUMENTS"> for more information.
--make <build-tool> Generate scripts for specified build tool
--compiler <compiler-name> Tune for specified C++ compiler
--converge-limit <loops> Tune convergence settle time
--copy-runtime Copy runtime library files to output
--coverage Enable all coverage
--coverage-line Enable line coverage
--coverage-toggle Enable toggle coverage
@ -639,6 +640,10 @@ functions to avoid error C1061.
Rarely needed. Specifies the maximum number of runtime iterations before
creating a model failed to converge error. Defaults to 100.
=item --copy-runtime
Copy runtime files.
=item --coverage
Enables all forms of coverage, alias for "--coverage-line --coverage-toggle

View File

@ -59,6 +59,20 @@ AC_ARG_ENABLE([tcmalloc],
[CFG_WITH_TCMALLOC=check;])
AC_MSG_RESULT($CFG_WITH_TCMALLOC)
# Flag to copy runtime library files by default
AC_MSG_CHECKING(whether to copy runtime library files to the output)
AC_ARG_ENABLE([copy-runtime-files-default],
[AS_HELP_STRING([--enable-copy-runtime-files-default],
[Copy runtime files by default])],
[case "${enableval}" in
yes) CFG_COPY_RUNTIME_DEFAULT=true ;;
no) CFG_COPY_RUNTIME_DEFAULT=false ;;
*) AC_MSG_ERROR([bad value '${enableval}' for --copy-runtime-files-default]) ;;
esac],
[CFG_COPY_RUNTIME_DEFAULT=false;])
AC_SUBST(CFG_COPY_RUNTIME_DEFAULT)
AC_MSG_RESULT($CFG_COPY_RUNTIME_DEFAULT)
# Special Substitutions - CFG_WITH_DEFENV
AC_MSG_CHECKING(whether to use hardcoded paths)
AC_ARG_ENABLE([defenv],

View File

@ -123,6 +123,8 @@ ifeq ($(CFG_WITH_DEFENV),yes)
endif
endif
CPPFLAGS += -DCOPY_RUNTIME_DEFAULT=@CFG_COPY_RUNTIME_DEFAULT@
HEADERS = $(wildcard V*.h v*.h)
ASTGEN = $(srcdir)/astgen

View File

@ -93,8 +93,13 @@ class CMakeEmitter {
*of << "\n### Constants...\n";
cmake_set(*of, "PERL", deslash(V3Options::getenvPERL()), "FILEPATH",
"Perl executable (from $PERL)");
cmake_set(*of, "VERILATOR_ROOT", deslash(V3Options::getenvVERILATOR_ROOT()), "PATH",
"Path to Verilator kit (from $VERILATOR_ROOT)");
if (v3Global.opt.copyRuntime()) {
cmake_set(*of, "VERILATOR_ROOT", "./vlt-runtime", "PATH",
"Path to Verilator kit (from $VERILATOR_ROOT)");
} else {
cmake_set(*of, "VERILATOR_ROOT", deslash(V3Options::getenvVERILATOR_ROOT()), "PATH",
"Path to Verilator kit (from $VERILATOR_ROOT)");
}
*of << "\n### Compiler flags...\n";

View File

@ -154,7 +154,11 @@ public:
of.puts("# Perl executable (from $PERL)\n");
of.puts("PERL = " + V3Options::getenvPERL() + "\n");
of.puts("# Path to Verilator kit (from $VERILATOR_ROOT)\n");
of.puts("VERILATOR_ROOT = " + V3Options::getenvVERILATOR_ROOT() + "\n");
if (v3Global.opt.copyRuntime()) {
of.puts("VERILATOR_ROOT = ./vlt-runtime\n");
} else {
of.puts("VERILATOR_ROOT = " + V3Options::getenvVERILATOR_ROOT() + "\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");

View File

@ -155,8 +155,10 @@ inline void V3FileDependImp::writeDepend(const string& filename) {
if (iter->target()) { *ofp << iter->filename() << " "; }
}
*ofp << " : ";
*ofp << v3Global.opt.bin();
*ofp << " ";
if (!v3Global.opt.copyRuntime()) {
*ofp << v3Global.opt.bin();
*ofp << " ";
}
for (std::set<DependFile>::iterator iter = m_filenameList.begin();
iter != m_filenameList.end(); ++iter) {
@ -330,6 +332,81 @@ void V3File::createMakeDir() {
}
}
void V3File::copyFile(const string& from, const string& to) {
std::ifstream src(from, std::ios::binary);
std::ofstream dst(to, std::ios::binary);
if (!src.is_open()) {
v3error("Cannot open file " + from);
}
dst << src.rdbuf();
}
void V3File::copyFiles(const string& from, const string& to, const char *files[]) {
V3Os::createDir(to);
for (int i = 0; files[i]; ++i) {
copyFile(from + files[i], to + files[i]);
}
}
void V3File::copyRuntimeFiles() {
V3Os::createDir(v3Global.opt.makeDir() + "/vlt-runtime/");
const char* files[] = {
"verilated.mk",
"verilated_config.h",
"verilated.h",
"verilated.cpp",
"verilated_dpi.h",
"verilated_dpi.cpp",
"verilatedos.h",
"verilated_heavy.h",
"verilated_imp.h",
"verilated_sym_props.h",
"verilated_syms.h",
"verilated_vcd_c.h",
"verilated_vcd_c.cpp",
"verilated_fst_c.h",
"verilated_fst_c.cpp",
"verilated_trace.h",
"verilated_trace_imp.cpp",
"verilated_intrinsics.h",
0
};
string srcdir = V3Options::getenvVERILATOR_ROOT() + "/include/";
string dstdir = v3Global.opt.makeDir() + "/vlt-runtime/include/";
copyFiles(srcdir, dstdir, files);
V3Os::createDir(dstdir + "vltstd");
copyFile(srcdir + "vltstd/svdpi.h", dstdir + "vltstd/svdpi.h");
string srcbindir = V3Options::getenvVERILATOR_ROOT() + "/bin/";
string dstbindir = v3Global.opt.makeDir() + "/vlt-runtime/bin/";
V3Os::createDir(dstbindir);
copyFile(srcbindir + "verilator_includer", dstbindir + "verilator_includer");
const char* gtkw_files[] = {
"fastlz.c",
"fastlz.h",
"fst_config.h",
"fstapi.c",
"fstapi.h",
"lz4.c",
"lz4.h",
"wavealloca.h",
0
};
string srcgtkwdir = V3Options::getenvVERILATOR_ROOT() + "/include/gtkwave/";
string dstgtkwdir = v3Global.opt.makeDir() + "/vlt-runtime/include/gtkwave/";
copyFiles(srcgtkwdir, dstgtkwdir, gtkw_files);
}
//######################################################################
// VInFilterImp

View File

@ -69,6 +69,11 @@ public:
// Directory utilities
static void createMakeDirFor(const string& filename);
static void createMakeDir();
// Copy files
static void copyFile(const string& from, const string& to);
static void copyFiles(const string& from, const string& to, const char* files[]);
static void copyRuntimeFiles();
};
//============================================================================

View File

@ -833,6 +833,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
else if (!strcmp(sw, "-build")) { m_build = true; }
else if (!strcmp(sw, "-cc")) { m_outFormatOk = true; m_systemC = false; }
else if ( onoff (sw, "-cdc", flag/*ref*/)) { m_cdc = flag; }
else if ( onoff (sw, "-copy-runtime", flag/*ref*/)) { m_copyRuntime = true; }
else if ( onoff (sw, "-coverage", flag/*ref*/)) { coverage(flag); }
else if ( onoff (sw, "-coverage-line", flag/*ref*/)){ m_coverageLine = flag; }
else if ( onoff (sw, "-coverage-toggle", flag/*ref*/)){ m_coverageToggle = flag; }
@ -1505,6 +1506,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 << " COPY_RUNTIME_DEFAULT = " << COPY_RUNTIME_DEFAULT << endl;
cout << endl;
cout << "Environment:\n";
@ -1532,6 +1534,7 @@ V3Options::V3Options() {
m_cdc = false;
m_cmake = false;
m_context = true;
m_copyRuntime = COPY_RUNTIME_DEFAULT;
m_coverageLine = false;
m_coverageToggle = false;
m_coverageUnderscore = false;

View File

@ -216,6 +216,7 @@ private:
bool m_cdc; // main switch: --cdc
bool m_cmake; // main switch: --make cmake
bool m_context; // main switch: --Wcontext
bool m_copyRuntime; // main switch: --copy-runtime
bool m_coverageLine; // main switch: --coverage-block
bool m_coverageToggle;// main switch: --coverage-toggle
bool m_coverageUnderscore;// main switch: --coverage-underscore
@ -412,6 +413,7 @@ public:
bool cdc() const { return m_cdc; }
bool cmake() const { return m_cmake; }
bool context() const { return m_context; }
bool copyRuntime() const { return m_copyRuntime; }
bool coverage() const { return m_coverageLine || m_coverageToggle || m_coverageUser; }
bool coverageLine() const { return m_coverageLine; }
bool coverageToggle() const { return m_coverageToggle; }

View File

@ -500,7 +500,9 @@ static void verilate(const string& argString) {
UINFO(1, "Option --verilate: Start Verilation\n");
// Can we skip doing everything if times are ok?
V3File::addSrcDepend(v3Global.opt.bin());
if (!v3Global.opt.copyRuntime()) {
V3File::addSrcDepend(v3Global.opt.bin());
}
if (v3Global.opt.skipIdentical().isTrue()
&& V3File::checkTimes(
v3Global.opt.makeDir() + "/" + v3Global.opt.prefix() + "__verFiles.dat", argString)) {
@ -556,6 +558,10 @@ static void verilate(const string& argString) {
argString);
}
if (v3Global.opt.copyRuntime()) {
V3File::copyRuntimeFiles();
}
// Final writing shouldn't throw warnings, but...
V3Error::abortIfWarnings();
#ifdef VL_LEAK_CHECKS