Forum Discussion
Altera_Forum
Honored Contributor
14 years agoUnsigned number math
Greetings,
Apparently when using unsigned numbers if you are performing a math operation using a statement like if shortwait = (others => '0') then next line of code.... is not allowed but you can overload an operator and compare it to an integer if shortwait = 0 then next line of code.... The above works, Can someone explain to me why I can get away with this and why I cannot use (others => '0') ? Thanks as always Bill2 Replies
- Altera_Forum
Honored Contributor
Thanks! Works Great.
- Altera_Forum
Honored Contributor
Because the tool doesn't know how large an unsigned (others => '0') should be. You could do something like this, if you were inclined.
The second equals in question is defined in numeric_std as specifically operating on two operands, one an unsigned and the other an integer, and starts off by defining an unsigned variable of the same length as the operand, mapping the integer into it using TO_UNSIGNED, and then performing the equality comparison.constant ZERO : unsigned(shortwait'range) := (others => '0'); if shortwait = ZERO then