7

The following code synthesizes and simulates correctly as far as I can tell, but XST is still giving the following warning: value(s) does not match array range, simulation mismatch. Is there something I'm missing?

Tool used: Xilinx ISE Project Navigator (synthesizer:XST) FPGA: SPARTAN 3E

module error_example(
    input [47:0] data,
    input [2:0] sel,
    output [5:0] data_out
);

   assign data_out = data[sel*6 +: 6];

endmodule

WARNING:Xst:790 - "error_example.v" line 8: Index value(s) does not match array range, simulation mismatch.

Like I said, this works and I've done the math:

sel can have values from 0 to 7,

if sel is 0, then data_out = data[5:0] ...

if sel is 7, then data_out = data[47:42]

Should I do something differently here? Is this a bug in XST?

6

1 Answer 1

5

I have created the example on EDAplayground, which runs without warning.

I would not normally use widths with parameters and if you do you might want to be consistent with the reg definitions.

Try:

  1. parameter data = 48'h123456789ABC;
  2. parameter [47:0] data = 48'h123456789ABC;

I do not think I have used parameters this way before but declaring a constant reg implies the same logic, which might avoid the warning.

  1. reg [47:0] data = 48'h123456789ABC;

NB: It is good practise to use upper case for constants (parameter,localparam).

Alternatively convert to a case statement:

always @* begin
  case (sel)
    3'd0: data_out = 6'dx;
    3'd1: data_out = 6'dx;
    // ...
    default :  data_out = 6'd0;
  endcase
end
Sign up to request clarification or add additional context in comments.

7 Comments

Regardless of the parameter, the warning still exists.. Edited my question.
I would raise the issue with your tool vendor, the +:6 should guarantee the widths are the same. However this is a relatively new feature (2005) and support takes some time to propagate to all tools.
Actually, the +: is relatively old. It was introduced in IEEE Std 1364-2001 section 4.2.1 Vector bit-select and part-select addressing
@Greg Your correct, I should double check my facts before stating them. Part 15 Of Sunburst Verilog 2001 also covers it quite well.
@Morgan I like your answer but it doesn't completely address my question. My data was really 768 bits wide (reduced for the example) and I didn't want to write 128 different cases.
|

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.