Ushort/short property conversion

With v2.4.7 it seems there’s an inconsistency in the type conversion functions available in ocpi.core/hdl/primitives/ocpi/types_body.vhd.

For “to_ushort” and “to_short” there’s only a conversion function with a natural type as a parameter, the function to convert from std_logic_vector to those types appear to be missing. These equivalents do seem to be present for the other types.

The HDL development guide document states:-

For all property data types there is a:
 VHDL type name specified in the OCS with a t suffix
 from
conversion function from the type to std_logic_vector
 to_ conversion function from std_logic_vector to the type
 to_ conversion function from the related VHDL type (below) to the type

Which seems to imply there should be three “to_short”/“to_ushort” functions, including one for std_logic_vector, one for the “related type” of numeric_std.short, as well as the one for natural/integer.

Further I note that the document has a typo in the subsequent paragraph:-

For example, for the ushort type, the ocpi.types package contains:
subtype ulong_t is unsigned (31 downto 0);
type ulong_array_t is array (natural range <>) of ulong_t;
constant ulong_max : ulong_t := x"ffff_ffff";
function to_ulong(c: natural) return ulong_t;
function to_ulong(c: std_logic_vector(31 downto 0)) return ulong_t;
function from_ulong(c: ulong_t) return std_logic_vector;
function to_slv(a: ulong_array_t) return std_logic_vector;
function to_ulong_array(a: std_logic_vector) return ulong_array_t;

Where it should read “For example, for the ulong type”

I have added the missing conversion functions to my current draft MR:

  • The particular commit
  • The MR