for( i = 0; i < 32; i ++ ) begin if ( (din >> i) & 0x1) // right shift and detect the lsb cnt = cnt + 1; end