Specman e 列出约束参考

发布于 2024-11-18 03:47:30 字数 4713 浏览 2 评论 0原文

我正在尝试执行以下操作:

unit parent {
              sons: list of sons is instance;
              grands: list of grands is instance;

              keep sons.size() == 4;
              keep grands.size() == 4;
};

unit sons {
            grands:list of grands is instance;
            keep grands == get_enclosing_unit(parent).grands.all( .id > 3 );

           //this is not working
           keep for each in grands {
              it.parent_age == 70;
           };
};

unit grands {
           id: uint;
           parent_age:uint;
};

extend sys {
   p : parent is instance;
   run() is also {
      print p;
      for each (s) in p.sons {
         print s;
      };
      for each (g) in p.grands {
         print g;
      };

   };
};

换句话说,我希望儿子列表指向父母列表的一部分,但仍然能够约束(不工作的部分)来自儿子单元/结构的孙子列表。

使用 9.20 上的 PGen 约束引擎,以上代码会生成:

Starting the test ...
Running the test ...
  p = parent-@0: parent   e_path: sys.p
  hdl_path:
        ----------------------------------------------  @tmp
0       sons:                           (4 items)
1       grands:                         (4 items)
  s = sons-@1: sons   e_path: sys.p.sons[0]
  hdl_path:
        ----------------------------------------------  @tmp
0       grands:                         (empty)
  s = sons-@2: sons   e_path: sys.p.sons[1]
  hdl_path:
        ----------------------------------------------  @tmp
0       grands:                         (empty)
  s = sons-@3: sons   e_path: sys.p.sons[2]
  hdl_path:
        ----------------------------------------------  @tmp
0       grands:                         (empty)
  s = sons-@4: sons   e_path: sys.p.sons[3]
  hdl_path:
        ----------------------------------------------  @tmp
0       grands:                         (empty)
  g = grands-@5: grands   e_path: sys.p.grands[0]
  hdl_path:
        ----------------------------------------------  @tmp
0       id:                             4107502109
1       parent_age:                     3829340118
  g = grands-@6: grands   e_path: sys.p.grands[1]
  hdl_path:
        ----------------------------------------------  @tmp
0       id:                             3657005019
1       parent_age:                     2354335776
  g = grands-@7: grands   e_path: sys.p.grands[2]
  hdl_path:
        ----------------------------------------------  @tmp
0       id:                             3238917208
1       parent_age:                     336300761
  g = grands-@8: grands   e_path: sys.p.grands[3]
  hdl_path:
        ----------------------------------------------  @tmp
0       id:                             1416976666
1       parent_age:                     2212224392

使用 Specman 9.20 上的 IntelliGen 约束引擎,以上代码会生成:

Starting the test ...
Running the test ...
  p = parent-@0: parent   e_path: sys.p
  hdl_path:
        ----------------------------------------------  @tmp
0       sons:                           (4 items)
1       grands:                         (4 items)
  s = sons-@1: sons   e_path: sys.p.sons[0]
  hdl_path:
        ----------------------------------------------  @tmp
0       grands:                         (4 items)
  s = sons-@2: sons   e_path: sys.p.sons[1]
  hdl_path:
        ----------------------------------------------  @tmp
0       grands:                         (4 items)
  s = sons-@3: sons   e_path: sys.p.sons[2]
  hdl_path:
        ----------------------------------------------  @tmp
0       grands:                         (4 items)
  s = sons-@4: sons   e_path: sys.p.sons[3]
  hdl_path:
        ----------------------------------------------  @tmp
0       grands:                         (4 items)
  g = grands-@5: grands   e_path: sys.p.grands[0]
  hdl_path:
        ----------------------------------------------  @tmp
0       id:                             619055518
1       parent_age:                     4122406610
  g = grands-@6: grands   e_path: sys.p.grands[1]
  hdl_path:
        ----------------------------------------------  @tmp
0       id:                             2908565159
1       parent_age:                     1741309063
  g = grands-@7: grands   e_path: sys.p.grands[2]
  hdl_path:
        ----------------------------------------------  @tmp
0       id:                             3091108084
1       parent_age:                     1231835435
  g = grands-@8: grands   e_path: sys.p.grands[3]
  hdl_path:
        ----------------------------------------------  @tmp
0       id:                             1717477430
1       parent_age:                     937745175
No actual running requested.
Checking the test ...
Checking is complete - 0 DUT errors, 0 DUT warnings.

i am trying to do the following :

unit parent {
              sons: list of sons is instance;
              grands: list of grands is instance;

              keep sons.size() == 4;
              keep grands.size() == 4;
};

unit sons {
            grands:list of grands is instance;
            keep grands == get_enclosing_unit(parent).grands.all( .id > 3 );

           //this is not working
           keep for each in grands {
              it.parent_age == 70;
           };
};

unit grands {
           id: uint;
           parent_age:uint;
};

extend sys {
   p : parent is instance;
   run() is also {
      print p;
      for each (s) in p.sons {
         print s;
      };
      for each (g) in p.grands {
         print g;
      };

   };
};

