Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
13 years ago

Constant declaraion with calculation in VHDL

Hi,

I have some constants declared in VHDL with the "third one" being dependent on the value of the other two. As my experience is, that I normally forget to change the "third" when changing either one, it would be best to have the compiler to calculate the third one. Thus I declared:

CONSTANT PWM_DC_min : STD_LOGIC_VECTOR (11 DOWNTO 0) := CONV_STD_LOGIC_VECTOR(120,12);

CONSTANT PWM_Crossover : STD_LOGIC_VECTOR (11 DOWNTO 0) := CONV_STD_LOGIC_VECTOR(6,12);

CONSTANT RAG_max : STD_LOGIC_VECTOR (11 DOWNTO 0) := (x"7FE"-PWM_DC_min-PWM_Crossover);

CONSTANT RAG_min : STD_LOGIC_VECTOR (11 DOWNTO 0) := (x"802"+PWM_DC_min+PWM_Crossover);

Unfortunately the compiler failed to calculate the Constants RAG_max and RAG_min correctly. Changing these constant definitions to

CONSTANT RAG_max : STD_LOGIC_VECTOR (11 DOWNTO 0) := x"780";

CONSTANT RAG_min : STD_LOGIC_VECTOR (11 DOWNTO 0) := x"880";

works perfect.

Is there any failure in declaration or are those multiple arithmetic defintions not supported in VHDL at all?

Thanks a lot,

Carlhermann

12 Replies