4

I have the following problem when accessing arrays in VHDL:

Say I have an array which is not of size 2^n, for example of size 6. Then, if I want to access this array using an index of width 3 bits (=ceil(log2(6))), it is clear that this index can reach two positions, 7 and 8, which are beyond the size of the array I am accessing. Xilinx ISE gives me a warning in this case.

How should I go about this? My possible solutions are as follows:

1.) Ignore the warnings. Hope synthesis is smart.

2.) Only use arrays of size 2^n. Hope unused portions of array will be optimized away.

1 Answer 1

3

I suggest to ignore the warnings in this case. Synthesis can handle this.

Synthesis can also easily optimize away anything not used, but artificially increasing array sizes seems like overkill.

Sign up to request clarification or add additional context in comments.

2 Comments

Just a thought: could you just use an "integer range 0 to 5" instead of a 3-bit vector. This might make the simulator happy, and give clear hints to the synthesis tool for optimization.
@Philippe The simulator would be equally happy or unhappy (in terms of run-time errors) for both cases. But a constrained integer is indeed a more direct way to express the intent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.