0

So I am trying to declare a variable sized array based on a generate variable, but my linting tool SpyGlass complains about rule BitOrder-ML and gives the following error message:

Declare 'Vector Size' bit order '[((1 << level) -1):0]' as per convention

This is the code that generates the problem:

genvar level;
localparam integer LEVELS = 3;
generate
   for (level=0; level<LEVELS; level=level+1) begin
      wire result[(1 << level)-1:0];
   end
endgenerate

Is SpyGlass sane here? Does it somehow think that the expression (1 << level)-1 would generate to a negative value?

The synthesize completes without a problem when the error is waived.

3
  • what will be the result for level == 0? you will get the result[-1:0] i would not blame spyglass for that. Commented Jul 21, 2017 at 13:26
  • @Serge: No, (1 << 0) - 1 = 0 Commented Jul 21, 2017 at 13:51
  • oops, your right. should have waked up first :-) Commented Jul 21, 2017 at 15:30

1 Answer 1

1

first of all

1-you have syntax problem

wire result[(1 << level)-1:0]]; you should delete last ].

2-you should declare level as a genvar not integer! genvar level; is correct.

NOTE : [(2^level)-1:0] is more regular than [(1 << level)-1:0]

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

3 Comments

Sorry, typos. Fixed the code. I can add that the code synthesize fine if i turb off linting of these lines.
I use ISE xilinx syntheses tool below code and it have no problem can U upload your full code to i check it?
It's the linting tool spyglass and also nlint that has problem with the code. The code is fine otherwise and able to synth.

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.