B
BERT
Guest
Hi,
I am a relative newbie to verilog. I am trying to write a parameterized
module, where I have declared a register as:
parameter pmW = 4;
reg [pmW-1:0] pmReg;
Now, I want to initialize this register using:
pmReg <= 0;
(as the bit-width is parameterized, and I also can't write something
like pmW'b0 or similar in verilog).
When, I try to synthesize the design in Altera Quartus II, I get a
warning for the above line that I am trying to truncate a 32-bit value
to a 4 bit value. So, I have two questions:
1. Since "0" is a constant, shouldn't the compiler recognize during
compile time that it will fit in a four-bit register.
2. I can remove the compiler warning using two methods:
a) by defining a parameter "zero" as:
parameter zero = 0;
pmReg <= zero[pmW-1:0];
b) re-writing the above line as:
pmReg <= 1'b0;
In either case, I feel this is completely unnecessary. Or, am I barking
up the wrong tree. (i.e.,) this is specific to the Altera Quartus
compiler ??
Thanks for any insight.
Thanks,
Vijay.
I am a relative newbie to verilog. I am trying to write a parameterized
module, where I have declared a register as:
parameter pmW = 4;
reg [pmW-1:0] pmReg;
Now, I want to initialize this register using:
pmReg <= 0;
(as the bit-width is parameterized, and I also can't write something
like pmW'b0 or similar in verilog).
When, I try to synthesize the design in Altera Quartus II, I get a
warning for the above line that I am trying to truncate a 32-bit value
to a 4 bit value. So, I have two questions:
1. Since "0" is a constant, shouldn't the compiler recognize during
compile time that it will fit in a four-bit register.
2. I can remove the compiler warning using two methods:
a) by defining a parameter "zero" as:
parameter zero = 0;
pmReg <= zero[pmW-1:0];
b) re-writing the above line as:
pmReg <= 1'b0;
In either case, I feel this is completely unnecessary. Or, am I barking
up the wrong tree. (i.e.,) this is specific to the Altera Quartus
compiler ??
Thanks for any insight.
Thanks,
Vijay.