Fix --public-flat-rw / DPI issue (#2858)

This commit is contained in:
Todd Strader 2021-03-26 18:24:31 -04:00 committed by GitHub
parent 4e41c13501
commit 87728a9ee3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View File

@ -330,7 +330,8 @@ class EmitCSyms final : EmitCBaseVisitor {
virtual void visit(AstVar* nodep) override {
nameCheck(nodep);
iterateChildren(nodep);
if (nodep->isSigUserRdPublic()) m_modVars.emplace_back(std::make_pair(m_modp, nodep));
if (nodep->isSigUserRdPublic() && !m_cfuncp)
m_modVars.emplace_back(std::make_pair(m_modp, nodep));
}
virtual void visit(AstCoverDecl* nodep) override {
// Assign numbers to all bins, so we know how big of an array to use

View File

@ -202,6 +202,8 @@ int mon_check() {
return 0; // Ok
}
void dpi_print(const char* somestring) { printf("SOMESTRING = %s\n", somestring); }
//======================================================================
#ifdef IS_VPI

View File

@ -12,6 +12,8 @@
import "DPI-C" context function int mon_check();
`endif
import "DPI-C" function void dpi_print(input string somestring);
`ifdef VERILATOR_COMMENTS
`define PUBLIC_FLAT_RD /*verilator public_flat_rd*/
`define PUBLIC_FLAT_RW /*verilator public_flat_rw @(posedge clk)*/
@ -54,6 +56,7 @@ extern "C" int mon_check();
// Test loop
initial begin
dpi_print("foo");
`ifdef VERILATOR
status = $c32("mon_check()");
`endif