Finding the next in round-robin scheduling by bit twiddling

前端 未结 9 1719
日久生厌
日久生厌 2021-02-02 02:46

Consider the following problem. You have a bit-string that represents the current scheduled slave in one-hot encoding. For example, \"00000100\" (with the leftmost bit being #7

9条回答
  •  天涯浪人
    2021-02-02 03:19

    Untested, but off the top of my head, I'd be surprised if this didn't produce ma reasonable synthesis... Has the advantage of being relatively readable (to me anyway) unlike typical bit-twiddling hacks.

    for i in current'range loop
      current := rotate_left(current, 1);
      if or_reduce(mask and current) = '1' then
         current:= mask and current;
      end if;
    end loop;
    

提交回复
热议问题