Skip to content

Commit 2160c7b

Browse files
committed
Add updates for 2x upsample rates and HDL hw checks
Signed-off-by: tfcollins <travisfcollins@gmail.com>
1 parent e9b6c64 commit 2160c7b

6 files changed

Lines changed: 295 additions & 2 deletions

File tree

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
% clear all;
2+
%commhdlQPSKTxRxModelInit
3+
4+
uri = 'ip:10.0.0.172';
5+
chan = 1;
6+
7+
%% Tx set up
8+
tx = adi.ADRV9002.Tx('uri',uri);
9+
tx.DataSource = 'DMA';
10+
tx.EnableCyclicBuffers = true;
11+
tx.AttenuationChannel0 = -30;
12+
% tx.CenterFrequencyChannel0 = tx.CenterFrequencyChannel0 + 100e3;
13+
tx.CenterFrequencyChannel1 = tx.CenterFrequencyChannel0;
14+
tx.EnabledChannels = chan;
15+
% data = load('tx_capture.mat');
16+
% x = data.tx_capture.Data;
17+
18+
frameSize = 2240;
19+
dataBits = reshape(repmat(randsrc(frameSize*1,1,[0,1],RandStream('mcg16807','Seed',0)), 59,1), [frameSize*59,1]);
20+
enabledScramble = false;
21+
[x,refQPSKSym] = generateQPSKTxReference(dataBits, enabledScramble);
22+
23+
% x = randi(10,1024,1);
24+
x = x ./ max(abs(x));
25+
x = x.* 2^15;
26+
27+
tx(x);
28+
pause(3);
29+
30+
%% Rx set up
31+
rx = adi.ADRV9002.Rx('uri',uri);
32+
% rx.EnabledChannels = 1;
33+
rx.EnabledChannels = chan;
34+
rx.kernelBuffersCount = 1;
35+
N = 0;
36+
rx.CenterFrequencyChannel0 = tx.CenterFrequencyChannel0 + N;
37+
rx.CenterFrequencyChannel1 = tx.CenterFrequencyChannel0 + N;
38+
rx.SamplesPerFrame = 2^20;
39+
40+
%% Run
41+
for k=1:30
42+
valid = false;
43+
while ~valid
44+
[y, valid] = rx();
45+
end
46+
end
47+
tx.release();
48+
rx.release();
49+
50+
% figure(1);
51+
% plot(0:numel(y)-1, real(y), 'r', 0:numel(y)-1, imag(y), 'b');
52+
% xlim([0 250]);
53+
% xlabel('sample index');
54+
% grid on;
55+
56+
%% To timeseries
57+
% Scale
58+
plot(real(y),imag(y));
59+
yy = double(y) ./ 2^13 * 3/2;
60+
% yy = yy(1:2^19);
61+
% Convert to timeseries Simulink can understand
62+
sampleTime = 1/(Rsym*Config.SamplesPerSymbol);
63+
% sampleTime = 1/1.92e6;
64+
numSteps = length(yy);
65+
time = sampleTime*[0:(numSteps-1)];
66+
data = yy;
67+
time = time';
68+
% data = data.';
69+
inputData = timeseries(data,time);
70+
save("rx_capture_adrv9002_hdl.mat","inputData","-v7.3");
71+
72+
%%
73+
function [txWaveform,QPSKModSymbols] = generateQPSKTxReference(databits, enableScramble)
74+
% This function is a algorithmic equivalent of QPSK Tx subsystem
75+
% in commhdlQPSKTxRx.slx. This will not generate frame gaps between the
76+
% frames where as the Simulink model does.
77+
78+
Params = commhdlQPSKTxRxParameters();
79+
80+
Preamble = Params.Preamble;
81+
DataBitsPerPacket = Params.DataBitsPerPacket;
82+
RRCCoef = Params.RRCCoef;
83+
SamplesPerSymbol = Params.SamplesPerSymbol;
84+
85+
dataBitsPacketWise = reshape(databits,DataBitsPerPacket,[]);
86+
ScrambledBitsPacketWise = zeros(size(dataBitsPacketWise));
87+
if enableScramble
88+
for packetNo = 1:size(dataBitsPacketWise,2)
89+
ScrambledBitsPacketWise(:,packetNo) = scramble(dataBitsPacketWise(:,packetNo));
90+
end
91+
else
92+
packetNo = size(dataBitsPacketWise,2);
93+
ScrambledBitsPacketWise = dataBitsPacketWise;
94+
end
95+
BitsPacketWise = [repmat(Preamble,1,packetNo);ScrambledBitsPacketWise];
96+
QPSKModSymbols = QPSKModulate(BitsPacketWise(:));
97+
98+
txWaveform = zeros(length(QPSKModSymbols)*SamplesPerSymbol,1);
99+
txWaveform(1:SamplesPerSymbol:end) = QPSKModSymbols;
100+
txWaveform = filter(RRCCoef,1,txWaveform);
101+
102+
end
103+
104+
function QPSKMod = QPSKModulate(sdata)
105+
106+
sdataI = sdata(1:2:end);
107+
sdataQ = sdata(2:2:end);
108+
QPSKMod = pskmod(sdataI*2+sdataQ,4,pi/4,'gray');
109+
110+
end
111+
112+
function output = scramble(input)
113+
114+
scramblePoly = [1 0 0 1 0 0 0];
115+
init_state = [1 0 1 1 1 0 1];
116+
currentState = init_state;
117+
output = zeros(size(input));
118+
for i = 1:length(input)
119+
bit = mod(nnz(currentState(scramblePoly == 1)),2);
120+
output(i) = bitxor(input(i),bit);
121+
currentState(1) = currentState(2);
122+
currentState(2) = currentState(3);
123+
currentState(3) = currentState(4);
124+
currentState(4) = currentState(5);
125+
currentState(5) = currentState(6);
126+
currentState(6) = currentState(7);
127+
currentState(7) = bit;
128+
end
129+
130+
end
131+
132+
function [RxBits,trueOffset] = getBitsofCorrectSyncedPackets(rxOut,simTimingOffset,srtLoc,endLoc,payloadLen)
133+
134+
data = cell(length(srtLoc),1);
135+
for i = 1:length(srtLoc)
136+
if any(srtLoc(i) == endLoc-payloadLen+1)
137+
data{i} = rxOut(srtLoc(i):srtLoc(i)+payloadLen-1);
138+
end
139+
end
140+
data = data(:);
141+
trueOffset = mode(simTimingOffset);
142+
RxBits = data;
143+
144+
end
145+
5.58 KB
Binary file not shown.

