Fix dpi context functions (#5788)
This commit is contained in:
parent
be1ace423e
commit
2a23ec74e4
|
|
@ -221,7 +221,8 @@ class LinkResolveVisitor final : public VNVisitor {
|
||||||
letp->user2(false);
|
letp->user2(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (nodep->taskp() && (nodep->taskp()->dpiContext() || nodep->taskp()->dpiExport())) {
|
if (nodep->taskp() && !nodep->scopeNamep()
|
||||||
|
&& (nodep->taskp()->dpiContext() || nodep->taskp()->dpiExport())) {
|
||||||
nodep->scopeNamep(new AstScopeName{nodep->fileline(), false});
|
nodep->scopeNamep(new AstScopeName{nodep->fileline(), false});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import vltest_bootstrap
|
||||||
|
|
||||||
test.scenarios('simulator')
|
test.scenarios('simulator')
|
||||||
|
|
||||||
test.compile(v_flags2=["t/t_dpi_context_c.cpp"])
|
test.compile(v_flags2=["t/t_dpi_context_c.cpp", "--debug", "-no-dump-tree"])
|
||||||
|
|
||||||
test.execute()
|
test.execute()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ module sub (input integer inst);
|
||||||
import "DPI-C" context function int dpic_save(int value);
|
import "DPI-C" context function int dpic_save(int value);
|
||||||
import "DPI-C" context function int dpic_restore();
|
import "DPI-C" context function int dpic_restore();
|
||||||
import "DPI-C" context function int unsigned dpic_getcontext();
|
import "DPI-C" context function int unsigned dpic_getcontext();
|
||||||
|
import "DPI-C" context function int unsigned dpic_get1();
|
||||||
|
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
|
@ -63,6 +64,11 @@ module sub (input integer inst);
|
||||||
if (dpic_restore() != 23+inst) $stop;
|
if (dpic_restore() != 23+inst) $stop;
|
||||||
endtask
|
endtask
|
||||||
|
|
||||||
|
function automatic int call_dpic_get1;
|
||||||
|
int res = dpic_get1();
|
||||||
|
return res;
|
||||||
|
endfunction
|
||||||
|
|
||||||
int unsigned cntxt1;
|
int unsigned cntxt1;
|
||||||
int unsigned cntxt2;
|
int unsigned cntxt2;
|
||||||
|
|
||||||
|
|
@ -74,6 +80,7 @@ module sub (input integer inst);
|
||||||
end
|
end
|
||||||
// svContext should be the context of the function declaration, not the context of the function call
|
// svContext should be the context of the function declaration, not the context of the function call
|
||||||
if (cntxt1 != cntxt2) $stop;
|
if (cntxt1 != cntxt2) $stop;
|
||||||
|
if (call_dpic_get1() != 1) $stop;
|
||||||
end
|
end
|
||||||
|
|
||||||
endmodule
|
endmodule
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ extern int dpic_line();
|
||||||
extern int dpic_save(int value);
|
extern int dpic_save(int value);
|
||||||
extern int dpic_restore();
|
extern int dpic_restore();
|
||||||
extern unsigned dpic_getcontext();
|
extern unsigned dpic_getcontext();
|
||||||
|
extern unsigned dpic_get1();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -151,6 +152,8 @@ unsigned dpic_getcontext() {
|
||||||
return (unsigned)(uintptr_t)scope;
|
return (unsigned)(uintptr_t)scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned dpic_get1() { return 1; }
|
||||||
|
|
||||||
void dpic_final() {
|
void dpic_final() {
|
||||||
static int s_once = 0;
|
static int s_once = 0;
|
||||||
if (s_once++) return;
|
if (s_once++) return;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue