UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 22066

8.2i XST - Using the same integer variable for two separate loops generates an incorrect netlist

Description

Using two "for" loops with the same integer variable, even if they are in two separate processes, generates an incorrect netlist.

The following example generates an incorrect netlist:

======================================================

module test_broken(a, y);

// Inputs and outputs

input [7:0] a;

output [7:0] y;

// Declare variables

reg [7:0] r;

reg [7:0] y;

// Declare iterator

integer i;

// Reverse input

always @(a) for (i = 0; i < 8; i = i + 1) r[i] = a[7-i];

// OR with mask 10101010

always @(r) for (i = 0; i < 8; i = i + 1) y[i] = r[i] | i[0];

endmodule

=======================================================

Solution

To work around this issue, use two separate integer variables as follows:

========================================================

module test_working(a, y);

// Inputs and outputs

input [7:0] a;

output [7:0] y;

// Declare variables

reg [7:0] r;

reg [7:0] y;

// Declare iterators

integer i, j;

// Reverse input

always @(a) for (i = 0; i < 8; i = i + 1) r[i] = a[7-i];

// OR with mask 10101010

always @(r) for (j = 0; j < 8; j = j + 1) y[j] = r[j] | j[0];

endmodule

==========================================================

This issue is scheduled to be fixed in ISE 11.1.

AR# 22066
Date Created 09/04/2007
Last Updated 12/15/2012
Status Active
Type General Article