From 6159a7dd8d89556106a719163649a46249c3a454 Mon Sep 17 00:00:00 2001 From: Andrew Nolte Date: Tue, 3 Jan 2023 07:38:55 -0500 Subject: [PATCH] Fix VPI generate scope array naming (#3835) (#3836) --- src/V3EmitCSyms.cpp | 10 +++++----- test_regress/t/t_vpi_var.cpp | 6 ++++++ test_regress/t/t_vpi_var.v | 10 +++++++++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/V3EmitCSyms.cpp b/src/V3EmitCSyms.cpp index 8b3e75d84..f6c26cb27 100644 --- a/src/V3EmitCSyms.cpp +++ b/src/V3EmitCSyms.cpp @@ -296,10 +296,10 @@ class EmitCSyms final : EmitCBaseVisitor { const string type = (nodep->origModName() == "__BEGIN__") ? "SCOPE_OTHER" : "SCOPE_MODULE"; const string name = nodep->scopep()->shortName() + "__DOT__" + nodep->name(); - const string name_dedot = AstNode::dedotName(name); + const string name_pretty = AstNode::prettyName(name); const int timeunit = m_modp->timeunit().powerOfTen(); - m_vpiScopeCandidates.insert( - std::make_pair(name, ScopeData(scopeSymString(name), name_dedot, timeunit, type))); + m_vpiScopeCandidates.insert(std::make_pair( + name, ScopeData(scopeSymString(name), name_pretty, timeunit, type))); } } void visit(AstScope* nodep) override { @@ -310,10 +310,10 @@ class EmitCSyms final : EmitCBaseVisitor { if (v3Global.opt.vpi() && !nodep->isTop()) { const string type = VN_IS(nodep->modp(), Package) ? "SCOPE_OTHER" : "SCOPE_MODULE"; - const string name_dedot = AstNode::dedotName(nodep->shortName()); + const string name_pretty = AstNode::prettyName(nodep->shortName()); const int timeunit = m_modp->timeunit().powerOfTen(); m_vpiScopeCandidates.insert( - std::make_pair(nodep->name(), ScopeData(scopeSymString(nodep->name()), name_dedot, + std::make_pair(nodep->name(), ScopeData(scopeSymString(nodep->name()), name_pretty, timeunit, type))); } } diff --git a/test_regress/t/t_vpi_var.cpp b/test_regress/t/t_vpi_var.cpp index 5d94e9567..2674af559 100644 --- a/test_regress/t/t_vpi_var.cpp +++ b/test_regress/t/t_vpi_var.cpp @@ -605,6 +605,12 @@ int _mon_check_putget_str(p_cb_data cb_data) { = vpi_handle_by_name((PLI_BYTE8*)"verbose", data[i].scope)); } + for (int i = 1; i <= 6; i++) { + char buf[32]; + snprintf(buf, sizeof(buf), TestSimulator::rooted("subs[%d].subsub"), i); + CHECK_RESULT_NZ(data[i].scope = vpi_handle_by_name((PLI_BYTE8*)buf, NULL)); + } + static t_cb_data cb_data; static s_vpi_value v; TestVpiHandle count_h = VPI_HANDLE("count"); diff --git a/test_regress/t/t_vpi_var.v b/test_regress/t/t_vpi_var.v index 672f987fc..8c28f7fb1 100644 --- a/test_regress/t/t_vpi_var.v +++ b/test_regress/t/t_vpi_var.v @@ -95,7 +95,15 @@ extern "C" int mon_check(); generate for (i=1; i<=6; i=i+1) begin : arr arr #(.LENGTH(i)) arr(); - end endgenerate + end + endgenerate + + genvar k; + generate + for (k=1; k<=6; k=k+1) begin : subs + sub subsub(); + end + endgenerate endmodule : t