Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Select the oldest ready micro-operation

Hardware interview practice

Select the oldest ready micro-operation

MediumRTL DesignSystemVerilog

An eight-entry issue queue exposes valid, ready, and age fields. Age 0 is oldest. Write combinational SystemVerilog that selects one entry.

Try it in the question bankReason first. Then compare.

Keep this exact question selected while you check your answer and review the full solution.

Practice this question →
Starting point

Question code

parameter int N=8;
input logic [N-1:0] valid, ready;
input logic [7:0] age [N];
output logic grant_valid;
output logic [$clog2(N)-1:0] grant_idx;
Reviewed example

Work through one case

Input
valid=ready=8'b0010_1000, age[3]=5, and age[5]=2.
Expected output
grant_valid=1 and grant_idx=5.

Entries 3 and 5 are eligible, and entry 5 has the smaller unsigned age value, so it is the oldest ready operation.

What to cover

Requirements

  1. Eligible entries are exactly those with valid[i] && ready[i].
  2. Choose the eligible entry with the smallest unsigned age value; if ages tie, choose the lower index.
  3. When no entry is eligible, set grant_valid=0 and grant_idx=0.
  4. Use complete combinational logic with no state; this is not a ready/valid transfer channel, so there is no backpressure and outputs need be stable only while inputs are stable.
Continue practicing

Related questions

RTL DesignEnabled modulo-five counter→RTL DesignAccumulate a four-lane signed dot product→RTL DesignEncode the highest active request and its one-hot form→
asic.fyi · Learn silicon end to end.info@asic.fyi