Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Verify a dictionary-order permutation streamer

Hardware interview practice

Verify a dictionary-order permutation streamer

MediumStreaming AlgorithmsSystemVerilog

Verify a single-request block that accepts one to seven distinct bytes and streams every permutation in lexicographic order while requests and responses may stall independently.

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

interface perm_if #(int N=7)(input logic clk);
  logic rst_n, req_valid, req_ready;
  logic [3:0] count;
  logic [7:0] item[N];
  logic out_valid, out_ready, out_last, out_error;
  logic [7:0] permutation[N];
  logic [3:0] out_count;
endinterface
Reviewed example

Work through one case

Input
accepted distinct bytes=[b,a,c]
Expected output
[abc, acb, bac, bca, cab, cba]

Sorting the captured frame establishes the first lexicographic permutation; successive next-permutation steps produce all 3! results.

What to cover

Requirements

  1. For a legal count, deep-copy and sort the accepted bytes, then expect exactly count-factorial permutations with unused lanes zero.
  2. A duplicate byte or count outside 1 through 7 produces one final zero-payload error beat and no successful permutations.
  3. Keep req_ready low until the final response handshake; bound the first beat, inter-beat gaps, and total completion when out_ready is high.
  4. Require stable stalled output, out_last only on the final item, and complete cancellation on reset.
Continue practicing

Related questions

Verification UtilitiesDrive random back-pressure→UVM ComponentsDrive a ready/valid interface correctly→UVM ComponentsMonitor a ready/valid interface→
asic.fyi · Learn silicon end to end.info@asic.fyi