%% File : sfun_bitop.tlc generated from sfun_bitop.ttlc revsion 1.3 %% $Date: 2000/03/02 22:39:22 $ %% %% Rob Aberg %% December 22, 1998 %% Copyright 1990-2000 The MathWorks, Inc. %% %% Description: %% Bitwise Logical Operator block target file %% Note that code generation for all built-in data types %% even though Simulink currently only supports double and boolean types %% for the Logic block. %% %implements sfun_bitop "C" %% Function: Outputs ========================================================== %% %% Purpose: %% Implement code generation for bitwise logic operations. %% %% Syntax: %% MEX mdlOutputs standard function %% %% Arguments: %% S-function standard arguments, plus operator, operand(s) and comment %% %% Returns: %% Result of bitwise operation on input and paramter(s) with the %% same data type as the input. %% %% Description: %% Performs the specified bitwise operation on the inputs. %% %% Note: %% %% %function Outputs(block, system) Output %% %% Select Operator %switch(SFcnParamSettings.Operator) %case "AND" %assign LogicOp = "&" %break %case "OR" %assign LogicOp = "|" %break %case "XOR" %assign LogicOp = "^" %break %case "SHIFT_LEFT" %assign LogicOp = "\<\<" %break %case "SHIFT_RIGHT" %assign LogicOp = "\>\>" %break %case "NOT" %assign LogicOp = "~" %break %default %error RTW Error: Illegal operator value: "%" %endswitch %% /* Bitwise Logic Block: % */ /* [input] % % */ %% %assign inputDataType = LibBlockInputSignalDataTypeName(0, "") %assign inputDTypeId = LibBlockInputSignalDataTypeId(0) %if SFcnParamSettings.Operator != "NOT" %% --- u P case: 1:N, N:1 and N:N cases for inputs:params %% %if SIZE(SFcnParamSettings.Operand,1) == 1 %% Second Operand is scalar, we can generate rolled code %assign opd = SFcnParamSettings.Operand[0] %assign opds = SFcnParamSettings.OperandString[0] %assign inplace = LibBlockInputSignalBufferDstPort(0) == 0 ... && SFcnParamSettings.Operator != "SHIFT_LEFT" ... && SFcnParamSettings.Operator != "SHIFT_RIGHT" %if inplace %assign rollVars = ["Y"] %else %assign rollVars = ["U", "Y"] %endif %roll idx = RollRegions, lcv = RollThreshold, block, "Roller", rollVars %assign u = LibBlockInputSignal(0, "", lcv, idx) %assign y = LibBlockOutputSignal(0, "", lcv, idx) %if SFcnParamSettings.Operator == "SHIFT_LEFT" ... || SFcnParamSettings.Operator == "SHIFT_RIGHT" % = % % %; %else %if LibBlockInputSignalBufferDstPort(0) == 0 % %= 0x%; %else % = % % 0x%; %endif %endif %endroll %else %foreach idx = LibBlockOutputSignalWidth(0) %assign opd = SFcnParamSettings.Operand[idx] %assign opds = SFcnParamSettings.OperandString[idx] %assign u = LibBlockInputSignal(0, "", "", idx) %assign y = LibBlockOutputSignal(0, "", "", idx) %if SFcnParamSettings.Operator == "SHIFT_LEFT" ... || SFcnParamSettings.Operator == "SHIFT_RIGHT" % = % % %; %else %if LibBlockInputSignalBufferDstPort(0) == 0 % %= 0x%; %else % = % % 0x%; %endif %endif %endforeach %endif %% %else %% --- unary case for NOT %assign rollVars = ["U", "Y"] %roll idx = RollRegions, lcv = RollThreshold, block, "Roller", rollVars %assign u = LibBlockInputSignal(0, "", lcv, idx) %assign y = LibBlockOutputSignal(0, "", lcv, idx) % = %(%); %endroll %endif %endfunction %% [EOF] sfun_bitop.ttlc