trx_examples/targeting/QPSKTxRxHDLExample/commhdlQPSKTxRxModelInit.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
% disp(isequal(a,b))
1616

1717
%%
18-
dataBits = eval(get_param([gcs '/Input Data'],'dataBits'));
19-
Rsym = eval(get_param([gcs '/Input Data'],'Rsym'));
18+
dataBits = eval(get_param([gcs '/Transmitter/Input Data'],'dataBits'));
19+
Rsym = eval(get_param([gcs '/Transmitter/Input Data'],'Rsym'));
2020
validateattributes(dataBits,{'double'},{'binary','column','finite'},'','dataBits');
2121
validateattributes(Rsym,{'double'},{'finite','scalar','positive'},'','Rsym');
2222

trx_examples/targeting/QPSKTxRxHDLExample/hdlworkflow.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@
7878
hdlset_param('commhdlQPSKTxRx/Transmitter/complex', 'IOInterface', 'No Interface Specified');
7979
hdlset_param('commhdlQPSKTxRx/Transmitter/complex', 'IOInterfaceMapping', '');
8080

81+
% Set Outport HDL parameters
82+
hdlset_param('commhdlQPSKTxRx/Transmitter/msg_count_out', 'IOInterface', 'AXI4-Lite');
83+
hdlset_param('commhdlQPSKTxRx/Transmitter/msg_count_out', 'IOInterfaceMapping', 'x"104"');
8184

