Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6132949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:09:56+00:00 2026-05-23T17:09:56+00:00

i am trying to do the following : unit parent { sons: list of

  • 0

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.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:09:57+00:00Added an answer on May 23, 2026 at 5:09 pm

    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 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following on from this question...I'm trying to unit test the following scenario: I have
I'm trying the following code to execute a search and it's not working. On
I am receiving the following exception when trying to run my unit tests using
I have the following method for which I am trying to write a unit
I'm trying to unit test, using VS unit testing facility following method. void Get(string
I have the following so far which I am trying to unit test: private
I am trying to create a unit test that makes sure all of my
I am trying to write a unit test for the following method in my
I have the following situation. I am trying to write a unit test for
When trying to run my unit test under Chess , it get the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.