A fetch director in a multithreaded microprocessor that concurrently
executes instructions of N threads is disclosed. The N threads request to
fetch instructions from an instruction cache. In a given selection cycle,
some of the threads may not be requesting to fetch instructions. The
fetch director includes a circuit for selecting one of threads in a
round-robin fashion to provide its fetch address to the instruction
cache. The circuit adds a first addend to a 1-bit left-rotated version of
a second addend to generate a sum and a carry-out bit. The circuit
includes the carry-out bit as a carry-in bit of the add to generate the
sum. The sum is ANDed with the inverse of the first addend to generate a
1-hot vector indicating which of the threads is selected next. The first
addend is an N-bit vector where each bit is false if the corresponding
thread is requesting to fetch instructions from the instruction cache.
The second addend is a 1-hot vector indicating the last selected thread.
In one embodiment threads with an empty instruction buffer are selected
at highest priority; a last dispatched but not fetched thread at middle
priority; all other threads at lowest priority. The threads are selected
round-robin within the highest and lowest priorities.