Specman: how to retrieve values of var which is stored in another var -
i have stored var name in var , want retrieve values original var.
for ex:
var var_a: list of uint = {1,3,2}; var var_a_str:string = "var_a";
//now want print var_a list of values using var_a_str. how can that?
print $var_a_str;
this called introspection or reflection. have use specman's rf_manager
. search in docs. however, docs don't show methods unit has. if want see methods, run snippet of code:
extend sys { run() { var rf_man : rf_struct = rf_manager.get_exact_subtype_of_instance(rf_manager); out(" rf manager:"); each (meth) in rf_man.get_declared_methods() { print meth; }; }; };
i'm not sure how iterate through list elements, can use snippet @ methods on reference object's instance members ( not subroutine's variable).
extend sys { : list of uint; keep == {1;3;2}; run() { 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#"); each (meth) in rf_rf_i.get_declared_methods() { print meth; }; }; };
in version ( 8.2 ) prints:
starting test ... running 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 test ...checking complete - 0 dut errors, 0 dut warnings.
i'm sure there's way want, can difficult use specman's reflection interface.
merry hacking!
Comments
Post a Comment