On Monday, December 12, 2011 8:53:44 PM UTC-8, Jim Wu wrote:
> On Dec 9, 12:03 pm, RolfK <
Rolf....@renesas.com> wrote:
> Unsized numbers are extended to 32-bit per Verilog LRM, so your code
> only works if WITH <= 31. A better approach for what you're trying to
> would be using concatenation operator vector[WITH:0] = {(WITH+1)
> {1'b1}};, which works for all WITH values.
This solution is probably the safest as far as making current simulation, lint, and synthesis tools happy and not giving you errors and warnings.
System Verilog added the '1, '0, 'x, and 'z unsized literals just for this purpose. Unfortunately, I've run into some tools that don't understand this syntax yet, so I've gone back to the replicate. Even for zero, which will extend correctly, some tools will give LHR/RHS size mismatch warnings so I just do something like this:
aaa = {($bits(aaa)){1'b0}}
which can be easily turned into the macro with arguments.
David