Altera_Forum
Honored Contributor
15 years agoExponents in Verilog
Hi, I am pretty new to Verilog and Quartus II, and was hoping someone could help me out.
My output is a 12-bit signed register. I get the value of this through an equation, and as part of that equation I have an exponential calculation, 2**B (where B is a register containing a value of 0-10). Doing this gives me an error "Warning (10230): Verilog HDL assignment warning at xxx.v(25): truncated value with size 32 to match size of target (12)", but the value of the calculation is correct. I think this is because it is treating the 2 as 32-bit integer, then when it truncates to 12 bits, it is just cutting off leading zeroes. So I tried changing it to something like 2'd2**B, but then the result of the calculation is wrong. Is there a way to do an exponent without getting an error? Thanks so much!