G
googler
Guest
I have a combinational 'always' block inside which I am assigning to
some signals. For some reason, some of the signal assignments are
inferring a latch. The 'always' block has a 'for' loop inside it which
repeats 8 times and inside this loop, the signals are assigned. The
code looks like below.
reg abcd1[7:0];
reg [3:0] wxyz1[7:0];
reg abcd2[7:0];
reg [3:0] wxyz2[7:0];
reg [11:0] ptr;
integer ii2;
always @(ptr or ..............)
begin
for (ii2 = 0; ii2 < 8; ii2 = ii2+1)
begin
abcd1[(ptr+ii2)%8] = <some expression>;
wxyz1[(ptr+ii2)%8] = <some expression>;
end
for (ii2 = 0; ii2 < 8; ii2 = ii2+1)
begin
abcd2[ii2] = <some expression>;
wxyz2[ii2] = <some expression>;
end
end
In the above code, the signals abcd1[0], abcd1[1],....,abcd1[7] and
wxyz1[0], wxyz1[1],.....,wxyz1[7] are inferring latches. These signals
are all assigned inside the first 'for' loop. However, the signals
inside the second 'for' loop are not inferring latch. From this
behavior, I understood that in case of the first 'for' loop it is
inferring latches because the synthesis tool expects all values of
'ptr' to be covered. (I think in this case it might be a limitation of
the tool, because the loop iterates 8 times, so all the 8 values of
the index are covered anyway)
So my question is, how to write this code so that the first 'for' loop
does not infer any latch? Thanks.
some signals. For some reason, some of the signal assignments are
inferring a latch. The 'always' block has a 'for' loop inside it which
repeats 8 times and inside this loop, the signals are assigned. The
code looks like below.
reg abcd1[7:0];
reg [3:0] wxyz1[7:0];
reg abcd2[7:0];
reg [3:0] wxyz2[7:0];
reg [11:0] ptr;
integer ii2;
always @(ptr or ..............)
begin
for (ii2 = 0; ii2 < 8; ii2 = ii2+1)
begin
abcd1[(ptr+ii2)%8] = <some expression>;
wxyz1[(ptr+ii2)%8] = <some expression>;
end
for (ii2 = 0; ii2 < 8; ii2 = ii2+1)
begin
abcd2[ii2] = <some expression>;
wxyz2[ii2] = <some expression>;
end
end
In the above code, the signals abcd1[0], abcd1[1],....,abcd1[7] and
wxyz1[0], wxyz1[1],.....,wxyz1[7] are inferring latches. These signals
are all assigned inside the first 'for' loop. However, the signals
inside the second 'for' loop are not inferring latch. From this
behavior, I understood that in case of the first 'for' loop it is
inferring latches because the synthesis tool expects all values of
'ptr' to be covered. (I think in this case it might be a limitation of
the tool, because the loop iterates 8 times, so all the 8 values of
the index are covered anyway)
So my question is, how to write this code so that the first 'for' loop
does not infer any latch? Thanks.