• 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. generate of specman (vs) randomize of systemverilog

Stats

  • Locked Locked
  • Replies 4
  • Subscribers 65
  • Views 15330
  • 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

generate of specman (vs) randomize of systemverilog

onkarkk
onkarkk over 16 years ago

Hi,

Could any one please explain me clearly steps of generate and randomize and their significance.

i.e ., in generate it is told there is pre-generate and post-generate methods i could not understand clearly why they required.

In the same way in randomize() also there are pre_randomize() and post_randomize() methods will be invoked , i didnt get sufficient clarity on their explanation .. could any 

one please clarify the significance of those methods.

Thanks in advance,

regards

Krishna Kishore 

  • Cancel
  • StephenH
    StephenH over 16 years ago

    Hi Krishna.

    In both e and SV, the pre_ and post_ methods are used as procedural hooks to do things that cannot or should not be done with constraints. Both methods are called automatically by the randomisation engine, either side of the actual randomisation process.

    The pre_ method is less commonly needed in Specman, because Specman's generate action actually allocates memory for the objects as it does the randomisation, unlike SV which (unhelpfully) forces the user to new() every object before randomisation can take place. This becomes important when you are randomising a nested object (e.g. a burst class that contains a list of transfer class objects). In SV you might use pre_randomize() to allocate the nested classes so that they can also be randomised.

    The post_ method is more commonly used. A typical problem is to generate a valid CRC  for the object.
    It can be hard and inefficient to do this with constraints especially if your object has many optional fields, so we typically use a post_generate method to do this. I'll illustrate with e because I prefer it to SV, but the principle applies to both:

    struct packet {
      %address : byte;
      %length : uint;
      %payload[length] : list of byte;
      crc_error: bool;
      %crc;
      post_generate() is also {
        if !crc_error {
          crc = crc8(%{address,length,payload});
        };
      };
    };

    This code would generate a random crc value when you randomise the struct. The post_generate method then computes the correct crc if the crc_error control field is not set.

    Hope this helps. I would strongly recommend that you open the Specman docs (type "sn_help.sh" at the Unix prompt) and search for post_generate. The docs give a lot of guidance about how to use these methods properly, to avoid over-constraining your tests.
    A little biased note: Specman's documentation is fantastic, and has loads of great info for actually building your testbench; it's almost a proper book in its own right. By contrast, SystemVerilog is just a dry LRM spec which leaves you try to work out how and why you should do things. This is just one of the many reasons I prefer Specman to SV, it's so much easier to use!

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • onkarkk
    onkarkk over 16 years ago

    Dear Stephen,

    I too feel e bit convenient than SV (with my little knowledge),  thats ok , thanks for your reply i am going through documents but not like sn_help.sh (i dont know why , it is not working on my system , yes i didnt put much concentration on it i will look at it),  from ur post what i understood is

    1. pre_ method will create some memory for random variables  ---->  my understanding is correct ??

    2. "It can be hard and inefficient to do this with constraints especially if your object has many optional fields" -- could u please elaborate it ..

    3. You have used post_generate method to calculate crc when there is an error , cant i use custom method say good_crc() instead of post_generate() , i.e, like pre_generate , post_generate also create some momory or like that??

    Please correct me if i am wrong ....

    Thanks in advance

    regards

    Krishna Kishore

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • StephenH
    StephenH over 16 years ago

    If sn_help.sh isn't working, you could use the PDF version of the docs instead.
    The Specman-e reference is: <install_dir>/doc/sn_eref/sn_eref.pdf
    The generation guide: <install_dir>/doc/sn_igenuser/sn_igenuser.pdf
    User Guide: <install_dir>/doc/sn_usage/sn_usage.pdf
    etc.

    Neither pre_ or post_ methods  do anything magic, eother in SV or e. They just give you a hook to execute some code just before or just after generation. As a day-to-day user of e, you can pretty much forget about these methods - I rarely find myself needing to use them, since the constraint solver "IntelliGen" is very powerful and can do everything I ever need it to.

    I don't quite get your point about "good_crc()". If you want to use this in a constraint, you'd have to make sure the method parameters define all the fields used to calculate the crc. For example:

    keep crc_error == FALSE => crc ==  good_crc(payload);

    If you want to apply good_crc() procedurally, you need to use post_generate() as the trigger to call your method:

    post_generate() is also {
      if !crc_error { crc = good_crc(); };
    };

     

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • onkarkk
    onkarkk over 16 years ago

    Thank you Stephen,

    Now i understood bit clearly, I will go further as u said...

    Thankyou verymuch.

    Regards

    Krishna Kishore 

    • 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