• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Functional Verification
  3. extend e language

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 66
  • Views 13295
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

extend e language

CatalinButnaru
CatalinButnaru over 10 years ago

Hello,

Does anyone have another idea on how to extend a unit or struct by two value of a field at a time? (macro'less I would prefer, micro'with I already have a solution)


type foo_t : [one, two, three];


unit foo_u {

foo_field : foo_t;

};

extend [one, two]'foo_field foo_u {

// enjoy here

};

 

Thanks,

Catalin

  • Cancel
  • Tudor Timi
    Tudor Timi over 10 years ago

    The best way to do it, from an encapsulation point of view, is to declare a separate determinant field that has the same value for 'ONE' and 'TWO'. Let's use a simple boolean in this case:

    extend foo_u {

      is_1_or_2 : bool;

      keep is_1_or_2 == foo_field in [ ONE, TWO ];

    };

    extend TRUE'is_1_or_2 foo_u {

      some_field : some_type_t;

      // enjoy here

    };

    This way, the extra code is truly common. Let's say that you define 'some_field' in both ways (with the macro and with the common determinant). This means, if you want to access 'some_field' in the macro case you have to cast to different types depending on the value of 'foo_field':

    'foo.as_a(ONE foo_u).some_field' or 'foo.as_a(TWO foo_u).some_field'

    In the other case, it's enough to say:

    'foo.as_a(TRUE foo_u).some_field'

    This cast will work for both 'ONE' and 'TWO' foos.

    The second approach is much better if you need to write generic code that handles fields defined in the extensions you want to add. If you don't need this and you only want to define extensions to methods, then the macro approach also works.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • CatalinButnaru
    CatalinButnaru over 10 years ago

    Good idea.

    Thanks,

    Catalin

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information