⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cast_c54x.m

📁 这是一个关于MATLAB的函数
💻 M
字号:
function dummy = cast_C54x(rr,datatype)
% Private. Casting for C54x register symbols.
% Copyright 2002 The MathWorks, Inc.
%   $Revision: 1.5 $  $Date: 2002/05/13 18:31:55 $

if (rr.bitsperstorageunit ~=16)
    error('A register unit must contain 16 bits for C54x register objects');
end

% Initialize (pre/post)pad
rr.prepad  = 0;  % Modified later, if necessary
rr.postpad = 0;

switch datatype
case {'double','long double'},
    % totalbits = 32;
    % rr.storageunitspervalue = round(totalbits/rr.bitsperstorageunit);
    rr.storageunitspervalue = 2;
    rr.represent = 'float';
    
case {'single','float'}
	% totalbits = 32;        
	% rr.storageunitspervalue = round(totalbits/rr.bitsperstorageunit);
    rr.storageunitspervalue = 2;
    rr.represent = 'float';
    
case {'long','signed long'}
    totalbits  = 32;        
    rr.postpad = 0;
    rr.storageunitspervalue = round(totalbits/rr.bitsperstorageunit);
    rr.represent = 'signed';
    
case {'int','signed int'}
    totalbits  = 16;        
    rr.storageunitspervalue = round(totalbits/rr.bitsperstorageunit);
    rr.represent = 'signed';
    
case {'short','signed int'}
    totalbits  = 16;
    rr.postpad = 0;
    rr.storageunitspervalue = round(totalbits/rr.bitsperstorageunit);
    rr.represent = 'signed';

case 'signed char'
    totalbits  = 16;        
    rr.storageunitspervalue = round(totalbits/rr.bitsperstorageunit);
    rr.represent = 'signed';
    
case 'unsigned long',
    totalbits  = 32;
    rr.storageunitspervalue = round(totalbits/rr.bitsperstorageunit);
    rr.represent = 'unsigned';
    
case 'unsigned int'
    totalbits  = 16;
    rr.storageunitspervalue = round(totalbits/rr.bitsperstorageunit);
    rr.represent = 'unsigned';
    
case 'unsigned short'
    totalbits  = 16;
    rr.storageunitspervalue = round(totalbits/rr.bitsperstorageunit);
    rr.represent = 'unsigned';
    
case {'char','unsigned char'}
    totalbits  = 16;        
    rr.storageunitspervalue = round(totalbits/rr.bitsperstorageunit);
    rr.represent = 'unsigned';
    
case 'int64'
    error('INT64 type not supported');
    
case 'uint64'
    error('UINT64 type not supported');
    
case 'int32'
    rr.storageunitspervalue = round(32/rr.bitsperstorageunit);
    rr.represent = 'signed';
    
case 'uint32'
    rr.storageunitspervalue = round(32/rr.bitsperstorageunit);
    rr.represent = 'unsigned';
    
case 'int16'
    totalbits  = 16;
    rr.storageunitspervalue = round(totalbits/rr.bitsperstorageunit);
    rr.represent = 'signed';
    
case 'uint16'
    totalbits  = 16;
    rr.storageunitspervalue = round(totalbits/rr.bitsperstorageunit);
    rr.represent = 'unsigned';
    
case 'int8'
    totalbits  = 16;
    rr.postpad = 8;
    rr.storageunitspervalue = round(totalbits/rr.bitsperstorageunit);
    rr.represent = 'signed';
    
case 'uint8'
    totalbits  = 16;
    rr.postpad = 8;
    rr.storageunitspervalue = round(totalbits/rr.bitsperstorageunit);
    rr.represent = 'unsigned';

%==========================================================================
% Special TI types
case 'Q0.15',
    %rr.storageunitspervalue = round(16/rr.bitsperstorageunit);
    rr.storageunitspervalue = 1;
    rr.postpad = 0;
    rr.represent = 'fract';
    rr.binarypt = 15; % future expansion? 
    
case 'Q0.31',
    %rr.storageunitspervalue = round(32/rr.bitsperstorageunit);
    rr.storageunitspervalue = 2;
    rr.represent = 'fract';
    rr.binarypt  = 31; % future expansion?
    
otherwise,
    error(['DATATYPE:' datatype ' is not recognized']);
end

% [EOF] cast_C54x.m

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -