forked from analogdevicesinc/ad936x-filter-wizard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update auto filter generation to passband ripple minimize base on sam…
…ple rate (analogdevicesinc#37) * Add enhanced command line function to try all FIR configuration to meet design spec. Some testing was added for this functionality * Fix analog filter bandwidth auto-generation to use hardware values not full precision. * Add specific tests for LTE filters * Add gitlab ci config Signed-off-by: Travis Collins <[email protected]>
- Loading branch information
Showing
15 changed files
with
166 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
stages: | ||
- test | ||
- test_hardware | ||
- deploy | ||
|
||
# Linux test | ||
test:linux: | ||
tags: | ||
- linux | ||
- matlab | ||
stage: test | ||
script: | ||
- /usr/local/MATLAB/R2018b/bin/matlab -nodisplay -nodesktop -nosplash -r "addpath(genpath('test'));runTests;" | ||
artifacts: | ||
paths: | ||
- test/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
function output = internal_design_filter_opt_ripple(input) | ||
|
||
% support a simple data rate input otherwise it must be a structure | ||
if isfloat(input) | ||
input = struct('Rdata', input); | ||
else | ||
error('Input must be the required samplerate only'); | ||
end | ||
|
||
input = cook_input(input); | ||
|
||
% use the internal FIR if unspecified | ||
if ~isfield(input, 'int_FIR') | ||
input.int_FIR = 1; | ||
end | ||
|
||
% nominal frequency can't be zero | ||
if ~input.wnom | ||
input.wnom = calculate_rfbw(input.PLL_rate, input.caldiv, input.RxTx, true); | ||
input.wnom = double(input.wnom); | ||
end | ||
|
||
FIR = [1,2,4]; | ||
outs = []; | ||
ripples = []; | ||
for i = 1:3 | ||
% Recalc clocks | ||
[input0, configIndx] = auto_fast_rates(input,FIR(i)); | ||
if configIndx == 0 | ||
continue; | ||
end | ||
% Update position of wnom since PLL can change | ||
if strcmp(input.RxTx, 'Rx') | ||
input0.wnom = 1.4 * input0.Fstop; % Rx | ||
else | ||
input0.wnom = 1.6 * input0.Fstop; % Tx | ||
end | ||
div = ceil((input0.PLL_rate/input0.wnom)*(log(2)/(2*pi))); | ||
input0.caldiv = min(max(div,1),511); | ||
input0.wnom = double(calculate_rfbw(input0.PLL_rate, input0.caldiv,... | ||
input0.RxTx, true)); | ||
% Design filter | ||
out = internal_design_filter(input0); | ||
outs = [outs; out]; %#ok<AGROW> | ||
ripples = [ripples;out.Apass_actual]; %#ok<AGROW> | ||
end | ||
|
||
if isempty(ripples) | ||
error('No valid design found'); | ||
end | ||
|
||
[~,i] = min(ripples); | ||
output = outs(i); | ||
|
||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
classdef FilterWizardTests < matlab.unittest.TestCase | ||
|
||
properties | ||
SampleRates = [0.52083333,0.6:0.1:61.44].*1e6; | ||
LTEModes = {'LTE5','LTE10','LTE15','LTE20'}; | ||
MaxRippleDB = 1; | ||
end | ||
|
||
methods(TestClassSetup) | ||
end | ||
|
||
methods (Static) | ||
end | ||
|
||
methods (Test) | ||
|
||
function testAutoGenerationRipple(testCase) | ||
import matlab.unittest.constraints.IsLessThanOrEqualTo | ||
sr = testCase.SampleRates; | ||
limit = testCase.MaxRippleDB; | ||
% Test ripple of generated filters | ||
parfor r = 1:length(sr) | ||
out = internal_design_filter_opt_ripple(sr(r)); | ||
verifyThat(testCase, out.Apass_actual, IsLessThanOrEqualTo(limit), ... | ||
sprintf('Generated filter for rate %d with ripple %f (Limit %f)',... | ||
sr(r),out.Apass_actual,limit)) | ||
end | ||
end | ||
|
||
function testLTEFilterGeneration(testCase) | ||
import matlab.unittest.constraints.IsEqualTo | ||
% Verify LTE filters are created correctly | ||
for m = testCase.LTEModes | ||
i = load([m{:},'_input.mat']); | ||
o = load([m{:},'_output.mat']); | ||
output = internal_design_filter(i.input); | ||
testCase.verifyThat(output,IsEqualTo(o.output)); | ||
end | ||
end | ||
|
||
end | ||
end |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import matlab.unittest.TestRunner; | ||
import matlab.unittest.TestSuite; | ||
import matlab.unittest.plugins.TestReportPlugin; | ||
import matlab.unittest.plugins.XMLPlugin | ||
import matlab.unittest.plugins.ToUniqueFile; | ||
import matlab.unittest.plugins.TAPPlugin; | ||
import matlab.unittest.plugins.DiagnosticsValidationPlugin | ||
|
||
try | ||
suite = testsuite({'FilterWizardTests'}); | ||
runner = matlab.unittest.TestRunner.withTextOutput('OutputDetail',1); | ||
runner.addPlugin(DiagnosticsValidationPlugin) | ||
|
||
xmlFile = 'FilterWizardTestResults.xml'; | ||
plugin = XMLPlugin.producingJUnitFormat(xmlFile); | ||
runner.addPlugin(plugin); | ||
|
||
|
||
results = runner.run(suite); | ||
|
||
t = table(results); | ||
disp(t); | ||
disp(repmat('#',1,80)); | ||
for test = results | ||
if test.Failed | ||
disp(test.Name); | ||
end | ||
end | ||
catch e | ||
disp(getReport(e,'extended')); | ||
bdclose('all'); | ||
exit(1); | ||
end | ||
|
||
save(['FilterWizardTests_',datestr(now,'dd_mm_yyyy-HH:MM:SS'),'.mat'],'t'); | ||
bdclose('all'); | ||
exit(any([results.Failed])); |