2

私は次のことをしようとしています:

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.
4

1 に答える 1

1

世代順の競合があると思います。

  • フィールドにsons.grands応じてリストが入力されます。つまり、最初にリストを生成する必要があります。grands.idgrands
  • は制約にgrands.parent_age依存します。つまり、最初にリストを生成する必要があります。sons parent_age == 70sons

このコードの問題を解決するための最も簡単で簡単な方法は次のとおりです(そして、あなたがばかげた例を挙げていることを私は知っています):

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

さらにテストした後、メソッド呼び出しと組み合わせた制約の順序の問題はかなり確実です。sons' grandメソッド呼び出しを行わずにこれらのポインターを設定しない限り、Specmanジェネレーターはリスト制約の制約に従いません。

<'
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()直接使用することを検討する必要があるかもしれません。csco_configまた、彼らがオープンソースで提供しているシスコのパッケージを調べることもできます(ここ)。そのパッケージを使用して、環境内で奇妙な制約と制約の伝播を行います。ただし、ほとんどの制約はトップダウンですが、あなたの例はピアが互いに変更することに関するもののようです。

もう1つのデザインノート。互いに制約し合う5つのレベルのリストは、メンテナンスの問題です。理想的には、各レベルは、せいぜいその子リストとその親リストについてのみ知っている必要があります。フィールドを提供し、そのフィールドをより低いレベルに波打つことで、各レベルが他のすべてのレベルについて知る必要がなくなります。ただし、設計ガイドラインに違反する理由があることはわかっています:-)

于 2011-07-06T21:39:25.590 に答える