in other words , i want the sons list to point to a part of the parents list , but still be able to constraint(the not working part) the list of grands from the sons unit/struct.

With PGen constraint engine on 9.20, the above code produces:

Starting the test ...
Running the test ...
  p = parent-@0: parent   e_path: sys.p
  hdl_path:
        ----------------------------------------------  @tmp
0       sons:                           (4 items)
1       grands:                         (4 items)
  s = sons-@1: sons   e_path: sys.p.sons[0]
  hdl_path:
        ----------------------------------------------  @tmp
0       grands:                         (empty)
  s = sons-@2: sons   e_path: sys.p.sons[1]
  hdl_path:
        ----------------------------------------------  @tmp
0       grands:                         (empty)
  s = sons-@3: sons   e_path: sys.p.sons[2]
  hdl_path:
        ----------------------------------------------  @tmp
0       grands:                         (empty)
  s = sons-@4: sons   e_path: sys.p.sons[3]
  hdl_path:
        ----------------------------------------------  @tmp
0       grands:                         (empty)
  g = grands-@5: grands   e_path: sys.p.grands[0]
  hdl_path:
        ----------------------------------------------  @tmp
0       id:                             4107502109
1       parent_age:                     3829340118
  g = grands-@6: grands   e_path: sys.p.grands[1]
  hdl_path:
        ----------------------------------------------  @tmp
0       id:                             3657005019
1       parent_age:                     2354335776
  g = grands-@7: grands   e_path: sys.p.grands[2]
  hdl_path:
        ----------------------------------------------  @tmp
0       id:                             3238917208
1       parent_age:                     336300761
  g = grands-@8: grands   e_path: sys.p.grands[3]
  hdl_path:
        ----------------------------------------------  @tmp
0       id:                             1416976666
1       parent_age:                     2212224392

With IntelliGen constraint engine on Specman 9.20, the above code produces:

Starting the test ...
Running the test ...
  p = parent-@0: parent   e_path: sys.p
  hdl_path:
        ----------------------------------------------  @tmp
0       sons:                           (4 items)
1       grands:                         (4 items)
  s = sons-@1: sons   e_path: sys.p.sons[0]
  hdl_path:
        ----------------------------------------------  @tmp
0       grands:                         (4 items)
  s = sons-@2: sons   e_path: sys.p.sons[1]
  hdl_path:
        ----------------------------------------------  @tmp
0       grands:                         (4 items)
  s = sons-@3: sons   e_path: sys.p.sons[2]
  hdl_path:
        ----------------------------------------------  @tmp
0       grands:                         (4 items)
  s = sons-@4: sons   e_path: sys.p.sons[3]
  hdl_path:
        ----------------------------------------------  @tmp
0       grands:                         (4 items)
  g = grands-@5: grands   e_path: sys.p.grands[0]
  hdl_path:
        ----------------------------------------------  @tmp
0       id:                             619055518
1       parent_age:                     4122406610
  g = grands-@6: grands   e_path: sys.p.grands[1]
  hdl_path:
        ----------------------------------------------  @tmp
0       id:                             2908565159
1       parent_age:                     1741309063
  g = grands-@7: grands   e_path: sys.p.grands[2]
  hdl_path:
        ----------------------------------------------  @tmp
0       id:                             3091108084
1       parent_age:                     1231835435
  g = grands-@8: grands   e_path: sys.p.grands[3]
  hdl_path:
        ----------------------------------------------  @tmp
0       id:                             1717477430
1       parent_age:                     937745175
No actual running requested.
Checking the test ...
Checking is complete - 0 DUT errors, 0 DUT warnings.

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

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

发布评论

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

