function sin_out = hdlcordicsin(theta, niters)
% CORDICSIN(theta, niters) Compute the CORDIC-based approximation to SIN(theta).

% Copyright 2009-2015 The MathWorks, Inc.
%#codegen
coder.extrinsic('hdlfeature');
coder.allowpcode('plain');
eml_prefer_const(theta);
eml_prefer_const(niters);
assert( coder.target('hdl') )

flag = coder.nullcopy( false(1,1)  );
flag = coder.internal.const( true(1,1) );

if ( flag )
    if (nargin == 1)
        % niters = -1 % to indicate unspecified for SysObj
        [~, createErr, newObj] = eml_const(feval('eml_try_catch', ...
            'hdl.internal.PIRHDLFunctionObject', ...
            'FunctionName', 'sin', 'Prop2', -1));
        sin_out = cordicsincos(theta);
        sin_out = eml_sea_method_call('step_hdl', newObj, 1, theta, sin_out);
        eml_assert(isempty(createErr), createErr);
    else        
        [~, createErr, newObj] = eml_const(feval('eml_try_catch', ...
            'hdl.internal.PIRHDLFunctionObject', ...
            'FunctionName', 'sin', 'Prop2', niters));
        sin_out = cordicsincos(theta, niters);
        sin_out = eml_sea_method_call('step_hdl', newObj, 1, theta, sin_out);
        eml_assert(isempty(createErr), createErr);
    end
else
    if (nargin == 1)
        sin_out = cordicsincos(theta);
    else
        sin_out = cordicsincos(theta, niters);
    end
end
