From f6d4f1ad0239db13e33059b11eac3080e3b8c146 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 2 Feb 2023 19:10:23 -0500 Subject: [PATCH] Fix very long VPI signal names (#3929). --- Changes | 1 + src/V3EmitCSyms.cpp | 6 +++--- test_regress/t/t_vpi_var.cpp | 9 +++++++++ test_regress/t/t_vpi_var.v | 1 + 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Changes b/Changes index b0bacebaf..e960eea2b 100644 --- a/Changes +++ b/Changes @@ -24,6 +24,7 @@ Verilator 5.007 devel * Fix real parameters of infinity and NaN. * Fix pattern assignment to unpacked structs (#3510). [Mostafa Garnal] * Fix single-element replication to dynarray/unpacked/queue (#3548). [Gustav Svensk] +* Fix very long VPI signal names (#3929). [Marlon James] Verilator 5.006 2023-01-22 diff --git a/src/V3EmitCSyms.cpp b/src/V3EmitCSyms.cpp index c3d65bdf1..a4c1c9707 100644 --- a/src/V3EmitCSyms.cpp +++ b/src/V3EmitCSyms.cpp @@ -235,9 +235,9 @@ class EmitCSyms final : EmitCBaseVisitor { } // UINFO(9, "For " << scopep->name() << " - " << varp->name() << " Scp " // << scpName << "Var " << varBase << endl); - const string varBasePretty = AstNode::prettyName(varBase); - const string scpPretty = AstNode::prettyName(scpName); - const string scpSym = scopeSymString(scpName); + const string varBasePretty = AstNode::prettyName(VName::dehash(varBase)); + const string scpPretty = AstNode::prettyName(VName::dehash(scpName)); + const string scpSym = scopeSymString(VName::dehash(scpName)); // UINFO(9, " scnameins sp " << scpName << " sp " << scpPretty << " ss " // << scpSym << endl); if (v3Global.opt.vpi()) varHierarchyScopes(scpName); diff --git a/test_regress/t/t_vpi_var.cpp b/test_regress/t/t_vpi_var.cpp index e06fda16c..2a65d9d68 100644 --- a/test_regress/t/t_vpi_var.cpp +++ b/test_regress/t/t_vpi_var.cpp @@ -414,6 +414,14 @@ int _mon_check_getput() { return 0; } +int _mon_check_var_long_name() { + TestVpiHandle vh2 = VPI_HANDLE("LONGSTART_a_very_long_name_which_will_get_hashed_a_very_long_name_which_will_get_hashed_a_very_long_name_which_will_get_hashed_a_very_long_name_which_will_get_hashed_LONGEND"); + CHECK_RESULT_NZ(vh2); + const char* p = vpi_get_str(vpiFullName, vh2); + CHECK_RESULT_CSTR(p, "t.LONGSTART_a_very_long_name_which_will_get_hashed_a_very_long_name_which_will_get_hashed_a_very_long_name_which_will_get_hashed_a_very_long_name_which_will_get_hashed_LONGEND"); + return 0; +} + int _mon_check_getput_iter() { TestVpiHandle vh2 = VPI_HANDLE("sub"); CHECK_RESULT_NZ(vh2); @@ -699,6 +707,7 @@ extern "C" int mon_check() { if (int status = _mon_check_value_callbacks()) return status; if (int status = _mon_check_var()) return status; if (int status = _mon_check_varlist()) return status; + if (int status = _mon_check_var_long_name()) return status; if (int status = _mon_check_getput()) return status; if (int status = _mon_check_getput_iter()) return status; if (int status = _mon_check_quad()) return status; diff --git a/test_regress/t/t_vpi_var.v b/test_regress/t/t_vpi_var.v index 79ee9e019..ebc707eb3 100644 --- a/test_regress/t/t_vpi_var.v +++ b/test_regress/t/t_vpi_var.v @@ -28,6 +28,7 @@ extern "C" int mon_check(); reg onebit /*verilator public_flat_rw @(posedge clk) */; reg [2:1] twoone /*verilator public_flat_rw @(posedge clk) */; reg [2:1] fourthreetwoone[4:3] /*verilator public_flat_rw @(posedge clk) */; + reg LONGSTART_a_very_long_name_which_will_get_hashed_a_very_long_name_which_will_get_hashed_a_very_long_name_which_will_get_hashed_a_very_long_name_which_will_get_hashed_LONGEND /*verilator public_flat_rw*/; // verilator lint_off LITENDIAN reg [0:61] quads[2:3] /*verilator public_flat_rw @(posedge clk) */;