D
DaveW
Guest
I came up with the following (simplified) code snippet for a leading
zero counter - question is: is this the "best" way to do it? I know it
works but I wonder if there is a more efficient/correct approach.
==============================================
:
input clk;
input [23:0] xn;
:
:
reg [23:0] lz_count_reg;
reg [4:0] count;
always @( posedge clk )
begin
lz_count_reg=24;
for( count=0; count<24; count=count+1 )
if( xn[ count ] )
lz_count_reg=23-count;
end
=================================================
Thanks in anticipation...
zero counter - question is: is this the "best" way to do it? I know it
works but I wonder if there is a more efficient/correct approach.
==============================================
:
input clk;
input [23:0] xn;
:
:
reg [23:0] lz_count_reg;
reg [4:0] count;
always @( posedge clk )
begin
lz_count_reg=24;
for( count=0; count<24; count=count+1 )
if( xn[ count ] )
lz_count_reg=23-count;
end
=================================================
Thanks in anticipation...