Fix duplicate scope identifiers decoding (#5584)

Signed-off-by: Bartłomiej Chmiel <bchmiel@antmicro.com>
Co-authored-by: Ryszard Rozak <rrozak@antmicro.com>
This commit is contained in:
Bartłomiej Chmiel 2024-11-04 15:06:15 +01:00 committed by GitHub
parent b3348a38d0
commit 4e71f359bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 12 deletions

View File

@ -156,7 +156,6 @@ class EmitCSyms final : EmitCBaseVisitorConst {
}
static string scopeDecodeIdentifier(const string& scpname) {
string out = scpname;
string::size_type pos = string::npos;
// Remove hierarchy
@ -172,17 +171,7 @@ class EmitCSyms final : EmitCBaseVisitorConst {
}
}
if (pos != std::string::npos) out.erase(0, pos + 1);
// Decode all escaped characters
while ((pos = out.find("__0")) != string::npos) {
unsigned int x;
std::stringstream ss;
ss << std::hex << out.substr(pos + 3, 2);
ss >> x;
out.replace(pos, 5, 1, (char)x);
}
return out;
return pos != string::npos ? scpname.substr(pos + 1) : scpname;
}
/// (scp, m_vpiScopeCandidates, m_scopeNames) -> m_scopeNames

View File

@ -135,6 +135,16 @@ int _mon_check_iter() {
TEST_CHECK_CSTR(p, "<null>"); // Unsupported
}
TestVpiHandle vh_null_name = MY_VPI_HANDLE("___0_");
TEST_CHECK_NZ(vh_null_name);
p = vpi_get_str(vpiName, vh_null_name);
TEST_CHECK_CSTR(p, "___0_");
TestVpiHandle vh_hex_name = MY_VPI_HANDLE("___0F_");
TEST_CHECK_NZ(vh_hex_name);
p = vpi_get_str(vpiName, vh_hex_name);
TEST_CHECK_CSTR(p, "___0F_");
TestVpiHandle vh10 = vpi_iterate(vpiReg, vh2);
TEST_CHECK_NZ(vh10);
TEST_CHECK_EQ(vpi_get(vpiType, vh10), vpiIterator);

View File

@ -63,6 +63,10 @@ extern "C" int mon_check();
sub \mod.with_dot (.cyc(cyc));
// Check if scope names are not decoded twice
sub ___0F_ (.cyc(cyc));
sub ___0_ (.cyc(cyc));
initial begin
`ifdef VERILATOR