在 Specman 中,如何判断对单元的引用前面是否带有“不生成”修饰符?

发布于 2024-07-11 04:25:27 字数 447 浏览 11 评论 0原文

在 Specman 中,如何判断对单元的引用在引用的定义中是否具有不生成修饰符“!”?

例如,

unit foo_u {
}; 

extend sys {
   foo : foo_u is instance;
   foo_ptr_generated : foo_u;
   keep foo_ptr_generated == foo;
   !foo_ptr_notgenerated : foo_u;
   connect_pointers() is also {
      foo_ptr_notgenerated = foo;
   };
};

在不检查代码或依赖命名约定的情况下,我如何知道 foo_ptr_generate 通过了 Specman 的约束求解器,并且 foo_ptr_notgenerate 已按程序设置?

In Specman, how can I tell if a reference to a unit has the do-not-generate modifier, '!', at the reference's definition?

e.g.

unit foo_u {
}; 

extend sys {
   foo : foo_u is instance;
   foo_ptr_generated : foo_u;
   keep foo_ptr_generated == foo;
   !foo_ptr_notgenerated : foo_u;
   connect_pointers() is also {
      foo_ptr_notgenerated = foo;
   };
};

Without inspecting the code or relying on a naming convention, how can I tell thatfoo_ptr_generated went through Specman's constraint solver andfoo_ptr_notgenerated was procedurally set?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

悲念泪 2024-07-18 04:25:27

终于明白了这一点。 此代码将通过反射接口确定 Specman 6 中生成了哪些引用,哪些不在 Specman 6 中:

<'
type my_t : [ A,B,C];
unit foo_u {
   sub_typiness : my_t;
   other_sub_typiness : my_t;


   when A'sub_typiness foo_u {
      !bar_ptr : bar_u;
   };

   when B'other_sub_typiness foo_u {
      in_b_sub_type : int;
   };

   when A'sub_typiness B'other_sub_typiness foo_u {
      in_a_b_subtype :int;
   };
   b : bah_u is instance;
};


unit bar_u {
   sub_typiness : my_t;
   other_sub_typiness :my_t;

   when B'sub_typiness bar_u {
      !foo_ptr : foo_u;
   };
   when C'other_sub_typiness bar_u {
      inc_sub_type : int;
   };

   when A'other_sub_typiness bar_u {
      !you_shouldnt_see_this_field : bah_u;
   };

   when B'sub_typiness C'other_sub_typiness bar_u{
      in_b_c_subtype :int;
   };
   !b : bah_u;
   b2 : bah_u;
};

unit bah_u {

};


extend any_unit {

   !path_to_parent :string;
   !my_e_path : string;


   post_generate() is also {
      if not me is a sys { 
         path_to_parent = get_parent_unit().e_path();
      };
      my_e_path = e_path();
   };

   print_pointers() is {
      for each ( wf ) in rf_manager.get_struct_of_instance(me).as_a(rf_like_struct).sd_.all_when_fields {
         if not str_match(wf.name,"/___/"){

         };
      };
      for each (sub_unit) in get_all_units(any_unit) {
         sub_unit.print_pointers();
      };
   };
};

