版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
最近在帮同事debug时发现一个问题:
class tr extends uvm_sequence_item;
...
bit[3:0] data_q[4][$];
`uvm_object_utils_begin(tr)
`uvm_field_queue_int(data_q[4],UVM_DEFAULT)
//`uvm_field_queue_int(data_q,UVM_DEFAULT) -->compile error
`uvm_object_utils_end
endclass
//in driver
seq_item_port.get_next_item(req);
$cast(trans,req.clone());
上述写法调用clone,并不会复制data[4][$]中的data。
对于data_q[4][$]称为array queue,但field automation 无法support这种类型,包括data_q[4][4]这种二维数组也无法support。
solution
class tr extends uvm_sequence_item;
...
bit[3:0] data_q[4][$];
`uvm_object_utils_begin(tr)
`uvm_field_queue_int(data_q[0],UVM_DEFAULT)
`uvm_field_queue_int(data_q[1],UVM_DEFAULT)
`uvm_field_queue_int(data_q[2],UVM_DEFAULT)
`uvm_field_queue_int(data_q[3],UVM_DEFAULT)
`uvm_object_utils_end
endclass