Here a very cute method to implement an FPGA round robin arbiter, inspired by [1].
Assumption
Incoming signals “req”/”ack”, outgoing signal “grant”.
Needed Behaviour
req = “0001000″ => grant = “0001000″ -ACK- grant = “0001000″
req = “0011000″ => grant = “0010000″ -ACK- grant = “0001000″ -ACK- grant = “0010000″ …
Technique
To create a priority arbiter, we just calculate the two’s complement of the request signal and bitwise AND the result with the request line (1). As result the least significant bit has the highest priority. This equation always returns the request with the highest priority.
(1) gnt <= req and not(req)+1;
To create a round robin arbiter we have to save the previous grant signal. We use this signal to masked out the previous grant signal (2) and use the method from (1) to get the least significant active bit.
(2) reqs <= req and not ((pre_gntM - 1) or pre_gntM); (1) gnts <= reqs and not(reqs)+1;
The last step to implement the RR-Arbiter is to select between “gnt” and “gnts” (3). If all previous grant signals are masked we just start with the highest priority of equation (1).
(3) gntM <= gnts when reqs /= 0 else gnt;
Conclusion
This technique can be used to create a round robin arbiter for any number of input bits. Only one parameter must be changed so increase/decrease inputs and outputs.
[update 2010] Since I got some requests, Round Robin Arbiter.
[1] http://stackoverflow.com/questions/480405/finding-the-next-in-round-robin-scheduling-by-bit-twiddling
Entries (RSS)