Alexium
Full Member level 2
Greetings!
Please take a look at my function:
This function is for word length of 4, obviously, but the length is actually a generic constant. Generate statement is not available for function body. How can I deal with this problem? Maybe, redesign the data types I'm using to achieve the desired behaviour?
Thanks in advance!
Please take a look at my function:
Code:
[syntax=vhdl]
constant ASCII_a: integer := 97;
constant ASCII_z: integer := 122;
subtype lower_case_character is integer range ASCII_a to ASCII_z;
type word is array (0 to string_length - 1) of lower_case_character;
function next_word (str: word) return word is
variable ret: word;
begin
ret := str;
if str(3) < lower_case_character'high then
ret(3) := str(3) + 1;
elsif str(2) < lower_case_character'high then
ret(3) := lower_case_character'low;
ret(2) := str(2) + 1;
elsif str(1) < lower_case_character'high then
ret(3) := lower_case_character'low;
ret(2) := lower_case_character'low;
ret(1) := str(1) + 1;
elsif str(0) < lower_case_character'high then
ret(3) := lower_case_character'low;
ret(2) := lower_case_character'low;
ret(1) := lower_case_character'low;
ret(0) := str(0) + 1;
end if;
return ret;
end function next_word;[/syntax]
This function is for word length of 4, obviously, but the length is actually a generic constant. Generate statement is not available for function body. How can I deal with this problem? Maybe, redesign the data types I'm using to achieve the desired behaviour?
Thanks in advance!