How to rewrite ULCO error compare between genvar and int?
You should use a cast to eliminate size mismatch errors
input wire valid;
wire [NUM_UNITS-1:0] valid_per_unit;

for (genvar unit = 0; unit &lt; NUM_UNITS; unit++) begin : gen_valid_per_unit
      assign valid_per_unit[unit] = valid &amp;&amp; (unit == int'(current_unit_r));
end