Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Pack and unpack ordering

Hardware interview practice

Pack and unpack ordering

MediumUVM ComponentsSystemVerilog

A packet packs addr first and len second, but unpacks len first and addr second. The total bit count matches. What is the correct diagnosis?

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

function void do_pack(uvm_packer p);
  super.do_pack(p);
  p.pack_field_int(addr, 16);
  p.pack_field_int(len,   8);
endfunction
function void do_unpack(uvm_packer p);
  super.do_unpack(p);
  len  = p.unpack_field_int(8);
  addr = p.unpack_field_int(16);
endfunction
Choose one

Answer choices

  1. A. The stream is positional, so unpack must mirror pack order; otherwise field values are decoded from the wrong bits
  2. B. The round trip is valid because only the total width matters
  3. C. uvm_packer automatically tags each field name and repairs the order
  4. D. Only enum fields can be packed manually
Continue practicing

Related questions

UVM ComponentsField automation reference copying→UVM ComponentsManual do_copy and do_compare→
asic.fyi · Learn silicon end to end.info@asic.fyi