Numeric std
numeric_std is a library package defined for VHDL. It provides arithmetic functions for vectors. Overrides of std_logic_vector are defined for signed and unsigned arithmetic. It defines numeric types and arithmetic functions for use with synthesis tools. Two numeric types are defined: UNSIGNED and SIGNED. The base element type is type STD_LOGIC. The leftmost bit is treated as the most significant bit. Signed vectors are represented in two's complement form. This package contains overloaded arithmetic operators on the SIGNED and UNSIGNED types. The package also contains useful type conversions functions.
It is typically included at the top of a design unit:
library ieee;
use ieee.std_logic_1164.all; -- standard unresolved logic UX01ZWLH-
use ieee.numeric_std.all; -- for the signed, unsigned types and arithmetic ops
The alternative numeric package ieee.std_logic_arith should not be used for new designs. This package does not provide overrides for mixing signed and unsigned functions. This package includes definitions for the following :
Operators and functions
Sign changing operators
- abs
- -
Arithmetic operators
- +
- -
- *
- /
- rem
- mod
Comparison operators
- ><<=
- >=
- =
- /=
Shift and rotate functions
- SHIFT_LEFT
- SHIFT_RIGHT
- ROTATE_LEFT
- ROTATE_RIGHT
- sll
- srl
- rol
- ror
Resize function
- RESIZE
Conversion functions
- TO_INTEGER
- TO_UNSIGNED
- TO_SIGNED
Logical operators">Logical connective">Logical operators
- not
- and
- or
- nand
- nor
- xor
- xnor
Match function
- STD_MATCH
Special translation function
- TO_01