mirror of
https://github.com/verilator/verilator.git
synced 2025-07-31 07:56:10 +00:00
Scope module fix (#2893)
This commit is contained in:
parent
4351abfe71
commit
12416bc0a3
@ -170,7 +170,12 @@ class EmitCSyms final : EmitCBaseVisitor {
|
||||
const auto scpit = m_vpiScopeCandidates.find(scp);
|
||||
if ((scpit != m_vpiScopeCandidates.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__");
|
||||
if (pos == string::npos) {
|
||||
@ -233,20 +238,20 @@ class EmitCSyms final : EmitCBaseVisitor {
|
||||
++it) {
|
||||
if (it->second.m_type != "SCOPE_MODULE") continue;
|
||||
|
||||
string name = it->second.m_prettyName;
|
||||
if (name.substr(0, 4) == "TOP.") name.replace(0, 4, "");
|
||||
string symName = it->second.m_symName;
|
||||
string above = symName;
|
||||
if (above.substr(0, 4) == "TOP.") above.replace(0, 4, "");
|
||||
|
||||
string above = name;
|
||||
while (!above.empty()) {
|
||||
string::size_type pos = above.rfind('.');
|
||||
string::size_type pos = above.rfind("__");
|
||||
if (pos == string::npos) break;
|
||||
above.resize(pos);
|
||||
if (m_vpiScopeHierarchy.find(above) != m_vpiScopeHierarchy.end()) {
|
||||
m_vpiScopeHierarchy[above].push_back(name);
|
||||
m_vpiScopeHierarchy[above].push_back(symName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_vpiScopeHierarchy[name] = std::vector<string>();
|
||||
m_vpiScopeHierarchy[symName] = std::vector<string>();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,9 +90,12 @@ int mon_check() {
|
||||
// modDump(it, 0);
|
||||
// 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(vpi_get(vpiType, topmod), vpiModule);
|
||||
|
||||
const char* t_name = vpi_get_str(vpiName, topmod);
|
||||
CHECK_RESULT_NZ(t_name);
|
||||
|
@ -17,9 +17,8 @@ compile(
|
||||
make_top_shell => 0,
|
||||
make_main => 0,
|
||||
make_pli => 1,
|
||||
iv_flags2 => ["-g2005-sv -D USE_VPI_NOT_DPI"],
|
||||
v_flags2 => ["+define+USE_VPI_NOT_DPI"],
|
||||
verilator_flags2 => ["-CFLAGS '-DVL_DEBUG -ggdb' --exe --vpi --no-l2name $Self->{t_dir}/t_vpi_module.cpp"],
|
||||
iv_flags2 => ["-g2005-sv"],
|
||||
verilator_flags2 => ["-CFLAGS '-DVL_DEBUG -ggdb' +define+USE_DOLLAR_C32 --exe --vpi --no-l2name $Self->{t_dir}/t_vpi_module.cpp"],
|
||||
);
|
||||
|
||||
execute(
|
||||
|
@ -6,9 +6,7 @@
|
||||
// Version 2.0.
|
||||
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||
|
||||
`ifdef USE_VPI_NOT_DPI
|
||||
//We call it via $c so we can verify DPI isn't required - see bug572
|
||||
`else
|
||||
`ifndef IVERILOG
|
||||
import "DPI-C" context function int mon_check();
|
||||
`endif
|
||||
|
||||
@ -21,7 +19,7 @@ module t (/*AUTOARG*/
|
||||
clk
|
||||
);
|
||||
|
||||
`ifdef VERILATOR
|
||||
`ifdef USE_DOLLAR_C32
|
||||
`systemc_header
|
||||
extern "C" int mon_check();
|
||||
`verilog
|
||||
@ -43,13 +41,11 @@ extern "C" int mon_check();
|
||||
|
||||
// Test loop
|
||||
initial begin
|
||||
`ifdef VERILATOR
|
||||
status = $c32("mon_check()");
|
||||
`endif
|
||||
`ifdef IVERILOG
|
||||
status = $mon_check();
|
||||
`endif
|
||||
`ifndef USE_VPI_NOT_DPI
|
||||
`elsif USE_DOLLAR_C32
|
||||
status = $c32("mon_check()");
|
||||
`else
|
||||
status = mon_check();
|
||||
`endif
|
||||
if (status!=0) begin
|
||||
|
34
test_regress/t/t_vpi_module_dpi.pl
Executable file
34
test_regress/t/t_vpi_module_dpi.pl
Executable file
@ -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;
|
Loading…
Reference in New Issue
Block a user