algorithm - Finding the next in round-robin scheduling by bit twiddling -


Consider the following problem: You have a bit string that shows the currently scheduled slave in one-hot encoding.

Now, I want to pick the next scheduled slave in the round-robin scheduling scheme, with a twist. I have a "request mask" that says what slave really wants to determine, the next slave should be chosen only from those who want to.

Some examples (round robin scheduling is done by rotating left). "00000100" Mask: "01100000"

  • Next timetable: "00100000" - In normal round-robin, # 1: "00000100"
  • 3 and then # 4 Should come after # 2, but they do not request, so # 5 is picked up. Example 2:

    • Current: "Mask:" 00001010 "
    • Next:" 00000010 "- Since scheduling left cycling , And # 1 is the first requestor in that order is a slave.

    Now, it can be easily coded into a loop, I know. I want to get my results without a loop, with a little bit of operating. Inspiration: I will call it VHDL / Verilog in hardware (in FPGA) .

    A bonus is for creating an algorithm which is generic for any slave N.

    By the way, it is not a homework question, it is an important problem. Whenever someone has to schedule slaves in some way, and the timeliness of the requests of slaves. My current solution is somewhat "heavy" and I want to know that I am not clear.

  • A loop

    I just

      turn on [i] = current [i-1] & mask [i] | // general changes logic mask [i] & Amp; Current [I-2] & amp; Mask [i-1] | // Create the expression for the logic ... ... / /  

    here and then put it in a generated loop (i.e. it will open in hardware), for which The parallel hardware will produce the expressions

    Other use of the solution mentioned herein many "-" I can only discourage them, because it will give you very expensive operation. In a warmer you can get more easily than 32 bits, which will not be easily implemented in HW, because the lender will have to go through all the bits (some FPAG's Dedicated Logistics makes it accessible to small numbers of bits ).


    Comments