U
Uwe Stange
Guest
Hi,
I encountered that traversing a vector bit by bit and incrementing a
counter for every zero found shows less performance than traversing
the vector in steps of two bit and adding 1 or 2 to the counter
depending on the bit pattern found.
Code snippet 1
--------------
for (i=0; i<=31; i=i+1)
if (vec_in == 1'b0)
counter = counter + 1'b1;
Code snippet 2
--------------
for (i=0; i<=30; i=i+2)
case( {vec_in[i+1],vec_in} )
2'b11: ;
2'b10: counter = counter + 1;
2'b01: counter = counter + 1;
2'b00: counter = counter + 2;
endcase
I'am 'measuring' performance in terms of estimated area, number of
nets and max path. Version 2 is at least 30% smaller/faster than
version 1. I do not know where such a big difference originates from.
Is this depending on the technology I am mapping to?
Any suggestions?
Bye! Uwe.
I encountered that traversing a vector bit by bit and incrementing a
counter for every zero found shows less performance than traversing
the vector in steps of two bit and adding 1 or 2 to the counter
depending on the bit pattern found.
Code snippet 1
--------------
for (i=0; i<=31; i=i+1)
if (vec_in == 1'b0)
counter = counter + 1'b1;
Code snippet 2
--------------
for (i=0; i<=30; i=i+2)
case( {vec_in[i+1],vec_in} )
2'b11: ;
2'b10: counter = counter + 1;
2'b01: counter = counter + 1;
2'b00: counter = counter + 2;
endcase
I'am 'measuring' performance in terms of estimated area, number of
nets and max path. Version 2 is at least 30% smaller/faster than
version 1. I do not know where such a big difference originates from.
Is this depending on the technology I am mapping to?
Any suggestions?
Bye! Uwe.