评论(1

我很坚强 2024-11-25 03:47:30

我认为您存在生成顺序冲突:

  • 根据 grands.id 字段填充 sons.grands 列表,这意味着您必须生成 grands< /code> 首先列出。
  • grands.parent_age 取决于 sons parent_age == 70 约束,这意味着您必须生成 sons先列出来。

解决这个代码问题的最简单、最直接的方法(我知道你给出了一个简单的例子)是:

extend parent {
   keep for each (g) in grands {
      ( g.id > 3 ) => g.parent_age == 70;
   };
};

经过更多测试,我很确定它是一个组合约束排序问题与方法调用。 Specman 生成器不会遵循 sons' grand 列表约束上的约束,除非您在不执行方法调用的情况下设置这些指针。

<'
unit parent {
   sons: list of sons is instance;     // <-- swapped these two lines
   grands: list of grands is instance; // <-- to do constraint ordering in IntelliGen
                                       //     even though Cadence says you don't need
                                       //     to
   keep for each (s) in sons {
      s.grands == grands; -- .all( .id > 3 ); -- removed the 'all' and 'get_enclosing_unit' invocation
   };

   keep sons.size() == 4;
   keep grands.size() == 4;
};

unit sons {
   grands:list of grands is instance;
   --keep grands == get_enclosing_unit(parent).grands.all( .id > 3 );

   //this is not working
   keep for each in grands {
      it.parent_age == 70;
   };
};       

unit grands {
   id: uint;
   parent_age:uint;
};

extend sys {
   p : parent is instance;
   run() is also {
      print p;
      for each (s) in p.sons {
         print s;
      };
      for each (g) in p.grands {
         print g;
      };
   };
};   
'>

使用IntelliGen(不适用于 PGen ):

Starting the test ...
Running the test ...
  p = parent-@0: parent   e_path: sys.p
  hdl_path:
        ----------------------------------------------  @tmp
0       sons:                           (4 items)
1       grands:                         (26 items)
  s = sons-@1: sons   e_path: sys.p.sons[0]
  hdl_path:
        ----------------------------------------------  @tmp
0       grands:                         (26 items)
  s = sons-@2: sons   e_path: sys.p.sons[1]
  hdl_path:
        ----------------------------------------------  @tmp
0       grands:                         (26 items)
  s = sons-@3: sons   e_path: sys.p.sons[2]
  hdl_path:
        ----------------------------------------------  @tmp
0       grands:                         (26 items)
  s = sons-@4: sons   e_path: sys.p.sons[3]
  hdl_path:
        ----------------------------------------------  @tmp
0       grands:                         (26 items)
  g = grands-@5: grands   e_path: sys.p.sons[3].grands[0]
  hdl_path:
        ----------------------------------------------  @tmp
0       id:                             4093923439
1       parent_age:                     70 
[snip]

您可能需要考虑直接使用pre_generate()/post_generate()。您还可以查看 Cisco 开源的 csco_config 软件包 (此处)。我们使用该包在我们的环境中进行奇怪的约束和约束传播。但是,大多数约束都是自上而下的,而您的示例似乎是关于同行互相修改的。

另一份设计说明。 5 级列表相互约束是一个维护问题。理想情况下,每个级别最多只应了解其子列表和父列表。提供一个字段,然后将该字段向下传递到较低的级别,将使每个级别不必了解所有其他级别。然而,我知道违反设计准则是有原因的:-)

I think you have generation order conflicts:

  • The sons.grands list is populated, depending on the grands.id field, which means you have to generate the grands list first.
  • The grands.parent_age depends on the sons parent_age == 70 constraint, which means you have to generate the sons list first.

The easiest and most straight forward way to solve this code issue ( and I know you're giving a dumbed down example) is :

extend parent {
   keep for each (g) in grands {
      ( g.id > 3 ) => g.parent_age == 70;
   };
};

After more testing, I'm pretty certain its a constraint ordering issue in combination with the method invocations. The Specman generator doesn't follow through the constraints on the sons' grand list constraint, unless you set those pointers without doing a method call.

<'
unit parent {
   sons: list of sons is instance;     // <-- swapped these two lines
   grands: list of grands is instance; // <-- to do constraint ordering in IntelliGen
                                       //     even though Cadence says you don't need
                                       //     to
   keep for each (s) in sons {
      s.grands == grands; -- .all( .id > 3 ); -- removed the 'all' and 'get_enclosing_unit' invocation
   };

   keep sons.size() == 4;
   keep grands.size() == 4;
};

unit sons {
   grands:list of grands is instance;
   --keep grands == get_enclosing_unit(parent).grands.all( .id > 3 );

   //this is not working
   keep for each in grands {
      it.parent_age == 70;
   };
};       

unit grands {
   id: uint;
   parent_age:uint;
};

extend sys {
   p : parent is instance;
   run() is also {
      print p;
      for each (s) in p.sons {
         print s;
      };
      for each (g) in p.grands {
         print g;
      };
   };
};   
'>

Using IntelliGen ( doesn't work with PGen ):

Starting the test ...
Running the test ...
  p = parent-@0: parent   e_path: sys.p
  hdl_path:
        ----------------------------------------------  @tmp
0       sons:                           (4 items)
1       grands:                         (26 items)
  s = sons-@1: sons   e_path: sys.p.sons[0]
  hdl_path:
        ----------------------------------------------  @tmp
0       grands:                         (26 items)
  s = sons-@2: sons   e_path: sys.p.sons[1]
  hdl_path:
        ----------------------------------------------  @tmp
0       grands:                         (26 items)
  s = sons-@3: sons   e_path: sys.p.sons[2]
  hdl_path:
        ----------------------------------------------  @tmp
0       grands:                         (26 items)
  s = sons-@4: sons   e_path: sys.p.sons[3]
  hdl_path:
        ----------------------------------------------  @tmp
0       grands:                         (26 items)
  g = grands-@5: grands   e_path: sys.p.sons[3].grands[0]
  hdl_path:
        ----------------------------------------------  @tmp
0       id:                             4093923439
1       parent_age:                     70 
[snip]

You might have to look into using pre_generate()/post_generate() directly. You can also look into Cisco's csco_config package that they open sourced (here). We use that package to do weird constraints and constraint propagation in our environment. However, most constraints are top-down, whereas your example seems to be about peers modifying each other.

One other design note. 5 levels of lists constraining each other is a bit of a maintenance issue. Ideally, each level should only know about its child lists and its parent lists at the most. Providing a field and then rippling that field down into lower levels will insulate each level from having to know about all the other levels. However, I know there are reasons to violate design guidelines :-)

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