Specman:如何检索存储在另一个变量中的变量的值 [英] Specman: how to retrieve values of var which is stored in another var

查看:151
本文介绍了Specman:如何检索存储在另一个变量中的变量的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将var名称存储在另一个var中,我想从原始var中检索值.

I have stored var name in another var and I want to retrieve values from original var.

例如:

var var_A: list of uint = {1,3,2};
var var_A_str:string = "var_A";

//现在,我想使用var_A_str打印var_A值列表.我该怎么办?

//Now i want to print var_A list of values using var_A_str. How can i do that?

print $var_A_str;

推荐答案

这称为自省或反思.您必须使用Specman的rf_manager.在文档中搜索.但是,文档并未向您显示此单元具有的所有方法.如果您真的想查看所有方法,请运行以下代码段:

This is called introspection or reflection. You have to use Specman's rf_manager. Search for it in the docs. However, the docs don't show you all the methods that this unit has. If you really want to see all the methods, run this snippet of code:

extend sys {
    run() is also {
        var rf_man : rf_struct = rf_manager.get_exact_subtype_of_instance(rf_manager);
        out(" RF Manager:");
        for each (meth) in rf_man.get_declared_methods() {
            print meth;
        };
    };
};

我不确定如何遍历list元素,但是您可以使用此代码段查看对对象的实例成员(而不是子例程的变量)的引用上的方法./p>

