Creating Configurable Environments with Hierarchical and Global Options (vmm_opts) in VMM

Verification environments need to accommodate changing specifications and at 
the same time cater to the requirements of different clusters and subsystems.
vmm_opts provides the ability to provide a high level of configurability so 
that environments can work for different DUTs. This article shows how to use 
vmm_opts not just to set the switches globally and hierarchically, but also to 
specify the address ranges in scenarios from the test cases and the 
command-line.


First, you need to create a list of controls/switches that should be 
provided as global options (like simulation timeout, scoreboard/coverage enable,
etc.) and then another set of hierarchical options to control instance specific
behavior (like number of transactions to be generated, burst enables, 
transaction speed, address ranges to be generated by a specific instance, etc.)


Global options:
Step 1:
Declare an integer, say simulation_timeout in the environment class or wherever
it is required and use vmm_opts::get_int(..) method as shown below. Specify a 
default value as well just in case, if the variable is not set anywhere.


simulation_timeout = vmm_opts::get_int("TIMEOUT", 10000);


Step 2:
Then either at the test case or at the command-line, this can be overridden
using vmm_opts::set_int or +vmm_opts+ runtime option.


Overridding from the test case:


vmm_opts::set_int("%*:TIMEOUT", 50000); 


In the examples above, "%*" specified any hierarchy and hence this will apply
to all classes wherever there is a TIMEOUT variable.
Overridding from the command-line.


./simv +vmm_opts+TIMEOUT=80000


Options can also be overridden from a command file. Also, options can be a 
string or Boolean variable as well.


Hierarchical options:
In order to use hierarchical options, the parent child hierarchy should be 
established across components while creating the verification environment. This
is possible by passing the parent handle to any component during construction
or through the set_parent_object() method. Since all VMM base classes extend
from vmm_object, all derived classes can thus use this method. This is required
since the hierarchy specified externally (from test case/command line) will be
used to map the hierarchy in the environment. The following steps shows how 
hierarchical options are used.


Step 1:
Declare options, say burst_enable and num_of_trans in a subenv class and use 
vmm_opts::get_object_bit(..) and vmm_opts::get_object_int(..) to retrieve 
appropriate values. This is done by passing the current hierarchy and default 
values as arguments. Also, for setting ranges, declare min_addr and max_addr,
 and use get_object_range().


