Hardware interview practice
Pack and unpack ordering
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?
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);
endfunctionChoose one
Answer choices
- A. The stream is positional, so unpack must mirror pack order; otherwise field values are decoded from the wrong bits
- B. The round trip is valid because only the total width matters
- C. uvm_packer automatically tags each field name and repairs the order
- D. Only enum fields can be packed manually