I'm not sure how to iterate through the list elements, but you can use this snippet to look at the methods on a reference to an object's instance members ( not a subroutine's variable).

extend sys {

    A : list of uint;
    keep A == {1;3;2};
    run() is also {

        var variable_name := "A";
        var rf_obj: rf_struct = rf_manager.get_exact_subtype_of_instance(sys);
        var rf_i : rf_field =  rf_obj.get_field(variable_name);
        print rf_i;
        var rf_rf_i := rf_manager.get_exact_subtype_of_instance(rf_i);
        out ( "#\n# RF_RFI\n#");
        for each (meth) in rf_rf_i.get_declared_methods() {
            print meth;
        }; 
    };
};    

在我的版本(8.2)中,它打印:

    开始测试...
    运行测试...
      rf_i = rf_field'A',@ rf_test4中的第7行
    #
    #RF_RFI
    #
      meth = rf_method'get_type',Specman的专用模块
      meth = rf_method'is_physical',Specman的专用模块
      meth = rf_method'get_svtp_pack',Specman的专用模块
      meth = rf_method'set_svtp_pack',Specman的专用模块
      meth = rf_method'is_ungenic',Specman的专用模块
      meth = rf_method'is_const',Specman的专用模块
      meth = rf_method'is_unit_instance',Specman的专用模块
      meth = rf_method'is_port_instance',Specman的专用模块
      meth = rf_method'is_reference',Specman的专用模块
      meth = rf_method'get_constrained_types',Specman的专用模块
      meth = rf_method'get_deep_copy_attr',Specman的专用模块
      meth = rf_method'get_value',Specman的专用模块
      meth = rf_method'set_value',Specman的专用模块
      meth = rf_method'get_value_unsafe',Specman的专用模块
      meth = rf_method'get_all_when_value_unsafe',Specman的专用模块
      meth = rf_method'set_value_unsafe',Specman的专用模块
      meth = rf_method'set_value_const_reassign_unsafe',Specman的专用模块
      meth = rf_method'get_interface_port_prefix',Specman的专用模块
      meth = rf_method'get_interface_port_suffix',Specman的专用模块
      meth = rf_method'is_gen_intelligen',Specman的专用模块
      meth = rf_method'get_long_name',Specman的专用模块
      meth = rf_method'get_implicit_constraints',Specman的专用模块
      meth = rf_method'make_path',Specman的专用模块
      meth = rf_method'make_element',Specman的专用模块
      meth = rf_method'make_list_size_path',Specman的专用模块
      meth = rf_method'is_unit_reference',Specman的专用模块
      meth = rf_method'get_id_name_for_port_type',Specman的专用模块
      meth = rf_method'get_list_upper_bound',Specman的专用模块
      meth = rf_method'get_sv_typename',Specman的专用模块
      meth = rf_method'get_sv_name_under_when',Specman的专用模块
      meth = rf_method'get_sv_size',Specman的专用模块
      meth = rf_method'sv_add_encode_lines',Specman的专用模块
      meth = rf_method'sv_get_decode_function_local_var_name',Specman的专用模块
      meth = rf_method'sv_get_decode_function_local_var_decl',Specman的专用模块
      meth = rf_method'sv_add_decode_lines',Specman的专用模块
      meth = rf_method'get_sv_field_name',Specman的专用模块
      meth = rf_method'get_sv_field',Specman的专用模块
      meth = rf_method'sv_must_be_protected_field',Specman的专用模块
      meth = rf_method'sv_add_get_set_field_functions',Specman的专用模块
      meth = rf_method'sv_add_get_set_field_function_decs',Specman的专用模块
      meth = rf_method'is_sv_exported_field',Specman的专用模块
      meth = rf_method'is_sv_determinant_field',Specman的专用模块
      meth = rf_method'field_configured_to_svtp_pack',Specman的专用模块
      meth = rf_method'get_ovm_field_macro',Specman的专用模块
      meth = rf_method'is_internal',Specman的专用模块
      meth = rf_method'get',Specman的专用模块
      meth = rf_method'eanalyze_lnt',Specman的专用模块
    无需实际运行.
    检查测试... 

In my version ( 8.2 ) this prints:

    Starting the test ...
    Running the test ...
      rf_i = rf_field 'A', line 7 in @rf_test4
    #
    # RF_RFI
    #
      meth = rf_method 'get_type', Specman's private modules
      meth = rf_method 'is_physical', Specman's private modules
      meth = rf_method 'get_svtp_pack', Specman's private modules
      meth = rf_method 'set_svtp_pack', Specman's private modules
      meth = rf_method 'is_ungenerated', Specman's private modules
      meth = rf_method 'is_const', Specman's private modules
      meth = rf_method 'is_unit_instance', Specman's private modules
      meth = rf_method 'is_port_instance', Specman's private modules
      meth = rf_method 'is_reference', Specman's private modules
      meth = rf_method 'get_constrained_types', Specman's private modules
      meth = rf_method 'get_deep_copy_attr', Specman's private modules
      meth = rf_method 'get_value', Specman's private modules
      meth = rf_method 'set_value', Specman's private modules
      meth = rf_method 'get_value_unsafe', Specman's private modules
      meth = rf_method 'get_all_when_value_unsafe', Specman's private modules
      meth = rf_method 'set_value_unsafe', Specman's private modules
      meth = rf_method 'set_value_const_reassign_unsafe', Specman's private modules
      meth = rf_method 'get_interface_port_prefix', Specman's private modules
      meth = rf_method 'get_interface_port_suffix', Specman's private modules
      meth = rf_method 'is_gen_intelligen', Specman's private modules
      meth = rf_method 'get_long_name', Specman's private modules
      meth = rf_method 'get_implicit_constraints', Specman's private modules
      meth = rf_method 'make_path', Specman's private modules
      meth = rf_method 'make_element', Specman's private modules
      meth = rf_method 'make_list_size_path', Specman's private modules
      meth = rf_method 'is_unit_reference', Specman's private modules
      meth = rf_method 'get_id_name_for_port_type', Specman's private modules
      meth = rf_method 'get_list_upper_bound', Specman's private modules
      meth = rf_method 'get_sv_typename', Specman's private modules
      meth = rf_method 'get_sv_name_under_when', Specman's private modules
      meth = rf_method 'get_sv_size', Specman's private modules
      meth = rf_method 'sv_add_encode_lines', Specman's private modules
      meth = rf_method 'sv_get_decode_function_local_var_name', Specman's private modules
      meth = rf_method 'sv_get_decode_function_local_var_decl', Specman's private modules
      meth = rf_method 'sv_add_decode_lines', Specman's private modules
      meth = rf_method 'get_sv_field_name', Specman's private modules
      meth = rf_method 'get_sv_field', Specman's private modules
      meth = rf_method 'sv_must_be_protected_field', Specman's private modules
      meth = rf_method 'sv_add_get_set_field_functions', Specman's private modules
      meth = rf_method 'sv_add_get_set_field_function_decs', Specman's private modules
      meth = rf_method 'is_sv_exported_field', Specman's private modules
      meth = rf_method 'is_sv_determinant_field', Specman's private modules
      meth = rf_method 'field_configured_to_svtp_pack', Specman's private modules
      meth = rf_method 'get_ovm_field_macro', Specman's private modules
      meth = rf_method 'is_internal', Specman's private modules
      meth = rf_method 'get', Specman's private modules
      meth = rf_method 'eanalyze_lnt', Specman's private modules
    No actual running requested.
    Checking the test ...

Checking is complete - 0 DUT errors, 0 DUT warnings.

我敢肯定有一种方法可以做你想做的事,但是使用Specman的反射界面可能会非常困难.

I'm sure there's a way to do what you want, but it can be very difficult to use Specman's reflection interface.

快乐黑客!

这篇关于Specman:如何检索存储在另一个变量中的变量的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