--=================================================================================================
-- File Name                           : foc_transforms.vhd

-- Description                         : This module integrates the following sub-modules:
--                   		                1. Clarke Transform
--		                                    2. Park Transform(cordic_scheduler_foc)
--        		                            3. Inverse Clarke Transform
--                		                    4. Inverse Park Transform(cordic_scheduler_foc)
--                   		                5. Multiplier with adder/subtractor

-- Targeted device                     : Microsemi-SoC
-- Author                              : India Solutions Team
--
-- SVN Revision Information            :
-- SVN $Revision                       :
-- SVN $Date                           :
--
-- COPYRIGHT 2016 BY MICROSEMI
-- THE INFORMATION CONTAINED IN THIS DOCUMENT IS SUBJECT TO LICENSING RESTRICTIONS FROM MICROSEMI
-- CORP. IF YOU ARE NOT IN POSSESSION OF WRITTEN AUTHORIZATION FROM MICROSEMI FOR USE OF THIS
-- FILE, THEN THE FILE SHOULD BE IMMEDIATELY DESTROYED AND NO BACK-UP OF THE FILE SHOULD BE MADE.
--
--=================================================================================================

--=================================================================================================
-- Libraries
--=================================================================================================
LIBRARY IEEE;
USE IEEE.std_logic_1164.ALL;
USE IEEE.std_logic_signed.ALL;
--=================================================================================================
-- foc_transforms entity declaration
--=================================================================================================
ENTITY FOC_TRANSFORMS IS
GENERIC(

    -- Specifies the number of clock delays required before the mas done signal is asserted.
	g_NO_MCYCLE_PATH                   : INTEGER RANGE 0 to 4 := 2
);
PORT (
-- Port list
    -- System reset
	reset_i                            : IN  STD_LOGIC;

    -- System clock
	sys_clk_i                          : IN  STD_LOGIC;

    -- Control input specifies the start of Clarke transform
	start_clarke_i                     : IN  STD_LOGIC;

    -- Control input specifies the start of Park transform
    start_park_i                       : IN  STD_LOGIC;

    -- Control input specifies the start of IPark transform
    start_ipark_i                      : IN  STD_LOGIC;

    -- Control input specifies the start of IClarke transform
    start_iclarke_i                    : IN  STD_LOGIC;

    -- Data input specifies the A-phase current value for Clarke computation
	ia_i                          	   : IN  STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Data input specifies the B-phase current value for Clarke computation
	ib_i                          	   : IN  STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Data input specifies the alpha-axis current input for Park computation
	ialpha_i               			   : IN  STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Data input specifies the beta-axis current input for Park computation
	ibeta_i                			   : IN  STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Data input specifies D-axis voltage input for Inverse Park computation
	vd_i                   			   : IN  STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Data input specifies Q-axis voltage input for Inverse Park computation
	vq_i                   			   : IN  STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Data input specifies the Alpha-axis voltage input for Inverse Clarke computation
	valpha_i                   		   : IN  STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Data input specifies the Beta-axis voltage input for Inverse Clarke computation
	vbeta_i                    		   : IN  STD_LOGIC_VECTOR(17 DOWNTO 0);

	-- Data input specifies the FOC angle
	theta_i                    		   : IN  STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Control output specifies the completion of Clarke transform
    clarke_done_o                      : OUT STD_LOGIC;

    -- Control output specifies the completion of Park transform
    park_done_o                        : OUT STD_LOGIC;

    -- Control output specifies the completion of Inverse Park transform
    ipark_done_o                       : OUT STD_LOGIC;

	-- Control output specifies the completion of Inverse Clarke transform
    iclarke_done_o                     : OUT STD_LOGIC;

    -- Data output specifies the alpha axis current output from Clarke computation
    ialpha_o             			   : OUT STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Data output specifies the beta axis current output from Clarke computation
	ibeta_o              			   : OUT STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Data output specifies the D-axis current output from Park computation
	id_o                   			   : OUT STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Data output specifies the Q-axis current output from Park computation
	iq_o                   			   : OUT STD_LOGIC_VECTOR(17 DOWNTO 0);

	-- Data output specifies the Alpha-axis voltage output from Inverse Park computation.
	valpha_o              	    	   : OUT STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Data output specifies the Beta-axis voltage output from Inverse Park computation.
	vbeta_o               			   : OUT STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Data output specifies the A-phase voltage output from Inverse Clarke computation
	va_o                        	   : OUT STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Data output specifies the B-phase voltage output from Inverse Clarke computation
	vb_o                        	   : OUT STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Data output specifies the C-phase voltage output from Inverse Clarke computation
	vc_o                        	   : OUT STD_LOGIC_VECTOR(17 DOWNTO 0)
);
END foc_transforms;

--=================================================================================================
-- foc_transforms architecture body
--=================================================================================================

ARCHITECTURE foc_transforms OF foc_transforms IS
`protect begin_protected
`protect version=1
`protect author="author-a", author_info="author-a-details"
`protect encrypt_agent="encryptP1735.pl", encrypt_agent_info="Synplify encryption scripts"