struct wank_s {
   oh_joy: int;
};
extend sys {
   foo : A'sub_typiness B'other_sub_typiness foo_u is instance;
   bar : B'sub_typiness C'other_sub_typiness bar_u is instance;
   keep bar.b2 == foo.b;

   wank : wank_s;

   connect_pointers() is also {
      foo.bar_ptr = bar;
      bar.foo_ptr = foo;
      bar.b = foo.b;
   };

   !possible_ptr : any_unit;
   !is_a_unit : bool;
   !an_e_path : string;
   !a_unit : any_unit;
   !a_field : field;
   -- 
   -- rf_manager.get_all_unit_instances
   my_specman( cmd : string ) : bool is {
      try {
         --out(cmd);
         specman(cmd);
      } else {
         return FALSE;
      };
      return TRUE;
   };

   check_generation() is also {
      out("PRINT OUT FIELDS");
      var all_units : list of any_unit;
      for each any_unit(u) in get_all_units(any_unit) {
         for each ( wf ) in rf_manager.get_struct_of_instance(u).as_a(rf_like_struct).sd_.all_when_fields {
            --print wf.source_ref;
            --print wf.source_ref.to_string().as_a(uint);
            --if wf.source_ref.to_string().as_a(uint) > 1000 and not str_match(wf.name,"/___/"){
            if not str_match(wf.name,"/___|driver_trans/"){
               an_e_path = append(u.e_path(),".",wf.name);
               an_e_path = append(an_e_path, " - marked_as_reachable=",wf.fgi.marked_as_reachable);
               if wf.base_type is a struct_descriptor (s){
                  an_e_path = append(an_e_path, " - instantiated == ", s.instantiated);
               };

               if wf.base_type is a struct_descriptor (s) and not s is a list_descriptor and not s is a long_descriptor {

                  sys.is_a_unit = FALSE;
                  if not my_specman(append("sys.is_a_unit = ( ",u.e_path(),".",wf.name,
                     " != NULL)")) {
                     sys.is_a_unit = FALSE;
                  };
                  if sys.is_a_unit {
                     if not my_specman(append(" sys.is_a_unit = (",u.e_path(),".",wf.name,
                        ".as_a(any_struct) == ",u.e_path(),".",wf.name,".get_enclosing_unit(any_unit).as_a(any_struct))")) {
                        sys.is_a_unit = FALSE;
                     };
                  };

                  if sys.is_a_unit and str_match(wf.name,"/([\w_]+'+[\w_']*)[\w_]+/") {
                     if not my_specman( append( "sys.is_a_unit = ( ",u.e_path(),
                           " is a ", $1, " ", 
                           rf_manager.get_struct_of_instance(u).as_a(rf_like_struct).sd_.name,
                           ")")) {
                        sys.is_a_unit = FALSE;
                     };
                  };


                  if is_a_unit {
                     sys.a_unit = NULL;
                     if not my_specman(append("sys.a_unit = (",u.e_path(),".",wf.name,
                        ".as_a(any_unit))")) {
                        sys.a_unit = NULL;
                     };

                     if sys.a_unit != NULL {

                        sys.an_e_path = NULL;
                        var printout := append(":: ",u.e_path(), ".", wf.name);
                        compute my_specman(append( "sys.an_e_path = ",u.e_path(),".",wf.name,
                           ".my_e_path"));
                        if append(u.e_path(),".",wf.name) != sys.an_e_path {
                           printout = append(printout, " -> ");

                           printout = append(printout, sys.an_e_path);
                           if wf.fgi != NULL and wf.fgi.gcs.size() > 0 and (
                              wf.fgi.gcs[0].last_reduction != UNDEF or
                              wf.fgi.gcs[0].gcois.size() > 0 ) {


                              printout = append(printout, " GENERATED POINTER");
                           };
                        };
                        out(printout);

                     };
                  };
               };


               --out( "    ",an_e_path);

               --specman(append("print ",u.e_path(),".",wf.name));
            };
         };

         --for each ( m ) in rf_manager.get_struct_of_instance(u).as_a(rf_like_struct).sd_.methods {
         --   if m != NULL {
         --      out(m.md.name);
         --   };
         --};
         --print u.get_all_attribute_names();
         --print u.get_attribute("agent");
         --print u.agent_kind();

         -- for each (m) in rf_manager.get_struct_of_instance(u).get_declared_methods() {
         --    print m;
         -- };
         -- out("fields at '",u.e_path(),"'s struct level:");
         -- for each (f) in rf_manager.get_struct_of_instance(u).get_declared_fields() {
         --    out( "    ",u.e_path()," -> ",f.f_.short_name);
         -- };
         -- out("fields at '",u.e_path(),"'s exact sub-type level:");
         -- for each (f) in rf_manager.get_exact_subtype_of_instance(u).get_declared_fields() {
         --    out( "    ",u.e_path()," -> ",f.f_.short_name);
         -- };
         -- out("");
      };

      -- out("\nPRINT OUT UNIT INSTANCES");
      -- for each any_unit(u) in {sys;foo;bar} {
      --    for each (i) in rf_manager.get_all_unit_instances(u) {
      --       if i != u {
      --          out(u.e_path(), " has unit ", i.e_path());
      --       };
      --    };
      -- };

   };

};

'>

运行:

specman -c 'load rf_test.e; gen'

生成:

Generating the test using seed 1...
PRINT OUT FIELDS
:: sys.bar.B'sub_typiness'foo_ptr -> sys.foo
:: sys.bar.b -> sys.foo.b
:: sys.bar.b2 -> sys.foo.b GENERATED POINTER
:: sys.foo.A'sub_typiness'bar_ptr -> sys.bar
:: sys.foo.b
:: sys.logger.base_unit -> sys
:: sys.logger
:: sys.foo
:: sys.bar

Starting the test ...
Running the test ...

Finally figured this out. This code will determine which references are generated and which aren't in Specman 6 via the reflection interface:

<'
type my_t : [ A,B,C];
unit foo_u {
   sub_typiness : my_t;
   other_sub_typiness : my_t;


   when A'sub_typiness foo_u {
      !bar_ptr : bar_u;
   };

   when B'other_sub_typiness foo_u {
      in_b_sub_type : int;
   };

   when A'sub_typiness B'other_sub_typiness foo_u {
      in_a_b_subtype :int;
   };
   b : bah_u is instance;
};


