- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 BillLink Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Because the tool doesn't know how large an unsigned (others => '0') should be. You could do something like this, if you were inclined.
constant ZERO : unsigned(shortwait'range) := (others => '0');
if shortwait = ZERO then
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks! Works Great.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page