%% Fixed-Point Multiplication
%
% This example shows how to use flow charts in a Stateflow(R) block to calculate the product of
% two fixed-point numbers.  
%
% The chart below defines two output variables, $out1$ and $out2$.  Both of these variables are of type fixdt. 
%
% $out1$ is defined as $fixdt(0,8,2)$
%
% $out2$ is defined as $fixdt(0,8,4)$  
%
% The first parameter, Signed, defines whether or not the variable can be signed as positive or negative.  Because Signed has a value of zero for both variables, 
% they are unsigned, and cannot be negative. The second parameter, which has a value of eight for both variables, is the WordLength.
% The WordLength defines how much space will be allocated for the entire number.
% The third parameter is the FractionLength, $out1$ has a value of $2$ bits for this parameter, and $out2$ has a value of $4$ bits. 
% Because $2^2 = 4$, this means that $out1$ can store one of the following fractions as the fractional part:
%
% $$ 0, 1/4, 2/4, 3/4 $$ 
%
% Because $2^4 = 16$, $out2$ can store one of the following fractions as the fractional part:
%
% $$ 0, 1/16 ... 15/16 $$
%
% $out2$'s larger FractionLength allows it greater precision.  The result of $5.75 * 2.375$ is exactly $13.65625$.  Because this is too
% precise for either output, Stateflow(R) truncates the results to $13.5$ for $out1$, and $13.625$ for $out2$.
%
% Please see the <https://www.mathworks.com/help/simulink/slref/fixdt.html fixdt documentation> for more information about fixdt.

% Copyright 2007 The MathWorks, Inc.

mdl = 'sf_fxptprecision';
open_system(mdl);
evalc('sim(mdl)');
