Verilog HDL

Using Parameterized Functions



In Verilog HDL, you can use a Module Instantiation to create an instance of a parameterized function (including a library of parameterized modules [LPM] function) supported by the Quartus® II software.

You can instantiate parameterized functions with a Module Instantiation in the same way as unparameterized functions, as described in Using a Quartus II Logic Function and Implementing a User-Defined Megafunction and Macrofunction, with a few additional steps:

The following example shows reg24lpm.v, a Verilog Design File (.v) for a 24-bit register that includes Module Instantiations for reg12a and reg12b, two instances of the Altera-provided lpm_ff parameterized megafunction. The Defparam Statement for each instance of lpm_ff defines the register width as 12 bits by setting the lpm_width parameter value to 12.

module reg24lpm (d, clk, q);

    input   [23:0] d; 
    input   clk;
    output  [23:0] q;

    lpm_ff reg12a (.q (q[11:0]), .data (d[11:0]), .clock (clk));
        defparam reg12a.lpm_width = 12;

    lpm_ff reg12b (.q (q[23:12]), .data (d[23:12]), .clock (clk));
        defparam reg12b.lpm_width = 12;
     
endmodule

For more information, see "Section 12.1.2: Module Instantiation" in the IEEE Std 1364-1995 IEEE Hardware Description Language Based on the Verilog Hardware Description Language manual.


Back to Top

- PLDWorld -

 

Created by chm2web html help conversion utility.