Is there any library in vhdl that defines * and + operators? I need to multiply and add more than 128 bit numbers .if yes, are they sythesizable?. Please help.
Yes. For example:
library ieee;
use ieee.numeric_std.all;
...
signal a : signed(31 downto 0); -- 32-bit signed value
signal b : signed(7 downto 0); -- 8-bit signed value
signal c : signed(39 downto 0); -- 40-bit signed value
...
c <= a * b; -- Note 'c' is as wide as the sum of a's length and b's length
The numeric_std
package defines unsigned
and signed
types. It also defines operators for these as well. Note it is also permissible (subject to some restrictions) to mix signed
and unsigned
with integers
and naturals
. For example:
signal a : signed(31 downto 0);
signal b : signed(31 downto 0);
...
b <= a * 17; -- Multiply by a constant
Care must be taken in these cases to ensure overflow does not occur.
And these are synthesizable (we use them all the time in real designs).