--=================================================================================================
-- File Name                           : hall_interface.vhd

-- Description                         : This module implements theta and omega generation from 
--                                       hall signals.

-- 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;                                                                                                  
USE IEEE.STD_LOGIC_ARITH.ALL;   
--USE IEEE.NUMERIC_STD.ALL;
--=================================================================================================
-- HALL_INTERFACE entity declaration
--=================================================================================================

ENTITY HALL_INTERFACE IS
PORT (
    -- System reset
    reset_i                                   : IN  STD_LOGIC;
	
    -- System clock
    sys_clk_i                                 : IN  STD_LOGIC;
	
	-- Hall input A
    ha_i									  : IN  STD_LOGIC;
	
	-- Hall input B
    hb_i                                      : IN  STD_LOGIC;
	
	-- Hall input C
	hc_i                                      : IN  STD_LOGIC;

    --Clear buffer
	clear_buffer_i                            : IN  STD_LOGIC;
    
    --Filter trigger
	fil_trig_i                                : IN  STD_LOGIC;
	    
    --Filter Factor
    filter_factor_i						      : IN STD_LOGIC_VECTOR(3 DOWNTO 0);

	-- Data input for hall sensor active high (1) or low (0)
	hall_sensor_pol_i                         : IN STD_LOGIC;

    -- Speed Factor Multiplier
    speed_factor_i  						  : IN STD_LOGIC_VECTOR(17 DOWNTO 0);
	
	-- Data output indicating motor speed computation complete
    omega_done_o                              : OUT STD_LOGIC;

    -- Data output indicating motor speed
    omega_out_o                               : OUT STD_LOGIC_VECTOR(17 DOWNTO 0);
	
	-- Data output indicating raw rotor angle from hall
	angle_out_raw_o                           : OUT STD_LOGIC_VECTOR(17 DOWNTO 0);
	
	-- Data output representing 
	theta_output_o							  : OUT STD_LOGIC_VECTOR(17 DOWNTO 0) 	
    
);
END HALL_INTERFACE;
`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
dfJFfnsWGGijhEITEPc+uiz5SnXNYvAIQsLqOX7ox86Ir6SKrtW1G1kt0sctYLCl5FRjKhOM4qoW
jFR13RrGdeeIuI2wUnzrHp1UVuXmCcZ96sAsJMTUXHABvNUHhxxeJ0YVqTGImTakuO2Qe1pD5Zbp
h8g2ifzjo5uWMOYPwCdtzWn7QV/8BPV3sgK2wfrivgHiJp2BxVQO66TPfp6gVQ7oM4HnKI6ItBiS
oNTd1N8szrA7KLzYhQzagyjCPzk3wCOmTGy3fjZUKgN1xlTkLslNrsBRWwATh40ud5VMIeY5CejB
FTYcTtaE6hTT1ZYf9c/prDYGT1P8cZDoNwS7zw==

`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
TxhJeIKJ7AdVv0he8lIKTk7FvB5i+0+JpVjZjoh9fzccwo0fjhzw+WVyWiNzPMHyH+exKVWco956
OurVu+D+3LaWXr36BRZxIDtWkJhyA722Fu7KxX5KVYB7IQJUC/Pf8qTt+FfDsl4wvblTzS4APz7N
4UfANuSnOCFRwnuIcFM=

`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
DuoNXmJF3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npPf2e6M6qgqJAJujU18v55SxJpJNsk/1y286+E7Ys5dspCCOOzku3Q7ionzg7AZl
IWR+oYKzHdwNNlKDwd9LzTlAib1hQGmMRnnLt6jdZ5asIB/R71oj/3yjxWrCUBaFXtdBJ7vIKXUs
wDutF5b+5AlXdj32Z3jkxP/RVJNKd+Fx2Zml4tF4+iKWbHeU4xooEyAWz7ARHmwV

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

`protect end_protected

