Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand AUTOINST default values for parameters #1447

Open
veripoolbot opened this issue May 24, 2019 · 4 comments
Open

Expand AUTOINST default values for parameters #1447

veripoolbot opened this issue May 24, 2019 · 4 comments

Comments

@veripoolbot
Copy link
Collaborator


Author Name: Mert Ustun
Original Redmine Issue: 1447 from https://www.veripool.org


When I use verilog-auto-inst-param-value:t, it can successfully replace bus indexes with parameter values only if the parameter is explicitly assigned a value during the module instantiation. In many cases, parameter values could be left as default without any explicit setting, especially if the default value is inferred from another assigned parameter.

For instance, taking the example in Issue #522,

module submod (/*AUTOARG*/
    // Outputs
    idx,
    // Inputs
    vec
    );
    parameter VEC_W = 32;
    parameter IDX_W = $clog2(VEC_W);
    input  [VEC_W-1:0]   vec;
    output [IDX_W-1:0]   idx;
endmodule

module mod;
    submod #
      (.VEC_W(8),
       .IDX_W($clog2(VEC_W)))
    submod
      (/*AUTOINST*/
       // Outputs
       .idx                              (idx[($clog2(8))-1:0]),
       // Inputs
       .vec                              (vec[7:0]));
endmodule
// Local Variables:
// verilog-auto-inst-param-value:t
// End:

There is no need to set IDX_W parameter during instantiation since it's same as the default assigned value. However, verilog-auto-inst-param-value will not expand the param value if the parameter value is not explicitly set during instantiation.

I actually realized my request was already there in Issue #522, at the bottom:

_My next request would be to make it work:

 if IDX_W isn't passed
 if IDX_W is a localparam in submod

These two conditions are very common and would be great if Verilog-mode could support parameter value expansion for these two cases.

@veripoolbot
Copy link
Collaborator Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2019-05-28T11:05:29Z


I agree this would be useful. It will be some work as requires parsing significant information that isn't presently parsed.

@edcarstens
Copy link

Yes it would be useful. I would really like to see this implemented too. There are some parameters that should remain parameters, not localparam, but have defaults.

@gxjinfeng
Copy link

Does this function add into verilog-mode? Its really useful.

@wsnyder
Copy link
Member

wsnyder commented Aug 18, 2022

The best way to get it is to create a pull request to add it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants