Can a function return a sub-type, e.g.:
function foo() return signed(15 down 0) is ...
It doesn't works on the Xilinx compiler I'm using, but return signed
(no sub-type) does.
However I don't know if that is a compiler bug or not?
Thanks in advance for any help,
Howard.
You can use a type or a subtype, but you cannot declare the subtype in that location. That is, this is allowed, but your example is not:
subtype my_subtype is signed(15 downto 0);
function example return my_subtype is
begin
return signed'(X"0123");
end function;
The grammar reason is that `signed(15 downto 0)` is a subtype_indication, but only a type_mark is allowed in the "return type" position of a function declaration. A type mark can be a declared type or subtype name.