Fix spurious VPI value change callbacks (#6274)

This commit is contained in:
Todd Strader 2025-08-07 11:37:33 -04:00 committed by GitHub
parent 5b7188fcaf
commit 6bd6663dc9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 23 additions and 1 deletions

View File

@ -429,7 +429,7 @@ public:
void createPrevDatap() {
if (VL_UNLIKELY(!m_prevDatap)) {
m_prevDatap = new uint8_t[entSize()];
std::memcpy(prevDatap(), varp()->datap(), entSize());
std::memcpy(prevDatap(), m_varDatap, entSize());
}
}
};

View File

@ -156,6 +156,12 @@ int _value_callback_quad(p_cb_data cb_data) {
return 0;
}
int _value_callback_never(p_cb_data cb_data) {
printf("%%Error: callback should never be called\n");
exit(-1);
return 0;
}
int _mon_check_value_callbacks() {
s_vpi_value v;
v.format = vpiIntVal;
@ -210,6 +216,18 @@ int _mon_check_value_callbacks() {
TestVpiHandle callback_h = vpi_register_cb(&cb_data);
CHECK_RESULT_NZ(callback_h);
}
{
TestVpiHandle vh1 = VPI_HANDLE("some_mem");
CHECK_RESULT_NZ(vh1);
TestVpiHandle vh2 = vpi_handle_by_index(vh1, 3);
CHECK_RESULT_NZ(vh2);
cb_data.obj = vh2;
cb_data.cb_rtn = _value_callback_never;
TestVpiHandle callback_h = vpi_register_cb(&cb_data);
CHECK_RESULT_NZ(callback_h);
}
return 0;
}

View File

@ -59,6 +59,8 @@ extern "C" int mon_check();
// keyword collision
localparam int nullptr /*verilator public */ = 123;
logic [31:0] some_mem [4] /* verilator public_flat_rd */ = {0, 0, 0, 432};
sub sub();
// Test loop

View File

@ -75,6 +75,7 @@ extern "C" int mon_check();
real real1;
string str1;
localparam int nullptr = 123;
logic [31:0] some_mem [4] = {0, 0, 0, 432};
/*verilator public_off*/
sub sub();

View File

@ -56,6 +56,7 @@ extern "C" int mon_check();
real real1;
string str1;
localparam int nullptr = 123;
logic [31:0] some_mem [4] = {0, 0, 0, 432};
sub sub();