Home > Community > Forums > Functional Verification > Declaring array of uniquely parameterized classes

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 array of uniquely parameterized classes 

Last post Thu, Jul 26 2012 5:43 PM by benbuchanan. 4 replies.
Started by benbuchanan 20 Jul 2012 09:10 AM. Topic has 4 replies and 1946 views
Page 1 of 1 (5 items)
Sort Posts:
  • Fri, Jul 20 2012 9:10 AM

    Declaring array of uniquely parameterized classes Reply

    In my SystemVerilog environment, I have an array of a class typefor which I need to customize instantiation parameters for each class in the array.  With all classes the same, I can do

     my_class #(.PARAM1(32), .PARAM2(8)) classes[8];

    However, I can't figure out how to customize the PARAM1 and PARAM2 parameters for each specialization.  Is this possible?

    • Post Points: 20
  • Wed, Jul 25 2012 10:17 AM

    • umery
    • Not Ranked
    • Joined on Thu, Dec 4 2008
    • HOME, NJ
    • Posts 2
    • Points 45
    Re: Declaring array of uniquely parameterized classes Reply

    I don't believe it is legal to have different parameterizations for an array in SystemVerilog. 

    You have atleast 2 options that come to mind:

    1) Use variables in classes that you can initialize, configure or constrain to different values to model different behavior.  I suspect that your params are affecting data types, value ranges, etc. so this may not be viable.

    2) Use different array identifiers to group classes with same parameters.   

    Umer 

    • Post Points: 20
  • Wed, Jul 25 2012 12:17 PM

    Re: Declaring array of uniquely parameterized classes Reply
    I thought that might be the case.  The issue is that in my case the parameters control the data bus width of the associated interface, so that must be available at compile time.  I think I'll just need to split the affected class specializations out of the array.

    Thanks,
    Ben
    • Post Points: 20
  • Wed, Jul 25 2012 12:41 PM

    • umery
    • Not Ranked
    • Joined on Thu, Dec 4 2008
    • HOME, NJ
    • Posts 2
    • Points 45
    RE: Declaring array of uniquely parameterized classes Reply
    Precisely.  This is what I meant by option 2.  Split the array by class specializations.

    It would be a neat feature for the language to support heterogeneous types in an array and pass parameters in the constructor to allocate appropriate storage, but that’s not the case with SystemVerilog.
    • Post Points: 20
  • Thu, Jul 26 2012 5:43 PM

    Re: Declaring array of uniquely parameterized classes Reply
    Thanks, and I agree.
    • Post Points: 5
Page 1 of 1 (5 items)
Sort Posts:
Started by benbuchanan at 20 Jul 2012 09:10 AM. Topic has 4 replies.