UVM Coding Practice · Senior

Reg Adapter reg2bus / bus2reg

Byte order, masks, APB mapping.

Interview prompt

Map 32-bit STATUS reg to APB read with byte lanes.

diagram
WHITEBOARD CHAIN

1. DECLARE    interfaces / types / ports you need
2. SKELETON   class extends + utils macro + key methods
3. MECHANISM  fill one critical method while narrating
4. PITFALL    name one bug juniors make on this pattern
5. TEST       how you would smoke-test the component

Reference sketch (≤40 lines)

systemverilog
virtual function void reg2bus(uvm_reg_item rw, ref apb_txn bus);
  bus.addr = rw.addr; bus.write = rw.kind != UVM_READ;
  bus.data = rw.data[0]; bus.strb = 4'b1111;
endfunction

Code lab drill

After reading, try Code lab exercise uvm-l8-int-reg-adapter — topic reference: /topics/uvm/coding-practice/ral-adapters/reg-adapter-reg2bus-bus2reg

Common pitfalls

  • Wrong endianness.

  • Mask ignores field width.

  • reg2bus for read path wrong data dir.