Factory机制: 1、 UVM强烈推荐使用uvm_component_utils或者uvm_object_utils宏来注册。用法: Class A extends uvm_component `uvm_component_utils(A); Endclass 创建一个A的实例如下: A a; a=A::type_id::create(“a”,this); 通过该方式,可以使用UVM的众多功能。
2、 override功能: 需要对某些类进行改写时,可用override功能。先从my_driver派生出一个类,定义为: Class new_driver extends my_driver; ……… `uvm_component_utils(new_driver) Endclass 之后在case的build_phase中调用override相关的函数: Class case_x extends base_test; Function void build_phase(uvm_phase phase); …….. Set_type_override_by_type(my_driver::get_type(),new_driver::get_type()); Endfunction Endclass 经过上诉过程后,在跑case_x的时候,系统运行my_driver就是new_driver类型,其行为就是new_driver。有个前提是在agent实例化的时候,要使用factory机制。 Class my_agent; My_driver drv; Function void buile_phase(uvm_phase phase); ……. Drv=my_driver::type_id::create(“drv”,this); Endfunction Endclass
3、 phase及objection 在不同时间做不同的事情,这是UVM中phase的设计哲学。 UVM中常用phase: 根绝是否消耗仿真时间的特性,分为function phase和task phase。Function phase 不消耗仿真时间,比如buile_phase,connect_phase等。另一类是run_phase等,通过task来消耗仿真时间。上图中除了run_phase消耗时间外,其他都不消耗时间。
各个phase的执行顺序: 除了Build_phase是一种自上而下的执行顺序,所有的不耗仿真时间的phase都是自下而上执行的。
UVM中所有的phase: 上图将run_phase分割为12个小的phase,自下而上的启动,同时运行。 Reset、configure、main、shutdown四个phase是核心。 在reset_phase对DUT进行复位,初始化等操作。 在configure_phase则进行DUT配置 在main_phase中运行 Shutdown_phase则做一些与DUT断电相关的操作。
Phase.raise_objection(this); ………………. Phase.drop_objection(this);来控制验证平台的开启和关闭 一般是将开启和关闭放在sequence中。
新闻热点
疑难解答