Simulating LPM_counter on Modelsim gives 'z' (high impedance) output
module lpm_counter(clock,q); is an empty black box. 

To get it to simulate, you will need to use the actual HDL rather than the black box. There are two options:


You can delete that module declaration and instruct Modelsim to compile the HDL file that was produced when you used MegaWizard.
Copy the contents from the HDL file from (1) into your source file to replace the black box.