The behavior I want is in example 1. I didn't verify example 2, and looking back there is probably a mistake anyway (zeros to right should be don't care, after ones). In either case, what I meant about being optimal is speed wise, I don't care if it uses more or less resources. My design ideally would be able to run in excess of 333 MHz which might not be realistic, but the closer I can get to that number or beyond the better, and I want to minimize logic layers. FvM I did find the code for example t2 in another book, and is nice and compact code, but I don't know what performance I can achieve yet. The input width's could be anywhere between 12-64. I was not able to find any information on altpriority_encoder, I can't find it in the MegaWizard. Where exactly is it located?