Parameters are constants and hence it's illegal to modify their value at runtime. It is illegal to redeclare a name already used by a net, variable or another parameter. There are two major types of parameters, module and specify and both accepts a range specification. But, they are normally made as wide as the value to be stored requires them to be and hence a range specification is not necessary.

Module parameters

Module parameters can be used to override parameter definitions within a module and this makes the module have a different set of parameters at compile time. A parameter can be modified with the defparam statement or in the module instance statement. It is a common practice to use uppercase letters as names for the parameter to make them instantly noticeable.

  parameter MSB = 7;                  // MSB is a parameter with a constant value 7
  parameter REAL = 4.5;               // REAL holds a real number
  parameter FIFO_DEPTH = 256, 
            MAX_WIDTH = 32;           // Declares two parameters
  parameter [7:0] f_const = 2'b3;     // value is converted to 8 bits; 8'b3

Now let's see a real usecase on how parameters become helpful. The module shown below uses parameters to specify the bus width, data width and the depth of FIFO within the design, and can be overriden with new values when the module is instantiated or by using defparam statements.

Login to your free account to read more ...

Was this article helpful ?