Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions +adi/+AD9081/+utils/findBestBitArrangement.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions hsx_examples/mxfe_sim/ExampleAD9081RxPFilter.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down