wtr
Full Member level 5
Hello all,
I've scanned the forums and found this thread https://www.edaboard.com/showthread...ggregate&highlight=vhdl+overloading+functions where #4 sort of touches on what I want to do.
Using VHDL subset = 2008
You may be asking why I'm doing this?
I've got instances where the entity may have byte_t type, and it freaks out when I feed in a slv even though the dimensions are the same.
I know I could have bespoke names but I want to used overloading, so I can apply it to any instance where I need to convert from special word defined dimension to a slv.
Regards,
Wes
I've scanned the forums and found this thread https://www.edaboard.com/showthread...ggregate&highlight=vhdl+overloading+functions where #4 sort of touches on what I want to do.
Using VHDL subset = 2008
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 subtype nibble_t is std_logic_vector(3 downto 0); subtype byte_t is std_logic_vector(7 downto 0); subtype word_t is std_logic_vector(15 downto 0); -- ****** function slv_2_wordtype (word : std_logic_vector) return nibble_t; function slv_2_wordtype (word : std_logic_vector) return byte_t; -- like I say later - second iteration I apply a range to slv (still get erro) -- @@@ Vivado is giving me the following errors -- @@@ "Error: A homograph of slv_2_wordtype is already declared in this region" --... --****** function wordtype_2_slv(word : nibble_t) return std_logic_vector; --... --****** function slv_2_wordtype(word : std_logic_vector) return nibble_t is variable var : nibble_t; begin var := word; return var; end function; -- In this instance I tried to constrain range however still get the same error function slv_2_wordtype(word : std_logic_vector(byte_t'range)) return byte_t is variable var : byte_t; begin var := word; return var; end function;
You may be asking why I'm doing this?
I've got instances where the entity may have byte_t type, and it freaks out when I feed in a slv even though the dimensions are the same.
I know I could have bespoke names but I want to used overloading, so I can apply it to any instance where I need to convert from special word defined dimension to a slv.
Regards,
Wes
Last edited: