From 8686ed9b0092f14b1cf69743eeeefb57f64aa1c1 Mon Sep 17 00:00:00 2001 From: Stefan Wallentowitz Date: Wed, 18 Sep 2019 12:24:19 -0400 Subject: [PATCH] Fix vpiType accessor, bug1510. Signed-off-by: Wilson Snyder --- Changes | 2 +- include/verilated_vpi.cpp | 3 +++ test_regress/t/t_vpi_var.cpp | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index 09ba95cbd..a9d57a947 100644 --- a/Changes +++ b/Changes @@ -16,7 +16,7 @@ The contributors that suggested a given feature are shown in []. Thanks! **** Fix false warning on backward indexing, bug1507. [Hao Shi] -**** Fix vpiType accessor, bug1509. [Stefan Wallentowitz] +**** Fix vpiType accessor, bug1509, bug1510. [Stefan Wallentowitz] * Verilator 4.018 2019-08-29 diff --git a/include/verilated_vpi.cpp b/include/verilated_vpi.cpp index 60e17ec36..215eb3bac 100644 --- a/include/verilated_vpi.cpp +++ b/include/verilated_vpi.cpp @@ -1203,6 +1203,9 @@ PLI_BYTE8 *vpi_get_str(PLI_INT32 property, vpiHandle object) { case vpiDefName: { return (PLI_BYTE8*)vop->defname(); } + case vpiType: { + return (PLI_BYTE8*) VerilatedVpiError::strFromVpiObjType(vop->type()); + } default: _VL_VPI_WARNING(__FILE__, __LINE__, "%s: Unsupported type %s, nothing will be returned", VL_FUNC, VerilatedVpiError::strFromVpiProp(property)); diff --git a/test_regress/t/t_vpi_var.cpp b/test_regress/t/t_vpi_var.cpp index 62e3e6c73..5cb0ff51c 100644 --- a/test_regress/t/t_vpi_var.cpp +++ b/test_regress/t/t_vpi_var.cpp @@ -235,6 +235,8 @@ int _mon_check_var() { CHECK_RESULT_CSTR(p, "t"); p = vpi_get_str(vpiFullName, vh2); CHECK_RESULT_CSTR(p, TestSimulator::top()); + p = vpi_get_str(vpiType, vh2); + CHECK_RESULT_CSTR (p, "*undefined*"); TestVpiHandle vh3 = vpi_handle_by_name((PLI_BYTE8*)"onebit", vh2); CHECK_RESULT_NZ(vh3); @@ -252,6 +254,8 @@ int _mon_check_var() { CHECK_RESULT_CSTR(p, "onebit"); p = vpi_get_str(vpiFullName, vh3); CHECK_RESULT_CSTR(p, TestSimulator::rooted("onebit")); + p = vpi_get_str(vpiType, vh3); + CHECK_RESULT_CSTR(p, "vpiReg"); // array attributes TestVpiHandle vh4 = VPI_HANDLE("fourthreetwoone"); @@ -259,6 +263,8 @@ int _mon_check_var() { if (TestSimulator::has_get_scalar()) { d = vpi_get(vpiVector, vh4); CHECK_RESULT(d, 1); + p = vpi_get_str(vpiType, vh4); + CHECK_RESULT_CSTR(p, "vpiMemory"); } t_vpi_value tmpValue; @@ -268,26 +274,38 @@ int _mon_check_var() { CHECK_RESULT_NZ(vh10); vpi_get_value(vh10, &tmpValue); CHECK_RESULT(tmpValue.value.integer,4); + p = vpi_get_str(vpiType, vh10); + CHECK_RESULT_CSTR(p, "*undefined*"); } { TestVpiHandle vh10 = vpi_handle(vpiRightRange, vh4); CHECK_RESULT_NZ(vh10); vpi_get_value(vh10, &tmpValue); CHECK_RESULT(tmpValue.value.integer,3); + p = vpi_get_str(vpiType, vh10); + CHECK_RESULT_CSTR(p, "*undefined*"); } { TestVpiHandle vh10 = vpi_iterate(vpiMemoryWord, vh4); CHECK_RESULT_NZ(vh10); + p = vpi_get_str(vpiType, vh10); + CHECK_RESULT_CSTR(p, "vpiIterator"); TestVpiHandle vh11 = vpi_scan(vh10); CHECK_RESULT_NZ(vh11); + p = vpi_get_str(vpiType, vh11); + CHECK_RESULT_CSTR(p, "vpiMemoryWord"); TestVpiHandle vh12 = vpi_handle(vpiLeftRange, vh11); CHECK_RESULT_NZ(vh12); vpi_get_value(vh12, &tmpValue); CHECK_RESULT(tmpValue.value.integer,2); + p = vpi_get_str(vpiType, vh12); + CHECK_RESULT_CSTR(p, "*undefined*"); TestVpiHandle vh13 = vpi_handle(vpiRightRange, vh11); CHECK_RESULT_NZ(vh13); vpi_get_value(vh13, &tmpValue); CHECK_RESULT(tmpValue.value.integer,1); + p = vpi_get_str(vpiType, vh13); + CHECK_RESULT_CSTR(p, "*undefined*"); } return 0;