]> git.nickg.me.uk Git - nvc.git/commit
vhpi: Implement size
authorSean Anderson <sean.anderson@seco.com>
Tue, 16 May 2023 22:18:34 +0000 (18:18 -0400)
committerNick Gasson <nick@nickg.me.uk>
Wed, 17 May 2023 19:10:13 +0000 (19:10 +0000)
commit8d08d390149701eb6e2339b980ed31bcaed3038a
tree1f6d9f34a5daab212196a50281cf8dbfb5322f5b
parent8cdb11c9885bb142e14f7ee498bd1960dc5e0879
vhpi: Implement size

This property isn't defined anywhere in the spec. Fortunately, there's a
blurb in the UML diagram [1]:

> If the object or value denoted by the name is determined, the value of
> the Size property is the number of scalar values denoted by the name.
> The object or value denoted by the name is determined for a locally
> static name.  The object or value denoted by the name may also be
> determined for a globally static name in the design hierarchy information
> model.  In other cases, the object or value denoted by the name is not
> determined, and the value of the Size property is vhpiUndefined.
>
> For a name that denotes an object or value of a scalar or access type,
> the value of the Size property is 1.
>
> For a name that denotes an object or value of a composite type, the value
> of the Size property is the number of scalar subelements of the object or
> value.
>
> For a name that denotes an object or value of a file type or a protected
> type, the value of the Size property is vhpiUndefined.

Effectively, this is the number of elements in the value. Although the
spec says to return vhpiUndefined on error, we return 0 instead to
placate existing applications.

[1] https://opensource.ieee.org/vasg/Packages/-/blob/release/vhpi_uml/vhpi_uml.xml
src/rt/model.c
src/rt/model.h
src/vhpi/vhpi-model.c