SV & UVM中的面向对象:应用


在UVM验证环境中,对于一笔RTL transaction,在TB中会创建一个对应的sbx_trans。伴随着RTL transaction在DUT中流动,运算,编解码等,我们会对sbx_trans的下属变量做对应的操作。SV的OOP特性很好的支持了这一点:

即对于一笔RTL transaction,只需创建一个sbx_trans对象,然后将sbx_trans的句柄通过analysis port广播到不同的UVM component,那么在不同的UVM component中,都可以通过sbx_trans的句柄访问唯一的sbx_trans对象。如下图所示:

 参考如下代码:

  • 该代码来自于driver中setup data阶段,首先创建一个sbx_trans对象;
  • 将sbx_trans对象的句柄广播给component B,component B会修改sbx_trans的下属变量;
  • 做一些其他的setup工作;
  • 最终将setup完成后的sbx_trans的句柄发送给sbx。
function rddata_setup();
    sbx_trans = sbx_transaction::type_id::create("sbx_trans", this);
    
    // broadcast sbx_trans handle to component B.
    sbx_rddata_encode_ap.write(sbx_trans);

    // do other things.

    // broadcast to sbx.
    sbx_rddata_ap.write(sbx_trans);

endfunction

问题在于:

由于所有的步骤都是在function中完成的,所以是不耗时的。那么在component B中对sbx_trans的修改,在通过sbx_rddata_ap广播给sbx的时候是否已经完成呢?

不必担心,sbx_rddata_encode_ap.write(sbx_trans)的本质是在调用function,虽然不耗时,但是只有这个function结束后程序才能往下走。因此sbx_trans在广播给sbx时,必然是能看到component B对sbx_trans的修改的。

UVM