Home > Community > Forums > Functional Verification > Declaring class outsside program block

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 Declaring class outsside program block 

Last post Sat, Jul 28 2007 3:10 AM by archive. 6 replies.
Started by archive 28 Jul 2007 03:10 AM. Topic has 6 replies and 1480 views
Page 1 of 1 (7 items)
Sort Posts:
  • Sat, Jul 28 2007 3:10 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    Declaring class outsside program block Reply

    Hello, Is it possible to declare class outside the program block like bellow? class gen; endclass program test; endprogram;


    Originally posted in cdnusers.org by sundar_80
    • Post Points: 0
  • Sat, Jul 28 2007 3:14 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: Declaring class outsside program block Reply

    Sorry for my earlier code for not following the rules, i have correct the format of the code now. class gen; endclass program test; endprogram; Sundar


    Originally posted in cdnusers.org by sundar_80
    • Post Points: 0
  • Sat, Jul 28 2007 4:40 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: Declaring class outsside program block Reply

    Sundar,
     >> Is it possible to declare class outside the program block like bellow?

    Yes, language allows it though I personally discourage it - atleast encapsulate them under packages. I know some debug tools today work best if classes are declared inside program.

    HTH
    Ajeetha, CVC
    www.noveldv.com  


    Originally posted in cdnusers.org by ajeetha
    • Post Points: 0
  • Sun, Jul 29 2007 11:28 PM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: Declaring class outsside program block Reply

    Hello Ajeetha,
    Thanks a lot for your mail, as you mentioned its always better to encapsulate it in package, i also feel that's the good practice.
    But one query, if a class is encapsulated inside package is it possible to use the class itself, as far my knowledge about SV(i have very little knowledge) only task defined in the package can be used not the class is that correct?

    Sundarraj


    Originally posted in cdnusers.org by sundar_80
    • Post Points: 0
  • Sun, Jul 29 2007 11:34 PM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: Declaring class outsside program block Reply

    Hi Sundar,
    You can encapsulate the class inside a package and whenever you want to use this class, just "import" that package. You can import the package using following

    import ::*;

    then you can easily use the class and its all properties and methods which were declared in that package.


    regards
    Jagvin


    Originally posted in cdnusers.org by jagvinder
    • Post Points: 0
  • Sun, Jul 29 2007 11:36 PM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: Declaring class outsside program block Reply

    The command for importing the package is

    import package_name::*;

    sorry, i missed it in last mail.


    regards
    Jagvinder


    Originally posted in cdnusers.org by jagvinder
    • Post Points: 0
  • Sun, Jul 29 2007 11:53 PM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    RE: Declaring class outsside program block Reply

    Hello Jagvinder,
    Thanks a lot for your mail. I will try to use as you mentioned.

    Sundarraj


    Originally posted in cdnusers.org by sundar_80
    • Post Points: 0
Page 1 of 1 (7 items)
Sort Posts:
Started by archive at 28 Jul 2007 03:10 AM. Topic has 6 replies.