Verilog HDL: Parameterized Counter

This example shows how to instantiate an LPM function in Verilog HDL. In this case, an LPM_COUNTER is instantiated using the aclr, clock, and q ports. The parameter values are set with the keyword defparam, as shown in red text. Both the port mapping and the parameter names are referred to by the period (.) operator after the variable name. In this case, the variable is u1.

For more information on using this example in your project, go to:


check_lpm.v

module check_lpm ( clk, reset, q);
// Port Declaration

input   clk;
input   reset;
output  [7:0] q;

lpm_counter u1 (.aclr(reset), .clock(clk), .q(q));
defparam u1.lpm_width= 8;
defparam u1.lpm_direction= "UP"

endmodule

Design Examples Disclaimer

These design examples may only be used within Altera Corporation devices and remain the property of Altera. They are being provided on an “as-is” basis and as an accommodation; therefore, all warranties, representations, or guarantees of any kind (whether express, implied, or statutory) including, without limitation, warranties of merchantability, non-infringement, or fitness for a particular purpose, are specifically disclaimed. Altera expressly does not recommend, suggest, or require that these examples be used in combination with any other product not provided by Altera.