其实大体看懂了源码的框架的话,这里也就是照猫画虎,phase源码参考:https://www.cnblogs.com/xuqing125/p/15826609.html
https://www.edrawmax.cn/online/share.html?code=83c3b8b8799e11ec8a7585ec8adb0e95
先来回顾一下phase是怎么从上面被调用起来的:
- uvm_domain::get_common_domain() ---- add()将整个链串串接起来
- 顶层的forever调用phase.execute_phase()
- execute_phase调用traverse()将UVM tree上所有的component对应的phase执行起来。
- excute call exec_task
需求在pre_reset_phase和reset_phase之间添加一个my_training_phase?
第一步:按照pre_reset_phase的写法来写my_traning_phase.svh。
将其做替换成my_training_phase,但是编译会报错,为什么呢?
上图就解释了在uvm_component里面其实有uvm_phase的callback的接口,也就是virtual实现的多肽,但是没有my_training_phase的hook,所以这里不能这样写。
解决方案一:修改uvm_component.svh的源码将它加上去。当然这个站在用户的角度来讲是不现实的。
解决方案二:直接修改my_training_phase.svh的exec_task函数。
第二步:从uvm_component中扩展C,写training_phase,并且将结点添加到原来的phase中。
- uvm_domain::get_uvm_schedule(),static的函数返回的是包含12个phase的schedule。return的类型是uvm_phase的类型。
- add函数,是将after_phase放在my_training_phase的前面,before_phase放在my_training_phase的后面。
修改add函数:
注意:add函数有with_phase的参数,这样的话可以将两个phase用fork...join并行起来。