VHDL error in Quartus

Status
Not open for further replies.

Adnan86

Full Member level 2
Joined
Apr 4, 2013
Messages
121
Helped
26
Reputation
52
Reaction score
26
Trophy points
1,308
Visit site
Activity points
2,153
I have this code
Code:
[B]IF x >= 1  THEN
    FOR i IN 1 TO x'length   LOOP
    ans := 10 * ans ;
    END LOOP [/B]

But i have this error :
Error (10438): VHDL attribute error at po.vhd(26): prefix of 'LENGTH attribute must be an object of array type or an array subtype
x , ans : integer ;
What can i do for solve it ?
Thanks

- - - Updated - - -

and if i didn't use length i have this error :
Error (10454): VHDL syntax error at p.vhd(26): right bound of range must be a constant
 

What do you want to achieve? An integer object hasn't a LENGTH attribute, but it has e.g. an attribute HIGH, giving the upper bound of it's range.

If you want to vary the number of iteration according to the value variable or signal, it doesn't work this way. An iteration can be only performed over a constant range. This is reasonable considering that a HDL iteration is a method to describe parallel hardware.

An iteration over the maximum range of a variable in combination with a conditional statement can achieve what you want.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…