Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
21613 Discussions

error: expression is not constant

Altera_Forum
Honored Contributor II
3,216 Views

Hi, 

My code is as followed: 

signal cnt_clks : natural range 0 to 300; ... ... cnt_clks <= conv_integer(unsigned(time)) * 25; process(clk_50, reset) begin if reset = '1' then enc_delay <= (others => '0'); enc_delay_in <= '0'; elsif rising_edge(clk_50) then enc_delay(cnt_clks downto 0) <= enc_delay((cnt_clks -1) downto 0) & enc_in(1); enc_delay_in <= enc_delay(cnt_clks); end if; end process;  

 

Modelsim compiles it with no problem. Quartus shows the 'Expression is not constant' error (I'm using Quartus 15). How can I overcome that? 

I tried defining cnt_clks as Integer, no luck. 

Roy
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
1,889 Views

what is definition for enc_delay. Hope it declared properly for at least 300 bits long. The size should be greater then maximum value of {cnt_clks} 300.  

it seems shift register that should shift for random number bits. How do you think synthesis tool could implent your code?
0 Kudos
Altera_Forum
Honored Contributor II
1,889 Views

It doesnt matter how enc_delay is calculated - quartus only supports slicing an array with a constant. And in your case your code implies slicing a variable number of bits out of an array, which is not possible with VHDL.

0 Kudos
Altera_Forum
Honored Contributor II
1,889 Views

You could rewrite your assignment with a for loop that goes through each bit of enc_delay and either shifts it or keeps it depending on the value of the index compared to cnt_clks. 

 

Do you really have a signal called "time" ? I'm surprised this doesn't conflict with the standard TIME type.
0 Kudos
Altera_Forum
Honored Contributor II
1,889 Views

 

--- Quote Start ---  

 

Do you really have a signal called "time" ? I'm surprised this doesn't conflict with the standard TIME type. 

--- Quote End ---  

 

 

time is not a reserved keyword, nor are any type names. So you can use it to confuse yourself thoroughly (and it works because VHDL is all context driven) 

 

signal time : std_logic; 

signal std_logic : integer range 0 to 153; 

signal integer : real range -0.1 to 100.66;
0 Kudos
Reply