diff --git a/Changes b/Changes index 3eca09ece..265c3cb0f 100644 --- a/Changes +++ b/Changes @@ -7,6 +7,8 @@ indicates the contributor was also the author of the fix; Thanks! *** Support "unsigned int" DPI import functions, msg966. [Alex Lee] +**** Fix non-integer vpi_get_value, bug587. [Rich Porter] + * Verilator 3.843 2012/12/01 diff --git a/include/verilated_vpi.h b/include/verilated_vpi.h index 70901c3fa..5ae3d5441 100644 --- a/include/verilated_vpi.h +++ b/include/verilated_vpi.h @@ -101,6 +101,7 @@ public: // cppcheck-suppress uninitVar // m_value VerilatedVpioCb(const t_cb_data* cbDatap, QData time) : m_cbData(*cbDatap), m_time(time) { + m_value.format = cbDatap->value?cbDatap->value->format:vpiSuppressVal; m_cbData.value = &m_value; } virtual ~VerilatedVpioCb() {} diff --git a/test_regress/t/t_vpi_var.cpp b/test_regress/t/t_vpi_var.cpp index ef64eec9b..9ce87a29a 100644 --- a/test_regress/t/t_vpi_var.cpp +++ b/test_regress/t/t_vpi_var.cpp @@ -31,6 +31,7 @@ unsigned int main_time = false; unsigned int callback_count = false; unsigned int callback_count_half = false; +unsigned int callback_count_quad = false; //====================================================================== @@ -69,6 +70,13 @@ public: return __LINE__; \ } +#define CHECK_RESULT_HEX(got, exp) \ + if ((got != exp)) { \ + cout<value->value.integer+10, main_time); - callback_count++; - return 0; + CHECK_RESULT(cb_data->value->value.integer+10, main_time); + callback_count++; + return 0; } int _value_callback_half(p_cb_data cb_data) { - CHECK_RESULT(cb_data->value->value.integer*2+10, main_time); - callback_count_half++; - return 0; + CHECK_RESULT(cb_data->value->value.integer*2+10, main_time); + callback_count_half++; + return 0; +} + +int _value_callback_quad(p_cb_data cb_data) { + for (int index=0;index<2;index++) { + CHECK_RESULT_HEX(cb_data->value->value.vector[1].aval, (unsigned long)((index==2)?0x1c77bb9bUL:0x12819213UL)); + CHECK_RESULT_HEX(cb_data->value->value.vector[0].aval, (unsigned long)((index==2)?0x3784ea09UL:0xabd31a1cUL)); + } + callback_count_quad++; + return 0; } int _mon_check_value_callbacks() { @@ -155,6 +172,25 @@ int _mon_check_value_callbacks() { cb_data.obj = vh1; cb_data.cb_rtn = _value_callback_half; + vh = vpi_register_cb(&cb_data); + CHECK_RESULT_NZ(vh); + + vh1 = vpi_handle_by_name((PLI_BYTE8*)"t.quads", NULL); + CHECK_RESULT_NZ(vh1); + + v.format = vpiVectorVal; + cb_data.obj = vh1; + cb_data.cb_rtn = _value_callback_quad; + + vh = vpi_register_cb(&cb_data); + CHECK_RESULT_NZ(vh); + + vh1 = vpi_handle_by_index(vh1, 2); + CHECK_RESULT_NZ(vh1); + + cb_data.obj = vh1; + cb_data.cb_rtn = _value_callback_quad; + vh = vpi_register_cb(&cb_data); CHECK_RESULT_NZ(vh); return 0; @@ -371,6 +407,7 @@ int main(int argc, char **argv, char **env) { } CHECK_RESULT(callback_count, 501); CHECK_RESULT(callback_count_half, 250); + CHECK_RESULT(callback_count_quad, 2); if (!Verilated::gotFinish()) { vl_fatal(FILENM,__LINE__,"main", "%Error: Timeout; never got a $finish"); }