unit bar_u {
   sub_typiness : my_t;
   other_sub_typiness :my_t;

   when B'sub_typiness bar_u {
      !foo_ptr : foo_u;
   };
   when C'other_sub_typiness bar_u {
      inc_sub_type : int;
   };

   when A'other_sub_typiness bar_u {
      !you_shouldnt_see_this_field : bah_u;
   };

   when B'sub_typiness C'other_sub_typiness bar_u{
      in_b_c_subtype :int;
   };
   !b : bah_u;
   b2 : bah_u;
};

unit bah_u {

};


extend any_unit {

   !path_to_parent :string;
   !my_e_path : string;


   post_generate() is also {
      if not me is a sys { 
         path_to_parent = get_parent_unit().e_path();
      };
      my_e_path = e_path();
   };

   print_pointers() is {
      for each ( wf ) in rf_manager.get_struct_of_instance(me).as_a(rf_like_struct).sd_.all_when_fields {
         if not str_match(wf.name,"/___/"){

         };
      };
      for each (sub_unit) in get_all_units(any_unit) {
         sub_unit.print_pointers();
      };
   };
};

struct wank_s {
   oh_joy: int;
};
extend sys {
   foo : A'sub_typiness B'other_sub_typiness foo_u is instance;
   bar : B'sub_typiness C'other_sub_typiness bar_u is instance;
   keep bar.b2 == foo.b;

   wank : wank_s;

   connect_pointers() is also {
      foo.bar_ptr = bar;
      bar.foo_ptr = foo;
      bar.b = foo.b;
   };

   !possible_ptr : any_unit;
   !is_a_unit : bool;
   !an_e_path : string;
   !a_unit : any_unit;
   !a_field : field;
   -- 
   -- rf_manager.get_all_unit_instances
   my_specman( cmd : string ) : bool is {
      try {
         --out(cmd);
         specman(cmd);
      } else {
         return FALSE;
      };
      return TRUE;
   };

   check_generation() is also {
      out("PRINT OUT FIELDS");
      var all_units : list of any_unit;
      for each any_unit(u) in get_all_units(any_unit) {
         for each ( wf ) in rf_manager.get_struct_of_instance(u).as_a(rf_like_struct).sd_.all_when_fields {
            --print wf.source_ref;
            --print wf.source_ref.to_string().as_a(uint);
            --if wf.source_ref.to_string().as_a(uint) > 1000 and not str_match(wf.name,"/___/"){
            if not str_match(wf.name,"/___|driver_trans/"){
               an_e_path = append(u.e_path(),".",wf.name);
               an_e_path = append(an_e_path, " - marked_as_reachable=",wf.fgi.marked_as_reachable);
               if wf.base_type is a struct_descriptor (s){
                  an_e_path = append(an_e_path, " - instantiated == ", s.instantiated);
               };

               if wf.base_type is a struct_descriptor (s) and not s is a list_descriptor and not s is a long_descriptor {

                  sys.is_a_unit = FALSE;
                  if not my_specman(append("sys.is_a_unit = ( ",u.e_path(),".",wf.name,
                     " != NULL)")) {
                     sys.is_a_unit = FALSE;
                  };
                  if sys.is_a_unit {
                     if not my_specman(append(" sys.is_a_unit = (",u.e_path(),".",wf.name,
                        ".as_a(any_struct) == ",u.e_path(),".",wf.name,".get_enclosing_unit(any_unit).as_a(any_struct))")) {
                        sys.is_a_unit = FALSE;
                     };
                  };

                  if sys.is_a_unit and str_match(wf.name,"/([\w_]+'+[\w_']*)[\w_]+/") {
                     if not my_specman( append( "sys.is_a_unit = ( ",u.e_path(),
                           " is a ", $1, " ", 
                           rf_manager.get_struct_of_instance(u).as_a(rf_like_struct).sd_.name,
                           ")")) {
                        sys.is_a_unit = FALSE;
                     };
                  };


                  if is_a_unit {
                     sys.a_unit = NULL;
                     if not my_specman(append("sys.a_unit = (",u.e_path(),".",wf.name,
                        ".as_a(any_unit))")) {
                        sys.a_unit = NULL;
                     };

                     if sys.a_unit != NULL {

                        sys.an_e_path = NULL;
                        var printout := append(":: ",u.e_path(), ".", wf.name);
                        compute my_specman(append( "sys.an_e_path = ",u.e_path(),".",wf.name,
                           ".my_e_path"));
                        if append(u.e_path(),".",wf.name) != sys.an_e_path {
                           printout = append(printout, " -> ");

                           printout = append(printout, sys.an_e_path);
                           if wf.fgi != NULL and wf.fgi.gcs.size() > 0 and (
                              wf.fgi.gcs[0].last_reduction != UNDEF or
                              wf.fgi.gcs[0].gcois.size() > 0 ) {


                              printout = append(printout, " GENERATED POINTER");
                           };
                        };
                        out(printout);

                     };
                  };
               };


               --out( "    ",an_e_path);

               --specman(append("print ",u.e_path(),".",wf.name));
            };
         };

         --for each ( m ) in rf_manager.get_struct_of_instance(u).as_a(rf_like_struct).sd_.methods {
         --   if m != NULL {
         --      out(m.md.name);
         --   };
         --};
         --print u.get_all_attribute_names();
         --print u.get_attribute("agent");
         --print u.agent_kind();

         -- for each (m) in rf_manager.get_struct_of_instance(u).get_declared_methods() {
         --    print m;
         -- };
         -- out("fields at '",u.e_path(),"'s struct level:");
         -- for each (f) in rf_manager.get_struct_of_instance(u).get_declared_fields() {
         --    out( "    ",u.e_path()," -> ",f.f_.short_name);
         -- };
         -- out("fields at '",u.e_path(),"'s exact sub-type level:");
         -- for each (f) in rf_manager.get_exact_subtype_of_instance(u).get_declared_fields() {
         --    out( "    ",u.e_path()," -> ",f.f_.short_name);
         -- };
         -- out("");
      };

      -- out("\nPRINT OUT UNIT INSTANCES");
      -- for each any_unit(u) in {sys;foo;bar} {
      --    for each (i) in rf_manager.get_all_unit_instances(u) {
      --       if i != u {
      --          out(u.e_path(), " has unit ", i.e_path());
      --       };
      --    };
      -- };

   };

};

'>

Running with:

specman -c 'load rf_test.e; gen'

Produces:

Generating the test using seed 1...
PRINT OUT FIELDS
:: sys.bar.B'sub_typiness'foo_ptr -> sys.foo
:: sys.bar.b -> sys.foo.b
:: sys.bar.b2 -> sys.foo.b GENERATED POINTER
:: sys.foo.A'sub_typiness'bar_ptr -> sys.bar
:: sys.foo.b
:: sys.logger.base_unit -> sys
:: sys.logger
:: sys.foo
:: sys.bar

Starting the test ...
Running the test ...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文