Forum Discussion
Altera_Forum
Honored Contributor
14 years agofunction error declaration in vhdl
hello guys ..i'm kind of new to this .. i have a problem in vhdl function declaration .. i want to define function that calculate the avg of two std logic vectors .. but it keeps telling me that ...
Altera_Forum
Honored Contributor
14 years agoa function has to be declared inside something. So it has to be decalred inside a package, or architecture or a process. Functions do not exist on their own.
Secondly - as you're new to VHDL, may I suggest you ditch std_logic_signed - it is a non-standard package. std_logic_vectors are not meant to represent numbers. VHDL is strongly typed, and has unsigned and signed types to deal with numeric vectors inside the numeric_std package (which is part of the VHDL standard).