K
kb33
Guest
Hi,
I have been struggling with this bit of code for sometime, trying to
find the best way to write and synthesize it without warnings...but
have not been able to achieve the desired results. Though the module
is long, the main problem/warnings occurs in the attached code - it is
part of a CASE statement, and when the case `SORT_DATA is encountered,
the stored data in the arrays has to be sorted. My specific queries
are the following:
1. Strangely, the first always block in the Combinational logic
synthesizes, but the second one doesn't, even though the two are
supposed to react to the same set of conditions. The synthesis tool
just keeps running infinitely..
reg [`ATTRIB_SZ-1:0] attr_arr [0: `NUM_RSRC-1],
attr_arr_comb [0: `NUM_RSRC-1];
reg [`RSRC_ID_SZ-1:0] rsrc_id_arr [0: `NUM_RSRC-1],
rsrc_id_arr_comb [0: `NUM_RSRC-1];
//FLip-flop declaration....
always @(posedge clk)
begin
for (i = 0; i < `NUM_RSRC; i = i+1)
begin
attr_arr <= #1 attr_arr_comb ;
rsrc_id_arr <= #1 rsrc_id_arr_comb ;
end
end
//Combinational Logic...
always @*
begin
.
.
.
`SORT_DATA:
for (q=0; q<`NUM_RSRC/2 ; q=q+1)
if (((var_a & var_c_arr[q+b_index]) == 0) && (attr_arr[var_c_arr[q
+b_index]] > attr_arr[var_bxorc_arr[q+b_index]]))
begin
attr_arr_comb[var_c_arr[q+b_index]] <= attr_arr[var_bxorc_arr[q
+b_index]];
attr_arr_comb[var_bxorc_arr[q+b_index]] <= attr_arr[var_c_arr[q
+b_index]];
end
else if (((var_a & var_c_arr[q+b_index]) != 0) &&
(attr_arr[var_c_arr[q+b_index]] < attr_arr[var_bxorc_arr[q+b_index]]))
begin
attr_arr_comb[var_c_arr[q+b_index]] <= attr_arr[var_bxorc_arr[q
+b_index]];
attr_arr_comb[var_bxorc_arr[q+b_index]] <= attr_arr[var_c_arr[q
+b_index]];
end
else
begin
attr_arr_comb[var_c_arr[q+b_index]] <= attr_arr[var_c_arr[q
+b_index]];
attr_arr_comb[var_bxorc_arr[q+b_index]] <= attr_arr[var_bxorc_arr[q
+b_index]];
end
.
.
.
end
//This doesn't synthesize....
always @*
begin
.
.
.
`SORT_DATA:
for (n=0; n<`NUM_RSRC/2 ; n=n+1)
if (((var_a & var_c_arr[n+b_index]) == 0) && (attr_arr[var_c_arr[n
+b_index]] > attr_arr[var_bxorc_arr[n+b_index]]))
begin
rsrc_id_arr_comb[var_c_arr[n + b_index]] <=
rsrc_id_arr[var_bxorc_arr[n + b_index]];
rsrc_id_arr_comb[var_bxorc_arr[n + b_index]] <=
rsrc_id_arr[var_c_arr[n + b_index]];
end
else if (((var_a & var_c_arr[n+b_index]) != 0) &&
(attr_arr[var_c_arr[n+b_index]] < attr_arr[var_bxorc_arr[n+b_index]]))
begin
rsrc_id_arr_comb[var_c_arr[n + b_index]] <=
rsrc_id_arr[var_bxorc_arr[n + b_index]];
rsrc_id_arr_comb[var_bxorc_arr[n + b_index]] <=
rsrc_id_arr[var_c_arr[n + b_index]];
end
else
begin
rsrc_id_arr_comb[var_c_arr[n + b_index]] <= rsrc_id_arr[var_c_arr[n
+ b_index]];
rsrc_id_arr_comb[var_bxorc_arr[n + b_index]] <=
rsrc_id_arr[var_bxorc_arr[n + b_index]];
end
.
.
.
end
2. As is clear from the above code, I am using a complex scheme of
referencing other arrays and variables in order to determine the swap
condition. Though this gives me the correct simulation results, I am
not sure if this is a good way to do it. BTW, the values in the
var_c_arr and var_bxorc_arr arrays are static, they are set at the
time of initialization. The variable b_index changes, though.
3. I figured out that when arrays are created structurally instead of
behavior models, the synthesis warnings about the array element not
being in the sensitivity list are eliminated. Hence I try to use the
GENERATE statement to create arrays as often as I can. However, in
this case, the array has to be written into, and then later, the
stored values have to be swapped/sorted....I cannot figure out how to
do them both using a structural model. The behavioral model, of
course, is generating multiple synthesis warnings.
Thanks
kb33
I have been struggling with this bit of code for sometime, trying to
find the best way to write and synthesize it without warnings...but
have not been able to achieve the desired results. Though the module
is long, the main problem/warnings occurs in the attached code - it is
part of a CASE statement, and when the case `SORT_DATA is encountered,
the stored data in the arrays has to be sorted. My specific queries
are the following:
1. Strangely, the first always block in the Combinational logic
synthesizes, but the second one doesn't, even though the two are
supposed to react to the same set of conditions. The synthesis tool
just keeps running infinitely..
reg [`ATTRIB_SZ-1:0] attr_arr [0: `NUM_RSRC-1],
attr_arr_comb [0: `NUM_RSRC-1];
reg [`RSRC_ID_SZ-1:0] rsrc_id_arr [0: `NUM_RSRC-1],
rsrc_id_arr_comb [0: `NUM_RSRC-1];
//FLip-flop declaration....
always @(posedge clk)
begin
for (i = 0; i < `NUM_RSRC; i = i+1)
begin
attr_arr <= #1 attr_arr_comb ;
rsrc_id_arr <= #1 rsrc_id_arr_comb ;
end
end
//Combinational Logic...
always @*
begin
.
.
.
`SORT_DATA:
for (q=0; q<`NUM_RSRC/2 ; q=q+1)
if (((var_a & var_c_arr[q+b_index]) == 0) && (attr_arr[var_c_arr[q
+b_index]] > attr_arr[var_bxorc_arr[q+b_index]]))
begin
attr_arr_comb[var_c_arr[q+b_index]] <= attr_arr[var_bxorc_arr[q
+b_index]];
attr_arr_comb[var_bxorc_arr[q+b_index]] <= attr_arr[var_c_arr[q
+b_index]];
end
else if (((var_a & var_c_arr[q+b_index]) != 0) &&
(attr_arr[var_c_arr[q+b_index]] < attr_arr[var_bxorc_arr[q+b_index]]))
begin
attr_arr_comb[var_c_arr[q+b_index]] <= attr_arr[var_bxorc_arr[q
+b_index]];
attr_arr_comb[var_bxorc_arr[q+b_index]] <= attr_arr[var_c_arr[q
+b_index]];
end
else
begin
attr_arr_comb[var_c_arr[q+b_index]] <= attr_arr[var_c_arr[q
+b_index]];
attr_arr_comb[var_bxorc_arr[q+b_index]] <= attr_arr[var_bxorc_arr[q
+b_index]];
end
.
.
.
end
//This doesn't synthesize....
always @*
begin
.
.
.
`SORT_DATA:
for (n=0; n<`NUM_RSRC/2 ; n=n+1)
if (((var_a & var_c_arr[n+b_index]) == 0) && (attr_arr[var_c_arr[n
+b_index]] > attr_arr[var_bxorc_arr[n+b_index]]))
begin
rsrc_id_arr_comb[var_c_arr[n + b_index]] <=
rsrc_id_arr[var_bxorc_arr[n + b_index]];
rsrc_id_arr_comb[var_bxorc_arr[n + b_index]] <=
rsrc_id_arr[var_c_arr[n + b_index]];
end
else if (((var_a & var_c_arr[n+b_index]) != 0) &&
(attr_arr[var_c_arr[n+b_index]] < attr_arr[var_bxorc_arr[n+b_index]]))
begin
rsrc_id_arr_comb[var_c_arr[n + b_index]] <=
rsrc_id_arr[var_bxorc_arr[n + b_index]];
rsrc_id_arr_comb[var_bxorc_arr[n + b_index]] <=
rsrc_id_arr[var_c_arr[n + b_index]];
end
else
begin
rsrc_id_arr_comb[var_c_arr[n + b_index]] <= rsrc_id_arr[var_c_arr[n
+ b_index]];
rsrc_id_arr_comb[var_bxorc_arr[n + b_index]] <=
rsrc_id_arr[var_bxorc_arr[n + b_index]];
end
.
.
.
end
2. As is clear from the above code, I am using a complex scheme of
referencing other arrays and variables in order to determine the swap
condition. Though this gives me the correct simulation results, I am
not sure if this is a good way to do it. BTW, the values in the
var_c_arr and var_bxorc_arr arrays are static, they are set at the
time of initialization. The variable b_index changes, though.
3. I figured out that when arrays are created structurally instead of
behavior models, the synthesis warnings about the array element not
being in the sensitivity list are eliminated. Hence I try to use the
GENERATE statement to create arrays as often as I can. However, in
this case, the array has to be written into, and then later, the
stored values have to be swapped/sorted....I cannot figure out how to
do them both using a structural model. The behavioral model, of
course, is generating multiple synthesis warnings.
Thanks
kb33