mirror of
https://github.com/verilator/verilator.git
synced 2026-08-22 05:57:29 +02:00
Scope module fix (#2893)
This commit is contained in:
+12
-7
@@ -170,7 +170,12 @@ class EmitCSyms final : EmitCBaseVisitor {
|
|||||||
const auto scpit = m_vpiScopeCandidates.find(scp);
|
const auto scpit = m_vpiScopeCandidates.find(scp);
|
||||||
if ((scpit != m_vpiScopeCandidates.end())
|
if ((scpit != m_vpiScopeCandidates.end())
|
||||||
&& (m_scopeNames.find(scp) == m_scopeNames.end())) {
|
&& (m_scopeNames.find(scp) == m_scopeNames.end())) {
|
||||||
m_scopeNames.emplace(scpit->second.m_symName, scpit->second);
|
auto scopeNameit = m_scopeNames.find(scpit->second.m_symName);
|
||||||
|
if (scopeNameit == m_scopeNames.end()) {
|
||||||
|
m_scopeNames.emplace(scpit->second.m_symName, scpit->second);
|
||||||
|
} else {
|
||||||
|
scopeNameit->second.m_type = scpit->second.m_type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
string::size_type pos = scp.rfind("__DOT__");
|
string::size_type pos = scp.rfind("__DOT__");
|
||||||
if (pos == string::npos) {
|
if (pos == string::npos) {
|
||||||
@@ -233,20 +238,20 @@ class EmitCSyms final : EmitCBaseVisitor {
|
|||||||
++it) {
|
++it) {
|
||||||
if (it->second.m_type != "SCOPE_MODULE") continue;
|
if (it->second.m_type != "SCOPE_MODULE") continue;
|
||||||
|
|
||||||
string name = it->second.m_prettyName;
|
string symName = it->second.m_symName;
|
||||||
if (name.substr(0, 4) == "TOP.") name.replace(0, 4, "");
|
string above = symName;
|
||||||
|
if (above.substr(0, 4) == "TOP.") above.replace(0, 4, "");
|
||||||
|
|
||||||
string above = name;
|
|
||||||
while (!above.empty()) {
|
while (!above.empty()) {
|
||||||
string::size_type pos = above.rfind('.');
|
string::size_type pos = above.rfind("__");
|
||||||
if (pos == string::npos) break;
|
if (pos == string::npos) break;
|
||||||
above.resize(pos);
|
above.resize(pos);
|
||||||
if (m_vpiScopeHierarchy.find(above) != m_vpiScopeHierarchy.end()) {
|
if (m_vpiScopeHierarchy.find(above) != m_vpiScopeHierarchy.end()) {
|
||||||
m_vpiScopeHierarchy[above].push_back(name);
|
m_vpiScopeHierarchy[above].push_back(symName);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_vpiScopeHierarchy[name] = std::vector<string>();
|
m_vpiScopeHierarchy[symName] = std::vector<string>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,9 +90,12 @@ int mon_check() {
|
|||||||
// modDump(it, 0);
|
// modDump(it, 0);
|
||||||
// return 1;
|
// return 1;
|
||||||
|
|
||||||
TestVpiHandle topmod = vpi_scan(it);
|
TestVpiHandle topmod;
|
||||||
|
// both somepackage and t exist at the top level
|
||||||
|
while ((topmod = vpi_scan(it))) {
|
||||||
|
if (vpi_get(vpiType, topmod) == vpiModule) break;
|
||||||
|
}
|
||||||
CHECK_RESULT_NZ(topmod);
|
CHECK_RESULT_NZ(topmod);
|
||||||
CHECK_RESULT(vpi_get(vpiType, topmod), vpiModule);
|
|
||||||
|
|
||||||
const char* t_name = vpi_get_str(vpiName, topmod);
|
const char* t_name = vpi_get_str(vpiName, topmod);
|
||||||
CHECK_RESULT_NZ(t_name);
|
CHECK_RESULT_NZ(t_name);
|
||||||
|
|||||||
@@ -17,9 +17,8 @@ compile(
|
|||||||
make_top_shell => 0,
|
make_top_shell => 0,
|
||||||
make_main => 0,
|
make_main => 0,
|
||||||
make_pli => 1,
|
make_pli => 1,
|
||||||
iv_flags2 => ["-g2005-sv -D USE_VPI_NOT_DPI"],
|
iv_flags2 => ["-g2005-sv"],
|
||||||
v_flags2 => ["+define+USE_VPI_NOT_DPI"],
|
verilator_flags2 => ["-CFLAGS '-DVL_DEBUG -ggdb' +define+USE_DOLLAR_C32 --exe --vpi --no-l2name $Self->{t_dir}/t_vpi_module.cpp"],
|
||||||
verilator_flags2 => ["-CFLAGS '-DVL_DEBUG -ggdb' --exe --vpi --no-l2name $Self->{t_dir}/t_vpi_module.cpp"],
|
|
||||||
);
|
);
|
||||||
|
|
||||||
execute(
|
execute(
|
||||||
|
|||||||
@@ -6,9 +6,7 @@
|
|||||||
// Version 2.0.
|
// Version 2.0.
|
||||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||||
|
|
||||||
`ifdef USE_VPI_NOT_DPI
|
`ifndef IVERILOG
|
||||||
//We call it via $c so we can verify DPI isn't required - see bug572
|
|
||||||
`else
|
|
||||||
import "DPI-C" context function int mon_check();
|
import "DPI-C" context function int mon_check();
|
||||||
`endif
|
`endif
|
||||||
|
|
||||||
@@ -21,7 +19,7 @@ module t (/*AUTOARG*/
|
|||||||
clk
|
clk
|
||||||
);
|
);
|
||||||
|
|
||||||
`ifdef VERILATOR
|
`ifdef USE_DOLLAR_C32
|
||||||
`systemc_header
|
`systemc_header
|
||||||
extern "C" int mon_check();
|
extern "C" int mon_check();
|
||||||
`verilog
|
`verilog
|
||||||
@@ -43,13 +41,11 @@ extern "C" int mon_check();
|
|||||||
|
|
||||||
// Test loop
|
// Test loop
|
||||||
initial begin
|
initial begin
|
||||||
`ifdef VERILATOR
|
|
||||||
status = $c32("mon_check()");
|
|
||||||
`endif
|
|
||||||
`ifdef IVERILOG
|
`ifdef IVERILOG
|
||||||
status = $mon_check();
|
status = $mon_check();
|
||||||
`endif
|
`elsif USE_DOLLAR_C32
|
||||||
`ifndef USE_VPI_NOT_DPI
|
status = $c32("mon_check()");
|
||||||
|
`else
|
||||||
status = mon_check();
|
status = mon_check();
|
||||||
`endif
|
`endif
|
||||||
if (status!=0) begin
|
if (status!=0) begin
|
||||||
|
|||||||
Executable
+34
@@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env perl
|
||||||
|
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
|
||||||
|
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||||
|
#
|
||||||
|
# Copyright 2010 by Wilson Snyder. This program is free software; you
|
||||||
|
# can redistribute it and/or modify it under the terms of either the GNU
|
||||||
|
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||||
|
# Version 2.0.
|
||||||
|
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||||
|
|
||||||
|
scenarios(simulator => 1);
|
||||||
|
|
||||||
|
skip("Known compiler limitation")
|
||||||
|
if $Self->cxx_version =~ /\(GCC\) 4.4/;
|
||||||
|
|
||||||
|
VM_PREFIX("Vt_vpi_module");
|
||||||
|
top_filename("t/t_vpi_module.v");
|
||||||
|
pli_filename("t_vpi_module.cpp");
|
||||||
|
|
||||||
|
compile(
|
||||||
|
make_top_shell => 0,
|
||||||
|
make_main => 0,
|
||||||
|
make_pli => 1,
|
||||||
|
iv_flags2 => ["-g2005-sv"],
|
||||||
|
verilator_flags2 => ["-CFLAGS '-DVL_DEBUG -ggdb' --exe --vpi --no-l2name $Self->{t_dir}/t_vpi_module.cpp"],
|
||||||
|
);
|
||||||
|
|
||||||
|
execute(
|
||||||
|
use_libvpi => 1,
|
||||||
|
check_finished => 1
|
||||||
|
);
|
||||||
|
|
||||||
|
ok(1);
|
||||||
|
1;
|
||||||
Reference in New Issue
Block a user