Hardware interview practice
Schedule bank commands with accepted-slot cooldown
Buffer a frame of commands for four banks, then reorder across banks so repeated commands to one bank have at least C intervening accepted slots. Emit accepted idle tokens only when no pending bank is eligible.
Reviewed example
Work through one case
Input
C=1; framed commands in arrival order: bank0=A, bank0=B, bank1=CExpected output
accepted slots: bank0 A, bank1 C, bank0 BBank 0 initially has the largest queue; after A, one accepted command from bank 1 supplies the required intervening cooldown slot before B.
What to cover
Requirements
- Buffer 1 through 16 commands and capture C in the range 0 through 3 with the first command.
- Preserve arrival order within each bank while allowing reordering across banks.
- Choose the eligible bank with the largest pending count and break ties by lower bank ID.
- Advance cooldown, FIFO heads, and pending counts only when slot_valid and slot_ready are both high.
- Count accepted idle tokens as intervening slots and hold the selected token stable during backpressure.
