Hi guys,
I've got some modules that can be used for varying sample widths. Say you have a 12bit ADC, you instantiate a module with the parameter SampleMSB = 11. The output of the module is a 32bit control register that hooks up to a standard bus the rest of the system shares. The upper 16 bits are used for something else.
assign Reg_Out[31:16] = SomethingElse;
assign Reg_Out[15:(SampleMSB+1)] = 0;
assign Reg_Out[SampleMSB:0] = SampleOut;
Now, this works well, but when I want to use it for 16 bit samples, the code fails, as (SampleMSB+1) is 16 and 15:16 is nonsense.
The obvious way is to keep it unconnected and the compiler will default it to zero, but will issue a warning when the module is used for say, 12 bits.
What would be the elegant way of filling out the rest of the register? I suppose I could use some awful generate command, but I was hoping for something a tad more elegant.
Thanks,
David