I have a function that works with string passed to it. The string should be defined as "a to b" rather than "a downto b". I have the following questions:
- How to find out if the string passed is defined in ascending or descending order?
- Why do strings not have index 0? The minimum index is 1.
-
I have string p is 1 to 10, while string q is 10 downto 1, assigning one to the other generates error:
Fatal: (vsim-3607) Slice range direction (downto) does not match slice prefix direction (to).
Why?
-
How do I assign p to q or q to p in this case?
Best Answer
There are a few attributes that can be used to determine the bounds of ranges :
No idea why VHDL strings usually start at 1
The problem is what means a string defined as (10 downto 1)? Is it some text in a right-to-left language as Arabic? It would make no sense to reverse the order of letters!
If you want to inverse the order, you can use a loop :
If it is just because the vector is badly defined, you can write