Using Module-Instance Parameter:
Parameter values can be overridden while a module is instantiated. New parameter values are passed at the time of module instantiation. Top-level module can pass parameters.
//define top-level module
module top;
//instantiate two hello-world modules; pass new parameter values
hello-world #(l) wl; //pass value 1 to module wl
hello-world #(2) w2; //pass value 2 to module w2
endmodule
If multiple parameters are defined in module, during module instantiation they can be overridden by specifying new values in the same order as the parameter declarations in the module. If an overriding value isn't specified, default parameter declaration values are taken.
//define module with delays
module bus-master;
parameter delayl = 2;
parameter delay2 = 3;
parameter delay3 = 7;
...
...
Endmodule
//top-level module; instantiates two bus-master modules
module top;
//Instantiate the modules with new delay values
bus-master # (4, 5, 6) bl ( ) ; //bl : delayl = 4, delay2 = 5, delay3 = 6
bus-master # (9,4) b2 ( ) ; //b2: delayl = 9, delay2 = 4, delay3 = 7 (default)
endmodule
Module-instance, parameter value assignment is a very useful method used to override parameter values and to customize module instances.