fiaccel
Accelerate fixed-point code and convert floating-point MATLAB code to fixed-point MATLAB code
Syntax
fiaccel -
options
fcn
fiaccel -float2fixed fcn
Description
fiaccel -
translates
the MATLAB® file options
fcn
fcn
.m
to
a MEX function, which accelerates fixed-point code. To use fiaccel
,
your code must meet one of these requirements:
The top-level function has no inputs or outputs, and the code uses
fi
The top-level function has an output or a non-constant input, and at least one output or input is a
fi
.The top-level function has at least one input or output containing a built-in integer class (
int8
,uint8
,int16
,uint16
,int32
,uint32
,int64
, oruint64
), and the code usesfi
.
Note
If your top-level file is on a path that contains Unicode characters, code generation might not be able to find the file.
fiaccel -float2fixed
converts
the floating-point MATLAB function, fcn
fcn
to
fixed-point MATLAB code.
Input Arguments
|
MATLAB function from which to generate a MEX function. |
|
Choice of compiler options.
|
Examples
Create a test file and compute the moving average. Then, use fiaccel
to
accelerate the code and compare.
function avg = test_moving_average(x) %#codegen if nargin < 1, x = fi(rand(100,1),1,16,15); end z = fi(zeros(10,1),1,16,15); avg = x; for k = 1:length(x) [avg(k),z] = moving_average(x(k),z); end function [avg,z] = moving_average(x,z) %#codegen if nargin < 2, z = fi(zeros(10,1),1,16,15); end z(2:end) = z(1:end-1); % Update buffer z(1) = x; % Add new value avg = mean(z); % Compute moving average % Use fiaccel to create a MEX function and % accelerate the code x = fi(rand(100,1),1,16,15); fiaccel test_moving_average -args {x} -report % Compare the non-accelerated and accelerated code. x = fi(rand(100,1),1,16,15); % Non-compiled version tic,avg = test_moving_average(x);toc % Compiled version tic,avg = test_moving_average_mex(x);toc
Convert Floating-Point MATLAB Code to Fixed Point
Create a coder.FixptConfig
object, fixptcfg
,
with default settings.
fixptcfg = coder.config('fixpt');
Set the test bench name. In this example, the test bench
function name is dti_test
.
fixptcfg.TestBenchName = 'dti_test';
Convert a floating-point MATLAB function to fixed-point MATLAB code.
In this example, the MATLAB function name is dti
.
fiaccel -float2fixed fixptcfg dti