title: First non-zero element encoder in Verilog
body: <p>Suppose I have an array A containing binary numbers, e.g. [0 0 1 0 1 1]. Now I want to build an encoder that can identify the location of the first '1' in array A. For example, the logic should output 3 for array A if we give index 1 to the first element in that array. Is there any elegant way of doing it? I guess one way to do it is using a ROM, but how do you write it in Verilog? Using a look up table?</p>