library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
USE IEEE.numeric_std.ALL;

entity Park_transformation is
    Port (
        alfa : in signed (15 downto 0); 
        beta : in signed (15 downto 0); 
        sin : in signed (15 downto 0);
        cos : in signed (15 downto 0);
        d : out signed (15 downto 0); 
        q : out signed (15 downto 0) 
    );
end Park_transformation;

architecture Behavioral of Park_transformation is

signal mul_temp1 : signed (31 downto 0);
signal mul_temp2 : signed (31 downto 0);
signal mul_temp3 : signed (31 downto 0);
signal mul_temp4 : signed (31 downto 0);
signal add_temp1 : signed (31 downto 0);
signal add_temp2 : signed (31 downto 0);

begin
 
mul_temp1 <= cos * alfa;
mul_temp2 <= sin * beta;
mul_temp3 <= sin * alfa;
mul_temp4 <= cos * beta;
add_temp1 <= mul_temp1 + mul_temp2;
add_temp2 <= mul_temp4 - mul_temp3;
d(15) <= add_temp1(31);
d(14 downto 0) <= add_temp1(29 downto 15);
q (15) <= add_temp2(31);
q (14 downto 0) <= add_temp2(29 downto 15);
  
end Behavioral;
