Thanks Tricky and Blooz.
I have one more question. If I will be multiplying signed integer numbers. I have a function which is Y = A*x1 + B*x2. Some of the coefficients in the function will be port inputs and some will be predetermined constants already known.
In the code below,
x1 and x2 are port signed integer inputs that are to be 8 bits in length.
Y is the signed integer output of the overall function which is to be 10 bits in length.
a and b are predetermined signed integer constants that will be used in the function calculation.
In the code below am I declaring the inputs, outputs, and constants correctly to represent a function that results in a 10 bit signed number?
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.numeric_std.ALL;
entity FunctionExample is
Port (
x1 : IN signed (7 downto 0);
x2 : IN signed (7 downto 0);
Y : OUT signed (9 downto 0));
end FunctionExample;
architecture Behavioral of FunctionExample is
constant A: integer:= 4;
constant B: integer:= 2;
begin
C <=TO_SIGNED(A*x1 + B*x2,10);
end Behavioral;