--=================================================================================================
-- File Name                           : pi_controller.vhd

-- Description                         : This module implements a PI controller.

-- Targeted device                     : Microsemi-SoC
-- Author                              : India Solutions Team
--
-- SVN Revision Information            :
-- SVN $Revision                       :
-- SVN $Date                           :
--
-- COPYRIGHT 2015 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;


--=================================================================================================
-- pi_controller entity declaration
--=================================================================================================
ENTITY PI_CONTROLLER IS
GENERIC(
-- Generic List
    
    -- Specifies the de-scaling kp value
    g_KP_Factor                        : INTEGER := 10;
    
    -- Specifies the de-scaling ki value
    g_KI_Factor                        : INTEGER := 16;
    
    -- 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 pi controller operation
    start_i                            : IN STD_LOGIC;
    
    -- Control input specifies whether the pi controller has to be initialized 
    pi_en_i                            : IN STD_LOGIC;
	
	-- Resets the accumulator of PI
    clear_buffer_i                     : IN STD_LOGIC;
    
    -- Data input specifies the reference input of pi controller
    ref_input_i                        : IN STD_LOGIC_VECTOR(17 DOWNTO 0);
    
    -- Data input specifies the actual input of pi controller
    act_input_i                        : IN STD_LOGIC_VECTOR(17 DOWNTO 0);
    
    -- Control input specifies the kp value
    kp_i                               : IN STD_LOGIC_VECTOR(17 DOWNTO 0);
    
    -- Control input specifies the ki value
    ki_i                               : IN STD_LOGIC_VECTOR(17 DOWNTO 0);
    
    -- Control input specifies the maximum limit for the pi controller output
    ymax_i                             : IN STD_LOGIC_VECTOR(17 DOWNTO 0);
    
    -- Control input specifies the minimum limit for the pi controller output
    ymin_i                             : IN STD_LOGIC_VECTOR(17 DOWNTO 0);
    
    -- Control input specifies the initialization value when pi_en_i is '1'
    init_i                             : IN STD_LOGIC_VECTOR(17 DOWNTO 0);
    
    -- Control output specifies that the pi_controller has finished its operation    
    done_o                             : OUT STD_LOGIC;
    
    -- Data output specifies the pi controller output valua
    output_y_o                         : OUT STD_LOGIC_VECTOR(17 DOWNTO 0)
);
END pi_controller;
`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
HUYqaR2+Hwo68SDijsgEmG7tfpEC9+fr6A46ZEpf//5I7XWJu3mjyoNdnOh0wk3nOuqhs6A8AOhj
l7hLUzHO5GKYpmB+RMu+ZFTuCq/4YgD8qEV+XjDKRJ2IL3XWirnKRUoOdoZHMuYWJLEsxlTmCoXt
TAHOMD+D2K9YOzkUmCpNQvULmhzuc2mt2o8ef/BID4s9XMCSEqXWesncs+/UGCcRQeQJByogZ/dr
sROi29OW2WwPOakYF3gsreUpLvRoCJoVoxoPsKH1Kwrrp7ao+5KbgF727R0JcWqX2RiMouGrlyvb
+/1+VnFgl0eImRN+iHGzvB0CHzDxSH9K/+9ing==

`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
VD3keUtCbKi4B/fGOap172THnGRtsFmAtXYUzoBDxuWemJdHSxje2Iynekt0Brm2s7rzhDgHI1yc
l/yAxkTWn/vJR8eFnyhlmROsCl6x3frI0qzFUye+YO0CnA7q2nctk1TZLY0tFib0Y5hJzyPuUpai
rYZcU9ynjN4R3Dm4IBM=

`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
B7/+s3NKRt9rF2sJG1mLfP+dTztr7jRYPVqqN60zuUN4XkrTsG4kixmLIGGveZ4CVTLVZWTPPia6
eKbyk7n+OppzUbTU03V/ckGt94QrdF1L9GuJd6G7MVOhg70CGwrlkqFaDA03g8716pc5rdr9xMQU
Ru/Jy23MHcQ8tlF9Keg2O/pOKOh5Oxk7M4oJSfU/PfsOwxRk2Xu7Av/fkQtGr09LkEiwcTaFnGoY
HcQEMeI1K0UxBvO4uCAtbd+oNlMBcz1t9/7tdFo/RVr4fp9WFItb6cxFG6KJl3tP3r7T1kfwhpKn
+49bGekE4DDVzQnXJstpaH5StbJim9gUOLYw9kFtcQNOrveplueLbotYAE+gmSpJsyY1J8X8T3g7
jdvc4erZqlAiDRTVZYYlfF5OPR2OgKpwsjd2yJLI7GaIQVovtmV824uSugFH19xMQmRjPLSznHOb
/uEBGEXoK81CO/Ggj2SL5Kje1ow3Uy0Roa43EweNWa3TfgLfvclHJTqj4V5Uq0gsRn3qjz29hFle
T7a/6c3jZ3dNw3OGJvBTQCkdBvHBfi6yfrjV0m1hb1X2W25sk0ryw3e6K0jeD+hA1JIgkrwjFgbf
0sI986d4oZNuZ/ASRsDrtRym8Czkv4HxhjriTtsMXjgbxOLLhluwUSx4HTGYLzzMDTEXLnNRbBI1
/zpVBxt0InsJbk5lXocO/OdYDPctNE7btMDBsgwxXXU58Kn6uIfMBJNkQMizP5nQAC8cVPmC5BBG
9R/w945YIDi4sYdjFAN9G3U5hjBV/nKuP7xPbhMyS61vgmQKA4nNV3W2tDd/7jFhOdpEODuGDeNu
fzjnsDF+iPfa2yj4VqFw6/X71PdJY6FLBPsG4HO2Q/Euo47LjM0JOcop6gqrK7NHnsmvbGQSczlf
z0HJiZLF+bD7a14+5BFXc5zSl05EszEG7XNcDIHK8BtA8rz7UoGSSu8+0cBDp7oFBaYP8BcAcZLP
m/8orGqUwdCWHS1g10NC9IGuN24AEw6x3NbGmf8u4+sUH4Y697JpwU4G2V3PcBZKsfSsw5EjpqFT
6tbfji5NhbmWO6jeNvNrLaAaZVkypubGsdaX74ZWA3LiEjpbvn0arV8Kzzz/3EpLjK5J/9S/fvJ3
mR9/FQzOq5adviFtuZVoD374QYsDa1odshFzRLPuWzkJn5DdIousjYGN12eQfiRRr14pluy11XEe
sXek/BkdY1OAfDNyygJwDxcw26Tqw1oqueInYdBzR83guq6/eIASUyGt/us0GquC

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

`protect end_protected

