79134203

Date: 2024-10-28 16:11:03
Score: 1.5
Natty:
Report link

Say your bitmap is 256 bits and you want to produce an index of 8 bits.

logic [255:0] bitmap;
logic   [7:0] idx;

always_comb begin
  idx = '0;
  for (int i = 0; i < 256; i++) begin 
    if (bitmap[i]) begin
      idx |= 8'(i);
    end
  end
end
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Biswajit Khandai