关于systemverilog:UVMC学习笔记三在SystemCC作用域实现UVM-factory操作

4次阅读

共计 3922 个字符,预计需要花费 10 分钟才能阅读完成。

前言

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 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>
  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);
    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,"");
}
正文完
 0