class master_subenv extends vmm_subenv;
    bit burst_enable;
    int num_of_trans;
    int min_addr;
    int max_addr;
    function void configure();
          bit is_set; //to determine if the default value is overridden
          burst_enable = vmm_opts::get_object_bit(is_set, this, "BURST_ENABLE");
          num_of_trans = vmm_opts::get_object_int(is_set, this, "NUM_TRANS", 100);
          vmm_opts::get_object_range(is_set, this, "ADDR_RANGE", 0, 32'hFFFF_FFFF);
          ....
    endfunction
 endclass


Step 2:
Build the environment with parent/child hierarchy either by passing the parent
handle through the constructor to every child, or using 
vmm_object::set_parent_object() method. This is easy as almost all base classes
 are extended from vmm_object by default.


class  dut_env extends vmm_env;
       virtual function build();
         .....
         mst0 = new("MST0", ....);
         mst0.set_parent_object(this);
         mst1 = new("MST1", ...);
         mst1.set_parent_object(this);
        ....
       endfunction
endclass


Step 3:
From the test case, you can override the default value using vmm_opts::set_bit 
or vmm_opts::set_int(..) specifying the hierarchy. You can also use pattern 
matching as well to avoid specifying the overrides only for specific instances
as in the patterns mentioned.  


vmm_opts::set_int("%*:MST0:NUM_TRANS", 50);
This will only override the NUM_TRANS value in MST0 instance to 50.


vmm_opts::set_int("%*:MST1:NUM_TRANS", 100); 
This will only override the NUM_TRANS value in MST1 instance.


vmm_opts::set_bit("%*:burst_enable);
This will override the burst_enable variable and set it to 1 in all instances.


vmm_opts::set_range("%*:MST1:ADDR_RANGE", 32'h1000_0000, 32'h1000_FFFF);
This will override the ADDR_RANGE in MST1 instance.


The default value can be overriden from the command-line as well.
./simv +vmm_opts+NUM_TRANS=50@%*:MST0+NUM_TRANS=100@%*:MST1+burst_enable@%*


In summary, vmm_opts provides a powerful and user friendly way of configuring 
the environment from the command-line or the test case. 
There is also a possibility to auto-document these options. You can provide the 
explanation of each of the options in the get_object_*() and get_*() methods 
and this will be displayed when vmm_opts::get_help() is called or 
+vmm+help is passed at runtime. The details of the override from different
hierarchies including the line numbers and the file numbers will also be 
displayed. For more details on these classes, please refer to the VMM User Guide.
<think>好的,用户想了解TI的CLB库中CLB_configLocalInputMux函数的用法和相关文档。首先,我需要回忆一下TI的C2000系列微控制器和CLB模块的相关知识。CLB(Configurable Logic Block)是C2000芯片上的可配置逻辑块,允许用户实现自定义数字逻辑功能,类似于FPGA中的逻辑单元。 根据用户提供的引用内容,特别是引用[1],里面提到CLB_configLocalInputMux函数用于配置CLB的本地输入多路选择器,需要包含clb.h头文件。此外,配置无法通过SysConfig工具完成,必须直接在代码中调用这些函数。用户可能在使用这个函数时遇到了问题,或者需要确认如何正确设置参数。 接下来,我需要确认函数的参数。引用[1]中的函数原型是CLB_configLocalInputMux(uint32_t base, CLB_Inputs inID, CLB_LocalInputMux localMuxCfg),其中base是CLB模块的基地址,inID指定要配置的输入引脚(如CLB_IN1、CLB_IN2等),localMuxCfg是输入源的选择,比如CLB_LOCAL_IN_MUX_GPIO或其他内部信号。 用户可能需要知道如何选择正确的输入源,以及如何确定基地址。根据引用[2],CLB的输入需要通过输入X-BAR和CLB X-BAR来配置,尤其是使用GPIO作为输入时。例如,如果用户想将某个GPIO引脚连接到CLB的输入IN1,需要配置相应的X-BAR设置,然后调用CLB_configLocalInputMux函数选择对应的多路器选项。 此外,引用[3]提到Xilinx的文档,虽然TI和Xilinx的CLB实现不同,但可能用户混淆了两者的文档,需要指出TI的具体例程位置,如C2000Ware中的clb例程,这些例程直接使用TI提供的底层函数进行配置,而不是直接操作寄存器。 用户可能需要示例代码,因此在回答中应该包含一个简单的示例,展示如何初始化CLB并配置输入。同时,提醒用户注意基地址的定义和头文件的包含,以及参考官方例程的重要性。 最后,考虑到用户可能遇到的常见问题,比如参数选择错误或未正确配置X-BAR,应该在相关问题中提出这些点,帮助用户进一步排查问题。</think>关于TI C2000系列芯片中`CLB_configLocalInputMux`函数的使用,以下是关键要点和配置步骤: ### 一、函数功能解析 该函数用于配置CLB模块的本地输入多路选择器,属于CLB底层驱动库的核心配置接口[^1]。其函数原型为: ```c void CLB_configLocalInputMux(uint32_t base, CLB_Inputs inID, CLB_LocalInputMux localMuxCfg) ``` 参数说明: - `base`:CLB模块基地址(如`CLB1_BASE`) - `inID`:输入引脚选择(取值范围`CLB_IN1`到`CLB_IN8`) - `localMuxCux`:输入源选择枚举值(如`CLB_LOCAL_IN_MUX_GPIO`) ### 二、配置流程 1. **硬件连接**: - 通过输入X-BAR将GPIO信号路由到CLB输入通道(参考图29-5的X-BAR配置结构[^2]) - 例如使用GPIO12作为CLB输入: ```c InputXbarRegs.INPUT12SELECT = 12; // 将GPIO12映射到输入X-BAR通道12 ``` 2. **CLB输入配置**: ```c #include "clb.h" // 选择CLB1的IN2引脚连接至GPIO输入 CLB_configLocalInputMux(CLB1_BASE, CLB_IN2, CLB_LOCAL_IN_MUX_GPIO); ``` 3. **组合配置**: - 需要配合`CLB_configInputMux`函数实现两级多路选择器配置[^1] - 典型配置序列: ```c CLB_configInputMux(CLB1_BASE, CLB_INPUT_2, CLB_INPUT_MUX_LOCAL); CLB_configLocalInputMux(CLB1_BASE, CLB_IN2, CLB_LOCAL_IN_MUX_EPWM1A); ``` ### 三、参数选择参考 | 输入源枚举值 | 信号类型 | |-------------------------------|------------------| | CLB_LOCAL_IN_MUX_GPIO | GPIO输入 | | CLB_LOCAL_IN_MUX_EPWM1A | ePWM模块输出 | | CLB_LOCAL_IN_MUX_CLB_OUT3 | CLB内部逻辑输出 | | CLB_LOCAL_IN_MUX_LOGIC_HIGH | 固定高电平 | ### 四、开发资源 1. 参考C2000Ware安装目录下的示例工程: ``` C:\ti\c2000\C2000Ware_x_xx_xx_xx\driverlib\f2837xd\examples\clb ``` 2. 查看`clb.h`头文件中的枚举定义和函数原型 3. 查阅技术文档《C2000 Microcontroller Technical Reference Manual》第29章[^2] 相关问题
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值