V
valtih1978
Guest
Here is a funny code that I have Modelsimed
process
function COMPUTE return boolean is
constant STR: string := "abc";
begin
-- Error1: Target of signal assignment
-- is not a signal.
--STR <= STR;
-- Error2: Constant "STR" cannot be target of
-- variable assignment statement.
--STR := STR;
-- Return assignment is OK!
return STR <= "xyz";
end function;
-- Error3: Type error resolving function call
-- "COMPUTE" as type std.STANDARD.STRING.
--constant STR: string := COMPUTE;
constant B2:boolean := COMPUTE;
begin
report "Computed b2 = " & boolean'image(B2);
wait;
end process;
I am getting "Computed b2 = true" in the output despite I do not see
anywhere how the assignment in the end of COMPUTE function evaluates to
a boolean. A stand-alone assignment would violate checks marked with
error1 and error2.
process
function COMPUTE return boolean is
constant STR: string := "abc";
begin
-- Error1: Target of signal assignment
-- is not a signal.
--STR <= STR;
-- Error2: Constant "STR" cannot be target of
-- variable assignment statement.
--STR := STR;
-- Return assignment is OK!
return STR <= "xyz";
end function;
-- Error3: Type error resolving function call
-- "COMPUTE" as type std.STANDARD.STRING.
--constant STR: string := COMPUTE;
constant B2:boolean := COMPUTE;
begin
report "Computed b2 = " & boolean'image(B2);
wait;
end process;
I am getting "Computed b2 = true" in the output despite I do not see
anywhere how the assignment in the end of COMPUTE function evaluates to
a boolean. A stand-alone assignment would violate checks marked with
error1 and error2.