--=================================================================================================
-- File Name                           : bldc_estimator.vhd

-- Description                         : This module integrates the following modules:
--                                       1. bldc_model
--                                       2. pll_theta_be
--                                       3. filter_be
--                                       4. pi_controller
--                                       5. MAS

-- 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_ARITH.ALL;
USE IEEE.STD_LOGIC_SIGNED.ALL;

--=================================================================================================
-- bldc_estimator entity declaration
--=================================================================================================
ENTITY BLDC_ESTIMATOR IS
GENERIC(
-- Generic list

    -- Specifies the number of multi-cycle path delays introduced
    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 flux estimator operation
    start_i                            : IN  STD_LOGIC;
	
	-- Clears all the buffers
	clear_buffer_i                     : IN  STD_LOGIC;

    -- Control input specifies the enable signal for PI controller
    angle_pi_en_i                      : IN  STD_LOGIC;

    -- Data input specifies the alpha axis voltage input for angle estimation
    v_alpha_i                          : IN  STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Data input specifies the beta axis voltage input for angle estimation
    v_beta_i                           : IN  STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Data input specifies the i_alpha value from Clarke module
    i_alpha_i                          : IN  STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Data input specifies the i_beta value from Clarke module
    i_beta_i                           : IN  STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Control input specifies the first estimator constant
    Ls_by_Ts_pu_i                      : IN  STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Control input specifies the second estimator constant
    Rs_pu_i                            : IN  STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Control input specifies the ealpha filter time constant input as an exponent of 2.
    ealpha_filter_factor_i             : IN  STD_LOGIC_VECTOR(3 DOWNTO 0);

    -- Control input specifies the ebeta filter time constant input as an exponent of 2.
    ebeta_filter_factor_i              : IN  STD_LOGIC_VECTOR(3 DOWNTO 0);

    -- Control input specifies the theta factor value for pll_theta computation
    pll_theta_factor_i                 : IN  STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Control input specifies the proportional constant for angle PI
    angle_pi_ki_i                      : IN  STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Control input specifies the integral constant for angle PI
    angle_pi_kp_i                      : IN  STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Control input specifies the omega filter time constant input as an exponent of 2.
    omega_filter_factor_i              : IN  STD_LOGIC_VECTOR(3 DOWNTO 0);

    -- Control output specifies the completion of omega computation
    done_o                             : OUT STD_LOGIC;

    -- Control output specifies the estimated theta output from PLL
    theta_o                            : OUT STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Control output specifies the ealpha filter output.
    ealpha_o                           : OUT STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Control output specifies the ealpha filter output.
    ebeta_o                            : OUT STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Control output specifies the ealpha filter output.
    ealpha_filtered_o                  : OUT STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Control output specifies the ebeta filter output
    ebeta_filtered_o                   : OUT STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Control output specifies the speed output from PLL
    pll_pi_out_o                       : OUT STD_LOGIC_VECTOR(17 DOWNTO 0);

    -- Control output specifies the speed filter output
    speed_filtered_o                   : OUT STD_LOGIC_VECTOR(17 DOWNTO 0)

);
END bldc_estimator;

--=================================================================================================
-- bldc_estimator architecture body
--=================================================================================================

ARCHITECTURE bldc_estimator OF bldc_estimator 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
nurpH43f100+FFXtQbOvcZX7gfKx7lckaAx7T7E38rjg8Q/OawQwYiOpNw4qtjxRnYXn7Xo8XVUq
Jg8a7ffK8fgWbsiOn0fN+gSG4R9o336tXJBJV3EPh/1dKQ87gJhUMcypGRUYqVHtTi0/Ef3nreFP
DPnAx6ObYV4GkS2ZfWs2nZ2URzo5J+pLB5zkoRzd5yP/UcKjkn28CjJUwkl+ORzbMx4IPa3GKu3Q
5J1CWGp7CQz02EXCP2IQoGEa4HhxP8mvVhwMok07PAxm5dYrFbwpWbQQ2qIcTFn5n4SKIGhb2Im7
kmKS11V5bEakj0P1kFXjvT5lUYINEV86TC/H5A==

`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
B7R2Y9gA/N0/BTosSDtvapEQKSQOJhwzPjKKCFHNW5bYarYFkNjg9SSCeskt5g5rr/ovxX4etlhs
MxsmNzRXAUSlZulUJJVDePFz95ejWCoOuRXFA5QC8I8OqBcW/30FGLhGZywrUTalLCxd+yrrw9+o
mtWdTRRSP9zhERa4zuc=

`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
iXYl568nNV1ayfwPzENMyOCb0cZBDTBGWxe9j6Q++J10hZ7JR9RJ2G6eDpN2gt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v4IalzvMAVTUL
joqQxHY6XyfPmfU8BtlQt5k2GSkK02v2WSIGazrSO1RXLjcfQJkvvVRRzeoLwjHGmeruMH78OBGz
STTz6LMSnpkSDMcKGIP5vZ8Fg+bHmvLDez6oj1HS7nAKe0zmhuw2YI5CkXKdI7fH

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

`protect end_protected

