[sv-bc] localparam declarations in V2K-style parameter port lists

From: Brad Pierce <Brad.Pierce_at_.....>
Date: Mon Oct 24 2005 - 13:40:15 PDT
As noted in V2K+5, subclause 12.2, "There are two different ways that
parameters can be defined. The first is the module_parameter_port_list
(see 12.1), and the second is as a module_item (see 4.10)."

However, there is only one way to write a local parameter -- as an
old-style module_item.

This means that ANSI-style port declarations cannot refer to local
parameters.

For example, this is disallowed

    module m #(parameter N = 16,
               localparam myN = (N > 32) ? $clog2(32) : $clog2(N))
           (input [myN-1:0] in, output [myN-1:0] out);

so to get the effect one must either do

    module m #(parameter N = 16)
           (input [((N > 32) ? $clog2(32) : $clog2(N))-1:0] in,
            output [((N > 32) ? $clog2(32) : $clog2(N))-1:0] out);

or

    module m (in, out);
    parameter N = 16;
    localparam myN = (N > 32) ? $clog2(32) : $clog2(N);
    input [myN-1:0] in;
    output [myN-1:0] out;
    
-- Brad
Received on Mon Oct 24 13:40:24 2005

This archive was generated by hypermail 2.1.8 : Mon Oct 24 2005 - 13:40:43 PDT