Parameters


Parameter

parameters in verilog is nothing but a way to instantiate constants in the digital design.

parameter is local to a module. but it can change value when the module is instantiated. It is used to define a property of the module.

Syntax
parameter <parameter_name> = <constant_expression>;

Example

  • parameter size = 4;
  • parameter clk = freq / 2;

This property can be left to default, or can be modified at instantiation of the module. For example

By default, the adder is 8-bit (the width parameter use the default assigned value of 8). However, the instantiator module can change parameter value.


Local Parameter

local parameter localparam is also used to store the constant in the digital design but the constant defined inside the module cannot be changed. (i.e from where the module is instantiated).

Syntax
localparam name = value;

Example

  • localparam len = width/12;
  • localparam size = 16;