diff --git a/+adi/+AD9081/+utils/findBestBitArrangement.m b/+adi/+AD9081/+utils/findBestBitArrangement.m index 3607946c..637c2b86 100644 --- a/+adi/+AD9081/+utils/findBestBitArrangement.m +++ b/+adi/+AD9081/+utils/findBestBitArrangement.m @@ -30,27 +30,24 @@ end end -error = zeros(size(PossibleCasts,1),1); +taps_fi = zeros(size(PossibleCasts,1), numel(taps)); +error = zeros(size(PossibleCasts,1),numel(taps)); for leading12s = 1:size(PossibleCasts,1) for group = 1:length(tapGroups) config = PossibleCasts(leading12s,group); tg = tapGroups{group}; - diff = abs( double(fi(tg,1,config,0)) - double(tg)); - error(leading12s) = error(leading12s) + sum(diff); + taps_fi(leading12s, 4*(group-1)+(1:4)) = fi(tg,1,config,0); end + error(leading12s, :) = abs(double(taps_fi(leading12s, :)) - taps); end -[tapError,bestCast] = min(error); +[~,bestCast] = min(sum(error, 2)); % plot(sort(error)); mode = PossibleCasts(bestCast,:); %% Apply new types to taps -quantizedTaps = length(taps); -for group = 1:length(tapGroups) - config = PossibleCasts(bestCast,group); - tg = tapGroups{group}; - quantizedTaps( (group-1)*4+1 : group*4) = int16((fi(tg,1,config,0))); -end +quantizedTaps = taps_fi(bestCast, :); +tapError = error(bestCast, :); end \ No newline at end of file diff --git a/hsx_examples/mxfe_sim/ExampleAD9081RxPFilter.m b/hsx_examples/mxfe_sim/ExampleAD9081RxPFilter.m index 9f51b9de..04243550 100644 --- a/hsx_examples/mxfe_sim/ExampleAD9081RxPFilter.m +++ b/hsx_examples/mxfe_sim/ExampleAD9081RxPFilter.m @@ -15,7 +15,7 @@ taps = [taps, zeros(1,N-length(taps))]; % Find best tap quantization for given filter -[config,tapsInt16,qt] = adi.AD9081.utils.DesignPFilt(taps,mode,N); +[config,tapsInt16,qt,tapError] = adi.AD9081.utils.DesignPFilt(taps,mode,N); %% Plots close all; figure(1); @@ -40,7 +40,7 @@ grid on; subplot(3,1,3); -stem(abs(tapsInt16-qt)); +stem(tapError); xlabel('Tap index'); ylabel('Tap magnitude Error'); grid on;