A parameter declaration has the general form "parameter name specification;", where specification is either "= expr" or "default expr". For example:
parameter function = 1; parameter byte_order default "little-endian";
A default value is overridden by an assignment (=). There can be at most one assignment, and at most one default value, for each parameter. Typically, a default value for a parameter is specified in a template, and the programmer may then choose to override it where the template is used. See Section 4.9.2 for more information about templates.
The specification part is in fact optional; if omitted, it means that the parameter is declared to exist (and must be given a value, or the program will not compile). This is sometimes useful in templates, as in:
template constant { parameter value; method get -> (v) { v = $value; } }so that wherever the template constant is used, the programmer is also forced to define the parameter value. E.g.:
register r0 size 2 @ 0x0000 is (constant) { parameter value = 0xffff; }
Note that simply leaving out the parameter declaration from the template definition can have unwanted effects if the programmer forgets to specify its value where the template is used. At best, it will only cause a more obscure error message, such as "unknown identifier"; at worst, the scoping rules will select an unrelated definition of the same parameter name.
You may see the following special form in some standard library files:
parameter name auto;for example,
parameter parent auto;This is used to explicitly declare the built-in automatic parameters, and should never be used outside the libraries.