前言

UVMC 提供了一组API可用于在SystemC layer对UVM的组件factory进行拜访操作,用于档次打印,组件重载,调试,以及打印重载类型等等

  1. 组件打印
    uvmc_print_factory(),
    传入参数当all_types为0时,只显示类型和实例笼罩。当all_types为1(默认值)时,所有注册的用户定义类型也会被打印进去,前提是它们具备与之关联的类型名称。(参数化类型通常不须要。)当all_types为2时,所有UVM类型(前缀为uvm_)都蕴含在注册类型列表中。
  2. 组件重载
    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_type
context: 用于实例替换,指明实例在仿真空间的档次

  1. 组件重载信息调试
    uvmc_debug_factory_create(requset_type, context)
    显示对于UVM factory将创立的对象类型的详细信息(给定申请的类型和上下文),列出指定context的利用的所有重载状况
    参数阐明与上文统一
    显示调试信息如下

    Given a request for an object of type 'producer' with an instancepath of 'e.prod' the factory encounteredthe following relevant overrides. An 'x' next to a match indicates amatch 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 instancepath of 'e.sb' the factory encounteredthe following relevant overrides. An 'x' next to a match indicates amatch that was ignored.Original Type  Instance Path  Override Type   -------------  -------------  --------------  scoreboard     e.*            scoreboard_extResult:  The factory will produce an object of type 'scoreboard_ext'(*) Types with no associated type name will be printed as <unknown>
  2. 取得以后对象的理论重载类型
    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_overrideuvmc_set_factory_inst_override的调用

  1. 实例阐明

    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);endfunctionendclassclass 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);endfunctionendclass

    以上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,"");}