In reply to megamind:
Further, I did not understood one thing here,
// this is a generate-if
if (WIDTH == 10) $fatal(0,“Width != 10”);
What do you mean by this? when we keep outside of initial begin , is that generate-if ? how that works ? do you have some good link which I can refer for both localparams and generate.
The $fatal() here is an elaboration system task (Section 20.11 of the SystemVerilog standard). These tasks are subtly different than similar runtime tasks, in that they occur (as the name implies) at elaboration time instead of runtime. They are very useful for implementing parameter value checking as Dave’s example shows, and as it appears you’re desiring. We use them extensively in our designs for this purpose - checking the validity of (sets) of parameter values.