8285
%% Workflow Configuration Settings
8386
% Construct the Workflow Configuration Object with default settings
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
%--------------------------------------------------------------------------
2+
% HDL Workflow Script
3+
% Generated with MATLAB 25.2 (R2025b) at 14:14:25 on 20/05/2026
4+
% This script was generated using the following parameter values:
5+
% Filename : 'C:\work\datalink\TransceiverToolbox\trx_examples\targeting\QPSKTxRxHDLExample\hdlworkflow_tx2.m'
6+
% Overwrite : true
7+
% Comments : true
8+
% Headers : true
9+
% DUT : 'commhdlQPSKTxRx/Transmitter'
10+
% To view changes after modifying the workflow, run the following command:
11+
% >> hWC.export('DUT','commhdlQPSKTxRx/Transmitter');
12+
%--------------------------------------------------------------------------
13+
14+
%% Load the Model
15+
load_system('commhdlQPSKTxRx');
16+
17+
%% Restore the Model to default HDL parameters
18+
%hdlrestoreparams('commhdlQPSKTxRx/Transmitter');
19+
20+
%% Model HDL Parameters
21+
%% Set Model 'commhdlQPSKTxRx' HDL parameters
22+
hdlset_param('commhdlQPSKTxRx', 'ClockRatePipelining', 'off');
23+
hdlset_param('commhdlQPSKTxRx', 'HDLSubsystem', 'commhdlQPSKTxRx/Transmitter');
24+
hdlset_param('commhdlQPSKTxRx', 'LUTMapToRAM', 'off');
25+
hdlset_param('commhdlQPSKTxRx', 'ProjectFolder', 'hdl_prj_jupiter');
26+
hdlset_param('commhdlQPSKTxRx', 'ReferenceDesign', 'JUPITER (TX)');
27+
hdlset_param('commhdlQPSKTxRx', 'ReferenceDesignParameter', {'project','jupiter_sdr','ref_design','tx','preprocess','off','postprocess','off','number_of_inputs','4','number_of_bits','16','number_of_valids','1','multiple','1','HDLVerifierAXI','off','HDLVerifierFDC','JTAG'});
28+
hdlset_param('commhdlQPSKTxRx', 'SynthesisTool', 'Xilinx Vivado');
29+
hdlset_param('commhdlQPSKTxRx', 'SynthesisToolChipFamily', 'Zynq UltraScale+');
30+
hdlset_param('commhdlQPSKTxRx', 'SynthesisToolDeviceName', 'xczu3eg-sfva625-2-e');
31+
hdlset_param('commhdlQPSKTxRx', 'SynthesisToolPackageName', '');
32+
hdlset_param('commhdlQPSKTxRx', 'SynthesisToolSpeedValue', '');
33+
hdlset_param('commhdlQPSKTxRx', 'TargetDirectory', 'hdl_prj_jupiter\hdlsrc');
34+
hdlset_param('commhdlQPSKTxRx', 'TargetLanguage', 'Verilog');
35+
hdlset_param('commhdlQPSKTxRx', 'TargetPlatform', 'AnalogDevices JUPITER');
36+
hdlset_param('commhdlQPSKTxRx', 'Workflow', 'IP Core Generation');
37+
38+
% Set SubSystem HDL parameters
39+
hdlset_param('commhdlQPSKTxRx/Transmitter', 'ProcessorFPGASynchronization', 'Free running');
40+
41+
% Set Inport HDL parameters
42+
hdlset_param('commhdlQPSKTxRx/Transmitter/debug', 'IOInterface', 'AXI4-Lite');
43+
hdlset_param('commhdlQPSKTxRx/Transmitter/debug', 'IOInterfaceMapping', 'x"100"');
44+
45+
% Set Inport HDL parameters
46+
hdlset_param('commhdlQPSKTxRx/Transmitter/dataI', 'IOInterface', 'IP Data 0 IN [0:15]');
47+
hdlset_param('commhdlQPSKTxRx/Transmitter/dataI', 'IOInterfaceMapping', '[0:15]');
48+
49+
% Set Inport HDL parameters
50+
hdlset_param('commhdlQPSKTxRx/Transmitter/dataQ', 'IOInterface', 'IP Data 1 IN [0:15]');
51+
hdlset_param('commhdlQPSKTxRx/Transmitter/dataQ', 'IOInterfaceMapping', '[0:15]');
52+
53+
% Set Inport HDL parameters
54+
hdlset_param('commhdlQPSKTxRx/Transmitter/validIn', 'IOInterface', 'IP Valid Tx Data IN');
55+
hdlset_param('commhdlQPSKTxRx/Transmitter/validIn', 'IOInterfaceMapping', '[0]');
56+
57+
hdlset_param('commhdlQPSKTxRx/Transmitter/QPSK Tx/Bit Packetizer/Data Bits FIFO/No HDL', 'Architecture', 'No HDL');
58+
59+
hdlset_param('commhdlQPSKTxRx/Transmitter/QPSK Tx/Bit Packetizer/Data Bits FIFO/No HDL/No HDL', 'Architecture', 'No HDL');
60+
61+
% Set Outport HDL parameters
62+
hdlset_param('commhdlQPSKTxRx/Transmitter/dataOutI', 'IOInterface', 'ADRV9002 DAC Data I0 [0:15]');
63+
hdlset_param('commhdlQPSKTxRx/Transmitter/dataOutI', 'IOInterfaceMapping', '[0:15]');
64+
65+
% Set Outport HDL parameters
66+
hdlset_param('commhdlQPSKTxRx/Transmitter/dataOutQ', 'IOInterface', 'ADRV9002 DAC Data Q0 [0:15]');
67+
hdlset_param('commhdlQPSKTxRx/Transmitter/dataOutQ', 'IOInterfaceMapping', '[0:15]');
68+
69+
% Set Outport HDL parameters
70+
hdlset_param('commhdlQPSKTxRx/Transmitter/txDiagBus', 'IOInterface', 'No Interface Specified');
71+
hdlset_param('commhdlQPSKTxRx/Transmitter/txDiagBus', 'IOInterfaceMapping', '');
72+
73+
% Set Outport HDL parameters
74+
hdlset_param('commhdlQPSKTxRx/Transmitter/validOut', 'IOInterface', 'IP Load Tx Data OUT');
75+
hdlset_param('commhdlQPSKTxRx/Transmitter/validOut', 'IOInterfaceMapping', '[0]');
76+
77+
% Set Outport HDL parameters
78+
hdlset_param('commhdlQPSKTxRx/Transmitter/complex', 'IOInterface', 'No Interface Specified');
79+
hdlset_param('commhdlQPSKTxRx/Transmitter/complex', 'IOInterfaceMapping', '');
80+
81+
% Set Outport HDL parameters
82+
hdlset_param('commhdlQPSKTxRx/Transmitter/msg_count_out', 'IOInterface', 'AXI4-Lite');
83+
hdlset_param('commhdlQPSKTxRx/Transmitter/msg_count_out', 'IOInterfaceMapping', 'x"104"');
84+
85+
% Set Outport HDL parameters
86+
hdlset_param('commhdlQPSKTxRx/Transmitter/dataOutQ2', 'IOInterface', 'ADRV9002 DAC Data I1 [0:15]');
87+
hdlset_param('commhdlQPSKTxRx/Transmitter/dataOutQ2', 'IOInterfaceMapping', '[0:15]');
88+
89+
% Set Outport HDL parameters
90+
hdlset_param('commhdlQPSKTxRx/Transmitter/dataOutI2', 'IOInterface', 'ADRV9002 DAC Data Q1 [0:15]');
91+
hdlset_param('commhdlQPSKTxRx/Transmitter/dataOutI2', 'IOInterfaceMapping', '[0:15]');
92+
93+
94+
%% Workflow Configuration Settings
95+
% Construct the Workflow Configuration Object with default settings
96+
hWC = hdlcoder.WorkflowConfig('SynthesisTool','Xilinx Vivado','TargetWorkflow','IP Core Generation');
97+
98+
% Specify the top level project directory
99+
hWC.ProjectFolder = 'hdl_prj_jupiter';
100+
hWC.AllowUnsupportedToolVersion = true;
101+
hWC.ReferenceDesignToolVersion = '2025.1';
102+
hWC.IgnoreToolVersionMismatch = false;
103+
104+
% Set Workflow tasks to run
105+
hWC.RunTaskGenerateRTLCodeAndIPCore = true;
106+
hWC.RunTaskCreateProject = true;
107+
hWC.RunTaskGenerateSoftwareInterface = true;
108+
hWC.RunTaskBuildFPGABitstream = true;
109+
hWC.RunTaskProgramTargetDevice = false;
110+
111+
% Set properties related to 'RunTaskGenerateRTLCodeAndIPCore' Task
112+
hWC.GenerateIPCoreReport = true;
113+
114+
% Set properties related to 'RunTaskCreateProject' Task
115+
hWC.Objective = hdlcoder.Objective.None;
116+
hWC.AdditionalProjectCreationTclFiles = '';
117+
hWC.EnableIPCaching = false;
118+
119+
% Set properties related to 'RunTaskGenerateSoftwareInterface' Task
120+
hWC.GenerateSoftwareInterfaceModel = false;
121+
hWC.OperatingSystem = 'Linux';
122+
hWC.HostTargetInterface = 'Ethernet';
123+
hWC.GenerateHostInterfaceModel = false;
124+
hWC.GenerateHostInterfaceScript = false;
125+
126+
% Set properties related to 'RunTaskBuildFPGABitstream' Task
127+
hWC.RunExternalBuild = true;
128+
hWC.EnableDesignCheckpoint = false;
129+
hWC.TclFileForSynthesisBuild = hdlcoder.BuildOption.Custom;
130+
hWC.CustomBuildTclFile = 'C:\work\datalink\TransceiverToolbox\CI\scripts\adi_build.tcl';
131+
hWC.DefaultCheckpointFile = 'Default';
132+
hWC.RoutedDesignCheckpointFilePath = '';
133+
hWC.MaxNumOfCoresForBuild = '';
134+
135+
% Set properties related to 'RunTaskProgramTargetDevice' Task
136+
% hWC.ProgrammingMethod = hdlcoder.ProgrammingMethod.Download;
137+
% hWC.IPAddress = '';
138+
% hWC.SSHUsername = '';
139+
% hWC.SSHPassword = '';
140+
141+
% Validate the Workflow Configuration Object
142+
hWC.validate;
143+
144+
%% Run the workflow
145+
hdlcoder.runWorkflow('commhdlQPSKTxRx/Transmitter', hWC, 'Verbosity', 'on');
Binary file not shown.

0 commit comments

Comments
 (0)