The following table shows fixed point instrumentation results
function OutputA = DSP_fixpt(InputA) %#codegen fm = get_fimath(); persistent out0; %Retains variable value between function calls. if isempty(out0) %Initialize the value for the first call. out0 = fi(0, 0, 15, 0, fm); end upperThreshold = fi(floor(2^15/10), 0, 12, 0, fm); %Set the upper threshold to 1/10 of the full positive range. lowerThreshold = fi(-floor(2^15/10), 1, 13, 0, fm); %Set the lower threshold to 1/10 of the full negative range. if InputA >upperThreshold %Logic to perform the Schmitt trigger function. out0(:) = 2^15-1; elseif InputA <lowerThreshold out0(:) = 0; end OutputA = fi(out0, 1, 16, 0, fm); %Assign variable out0 to the output. end
Variable Name | Type | Sim Min | Sim Max |
---|---|---|---|
InputA | numerictype(1, 16, 0) | -7170 | 7432 |
OutputA | numerictype(1, 16, 0) | 0 | 32767 |
lowerThreshold | numerictype(1, 13, 0) | -3276 | -3276 |
out0 | numerictype(0, 15, 0) | 0 | 32767 |
upperThreshold | numerictype(0, 12, 0) | 3276 | 3276 |