function hLib = Ifx_IpoMap_CRLEntry(hLib)
% Key: interp2D
% y1: Result
% u1: dpResultX->Index
% u2: dpResultX->Ratio
% u3: dpResultY->Index
% u4: dpResultY->Ratio
% u5: Val_array   
% u6: Nx
% u7: Ny    

%% Code Replacement Library Entries   
% Code replacement library entries when index and fraction are on separate
% input lines:
inputIsBus = false;
inputs = {'u1','u2','u3','u4', 'u5', 'u6', 'u7'};
hLib = Ifx_addEntries_IpoMap(hLib, inputIsBus, inputs);
% Code replacement library entries when index and fraction are on the same
% output line via a bus:
inputIsBus = true;
inputs = {'u1','dummy1','u2','dummy2', 'u3', 'u4', 'u5'};
hLib = Ifx_addEntries_IpoMap(hLib, inputIsBus, inputs);
end

function hLib = Ifx_addEntries_IpoMap(hLib, inputIsBus, inputs)
%% DataType
               % Conceptual datatype                           Implementation datatype 
int8datatype =   {'fixdt(1,8,0)',                              'int8'};
int16datatype =  {'fixdt(1,16,0)',                             'int16'};
uint8datatype =  {'fixdt(0,8,0)',                              'uint8'};
uint16datatype = {'fixdt(0,16,0)',                             'uint16'};
fuint16datatype = {'fixdt(0,16,16)',                           'uint16'};    

%% Code Replacement Library Entries  
%% Column-major routines (COLUMN_DIR)
%0x010
hLib.addEntry( Ifx_addEntry_IpoMap('Ifx_IpoMap_u8', uint8datatype, uint16datatype, fuint16datatype,  ...
    uint16datatype, fuint16datatype, uint16datatype, uint8datatype, inputIsBus, inputs, false) );
%0x011
hLib.addEntry( Ifx_addEntry_IpoMap('Ifx_IpoMap_u16', uint16datatype, uint16datatype, fuint16datatype,  ...
    uint16datatype, fuint16datatype, uint16datatype, uint16datatype, inputIsBus, inputs, false) );
%0x012
hLib.addEntry( Ifx_addEntry_IpoMap('Ifx_IpoMap_s8', int8datatype, uint16datatype, fuint16datatype,  ...
    uint16datatype, fuint16datatype, uint16datatype, int8datatype, inputIsBus, inputs, false) );
%0x013
hLib.addEntry( Ifx_addEntry_IpoMap('Ifx_IpoMap_s16', int16datatype, uint16datatype, fuint16datatype,  ...
    uint16datatype, fuint16datatype, uint16datatype, int16datatype, inputIsBus, inputs, false) );

%% Row-major routines (ROW_DIR)
hLib.addEntry( Ifx_addEntry_IpoMap('Ifx_IpoMap_u8', uint8datatype, uint16datatype, fuint16datatype,  ...
    uint16datatype, fuint16datatype, uint16datatype, uint8datatype, inputIsBus, inputs, true) );
%0x011
hLib.addEntry( Ifx_addEntry_IpoMap('Ifx_IpoMap_u16', uint16datatype, uint16datatype, fuint16datatype,  ...
    uint16datatype, fuint16datatype, uint16datatype, uint16datatype, inputIsBus, inputs, true) );
%0x012
hLib.addEntry( Ifx_addEntry_IpoMap('Ifx_IpoMap_s8', int8datatype, uint16datatype, fuint16datatype,  ...
    uint16datatype, fuint16datatype, uint16datatype, int8datatype, inputIsBus, inputs, true) );
%0x013
hLib.addEntry( Ifx_addEntry_IpoMap('Ifx_IpoMap_s16', int16datatype, uint16datatype, fuint16datatype,  ...
    uint16datatype, fuint16datatype, uint16datatype, int16datatype, inputIsBus, inputs, true) );

end

function hEnt = Ifx_addEntry_IpoMap(signature, datatype_y1, datatype_u1, datatype_u2, datatype_u3, ...
    datatype_u4, datatype_num_value, datatype_u5, inputIsBus, inputs, createRowMajorRoutine)

if ~inputIsBus
    hEnt = coder.Ifx_MapCustomEntry;
else
    hEnt = coder.Ifx_MapBusCustomEntry;
end

%% Set Function Entry Parameters
hEnt.setTflCFunctionEntryParameters( ...
          'Key', 'interp2D', ...
          'Priority', 100, ...
          'SupportSymbolicDimensions', true, ...
          'ImplementationName', signature, ...
          'ImplementationHeaderFile', 'Ifx.h');

%% Add Algorithm Properties
                   % Parameter                                  Value
algPropertyList = {{'InterpMethod',                              'Linear'},...
                   {'ExtrapMethod',                              'Clip'},...
                   {'ValidIndexMayReachLast'                     'on'},...
                   {'RemoveProtectionIndex'                      'off'},...
                   {'RndMeth',                                   {'Round', 'Zero'}}};  
               
%% Set ArrayLayout and UseRowMajorAlgorithm
[hEnt, algPropertyList] = Ifx_setMapRowMajorAttributes(hEnt, algPropertyList, createRowMajorRoutine);                 

hEnt = addAlgorithmParameters(hEnt, algPropertyList);
      
%% Add Conceptual and implementation Arguments
% Conceptual Arguments
hEnt = Ifx_addMapConceptualArguments(hEnt, datatype_y1, datatype_u1, datatype_u2, datatype_u3, ...
	datatype_u4, datatype_u5, inputIsBus, inputs);

% Implementation Arguments
hEnt = Ifx_addMapImplementationArguments(hEnt, datatype_y1, datatype_u5, datatype_num_value, ...
    inputIsBus, inputs, createRowMajorRoutine);

%% Map and cache argument locations for use in do_match tasks
hEnt.mapAndCacheLabeledArgLocations();

end
