• 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. Controlling generation

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 64
  • Views 13514
  • 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

Controlling generation

archive
archive over 18 years ago

Hello, I have a query in generation. Suppose if i need to generate a field based on other field, For example class gen; rand rw_wr; rand data; endclass in the above code i want to generate data only when rw_wr = 1 if rw_wr = '0' data should not be generated. For the above scenario how to write the generation constraint. Sundar


Originally posted in cdnusers.org by sundar_80
  • Cancel
Parents
  • archive
    archive over 18 years ago

    Hi Sundar.

    Bear in mind that if you declare a class item as being "rand", the simulator has to generate a value for it.
    Vivek's example shows one possible way to fix the data to a known value when you don't want a random value of data.
    However, this can impact performance.
    If you impose no constraints on the "data" item, the generator is free to just assign a totally random number to it, which is probably quite quick in terms of CPU cycles.
    Once you impose constraints on "data", that forces the simulator to so more work each time you call randomize: it has to check the order of generation, then check if the control field is set to 1 or 0, then find a value of "data" that fits the constraint.

    So before implementing this, ask yourself what's most important to you, and whether it's really necessary to "not generate" a value. After all, I assume you BFM (transactor) just ignores the data item if rw_wr == 0. In this case, you can safely let the generator pick any value for data, and you save some performance.

    It's also generally better to avoid any constraints that are not absolutely necessary, because this might limit future reuse of the class. Always try to leave scope for customisation in anything you do :-)


    Originally posted in cdnusers.org by stephenh
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • archive
    archive over 18 years ago

    Hi Sundar.

    Bear in mind that if you declare a class item as being "rand", the simulator has to generate a value for it.
    Vivek's example shows one possible way to fix the data to a known value when you don't want a random value of data.
    However, this can impact performance.
    If you impose no constraints on the "data" item, the generator is free to just assign a totally random number to it, which is probably quite quick in terms of CPU cycles.
    Once you impose constraints on "data", that forces the simulator to so more work each time you call randomize: it has to check the order of generation, then check if the control field is set to 1 or 0, then find a value of "data" that fits the constraint.

    So before implementing this, ask yourself what's most important to you, and whether it's really necessary to "not generate" a value. After all, I assume you BFM (transactor) just ignores the data item if rw_wr == 0. In this case, you can safely let the generator pick any value for data, and you save some performance.

    It's also generally better to avoid any constraints that are not absolutely necessary, because this might limit future reuse of the class. Always try to leave scope for customisation in anything you do :-)


    Originally posted in cdnusers.org by stephenh
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

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