`protect key_keyowner="Synplicity", key_keyname="SYNP05_001", key_method="rsa"
`protect encoding=(enctype="base64", line_length=76, bytes=256)
`protect key_block
EhDDqI2Ny7ARMrwIs2b5ZFSddaiE6R8QBo8w7DW0YaxdGqkG6CUH9vNQmVLFWOloov70sgpPVKqJ
qxcIQrwHMxG2l8iIF6tsgfH6ZL8LLryVO6P95EzTAvE/D+XSar8C6i2mzgJUloEbsAolk0qACCKg
1bNwxrFUvgP0+btX2eTG3sfyboaAAGm8mFJj9gs5xnB5ILtpJcAgteucmZ85nbAVFaq9L4kGh8kZ
FIHvzu2hDYKCn8kcA+xU2l+iM05fD+BKusbVxvJaWsSfnbG+/7dqp/ZpnfK1sJ8wkeIXt2O8hESc
vnN4sCKOuMIyxf8lp86YL5bneUCj3z59mtlKlg==

`protect key_keyowner="Mentor Graphics Corporation", key_keyname="MGC-VERIF-SIM-RSA-1", key_method="rsa"
`protect encoding=(enctype="base64", line_length=76, bytes=128)
`protect key_block
am7gcHt5YDH3WHnJuH3TrxRy+fvaCUriVYnmujzsiirn9eJcYvgfgtJQ5HGk6fFu223sKZZQCnCa
bOcLNdjDavIVLEDyM0TRAlw4Ap/QUMqaXDWEDam1b6O9OGwsKhuVM5s5uEBY1UihkX3TGG600TRr
+EvSoSuN0fVxFLH6a/0=

`protect key_keyowner="Microsemi Corporation", key_keyname="MSC-IP-KEY-RSA", key_method="rsa"
`protect encoding=(enctype="base64", line_length=76, bytes=960)
`protect key_block
jBc7MJMEr3WBWbyHuJYbZOG4uxrUKJQM3sG+nCZuyzNviYSPvyNCBXRn1V8rsNjNx/z0jWmKMn3f
8ekrfwaN3LfJjABHmtJ6xzEg5Le7+fOSqjvILL7zjff4lkSedzLkewyHnQ1cePtJ3g84hKmxnKuS
7e80dD6QJOtqHEmw8PDC0wCPsSQ2YVAsQ3ZogpkbmXlopWR8tLPXDQcNRnIJo0GR9QaN3FG1gBhx
sfgKN5GOV8yzK3QNwnve/sbcQlFKtHds+yTGBlb2QXpUSvI3RdDvDWHe/3XDlsk8Prhf73T8r+6W
w44kFwiU7999GMrR+woD7Jrul+afCPGr2ZANrqTHOW2AQLMK9ABk4IaNxoKJyqQHrX3DcGgnZTeZ
Qbk8b99I+Hm1d218ksVs/yZVPQGVzGM4rEsIAVrb3L1EwmJ1uFmQZ5JN4xyIpQCnxTCNHFZ0uhqK
L4y6hoDOVF7gyCA5qLmKkK9xjyJUec8wYfjd3sTifOiTAw2U9Hesr5s9vrE6+7JBQORZAEJs2L5P
dC4T8iAWOT/FcMIemujyo+HzAIKFcIC7U8s5/Au+dApiLUpN6cJAwBUfNSFGilDztBQQBIm/UiWX
+FC+X6MeypLVQmvvfmuOD6Rc7dhJEiynoMf2lRvHtyqlTdB8E+/HKmLxBBSc5W22PGLdYkljTtrW
Z2gPb8+4uUBmwPrBQRv0jmGW8fjLvq2+Y0MsZjBIHXarAS2yvCFloDidOEsxZ3bP2T6cW/MBb6DS
V6VkOJf2S2ObUouGb+fVW61oQLOIAByfF/oEMPzicxdglQ1zGqieJS4m9YdDtnBX9Zs6ftBON9uN
TQrKLADrT+F1/JnX1QdjmvUsui28fWbb55sgYRAmTfnhM5Fa1PWzl2wedzGA5Z6hXHhov68UYYq9
wGpSah+4Uyc/q2SzT4HbvN1FJpx3nkaRIc+EaQRDNDG2FKPceSLCu3cVBvZ4zYibW9m3hLCN26yH
zjbi6q+NUgfOaYYUkDiopeEDzCRxQ6lR7WlUHH1X9GJh092y7MCeJRG3uxBCrJ1o8uPA2jvJ+S2N
3asBT1ucTO5oH5/2rzXQqhPgzXZZOWrtRWgxT1ZaMr6SQ2+YFKxXjL86zvVFYxvPZuwA2xVoV0xo
Zm6EAEvC2dAS6AdUUGKzQuCJHuxcpDqQkOy0m2HbTe9evqvzP0+DAItTV9l9hbHoLBYZnLA9+1OG
Ofo6Gli9kO70IoQbQRVFtiNxTk48pCZHxyUIQptebTAk2jx7KyRf4owXEo1g+Ls4

`protect data_keyowner="ip-vendor-a", data_keyname="fpga-ip", data_method="aes128-cbc"
`protect encoding=(enctype="base64", line_length=76, bytes=84240)
`protect data_block
[encoded data, 112320 characters]

`protect end_protected

