|
LCS-2016-072b History |
|
18 |
|
23-Mar-2017 |
|
Voting |
|
Kevin Jennings, Martin Zabel, Jim Lewis, and Patrick Lehmann |
|
FunctionKnowsVectorSize |
|
LCS_2016_072 |
constant w_uv8 : unsigned(7 downto 0) := to_unsigned(15); constant x_uv10 : unsigned(9 downto 0) := to_unsigned(15); signal y_uv8 : unsigned(7 downto 0) := w_uv8 ; --! signal z_uv10 : unsigned(9 downto 0) := w_uv8 ; -- error constant x_uv10 : unsigned(9 downto 0) := to_unsigned(15);A pure function returns the same value every time it is called. Since to_unsigned(15) can return a different subtype for each call, to_unsigned[integer] is an impure function. OTOH, I suppose if the return value is a scalar or an already sized return value, then it need not be impure. OTOH, if the return_identifier is used to provide array constraints or determine the value, the function is impure. However, I do not need to make that observation here as it is already a part of the definition of pure and impure. -- Jim Lewis - 2017-03-22 A pure function's result depend only upon its interface elements. The return context is an explicit part of the interface when functions are declared this way. The function is pure when you consider both the target subtype and the input argument. constant w_uv8 : unsigned(7 downto 0) := to_unsigned(15); constant w_uv8_2 : unsigned(7 downto 0) := to_unsigned(15); These two will always result in the same value regardless of simulator or external state. -- Karl Eisenhofer - 2017-03-23