VHDL parameterized constant

Status
Not open for further replies.

campo85

Newbie level 5
Joined
Apr 24, 2012
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,341
Hi all, I have a problem. I have coded a vhdl module with some generics to parameterized the design based on width bus. In the design I have a counter and I need to stop the counter when it has achieved the half value. So, I've declared a constant but Active HDL gives me an error. I declared the constant in this way :

Code:
constant LENGTH_COUNTER : integer := integer(ceil(log2(real(WIDTH_MULTIPLIER))));	
constant STOP_COUNTER : std_logic_vector(LENGTH_COUNTER downto 0) := (LENGTH_COUNTER => '1', others => '0');
signal counter : std_logic_vector( LENGTH_COUNTER downto 0);

the error is :

# Error: COMP96_0597: modular_exponetiantiation.vhd : (42, 72): Aggregate with multiple choices has a non-static or null choice. Use -relax to compile aggregates composed of one non-static or null choice and choice others.

I've also tried to declare in this way :

Code:
constant LENGTH_COUNTER : integer := integer(ceil(log2(real(WIDTH_MULTIPLIER))));	
constant STOP_COUNTER : std_logic_vector(LENGTH_COUNTER downto 0) := (LENGTH_COUNTER => '1', LENGTH_COUNTER-1 downto 0 => '0');
signal counter : std_logic_vector( LENGTH_COUNTER downto 0);

But I get :


Can someone give me some tips ? Thanks for any reply.

Kind regards.
 

Seems to be a specific ActiveHDL problem. Try
Code:
constant STOP_COUNTER : std_logic_vector(LENGTH_COUNTER downto 0) := std_logic_vector(to_unsigned(2**LENGTH_COUNTER,LENGTH_COUNTER+1));
 

As a side note - if all you are doing is checking for a half way value, instead of comparing the whole counter to a specified half value, why not just check the MSB? If the MSB is set, then it must be half way.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…