diff --git a/include/verilated.cpp b/include/verilated.cpp index 698ecaedd..1e3b1a256 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -3544,14 +3544,16 @@ void VerilatedContextImp::commandArgVl(const std::string& arg) { // and the run can be reproduced by passing +verilator+seed+. if (u64 == 0) u64 = pickRandomSeed(); randSeed(static_cast(u64)); - } else if (0 == std::strncmp(arg.c_str(), "+verilator+vpi+", std::strlen("+verilator+vpi+"))) { + } else if (0 + == std::strncmp(arg.c_str(), "+verilator+vpi+", + std::strlen("+verilator+vpi+"))) { // With --vpi the generated --main (vl_load_vpi_libs) consumes this, so accept // it silently here. Without --vpi there is no loader, so warn it is ignored. #if !VM_VPI - VL_WARN_MT("COMMAND_LINE", 0, "", - ("+verilator+vpi+ ignored: simulation was not compiled with --vpi (" + arg - + ")") - .c_str()); + VL_WARN_MT( + "COMMAND_LINE", 0, "", + ("+verilator+vpi+ ignored: simulation was not compiled with --vpi (" + arg + ")") + .c_str()); #endif } else if (arg == "+verilator+V") { VerilatedImp::versionDump(); // Someday more info too diff --git a/src/V3EmitCMain.cpp b/src/V3EmitCMain.cpp index bef1524c4..2ec909b3c 100644 --- a/src/V3EmitCMain.cpp +++ b/src/V3EmitCMain.cpp @@ -76,7 +76,8 @@ private: // Runtime loader for VPI shared libraries requested via +verilator+vpi+. // POSIX only: relies on the executable exporting its VPI symbols. - puts("// Load VPI shared libraries requested via +verilator+vpi+[:]\n"); + puts( + "// Load VPI shared libraries requested via +verilator+vpi+[:]\n"); puts("static void vl_load_vpi_libs(int argc, char** argv) {\n"); puts(/**/ "const char* prefix = \"+verilator+vpi+\";\n"); puts(/**/ "const size_t pfx_len = std::strlen(prefix);\n"); @@ -93,7 +94,8 @@ private: puts(/****/ "// Split : on the last ':'\n"); puts(/****/ "const std::string::size_type colon_pos = arg.rfind(':');\n"); puts(/****/ "const bool has_entry = (colon_pos != std::string::npos);\n"); - puts(/****/ "const std::string libpath = has_entry ? arg.substr(0, colon_pos) : arg;\n"); + puts(/****/ "const std::string libpath = has_entry ? arg.substr(0, colon_pos) : " + "arg;\n"); puts(/****/ "const std::string entry_name\n"); puts(/******/ "= has_entry ? arg.substr(colon_pos + 1) : std::string{};\n"); puts(/****/ "void* handle = dlopen(libpath.c_str(), RTLD_LAZY);\n"); @@ -104,7 +106,8 @@ private: puts(/******/ "vlog_startup_t bsp = reinterpret_cast(" "dlsym(handle, entry_name.c_str()));\n"); puts(/******/ "if (!bsp)\n"); - puts(/********/ "VL_FATAL_MT(\"\", 0, \"\", (std::string{\"Cannot find VPI bootstrap '\"}\n"); + puts(/********/ "VL_FATAL_MT(\"\", 0, \"\", (std::string{\"Cannot find VPI bootstrap " + "'\"}\n"); puts(/**********/ "+ entry_name + \"' in: \" + libpath).c_str());\n"); puts(/******/ "bsp();\n"); puts(/****/ "} else {\n"); @@ -112,7 +115,7 @@ private: puts(/********/ "dlsym(handle, \"vlog_startup_routines\"));\n"); puts(/******/ "if (!routinesp)\n"); puts(/********/ "VL_FATAL_MT(\"\", 0, \"\"," - " (std::string{\"Cannot find 'vlog_startup_routines' in: \"}\n"); + " (std::string{\"Cannot find 'vlog_startup_routines' in: \"}\n"); puts(/**********/ "+ libpath).c_str());\n"); puts(/******/ "for (int j = 0; routinesp[j]; ++j) routinesp[j]();\n"); puts(/****/ "}\n"); diff --git a/test_regress/t/t_flag_main_vpi.py b/test_regress/t/t_flag_main_vpi.py old mode 100644 new mode 100755 index 70e765911..43282cb6a --- a/test_regress/t/t_flag_main_vpi.py +++ b/test_regress/t/t_flag_main_vpi.py @@ -13,9 +13,7 @@ test.scenarios('vlt') # Compile with --binary --vpi to exercise the VPI-aware generated main. # Also compile a VPI shared library to be loaded at runtime via +verilator+vpi+. -test.compile( - make_pli=True, - verilator_flags2=["--binary --vpi --public-flat-rw"]) +test.compile(make_pli=True, verilator_flags2=["--binary --vpi --public-flat-rw"]) # With --vpi and an executable (--binary implies --exe), the Makefile must, on Linux, # export the executable's symbols (-rdynamic) and link libdl for the generated loader's @@ -26,7 +24,6 @@ test.file_grep(mk, r'LDFLAGS \+= -rdynamic') test.file_grep(mk, r'LDLIBS \+= -ldl') # Run the generated binary; load the VPI library via the +verilator+vpi+ plusarg. -test.execute(all_run_flags=["+verilator+vpi+" + test.obj_dir + "/libvpi.so"], - check_finished=True) +test.execute(all_run_flags=["+verilator+vpi+" + test.obj_dir + "/libvpi.so"], check_finished=True) test.passes() diff --git a/test_regress/t/t_flag_main_vpi_badentry.py b/test_regress/t/t_flag_main_vpi_badentry.py old mode 100644 new mode 100755 diff --git a/test_regress/t/t_flag_main_vpi_badlib.py b/test_regress/t/t_flag_main_vpi_badlib.py old mode 100644 new mode 100755 diff --git a/test_regress/t/t_flag_main_vpi_bootstrap.py b/test_regress/t/t_flag_main_vpi_bootstrap.py old mode 100644 new mode 100755 index 6a7283eeb..ecf4e5f65 --- a/test_regress/t/t_flag_main_vpi_bootstrap.py +++ b/test_regress/t/t_flag_main_vpi_bootstrap.py @@ -16,12 +16,9 @@ test.scenarios('vlt') test.top_filename = 't/t_flag_main_vpi.v' test.pli_filename = 't/t_flag_main_vpi.cpp' -test.compile( - make_pli=True, - verilator_flags2=["--binary --vpi --public-flat-rw"]) +test.compile(make_pli=True, verilator_flags2=["--binary --vpi --public-flat-rw"]) -test.execute( - all_run_flags=["+verilator+vpi+" + test.obj_dir + "/libvpi.so:my_vpi_bootstrap"], - check_finished=True) +test.execute(all_run_flags=["+verilator+vpi+" + test.obj_dir + "/libvpi.so:my_vpi_bootstrap"], + check_finished=True) test.passes() diff --git a/test_regress/t/t_flag_main_vpi_multi.py b/test_regress/t/t_flag_main_vpi_multi.py old mode 100644 new mode 100755 index cbd691016..ee8244242 --- a/test_regress/t/t_flag_main_vpi_multi.py +++ b/test_regress/t/t_flag_main_vpi_multi.py @@ -24,8 +24,10 @@ test.compile(make_pli=True, verilator_flags2=["--binary --vpi --public-flat-rw"] # Build the second VPI library (make_pli only builds libvpi.so), mirroring the # driver's own pli flags. root = os.environ['VERILATOR_ROOT'] -pli2_cmd = [os.environ['CXX'], "-I" + root + "/include/vltstd", "-I" + root + "/include", "-fPIC", - "-shared"] +pli2_cmd = [ + os.environ['CXX'], "-I" + root + "/include/vltstd", "-I" + root + "/include", "-fPIC", + "-shared" +] pli2_cmd += (["-Wl,-undefined,dynamic_lookup"] if platform.system() == 'Darwin' else ["-rdynamic"]) pli2_cmd += ["-o", test.obj_dir + "/libvpi2.so", "t/t_flag_main_vpi_lib2.cpp"] test.run(logfile=test.obj_dir + "/pli2_compile.log", cmd=pli2_cmd) diff --git a/test_regress/t/t_flag_main_vpi_noarray.py b/test_regress/t/t_flag_main_vpi_noarray.py old mode 100644 new mode 100755 diff --git a/test_regress/t/t_flag_main_vpi_noexe.py b/test_regress/t/t_flag_main_vpi_noexe.py old mode 100644 new mode 100755 diff --git a/test_regress/t/t_flag_main_vpi_nowarn.py b/test_regress/t/t_flag_main_vpi_nowarn.py old mode 100644 new mode 100755 index 07ab25bcd..740b72e77 --- a/test_regress/t/t_flag_main_vpi_nowarn.py +++ b/test_regress/t/t_flag_main_vpi_nowarn.py @@ -13,15 +13,13 @@ test.scenarios('vlt') # Compile with --binary but WITHOUT --vpi. # Passing +verilator+vpi+ at runtime should emit a warning, not load anything. -test.compile( - top_filename='t/t_flag_main.v', - verilator_flags2=["--binary"]) +test.compile(top_filename='t/t_flag_main.v', verilator_flags2=["--binary"]) -test.execute( - all_run_flags=["+verilator+vpi+/nonexistent.so"], - check_finished=True) +test.execute(all_run_flags=["+verilator+vpi+/nonexistent.so"], check_finished=True) -test.file_grep(test.run_log_filename, - r'%Warning: COMMAND_LINE:0: \+verilator\+vpi\+ ignored: simulation was not compiled with --vpi') +test.file_grep( + test.run_log_filename, + r'%Warning: COMMAND_LINE:0: \+verilator\+vpi\+ ignored: simulation was not compiled with --vpi' +) test.passes()