There are 2-3 ways to code this. The obvious is a for loop from msb to lsb. This actually works when the synthesis tool understands and implements this in a good way. The fancy way uses "bitscan" with (x) & (-x). This expression returns a one-hot vector with the lowest 1 being the only bit set. The third method is manually generating the logic for a priority encoder.
There is also a priority encoder implementation that takes a 1-hot vector and does the and-or map-reduce with 10101010, 11001100, 11110000, etc...