%% $RCSfile: sfun_user_fxp_asr.tlc,v $
%% $Revision: 1.1.6.1 $
%% $Date: 2003/03/05 07:08:08 $

%% Copyright 1994-2003 The MathWorks, Inc.
%%
%% Abstract:
%%     User SFunction Fixed-point Shift Right

%implements sfun_user_fxp_asr "C"

%include "fix_published.tlc"

%function BlockInstanceSetup(block, system) void
  %%
%endfunction


%function Outputs(block, system) Output
  %%
  %%  Put comment into the generated C code
  %%
  /* User Sfunction fixed-point ASR */
  %%
  %assign labelForInput  = LibBlockInputSignal( 0,     "", "", 0 )
  %assign labelForOutput = LibBlockOutputSignal(0,     "", "", 0 )
  %%
  %assign dataTypeIdY0 = LibBlockOutputSignalDataTypeId(0)
  %assign dataTypeIdU0 = LibBlockInputSignalDataTypeId(0)
  %%
  %assign fractionLengthY0 = FixPt_DataTypeFractionLength( block, dataTypeIdY0 )
  %assign fractionLengthU0 = FixPt_DataTypeFractionLength( block, dataTypeIdU0 )
  %%
  %assign numBitsShiftRight = fractionLengthU0 - fractionLengthY0
  %%
  %% put the assignment into the generated C code, there is no need to
  %% worry about the data types that are used.  The storage container 
  %% data type for the input and the output are the same integer type.
  %% The variables have already been declared elsewhere by Real Time Workshop.
  %% The compiler will apply use the usual C promotion rules to select
  %% the proper data type for the shift operation.  The compiler will
  %% also cast back down to the output data type if needed.
  %%     In this case, the same line of TLC code works for all possible
  %% data types.
  %%
  %% However, there is one key assumption here.  It is assumed that
  %% shift right for signed numbers is arithmetic.  The C standard does
  %% not require shift right on signed to be arithmetic, but it does
  %% seem to be highly common.  
  %%
  %<labelForOutput> = %<labelForInput> >> %<numBitsShiftRight>;
  %%
  %% blank line for formating

%endfunction
