Apply 'make format'

This commit is contained in:
github action 2026-06-06 19:56:37 +00:00 committed by Matthew Ballance
parent 47b3e6dd6c
commit 3f04d3d955
10 changed files with 29 additions and 30 deletions

View File

@ -3544,14 +3544,16 @@ void VerilatedContextImp::commandArgVl(const std::string& arg) {
// and the run can be reproduced by passing +verilator+seed+<that_value>. // and the run can be reproduced by passing +verilator+seed+<that_value>.
if (u64 == 0) u64 = pickRandomSeed(); if (u64 == 0) u64 = pickRandomSeed();
randSeed(static_cast<int>(u64)); randSeed(static_cast<int>(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 // 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. // it silently here. Without --vpi there is no loader, so warn it is ignored.
#if !VM_VPI #if !VM_VPI
VL_WARN_MT("COMMAND_LINE", 0, "", VL_WARN_MT(
("+verilator+vpi+ ignored: simulation was not compiled with --vpi (" + arg "COMMAND_LINE", 0, "",
+ ")") ("+verilator+vpi+ ignored: simulation was not compiled with --vpi (" + arg + ")")
.c_str()); .c_str());
#endif #endif
} else if (arg == "+verilator+V") { } else if (arg == "+verilator+V") {
VerilatedImp::versionDump(); // Someday more info too VerilatedImp::versionDump(); // Someday more info too

View File

@ -76,7 +76,8 @@ private:
// Runtime loader for VPI shared libraries requested via +verilator+vpi+<lib>. // Runtime loader for VPI shared libraries requested via +verilator+vpi+<lib>.
// POSIX only: relies on the executable exporting its VPI symbols. // POSIX only: relies on the executable exporting its VPI symbols.
puts("// Load VPI shared libraries requested via +verilator+vpi+<lib>[:<bootstrap>]\n"); puts(
"// Load VPI shared libraries requested via +verilator+vpi+<lib>[:<bootstrap>]\n");
puts("static void vl_load_vpi_libs(int argc, char** argv) {\n"); puts("static void vl_load_vpi_libs(int argc, char** argv) {\n");
puts(/**/ "const char* prefix = \"+verilator+vpi+\";\n"); puts(/**/ "const char* prefix = \"+verilator+vpi+\";\n");
puts(/**/ "const size_t pfx_len = std::strlen(prefix);\n"); puts(/**/ "const size_t pfx_len = std::strlen(prefix);\n");
@ -93,7 +94,8 @@ private:
puts(/****/ "// Split <lib>:<bootstrap> on the last ':'\n"); puts(/****/ "// Split <lib>:<bootstrap> on the last ':'\n");
puts(/****/ "const std::string::size_type colon_pos = arg.rfind(':');\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 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(/****/ "const std::string entry_name\n");
puts(/******/ "= has_entry ? arg.substr(colon_pos + 1) : std::string{};\n"); puts(/******/ "= has_entry ? arg.substr(colon_pos + 1) : std::string{};\n");
puts(/****/ "void* handle = dlopen(libpath.c_str(), RTLD_LAZY);\n"); puts(/****/ "void* handle = dlopen(libpath.c_str(), RTLD_LAZY);\n");
@ -104,7 +106,8 @@ private:
puts(/******/ "vlog_startup_t bsp = reinterpret_cast<vlog_startup_t>(" puts(/******/ "vlog_startup_t bsp = reinterpret_cast<vlog_startup_t>("
"dlsym(handle, entry_name.c_str()));\n"); "dlsym(handle, entry_name.c_str()));\n");
puts(/******/ "if (!bsp)\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(/**********/ "+ entry_name + \"' in: \" + libpath).c_str());\n");
puts(/******/ "bsp();\n"); puts(/******/ "bsp();\n");
puts(/****/ "} else {\n"); puts(/****/ "} else {\n");
@ -112,7 +115,7 @@ private:
puts(/********/ "dlsym(handle, \"vlog_startup_routines\"));\n"); puts(/********/ "dlsym(handle, \"vlog_startup_routines\"));\n");
puts(/******/ "if (!routinesp)\n"); puts(/******/ "if (!routinesp)\n");
puts(/********/ "VL_FATAL_MT(\"\", 0, \"\"," 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(/**********/ "+ libpath).c_str());\n");
puts(/******/ "for (int j = 0; routinesp[j]; ++j) routinesp[j]();\n"); puts(/******/ "for (int j = 0; routinesp[j]; ++j) routinesp[j]();\n");
puts(/****/ "}\n"); puts(/****/ "}\n");

7
test_regress/t/t_flag_main_vpi.py Normal file → Executable file
View File

@ -13,9 +13,7 @@ test.scenarios('vlt')
# Compile with --binary --vpi to exercise the VPI-aware generated main. # 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+. # Also compile a VPI shared library to be loaded at runtime via +verilator+vpi+.
test.compile( test.compile(make_pli=True, verilator_flags2=["--binary --vpi --public-flat-rw"])
make_pli=True,
verilator_flags2=["--binary --vpi --public-flat-rw"])
# With --vpi and an executable (--binary implies --exe), the Makefile must, on Linux, # 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 # 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') test.file_grep(mk, r'LDLIBS \+= -ldl')
# Run the generated binary; load the VPI library via the +verilator+vpi+ plusarg. # 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"], test.execute(all_run_flags=["+verilator+vpi+" + test.obj_dir + "/libvpi.so"], check_finished=True)
check_finished=True)
test.passes() test.passes()

0
test_regress/t/t_flag_main_vpi_badentry.py Normal file → Executable file
View File

0
test_regress/t/t_flag_main_vpi_badlib.py Normal file → Executable file
View File

9
test_regress/t/t_flag_main_vpi_bootstrap.py Normal file → Executable file
View File

@ -16,12 +16,9 @@ test.scenarios('vlt')
test.top_filename = 't/t_flag_main_vpi.v' test.top_filename = 't/t_flag_main_vpi.v'
test.pli_filename = 't/t_flag_main_vpi.cpp' test.pli_filename = 't/t_flag_main_vpi.cpp'
test.compile( test.compile(make_pli=True, verilator_flags2=["--binary --vpi --public-flat-rw"])
make_pli=True,
verilator_flags2=["--binary --vpi --public-flat-rw"])
test.execute( test.execute(all_run_flags=["+verilator+vpi+" + test.obj_dir + "/libvpi.so:my_vpi_bootstrap"],
all_run_flags=["+verilator+vpi+" + test.obj_dir + "/libvpi.so:my_vpi_bootstrap"], check_finished=True)
check_finished=True)
test.passes() test.passes()

6
test_regress/t/t_flag_main_vpi_multi.py Normal file → Executable file
View File

@ -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 # Build the second VPI library (make_pli only builds libvpi.so), mirroring the
# driver's own pli flags. # driver's own pli flags.
root = os.environ['VERILATOR_ROOT'] root = os.environ['VERILATOR_ROOT']
pli2_cmd = [os.environ['CXX'], "-I" + root + "/include/vltstd", "-I" + root + "/include", "-fPIC", pli2_cmd = [
"-shared"] 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 += (["-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"] 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) test.run(logfile=test.obj_dir + "/pli2_compile.log", cmd=pli2_cmd)

0
test_regress/t/t_flag_main_vpi_noarray.py Normal file → Executable file
View File

0
test_regress/t/t_flag_main_vpi_noexe.py Normal file → Executable file
View File

14
test_regress/t/t_flag_main_vpi_nowarn.py Normal file → Executable file
View File

@ -13,15 +13,13 @@ test.scenarios('vlt')
# Compile with --binary but WITHOUT --vpi. # Compile with --binary but WITHOUT --vpi.
# Passing +verilator+vpi+ at runtime should emit a warning, not load anything. # Passing +verilator+vpi+ at runtime should emit a warning, not load anything.
test.compile( test.compile(top_filename='t/t_flag_main.v', verilator_flags2=["--binary"])
top_filename='t/t_flag_main.v',
verilator_flags2=["--binary"])
test.execute( test.execute(all_run_flags=["+verilator+vpi+/nonexistent.so"], check_finished=True)
all_run_flags=["+verilator+vpi+/nonexistent.so"],
check_finished=True)
test.file_grep(test.run_log_filename, test.file_grep(
r'%Warning: COMMAND_LINE:0: \+verilator\+vpi\+ ignored: simulation was not compiled with --vpi') test.run_log_filename,
r'%Warning: COMMAND_LINE:0: \+verilator\+vpi\+ ignored: simulation was not compiled with --vpi'
)
test.passes() test.passes()