Altera_Forum
Honored Contributor
10 years agoInterpretation of numberic constants as signed/unsigned
Hi All,
I'm new to this forum, and very new to FPGAs. I've got myself a simple Cyclone II dev board and a copy of Quartus, and I'm attempting to learn some VHDL. I've just got to the stage of blinking my first LED... I have a very simple (I think) opening question regarding VHDL. I wanted to design a modulo-n frequency divider with a 32bit counter, and so I defined the type that I would later use for my counter as follows: type uint32 is range 0 to 16#ff_ff_ff_ff# ; (I also later tried subtype uint32 is integer range 0 to 16#ff_ff_ff_ff# ;) In both these cases 16#FF_FF_FF_FF# appears to have been interpreted as a signed two's complement integer, that is, as the value -1. My type therefore has the range 0 to -1, not 0 to 4294967296 as I intended. My question is, then, how would I define an unsigned integer as I intended? Thanks in advance. No doubt I'll be back with more daft questions very soon! (PS. What, if anything, is the difference between the types defined by the two lines of code above?)