Forum Discussion
Altera_Forum
Honored Contributor
14 years agoYou can use a function, like the one below and hope that Quartus synthesizes it efficiently.
It will produce a rather long combinational path, but I don't think that can be avoided. function [5:0] getIndex(input [63:0] data); integer i; for(i = 63; i >= 0; i = i - 1) begin if (data[63-i] == 1'b1) getIndex = i; end endfunction assign index = getIndex(sum);