Fix VPI + SYMRSVDWORD intersection (#5686)

This commit is contained in:
Todd Strader 2024-12-19 15:15:28 -05:00 committed by GitHub
parent 8a9fc9237d
commit 74d5d008bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 21 additions and 4 deletions

View File

@ -222,12 +222,14 @@ string AstNode::vpiName(const string& namein) {
// This is slightly different from prettyName, in that when we encounter escaped characters,
// we change that identifier to an escaped identifier, wrapping it with '\' and ' '
// as specified in LRM 23.6
string name = namein;
if (0 == namein.substr(0, 7).compare("__SYM__")) { name = namein.substr(7); }
string pretty;
pretty.reserve(namein.length());
pretty.reserve(name.length());
bool inEscapedIdent = false;
int lastIdent = 0;
for (const char* pos = namein.c_str(); *pos;) {
for (const char* pos = name.c_str(); *pos;) {
char specialChar = 0;
if (pos[0] == '-' && pos[1] == '>') { // ->
specialChar = '.';

View File

@ -405,6 +405,16 @@ int _mon_check_var() {
CHECK_RESULT_CSTR(p, "vpiConstant");
}
// C++ keyword collision
{
TestVpiHandle vh10 = VPI_HANDLE("nullptr");
CHECK_RESULT_NZ(vh10);
vpi_get_value(vh10, &tmpValue);
CHECK_RESULT(tmpValue.value.integer, 123);
p = vpi_get_str(vpiType, vh10);
CHECK_RESULT_CSTR(p, "vpiParameter");
}
// non-integer variables
tmpValue.format = vpiRealVal;
{

View File

@ -17,7 +17,7 @@ test.compile(make_top_shell=False,
sim_time=2100,
iv_flags2=["-g2005-sv -D USE_VPI_NOT_DPI -DWAVES"],
v_flags2=["+define+USE_VPI_NOT_DPI"],
verilator_flags2=["--exe --vpi --no-l2name", test.pli_filename])
verilator_flags2=["-Wno-SYMRSVDWORD --exe --vpi --no-l2name", test.pli_filename])
test.execute(use_libvpi=True, all_run_flags=['+PLUS +INT=1234 +STRSTR'])

View File

@ -55,6 +55,9 @@ extern "C" int mon_check();
real real1 /*verilator public_flat_rw */;
string str1 /*verilator public_flat_rw */;
// specifically public and not public_flat_rw here so as to induce the C++
// keyword collision
localparam int nullptr /*verilator public */ = 123;
sub sub();

View File

@ -18,7 +18,7 @@ test.compile(make_top_shell=False,
sim_time=2100,
iv_flags2=["-g2005-sv -D USE_VPI_NOT_DPI -DWAVES -DT_VPI_VAR2"],
v_flags2=["+define+USE_VPI_NOT_DPI"],
verilator_flags2=["--exe --vpi --no-l2name", test.pli_filename])
verilator_flags2=["-Wno-SYMRSVDWORD --exe --vpi --no-l2name", test.pli_filename])
test.execute(use_libvpi=True, all_run_flags=['+PLUS +INT=1234 +STRSTR'])

View File

@ -74,6 +74,7 @@ extern "C" int mon_check();
/*verilator public_flat_rw_on*/
real real1;
string str1;
localparam int nullptr = 123;
/*verilator public_off*/
sub sub();

View File

@ -55,6 +55,7 @@ extern "C" int mon_check();
real real1;
string str1;
localparam int nullptr = 123;
sub sub();