From 35231fb728384c5f388b5e930faecd43d6f1aceb Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Mon, 29 May 2023 16:06:09 -0400 Subject: [PATCH] vhpi: Support NumDimensions Support NumDimensions for arrays. --- src/vhpi/vhpi-model.c | 10 ++++++++++ test/regress/gold/vhpi1.txt | 1 + test/vhpi/vhpi1.c | 1 + 3 files changed, 12 insertions(+) diff --git a/src/vhpi/vhpi-model.c b/src/vhpi/vhpi-model.c index 2d20eb35..dcea193d 100644 --- a/src/vhpi/vhpi-model.c +++ b/src/vhpi/vhpi-model.c @@ -1223,6 +1223,16 @@ vhpiIntT vhpi_get(vhpiIntPropertyT property, vhpiHandleT handle) vhpi_error(vhpiInternal, &(obj->loc), "vhpiArgcP is only supported for tool objects"); return 0; + case vhpiNumDimensionsP: + { + c_arrayTypeDecl *a = cast_arrayTypeDecl(obj); + if (a == NULL) + return vhpiUndefined; + + VHPI_TRACE("dims=%d", a->NumDimensions); + return a->NumDimensions; + } + case vhpiIsUnconstrainedP: { c_range *r = is_range(obj); diff --git a/test/regress/gold/vhpi1.txt b/test/regress/gold/vhpi1.txt index 5edabcfe..67ee8953 100644 --- a/test/regress/gold/vhpi1.txt +++ b/test/regress/gold/vhpi1.txt @@ -27,6 +27,7 @@ VHPI printf v full name is :VHPI1:V VHPI printf v type handle VHPI printf v type name is BIT_VECTOR VHPI printf v type full name is @STD:STANDARD:BIT_VECTOR +VHPI printf v dimensions 1 VHPI printf v type range handle VHPI printf v left bound 3 VHPI printf v right bound 0 diff --git a/test/vhpi/vhpi1.c b/test/vhpi/vhpi1.c index 3e425abb..55181fbd 100644 --- a/test/vhpi/vhpi1.c +++ b/test/vhpi/vhpi1.c @@ -405,6 +405,7 @@ void vhpi1_startup(void) vhpi_printf("v type handle %p", v_type); vhpi_printf("v type name is %s", vhpi_get_str(vhpiNameP, v_type)); vhpi_printf("v type full name is %s", vhpi_get_str(vhpiFullNameP, v_type)); + vhpi_printf("v dimensions %d", vhpi_get(vhpiNumDimensionsP, v_type)); fail_if(vhpi_get(vhpiIsUnconstrainedP, v_type)); vhpiHandleT v_constrs = vhpi_iterator(vhpiConstraints, v_type); -- 2.39.2