mirror of
https://github.com/verilator/verilator.git
synced 2025-04-05 12:12:39 +00:00
Fix missing VPI scopes (#4918)
This commit is contained in:
parent
93e5ca3f6d
commit
290b313dc0
@ -184,7 +184,15 @@ class EmitCSyms final : EmitCBaseVisitorConst {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// (scp, m_vpiScopeCandidates, m_scopeNames) -> m_scopeNames
|
||||||
|
/// Look for parent scopes of scp in m_vpiScopeCandidates (separated by __DOT__ or ".")
|
||||||
|
/// Then add/update entry in m_scopeNames if not already there
|
||||||
void varHierarchyScopes(string scp) {
|
void varHierarchyScopes(string scp) {
|
||||||
|
|
||||||
|
// we want no result to be -1, so use ints
|
||||||
|
string::size_type prd_pos = scp.rfind('.');
|
||||||
|
string::size_type dot_pos = scp.rfind("__DOT__");
|
||||||
|
|
||||||
while (!scp.empty()) {
|
while (!scp.empty()) {
|
||||||
const auto scpit = m_vpiScopeCandidates.find(scopeSymString(scp));
|
const auto scpit = m_vpiScopeCandidates.find(scopeSymString(scp));
|
||||||
if ((scpit != m_vpiScopeCandidates.end())
|
if ((scpit != m_vpiScopeCandidates.end())
|
||||||
@ -193,12 +201,16 @@ class EmitCSyms final : EmitCBaseVisitorConst {
|
|||||||
const auto pair = m_scopeNames.emplace(scpit->second.m_symName, scpit->second);
|
const auto pair = m_scopeNames.emplace(scpit->second.m_symName, scpit->second);
|
||||||
if (!pair.second) pair.first->second.m_type = scpit->second.m_type;
|
if (!pair.second) pair.first->second.m_type = scpit->second.m_type;
|
||||||
}
|
}
|
||||||
string::size_type pos = scp.rfind("__DOT__");
|
|
||||||
if (pos == string::npos) {
|
// resize and advance pointers
|
||||||
pos = scp.rfind('.');
|
if (prd_pos < dot_pos && dot_pos != string::npos) {
|
||||||
if (pos == string::npos) break;
|
scp.resize(dot_pos);
|
||||||
|
dot_pos = scp.rfind("__DOT__");
|
||||||
|
} else {
|
||||||
|
if (prd_pos == string::npos) break;
|
||||||
|
scp.resize(prd_pos);
|
||||||
|
prd_pos = scp.rfind('.');
|
||||||
}
|
}
|
||||||
scp.resize(pos);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,14 @@ t (vpiModule) t
|
|||||||
vpiReg:
|
vpiReg:
|
||||||
t.cond_scope.scoped_sub.subsig1 (vpiReg) t.cond_scope.scoped_sub.subsig1
|
t.cond_scope.scoped_sub.subsig1 (vpiReg) t.cond_scope.scoped_sub.subsig1
|
||||||
t.cond_scope.scoped_sub.subsig2 (vpiReg) t.cond_scope.scoped_sub.subsig2
|
t.cond_scope.scoped_sub.subsig2 (vpiReg) t.cond_scope.scoped_sub.subsig2
|
||||||
|
t.cond_scope.sub_wrap_gen (vpiModule) t.cond_scope.sub_wrap_gen
|
||||||
|
vpiInternalScope:
|
||||||
|
t.cond_scope.sub_wrap_gen.my_sub (vpiModule) t.cond_scope.sub_wrap_gen.my_sub
|
||||||
|
vpiNet:
|
||||||
|
t.cond_scope.sub_wrap_gen.my_sub.redundant (vpiNet) t.cond_scope.sub_wrap_gen.my_sub.redundant
|
||||||
|
vpiReg:
|
||||||
|
t.cond_scope.sub_wrap_gen.my_sub.subsig1 (vpiReg) t.cond_scope.sub_wrap_gen.my_sub.subsig1
|
||||||
|
t.cond_scope.sub_wrap_gen.my_sub.subsig2 (vpiReg) t.cond_scope.sub_wrap_gen.my_sub.subsig2
|
||||||
t.intf_arr[0] (vpiModule) t.intf_arr[0]
|
t.intf_arr[0] (vpiModule) t.intf_arr[0]
|
||||||
t.intf_arr[1] (vpiModule) t.intf_arr[1]
|
t.intf_arr[1] (vpiModule) t.intf_arr[1]
|
||||||
t.outer_scope[1] (vpiGenScope) t.outer_scope[1]
|
t.outer_scope[1] (vpiGenScope) t.outer_scope[1]
|
||||||
@ -226,5 +234,13 @@ t (vpiModule) t
|
|||||||
vpiReg:
|
vpiReg:
|
||||||
t.sub.subsig1 (vpiReg) t.sub.subsig1
|
t.sub.subsig1 (vpiReg) t.sub.subsig1
|
||||||
t.sub.subsig2 (vpiReg) t.sub.subsig2
|
t.sub.subsig2 (vpiReg) t.sub.subsig2
|
||||||
|
t.sub_wrap (vpiModule) t.sub_wrap
|
||||||
|
vpiInternalScope:
|
||||||
|
t.sub_wrap.my_sub (vpiModule) t.sub_wrap.my_sub
|
||||||
|
vpiNet:
|
||||||
|
t.sub_wrap.my_sub.redundant (vpiNet) t.sub_wrap.my_sub.redundant
|
||||||
|
vpiReg:
|
||||||
|
t.sub_wrap.my_sub.subsig1 (vpiReg) t.sub_wrap.my_sub.subsig1
|
||||||
|
t.sub_wrap.my_sub.subsig2 (vpiReg) t.sub_wrap.my_sub.subsig2
|
||||||
*-* All Finished *-*
|
*-* All Finished *-*
|
||||||
t/t_vpi_dump.v:75: $finish called at 0 (1s)
|
t/t_vpi_dump.v:76: $finish called at 0 (1s)
|
||||||
|
@ -78,6 +78,15 @@ t (vpiModule) t
|
|||||||
subsig1 (vpiReg) t.cond_scope.scoped_sub.subsig1
|
subsig1 (vpiReg) t.cond_scope.scoped_sub.subsig1
|
||||||
subsig2 (vpiReg) t.cond_scope.scoped_sub.subsig2
|
subsig2 (vpiReg) t.cond_scope.scoped_sub.subsig2
|
||||||
vpiParameter:
|
vpiParameter:
|
||||||
|
sub_wrap_gen (vpiModule) t.cond_scope.sub_wrap_gen
|
||||||
|
vpiReg:
|
||||||
|
vpiParameter:
|
||||||
|
vpiInternalScope:
|
||||||
|
my_sub (vpiModule) t.cond_scope.sub_wrap_gen.my_sub
|
||||||
|
vpiReg:
|
||||||
|
subsig1 (vpiReg) t.cond_scope.sub_wrap_gen.my_sub.subsig1
|
||||||
|
subsig2 (vpiReg) t.cond_scope.sub_wrap_gen.my_sub.subsig2
|
||||||
|
vpiParameter:
|
||||||
intf_arr[0] (vpiModule) t.intf_arr[0]
|
intf_arr[0] (vpiModule) t.intf_arr[0]
|
||||||
vpiReg:
|
vpiReg:
|
||||||
addr (vpiReg) t.intf_arr[0].addr
|
addr (vpiReg) t.intf_arr[0].addr
|
||||||
@ -286,4 +295,13 @@ t (vpiModule) t
|
|||||||
subsig1 (vpiReg) t.sub.subsig1
|
subsig1 (vpiReg) t.sub.subsig1
|
||||||
subsig2 (vpiReg) t.sub.subsig2
|
subsig2 (vpiReg) t.sub.subsig2
|
||||||
vpiParameter:
|
vpiParameter:
|
||||||
|
sub_wrap (vpiModule) t.sub_wrap
|
||||||
|
vpiReg:
|
||||||
|
vpiParameter:
|
||||||
|
vpiInternalScope:
|
||||||
|
my_sub (vpiModule) t.sub_wrap.my_sub
|
||||||
|
vpiReg:
|
||||||
|
subsig1 (vpiReg) t.sub_wrap.my_sub.subsig1
|
||||||
|
subsig2 (vpiReg) t.sub_wrap.my_sub.subsig2
|
||||||
|
vpiParameter:
|
||||||
*-* All Finished *-*
|
*-* All Finished *-*
|
||||||
|
@ -6,6 +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
|
||||||
|
|
||||||
|
/* verilator public_on */
|
||||||
|
|
||||||
typedef struct packed {
|
typedef struct packed {
|
||||||
logic [3:0][7:0] adr; // address
|
logic [3:0][7:0] adr; // address
|
||||||
@ -95,15 +96,19 @@ module t ( /*AUTOARG*/
|
|||||||
end
|
end
|
||||||
endgenerate
|
endgenerate
|
||||||
|
|
||||||
|
sub_wrapper sub_wrap ();
|
||||||
|
|
||||||
|
|
||||||
|
generate
|
||||||
if (do_generate == 1) begin : cond_scope
|
if (do_generate == 1) begin : cond_scope
|
||||||
sub scoped_sub ();
|
sub scoped_sub ();
|
||||||
parameter int scoped_wire = 1;
|
parameter int scoped_wire = 1;
|
||||||
|
|
||||||
|
sub_wrapper sub_wrap_gen ();
|
||||||
end else begin : cond_scope_else
|
end else begin : cond_scope_else
|
||||||
sub scoped_sub ();
|
sub scoped_sub_else ();
|
||||||
parameter int scoped_wire = 2;
|
|
||||||
end
|
end
|
||||||
|
endgenerate
|
||||||
|
|
||||||
endmodule : t
|
endmodule : t
|
||||||
|
|
||||||
@ -138,3 +143,8 @@ module arr;
|
|||||||
end
|
end
|
||||||
|
|
||||||
endmodule : arr
|
endmodule : arr
|
||||||
|
|
||||||
|
|
||||||
|
module sub_wrapper;
|
||||||
|
sub my_sub ();
|
||||||
|
endmodule
|
||||||
|
Loading…
Reference in New Issue
Block a user