VHDL Types
VHDL Types
• Basic Types
Type Class Synthesizable Usage
boolean enumerated Y indirect - comparisons
bit enumerated Y not recommended
character enumerated Y not recommended
severity_level enumerated N simulation
integer integer Y array indices,
natural integer (subtype) Y compile time calculation,
positive integer (subtype) Y simulation
• Operators
• Comparison**: =, /=, <, <=, >, >= • Shifting: srl, sll, rol, ror
• Boolean: not, and, or, nand, nor, xor, xnor • Concatenation: &
Common – last updated 8/20/19 2 © tj
VHDL Types
• Numeric Types – numeric_std
• 2 types
• signed array of std_logic (analogous to a std_logic_vector)
• unsigned array of std_logic (analogous to a std_logic_vector)
• Values
• signed is interpreted as 2’s complement (positive and negative)
• unsigned is interpreted as unsigned magnitude (always positive)
• Operators
• Comparison: =, /=, <, <=, >, >= • Shifting: srl, sll, rol, ror
• Boolean: not††, and, or, nand, nor, xor, xnor • Concatenation: &
• Arithmetic†: sign -††††, abs††††, +, -, *†††, /†††, mod, rem, **†††††
• Functions
• resize resize unsigned using zero extension
resize signed using sign extension
† Arithmetic operators other than multiplication preserve the length of the result vector i.e. wrap
†† negation of 2’s complement most negative value will return the most negative value
††† * and / will create large logical solutions
†††† signed only
†††† only use with a base of 2
Common – last updated 8/20/19 3 © tj
VHDL Types
• Fixed Point Types – fixed_pkg
• 2 types Positive indices represent the integer portion of the number
• sfixed array of std_logic Negative indices represent the fractional portion of the number
• ufixed array of std_logic signal foo: sfixed(7 downto -8);
• Values msb 1 0 -1 -2 lsb
• sfixed is interpreted as 2’s complement fixed point number (positive and negative)
• unsigned is interpreted as unsigned magnitude fixed point number (always positive)
• Operators
• Comparison: =, /=, <, <=, >, >=
• Boolean: not, and, or, nand, nor, xor, xnor
• Arithmetic: †: sign -††††, abs††††, +, -, *†††, /†††, mod, rem
• Functions ††† * and / will create large logical solutions
• resize resize unsigned using zero extension †††† signed only
resize signed using sign extension
• is_negative determines if the value is less than 0
• add_carry create a carry out during addition
• scalb scales the value by a factor of two (shift)
• is_negative determines if the value is less than 0
• maximum, minimum provides the largest or smallest of two values
• saturate provides the largest possible value for the given range