+ Post New Thread
Results 1 to 8 of 8
  1. #1
    Member level 2
    Points: 193, Level: 2

    Join Date
    May 2018
    Posts
    43
    Helped
    0 / 0
    Points
    193
    Level
    2

    generic parameter while instantiating design at top level if allowed

    Can a module be instantiated with a generic variable for parameter value as done in the following codes for the instances
    multiplier #(k) multiplier0, divider #(v) divider0, block_p #(k,v) block_p0?

    Here multiplier0 is the instance of multiplier module whose rtl has a parameter named z inside it. The block_p0 is the instance of a module named block_p whose rt has two parameter named u and x inside it. The divider0 is also an instance of a module named divider whose rtl also has a paramer declared.

    Code:
    module toplevel (.....);
    
    parameter k =6;
    parameter v=9;
    
    input .......
    output ......
    reg ..........
    
    
    multiplier #(k) multiplier0
    
    divider #(v) divider0
    
    block_p #(k,v) block_p0
    
    ............
    
    endmodule

    •   Alt27th May 2018, 10:05

      advertising

        
       

  2. #2
    Advanced Member level 5
    Points: 12,642, Level: 26
    pancho_hideboo's Avatar
    Join Date
    Oct 2006
    Location
    Real Homeless
    Posts
    1,853
    Helped
    506 / 506
    Points
    12,642
    Level
    26

    Re: generic parameter while instantiating design at top level if allowed

    Quote Originally Posted by sky_above View Post
    Can a module be instantiated with a generic variable for parameter value as done in the following codes for the instances
    multiplier #(k) multiplier0, divider #(v) divider0, block_p #(k,v) block_p0?
    Yes.
    However "defparam statements" are used in general.

    http://fullchipdesign.com/verilog_defparam.htm
    http://www.asic-world.com/verilog/para_modules1.html



    •   Alt27th May 2018, 13:49

      advertising

        
       

  3. #3
    Super Moderator
    Points: 29,067, Level: 41
    ads-ee's Avatar
    Join Date
    Sep 2013
    Location
    USA
    Posts
    6,682
    Helped
    1604 / 1604
    Points
    29,067
    Level
    41

    Re: generic parameter while instantiating design at top level if allowed

    Quote Originally Posted by pancho_hideboo View Post
    No defparam has been depricated it is not the recomended method of setting parameters for modules



    •   Alt28th May 2018, 02:02

      advertising

        
       

  4. #4
    Advanced Member level 5
    Points: 12,642, Level: 26
    pancho_hideboo's Avatar
    Join Date
    Oct 2006
    Location
    Real Homeless
    Posts
    1,853
    Helped
    506 / 506
    Points
    12,642
    Level
    26

    Re: generic parameter while instantiating design at top level if allowed

    Quote Originally Posted by ads-ee View Post
    No defparam has been depricated
    it is not the recomended method of setting parameters for modules
    I don't think so.

    "defparam" have many merits than instance parameter.



  5. #5
    Advanced Member level 4
    Points: 6,011, Level: 18

    Join Date
    Apr 2016
    Posts
    1,271
    Helped
    221 / 221
    Points
    6,011
    Level
    18

    Re: generic parameter while instantiating design at top level if allowed

    Quote Originally Posted by pancho_hideboo View Post
    I don't think so.

    "defparam" have many merits than instance parameter.
    I haven't seen anyone use it in the last few years. defparam is not a thing anymore. which is great, it was always messy.
    Really, I am not Sam.



    •   Alt29th May 2018, 15:30

      advertising

        
       

  6. #6
    Super Moderator
    Points: 29,067, Level: 41
    ads-ee's Avatar
    Join Date
    Sep 2013
    Location
    USA
    Posts
    6,682
    Helped
    1604 / 1604
    Points
    29,067
    Level
    41

    Re: generic parameter while instantiating design at top level if allowed

    Quote Originally Posted by ThisIsNotSam View Post
    I haven't seen anyone use it in the last few years. defparam is not a thing anymore. which is great, it was always messy.
    Not just messy how about code breaking...

    A defparam can be define ANYWHERE in any portion of code, so a defparam in another file that was mistakenly copied into another file can override the defparam you wanted defined. If you have multiple defparams for the same parameter in the same file then the last one takes precedence. There are many ways to abuse this and cause design failures and wasted time.

    Pancho maybe you should read this. Cummings has been a part of the working groups that define the language, so if you don't want to take my word for it, then take his word for it. defparam IS deprecated (see bottom of pg 5).

    Using passed parameters with named association is a much better approach.



  7. #7
    Advanced Member level 3
    Points: 6,052, Level: 18
    Achievements:
    Created Blog entry 7 years registered

    Join Date
    Dec 2011
    Location
    Fremont, CA, USA
    Posts
    745
    Helped
    344 / 344
    Points
    6,052
    Level
    18
    Blog Entries
    4

    Re: generic parameter while instantiating design at top level if allowed

    Agreed, but the IEEE standard is the last word. Section C.4.1 Defparam statementsIt says defparam has been identified for depreciation, which is not the same IS deprecated. The reason is that the SystemVerilog committee is unlikely to completely remove features that would make existing working code inoperable. Features that actually get deprecated are ones that no one ever implemented, or had too many problematic issues to make it work.
    Dave Rich
    Senior Verification Consultant
    Mentor Graphics Corporation


    2 members found this post helpful.

  8. #8
    Super Moderator
    Points: 29,067, Level: 41
    ads-ee's Avatar
    Join Date
    Sep 2013
    Location
    USA
    Posts
    6,682
    Helped
    1604 / 1604
    Points
    29,067
    Level
    41

    Re: generic parameter while instantiating design at top level if allowed

    thanks dave, I'll admit I didn't check the exact wording in the LRM, but I tend to switch to newer (usually better) techniques once tools catch up and especially if something has been "identified for depreciation".

    Even if it isn't deprecated but only identified for depreciation I'd still avoid using it as it's is messy and can get you in trouble (first hand experience, i.e. running a long simulation (hours) that fails because someone left some "test" code with a parameter set differently than the correct value).



--[[ ]]--