NVIDIA Interview Question

Design an arbiter.

Interview Answer

Anonymous

May 30, 2016

Let's say we want to take turns to dequeue from two FIFOs. For the first fifo, the interface is vld0, deq0. For the second FIFO, the interface is vld1, deq1. The code can be like this: assign deq0 = vld0 & (~sel | ~vld1); assign deq1 = vld1 & ( sel | ~vld0); assign next_sel = ( (deq0 & ~sel) | (deq1 & sel) ) ? ~sel : sel; always_ff @(posedge clk) if( ~rst) sel <= 1'b0; else sel <= next_sel; end end