前言
UVMC 提供了一组API可用于在SystemC layer对UVM的组件factory进行访问操作,用于层次打印,组件重载,调试,以及打印重载类型等等
- 组件打印:
uvmc_print_factory(),
传入参数当all_types为0时,只显示类型和实例覆盖。当all_types为1(默认值)时,所有注册的用户定义类型也会被打印出来,前提是它们具有与之关联的类型名称。(参数化类型通常不需要。)当all_types为2时,所有UVM类型(前缀为uvm_)都包含在注册类型列表中。 - 组件重载
uvmc_set_factory_type_override(request_type,override_type, context
) 设置类型覆盖uvmc_set_factory_inst_override(request_type,override_type, context)
设置指定类型实例覆盖
所有被覆盖的类型必须要首先被工厂模式所注册
参数说明:request_type
: 需要替换的原始类型override_type
: 将要替换的目标类型, override_type 必须继承自request_typecontext
: 用于实例替换,指明实例在仿真空间的层次
组件重载信息调试
uvmc_debug_factory_create(requset_type, context)
显示关于UVM factory将创建的对象类型的详细信息(给定请求的类型和上下文),列出指定context的应用的所有重载情况
参数说明与上文一致
显示调试信息如下Given a request for an object of type 'producer' with an instance path of 'e.prod' the factory encountered the following relevant overrides. An 'x' next to a match indicates a match that was ignored. Original Type Instance Path Override Type ------------- ------------- ------------- producer * producer_ext <type override> Result: The factory will produce an object of type 'producer_ext' (*) Types with no associated type name will be printed as <unknown> #### UVM_INFO /home/shawntan/EDA/snps/vcs_2018.09/vcs-mx/O-2018.09/etc/uvm/src/base/uvm_factory.svh(1786) @ 0: reporter [UVM/FACTORY/DUMP] #### Factory Override Information (*) Given a request for an object of type 'scoreboard' with an instance path of 'e.sb' the factory encountered the following relevant overrides. An 'x' next to a match indicates a match that was ignored. Original Type Instance Path Override Type ------------- ------------- -------------- scoreboard e.* scoreboard_ext Result: The factory will produce an object of type 'scoreboard_ext' (*) Types with no associated type name will be printed as <unknown>
获得当前对象的实际重载类型
string uvmc_find_factory_override(requeset_type, context)
返回类型为context指明组件重载类型的字符串名字
参数:request_type
:为要创建的假设调用请求的类型名context
: 发出请求的组件的层次结构路径。不允许通配符或正则表达式。上下文必须与现有组件的层次结构名称完全匹配,或者可以是指定全局上下文的空字符串
实际的操作效果如下:uvmc_set_type_override("B","C");
uvmc_set_type_override("A","B");
uvmc_set_inst_override("D", "C", "top.env.agent1.*");
$display(uvmc_find_factory_override("A"));
显示类型为“C”,说明重载的链式关系
*$display(uvmc_find_factory_override("A", "top.env.agent1.driver"));
, 显示类型为“D”, 因为假设创建driver的类型与A不一致,所以显示driver的类型为“D”
返回的字符串可用于随后对uvmc_set_factory_type_override
和uvmc_set_factory_inst_override
的调用
实例说明
class producer_ext extends producer; `uvm_component_utils(producer_ext) function new(string name, uvm_component parent=null); super.new(name,parent); `uvm_info("PRODUCER_EXTENSION","Derived producer created!",UVM_NONE); endfunction endclass class scoreboard_ext extends scoreboard; `uvm_component_utils(scoreboard_ext) function new(string name, uvm_component parent=null); super.new(name,parent); `uvm_info("SCOREBOARD_EXTENSION","Derived scoreboard created!",UVM_NONE); endfunction endclass
以上producer_ext和scoreboard_ext 均派生自工厂方法注册的producer_ext/scoreboard基本类
在systemC侧的factory方法如下
void top::show_uvm_factory()
{
string override;
// print the factory before we do anything
uvmc_print_factory();
// what type would the factory give if we asked for a producer?
override = uvmc_find_factory_override("producer","e.prod");
UVMC_INFO("SHOW_FACTORY",
(string("Factory override for type 'producer' ") +
+ "in context 'e.prod' is " + override).c_str(),
UVM_NONE,"");
// show how factory chooses what type it creates
uvmc_debug_factory_create("producer","e.prod");
// set a type and instance override
uvmc_set_factory_type_override("producer","producer_ext","e.*");
uvmc_set_factory_inst_override("scoreboard","scoreboard_ext","e.*");
// print the factory after setting overrides
uvmc_print_factory();
uvmc_debug_factory_create("producer","e.prod");
uvmc_debug_factory_create("scoreboard","e.sb");
// NOW what type would the factory give if we asked for a producer?
override = uvmc_find_factory_override("producer","e.prod");
UVMC_INFO("SHOW_FACTORY",
(string("Factory override for type 'producer' ") +
+ "with context 'e.prod' is " + override).c_str(),
UVM_NONE,"");
// What type would the factory give if we asked for a scoreboard?
override = uvmc_find_factory_override("scoreboard","e.*");
UVMC_INFO("SHOW_FACTORY",
(string("Factory override for type 'scoreboard' ") +
+ "given a context 'e.*' is " + override).c_str(),
UVM_NONE,"");
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。