Hello Brian,
I wanted to leave some problems for you... No, iit's not exactly the same code, it's easier. In the generate version, no VARIABLE object can be used, thus you need these long-winded CONSTANT constructs. With functions, all calculations can use VARIABLE objects. If you like, you could do the calculation in a single expression without variables except romvar. But with variables, readability is improved, I think.
TYPE ROM IS ARRAY(0 TO 511) OF UNSIGNED(8 DOWNTO 0);
FUNCTION INIT_ROM RETURN ROM IS
VARIABLE romvar: ROM;
VARIABLE x: REAL;
begin
for I in 0 TO 511 loop
x:= SIN(real(i)*MATH_PI/real(511));
romvar(i):=CONV_UNSIGNED(INTEGER(x*real(511)),9);
end loop;
return romvar;
end;
Regards,
Frank