local_parameter_declaration ::=
localparam [ signing ]
{ packed_dimension } [
range ] list_of_param_assignments ;
| localparam data_type
list_of_param_assignments ;
parameter_declaration ::=
parameter [ signing ]
{ packed_dimension } [
range ] list_of_param_assignments
| parameter
data_type list_of_param_assignments
| parameter
type list_of_type_assignments
specparam_declaration ::=
specparam [ packed_dimension range ] list_of_specparam_assignments
;
constant_declaration ::= const data_type
const_assignment ; //
from Annex A.2.1.3
const_assignment ::= const_identifier
= constant_expression // from Annex A.2.4
param_assignment ::= parameter_identifier
= constant_param_expression // from Annex A.2.4
type_assignment ::= type_identifier
= data_type
parameter_port_list ::= //
from Annex A.1.4
# ( list_of_param_assignments { ,
parameter_port_declaration } )
| # ( parameter_port_declaration { , parameter_port_declaration
} )
parameter_port_declaration ::=
parameter_declaration
| data_type list_of_param_assignments
| type list_of_type_assignments
A module, interface, program, or class or an interface can have parameters, which are set
during elaboration and are constant during simulation. They are defined with
data types and default values. With SystemVerilog, if
no data type is supplied, parameters default to type logic of arbitrary size for Verilog-2001 compatibility and
interoperability.
SystemVerilog also adds the ability to omit the parameter keyword in a parameter port list.
class vector #(size =
1);
logic [size-1:0] v;
endclass
typedef vector#(16) word;
interface simple_bus #(AWIDTH = 64, type T = word) (input
bit clk) ;
endinterface
In a list of parameters, a parameter can depend on earlier
parameters. In the following declaration, the default value of the second
parameter depends on the value of the first parameter. The third parameter is a
type, and the fourth parameter is a value of that type.
module mc # (int N = 5, M = N*16, type T = int, T x = 0)
( ... );
...
endmodule