Monday, August 11, 2008

VHDL Part 8 : integer vs natural vs positive

I am fond of using generic statements since this makes the codes I am writing more flexible. I mean I can use them as components in different topblocks without editing them. I will just have to map their generics to my main block's generics.

VHDL allows a user to define his own data types.

Integer is a data type that covers integer values from -2147483647 to +2147483647.

A subtype is a type with limits. Operations between different data types are not allowed but operations with a subtype and its respective data type is allowed.

Natural is a subtype that limits the range from 0 to +2147483647.
Positive is a subtype that covers 1 to 2147483647.

I often use natural and positive in my generic statements.

References:
(1) Pedroni, V., Circuit Design with VHDL, The MIT Press, 2004.
(2) Pellerin, D. and Taylor, D., VHDL Made Easy, Prentice Hall PTR, 1996.

2 comments:

Tausen said...

Thanks for clearing this up, much appreciated.

Vivek Joshi said...

Thanks a ton