CLEANUP - changes to folder structure
This commit is contained in:
400
Classes/DataBaseHandler/sql_query_collection.txt
Normal file
400
Classes/DataBaseHandler/sql_query_collection.txt
Normal file
@@ -0,0 +1,400 @@
|
|||||||
|
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM `Results`
|
||||||
|
|
||||||
|
SELECT COUNT(DISTINCT run_id) AS unique_run_count
|
||||||
|
FROM `Results`;
|
||||||
|
|
||||||
|
SELECT COUNT(*) AS entries_for_run
|
||||||
|
FROM `Results`
|
||||||
|
WHERE run_id = -- your desired run_id here
|
||||||
|
2937;
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE `Runs`
|
||||||
|
ADD COLUMN grossrate DOUBLE GENERATED ALWAYS AS (
|
||||||
|
(
|
||||||
|
CASE
|
||||||
|
WHEN pam_level = 4 THEN 2.0
|
||||||
|
WHEN pam_level = 6 THEN 2.5
|
||||||
|
WHEN pam_level = 8 THEN 3.0
|
||||||
|
ELSE FLOOR(LOG2(pam_level) * 10) / 10
|
||||||
|
END
|
||||||
|
) * symbolrate
|
||||||
|
) STORED;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
JSON_EXTRACT(voa_class, '$.atten_state[1]') AS atten_state_second
|
||||||
|
FROM Runs
|
||||||
|
WHERE run_id = 1000;
|
||||||
|
|
||||||
|
SELECT DISTINCT
|
||||||
|
run_id
|
||||||
|
FROM Results r
|
||||||
|
WHERE date_of_processing > '2025-11-14 12:00:00';
|
||||||
|
|
||||||
|
SELECT DISTINCT
|
||||||
|
symbolrate
|
||||||
|
FROM Runs
|
||||||
|
WHERE pam_level = 4
|
||||||
|
AND symbolrate IS NOT NULL
|
||||||
|
ORDER BY symbolrate;
|
||||||
|
|
||||||
|
|
||||||
|
SELECT DISTINCT
|
||||||
|
wavelength
|
||||||
|
FROM Runs
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
run_id,
|
||||||
|
COUNT(DISTINCT eq_id) AS unique_eq_count,
|
||||||
|
COUNT(*) AS entries_for_run
|
||||||
|
FROM `Results`
|
||||||
|
WHERE run_id IS NOT NULL
|
||||||
|
GROUP BY run_id
|
||||||
|
ORDER BY run_id;
|
||||||
|
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
COUNT(DISTINCT eq_id) AS unique_eq_count,
|
||||||
|
COUNT(*) AS entries_for_run
|
||||||
|
FROM `Results`
|
||||||
|
WHERE run_id = -- your run_id here
|
||||||
|
2936;
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
run_id,
|
||||||
|
COUNT(DISTINCT eq_id) AS unique_eq_count
|
||||||
|
FROM `Results`
|
||||||
|
WHERE run_id IS NOT NULL
|
||||||
|
GROUP BY run_id
|
||||||
|
ORDER BY run_id;
|
||||||
|
|
||||||
|
|
||||||
|
SELECT DISTINCT
|
||||||
|
r.run_id,
|
||||||
|
r.eq_id,
|
||||||
|
e.equalizer_structure,
|
||||||
|
e.eq,
|
||||||
|
e.mlse
|
||||||
|
FROM Results AS r
|
||||||
|
JOIN Equalizer AS e USING (eq_id)
|
||||||
|
WHERE r.run_id = -- your run_id here
|
||||||
|
2731
|
||||||
|
ORDER BY r.run_id, r.eq_id
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SELECT DISTINCT
|
||||||
|
r.run_id
|
||||||
|
FROM Results AS r
|
||||||
|
JOIN Runs AS u
|
||||||
|
ON r.run_id = u.run_id
|
||||||
|
WHERE u.pam_level = 6
|
||||||
|
ORDER BY r.run_id;
|
||||||
|
|
||||||
|
-- older than aug 2025
|
||||||
|
CREATE OR REPLACE VIEW dashboard_old AS
|
||||||
|
SELECT
|
||||||
|
r.run_id,
|
||||||
|
r.eq_id,
|
||||||
|
e.equalizer_structure,
|
||||||
|
|
||||||
|
-- extract the DIR field from the JSON in e.MLSE
|
||||||
|
MAX(JSON_UNQUOTE(JSON_EXTRACT(e.MLSE, '$.DIR'))) AS DIR,
|
||||||
|
|
||||||
|
u.symbolrate,
|
||||||
|
u.pam_level,
|
||||||
|
u.wavelength,
|
||||||
|
u.fiber_length,
|
||||||
|
u.db_mode,
|
||||||
|
|
||||||
|
-- accumulated dispersion in ps
|
||||||
|
0.09 * u.fiber_length * (u.wavelength - 1310) AS accumulated_dispersion,
|
||||||
|
|
||||||
|
-- BER & new averages
|
||||||
|
AVG(r.BER) AS avg_BER,
|
||||||
|
MAX(r.SNR) AS max_SNR,
|
||||||
|
MAX(r.GMI) AS max_GMI,
|
||||||
|
AVG(r.Alpha) AS avg_Alpha,
|
||||||
|
|
||||||
|
MIN(r.BER) AS min_BER,
|
||||||
|
AVG(r.BER_precoded) AS avg_BER_precoded,
|
||||||
|
MIN(r.BER_precoded) AS min_BER_precoded,
|
||||||
|
COUNT(*) AS num_occurrences
|
||||||
|
FROM Results AS r
|
||||||
|
JOIN Runs AS u ON r.run_id = u.run_id
|
||||||
|
JOIN Equalizer AS e ON r.eq_id = e.eq_id
|
||||||
|
WHERE r.eq_id IS NOT NULL
|
||||||
|
AND r.date_of_processing < '2025-08-01 00:00:00'
|
||||||
|
GROUP BY
|
||||||
|
r.run_id,
|
||||||
|
r.eq_id,
|
||||||
|
e.equalizer_structure,
|
||||||
|
u.symbolrate,
|
||||||
|
u.pam_level,
|
||||||
|
u.wavelength,
|
||||||
|
u.fiber_length,
|
||||||
|
u.db_mode
|
||||||
|
ORDER BY
|
||||||
|
r.run_id,
|
||||||
|
r.eq_id;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW dashboard_new AS
|
||||||
|
SELECT
|
||||||
|
r.run_id,
|
||||||
|
r.eq_id,
|
||||||
|
e.equalizer_structure,
|
||||||
|
|
||||||
|
-- extract the DIR field from the JSON in e.MLSE
|
||||||
|
MAX(JSON_UNQUOTE(JSON_EXTRACT(e.MLSE, '$.DIR'))) AS DIR,
|
||||||
|
|
||||||
|
u.symbolrate,
|
||||||
|
u.pam_level,
|
||||||
|
u.wavelength,
|
||||||
|
u.fiber_length,
|
||||||
|
u.db_mode,
|
||||||
|
|
||||||
|
-- accumulated dispersion in ps
|
||||||
|
0.09 * u.fiber_length * (u.wavelength - 1310) AS accumulated_dispersion,
|
||||||
|
|
||||||
|
-- BER & new averages
|
||||||
|
AVG(r.BER) AS avg_BER,
|
||||||
|
MAX(r.SNR) AS max_SNR,
|
||||||
|
MAX(r.GMI) AS max_GMI,
|
||||||
|
AVG(r.Alpha) AS avg_Alpha,
|
||||||
|
|
||||||
|
MIN(r.BER) AS min_BER,
|
||||||
|
AVG(r.BER_precoded) AS avg_BER_precoded,
|
||||||
|
MIN(r.BER_precoded) AS min_BER_precoded,
|
||||||
|
COUNT(*) AS num_occurrences
|
||||||
|
FROM Results AS r
|
||||||
|
JOIN Runs AS u ON r.run_id = u.run_id
|
||||||
|
JOIN Equalizer AS e ON r.eq_id = e.eq_id
|
||||||
|
WHERE r.eq_id IS NOT NULL
|
||||||
|
AND r.date_of_processing >= '2025-08-01 00:00:00'
|
||||||
|
GROUP BY
|
||||||
|
r.run_id,
|
||||||
|
r.eq_id,
|
||||||
|
e.equalizer_structure,
|
||||||
|
u.symbolrate,
|
||||||
|
u.pam_level,
|
||||||
|
u.wavelength,
|
||||||
|
u.fiber_length,
|
||||||
|
u.db_mode
|
||||||
|
ORDER BY
|
||||||
|
r.run_id,
|
||||||
|
r.eq_id;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW dashboard_ungrouped_alltime AS
|
||||||
|
SELECT
|
||||||
|
r.result_id,
|
||||||
|
r.run_id,
|
||||||
|
r.eq_id,
|
||||||
|
e.equalizer_structure,
|
||||||
|
u.bitrate,
|
||||||
|
u.grossrate,
|
||||||
|
u.symbolrate,
|
||||||
|
u.pam_level,
|
||||||
|
u.wavelength,
|
||||||
|
u.fiber_length,
|
||||||
|
u.db_mode,
|
||||||
|
u.rop_attenuation,
|
||||||
|
-- accumulated dispersion in ps
|
||||||
|
0.07 * u.fiber_length * (u.wavelength - 1310) AS accumulated_dispersion,
|
||||||
|
r.date_of_processing,
|
||||||
|
r.numBits,
|
||||||
|
r.numBitErr,
|
||||||
|
r.BER,
|
||||||
|
r.numBitErr_precoded,
|
||||||
|
r.BER_precoded,
|
||||||
|
r.STD,
|
||||||
|
r.STDrx,
|
||||||
|
r.GMI,
|
||||||
|
r.AIR,
|
||||||
|
r.EVM,
|
||||||
|
r.Alpha
|
||||||
|
FROM Results AS r
|
||||||
|
JOIN Runs AS u ON r.run_id = u.run_id
|
||||||
|
JOIN Equalizer AS e ON r.eq_id = e.eq_id
|
||||||
|
WHERE r.eq_id IS NOT NULL;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW dashboard_ungrouped_aug_nov_2025 AS
|
||||||
|
SELECT
|
||||||
|
r.result_id,
|
||||||
|
r.run_id,
|
||||||
|
r.eq_id,
|
||||||
|
e.equalizer_structure,
|
||||||
|
u.bitrate,
|
||||||
|
u.grossrate,
|
||||||
|
u.symbolrate,
|
||||||
|
u.pam_level,
|
||||||
|
u.wavelength,
|
||||||
|
u.fiber_length,
|
||||||
|
u.db_mode,
|
||||||
|
u.rop_attenuation,
|
||||||
|
-- accumulated dispersion in ps
|
||||||
|
0.07 * u.fiber_length * (u.wavelength - 1310) AS accumulated_dispersion,
|
||||||
|
r.date_of_processing,
|
||||||
|
r.numBits,
|
||||||
|
r.numBitErr,
|
||||||
|
r.BER,
|
||||||
|
r.numBitErr_precoded,
|
||||||
|
r.BER_precoded,
|
||||||
|
r.STD,
|
||||||
|
r.STDrx,
|
||||||
|
r.GMI,
|
||||||
|
r.AIR,
|
||||||
|
r.EVM,
|
||||||
|
r.Alpha
|
||||||
|
FROM Results AS r
|
||||||
|
JOIN Runs AS u ON r.run_id = u.run_id
|
||||||
|
JOIN Equalizer AS e ON r.eq_id = e.eq_id
|
||||||
|
WHERE r.eq_id IS NOT NULL
|
||||||
|
AND r.date_of_processing >= '2025-08-01 00:00:00'
|
||||||
|
AND r.date_of_processing < '2025-11-14 00:00:00';
|
||||||
|
|
||||||
|
|
||||||
|
-- Das waren meine ehemals besten BERs, im Nov habe ich ML-based hinzugefügt und
|
||||||
|
-- das Rx Filter nochmal sehr eng gestellt, das war inbesondere bei geringeren Raten sehr hilfreich um
|
||||||
|
-- out.of-band noise zu filtern -> BER ging ja teilweise runter und wieder hoch...
|
||||||
|
CREATE OR REPLACE VIEW dashboard_ungrouped_aug_nov_2025 AS
|
||||||
|
SELECT
|
||||||
|
r.result_id,
|
||||||
|
r.run_id,
|
||||||
|
r.eq_id,
|
||||||
|
e.equalizer_structure,
|
||||||
|
u.bitrate,
|
||||||
|
u.grossrate,
|
||||||
|
u.symbolrate,
|
||||||
|
u.pam_level,
|
||||||
|
u.wavelength,
|
||||||
|
u.fiber_length,
|
||||||
|
u.db_mode,
|
||||||
|
u.rop_attenuation,
|
||||||
|
-- accumulated dispersion in ps
|
||||||
|
0.07 * u.fiber_length * (u.wavelength - 1310) AS accumulated_dispersion,
|
||||||
|
r.date_of_processing,
|
||||||
|
r.numBits,
|
||||||
|
r.numBitErr,
|
||||||
|
r.BER,
|
||||||
|
r.numBitErr_precoded,
|
||||||
|
r.BER_precoded,
|
||||||
|
r.STD,
|
||||||
|
r.STDrx,
|
||||||
|
r.GMI,
|
||||||
|
r.AIR,
|
||||||
|
r.EVM
|
||||||
|
FROM Results AS r
|
||||||
|
JOIN Runs AS u ON r.run_id = u.run_id
|
||||||
|
JOIN Equalizer AS e ON r.eq_id = e.eq_id
|
||||||
|
WHERE r.eq_id IS NOT NULL
|
||||||
|
AND r.date_of_processing >= '2025-08-01 00:00:00'
|
||||||
|
AND r.date_of_processing < '2025-11-14 00:00:00';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW dashboard_ungrouped_old AS
|
||||||
|
SELECT
|
||||||
|
r.result_id,
|
||||||
|
r.run_id,
|
||||||
|
r.eq_id,
|
||||||
|
e.equalizer_structure,
|
||||||
|
u.symbolrate,
|
||||||
|
u.pam_level,
|
||||||
|
u.wavelength,
|
||||||
|
u.fiber_length,
|
||||||
|
u.db_mode,
|
||||||
|
-- accumulated dispersion in ps
|
||||||
|
0.07 * u.fiber_length * (u.wavelength - 1310) AS accumulated_dispersion,
|
||||||
|
r.date_of_processing,
|
||||||
|
r.numBits,
|
||||||
|
r.numBitErr,
|
||||||
|
r.BER,
|
||||||
|
r.numBitErr_precoded,
|
||||||
|
r.BER_precoded,
|
||||||
|
r.STD,
|
||||||
|
r.STDrx,
|
||||||
|
r.GMI,
|
||||||
|
r.AIR,
|
||||||
|
r.EVM
|
||||||
|
FROM Results AS r
|
||||||
|
JOIN Runs AS u ON r.run_id = u.run_id
|
||||||
|
JOIN Equalizer AS e ON r.eq_id = e.eq_id
|
||||||
|
WHERE r.eq_id IS NOT NULL
|
||||||
|
AND r.date_of_processing < '2025-08-01 00:00:00';
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW dashboard_ungrouped_during_ecoc AS
|
||||||
|
SELECT
|
||||||
|
r.result_id,
|
||||||
|
r.run_id,
|
||||||
|
r.eq_id,
|
||||||
|
e.equalizer_structure,
|
||||||
|
u.symbolrate,
|
||||||
|
u.pam_level,
|
||||||
|
u.wavelength,
|
||||||
|
u.fiber_length,
|
||||||
|
u.db_mode,
|
||||||
|
-- accumulated dispersion in ps
|
||||||
|
0.07 * u.fiber_length * (u.wavelength - 1310) AS accumulated_dispersion,
|
||||||
|
r.date_of_processing,
|
||||||
|
r.numBits,
|
||||||
|
r.numBitErr,
|
||||||
|
r.BER,
|
||||||
|
r.numBitErr_precoded,
|
||||||
|
r.BER_precoded,
|
||||||
|
r.STD,
|
||||||
|
r.STDrx,
|
||||||
|
r.GMI,
|
||||||
|
r.AIR,
|
||||||
|
r.EVM
|
||||||
|
FROM Results AS r
|
||||||
|
JOIN Runs AS u ON r.run_id = u.run_id
|
||||||
|
JOIN Equalizer AS e ON r.eq_id = e.eq_id
|
||||||
|
WHERE r.eq_id IS NOT NULL
|
||||||
|
AND r.date_of_processing > '2025-09-20 00:00:00';
|
||||||
|
|
||||||
|
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM `dashboard_ungrouped`
|
||||||
|
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW power_state_info AS
|
||||||
|
SELECT
|
||||||
|
run_id,
|
||||||
|
|
||||||
|
power_laser AS power_laser,
|
||||||
|
|
||||||
|
power_rop AS power_mzm,
|
||||||
|
|
||||||
|
-- new power_rop first
|
||||||
|
power_pd_in
|
||||||
|
+ CAST(voa_class->>'$.atten_state[1]' AS DECIMAL(12,6))
|
||||||
|
AS power_rop,
|
||||||
|
|
||||||
|
-- then voa_atten
|
||||||
|
CAST(voa_class->>'$.atten_state[1]' AS DECIMAL(12,6))
|
||||||
|
AS voa_atten,
|
||||||
|
|
||||||
|
-- then the photodiode input power
|
||||||
|
power_pd_in AS power_pd_in,
|
||||||
|
|
||||||
|
-- appended columns
|
||||||
|
wavelength,
|
||||||
|
pam_level,
|
||||||
|
db_mode,
|
||||||
|
is_mpi,
|
||||||
|
fiber_length
|
||||||
|
|
||||||
|
FROM Runs;
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
classdef TestRand_examplecode < matlab.unittest.TestCase
|
|
||||||
properties (ClassSetupParameter)
|
|
||||||
generator = {'twister','combRecursive','multFibonacci'};
|
|
||||||
end
|
|
||||||
|
|
||||||
properties (MethodSetupParameter)
|
|
||||||
seed = {0,123,4294967295};
|
|
||||||
end
|
|
||||||
|
|
||||||
properties (TestParameter)
|
|
||||||
dim1 = struct('small',1,'medium',2,'large',3);
|
|
||||||
dim2 = struct('small',2,'medium',3,'large',4);
|
|
||||||
dim3 = struct('small',3,'medium',4,'large',5);
|
|
||||||
type = {'single','double'};
|
|
||||||
end
|
|
||||||
|
|
||||||
methods (TestClassSetup)
|
|
||||||
function classSetup(testCase,generator)
|
|
||||||
orig = rng;
|
|
||||||
testCase.addTeardown(@rng,orig)
|
|
||||||
rng(0,generator)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
methods (TestMethodSetup)
|
|
||||||
function methodSetup(testCase,seed)
|
|
||||||
orig = rng;
|
|
||||||
testCase.addTeardown(@rng,orig)
|
|
||||||
rng(seed)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
methods (Test, ParameterCombination = 'sequential')
|
|
||||||
function testSize(testCase,dim1,dim2,dim3)
|
|
||||||
testCase.verifySize(rand(dim1,dim2,dim3),[dim1 dim2 dim3])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
methods (Test, ParameterCombination = 'pairwise')
|
|
||||||
function testRepeatable(testCase,dim1,dim2,dim3)
|
|
||||||
state = rng;
|
|
||||||
firstRun = rand(dim1,dim2,dim3);
|
|
||||||
rng(state)
|
|
||||||
secondRun = rand(dim1,dim2,dim3);
|
|
||||||
testCase.verifyEqual(firstRun,secondRun)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
methods (Test)
|
|
||||||
function testClass(testCase,dim1,dim2,type)
|
|
||||||
testCase.verifyClass(rand(dim1,dim2,type),type)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
|
|
||||||
db = DBHandler("type","mysql");
|
|
||||||
|
|
||||||
db.tableNames
|
|
||||||
currentTime = datetime('now', 'Format', 'yyyyMMdd_HHmmss');
|
|
||||||
newRun = db.tables.Runs;
|
|
||||||
newRun.run_id = NaN;
|
|
||||||
newRun.loop_id = 82;
|
|
||||||
newRun.date_of_run = datetime(currentTime, 'InputFormat', 'yyyyMMdd_HHmmss');
|
|
||||||
newRun.tx_bits_path = 'pathtohell';
|
|
||||||
newRun.tx_symbols_path = 'pathtohell2';
|
|
||||||
newRun.rx_sync_path = ""; % Leave empty for now
|
|
||||||
newRun.rx_raw_path = 'pathtohell4';
|
|
||||||
newRun.filename = 'filenametohell';
|
|
||||||
newRun.tx_signal_path = 'pathtohell';
|
|
||||||
|
|
||||||
run_id = db.appendToTable('Runs', newRun);
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
function output = exampleFunction(varargin)
|
|
||||||
|
|
||||||
% Default values for optional variables
|
|
||||||
var_1 = 1;
|
|
||||||
var_2 = 2;
|
|
||||||
var_4 = 10; % Default value for var4
|
|
||||||
var_5 = 20; % Default value for var5
|
|
||||||
var_6 = 30; % Default value for var6
|
|
||||||
var_7 = 40; % Default value for var7
|
|
||||||
var_8 = 50; % Default value for var8
|
|
||||||
var_9 = 60; % Default value for var9
|
|
||||||
var_10 = 70; % Default value for var10
|
|
||||||
|
|
||||||
% Parse optional input arguments
|
|
||||||
if ~isempty(varargin)
|
|
||||||
var_s = varargin{1};
|
|
||||||
if isstruct(var_s)
|
|
||||||
fields = fieldnames(var_s);
|
|
||||||
for i = 1:numel(fields)
|
|
||||||
eval([fields{i}, ' = ', num2str( var_s.(fields{i}) ), ';']);
|
|
||||||
fprintf("%s <-- %.2f \n",fields{i},var_s.(fields{i}))
|
|
||||||
end
|
|
||||||
else
|
|
||||||
error('Optional variables should be passed as a struct.');
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
output = var_4+var_10+var_9+var_8+var_1+var_2;
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
x = -10:2:25; % Input power [dBm]
|
|
||||||
|
|
||||||
y1 = 1e-5 * 10.^(0.12*x); % Dispersion-only
|
|
||||||
y2 = 1e0 ./ (1 + exp(-0.4*(x-12))); % NLPN
|
|
||||||
y3 = 1e-6 * 10.^(0.45*x); % RP on gamma
|
|
||||||
y4 = 1e-2 * 10.^(0.18*(x-8)); % RP on beta2
|
|
||||||
|
|
||||||
cmap = WesPalette.AsteroidCity1.rgb(4);
|
|
||||||
cmap = linspecer(4);
|
|
||||||
figure1=figure(202998);clf;hold on
|
|
||||||
lw = 0.8; ms = 3;
|
|
||||||
plot(x,y1,'LineWidth',lw,'Color',cmap(1,:),'Marker','o','MarkerEdgeColor',cmap(1,:),'MarkerFaceColor',[1,1,1],'MarkerSize',ms);
|
|
||||||
plot(x,y2,'LineWidth',lw,'Color',cmap(2,:),'Marker','square','MarkerEdgeColor',cmap(2,:),'MarkerFaceColor',[1,1,1],'MarkerSize',ms);
|
|
||||||
plot(x,y3,'LineWidth',lw,'Color',cmap(3,:),'Marker','o','MarkerEdgeColor',cmap(3,:),'MarkerFaceColor',[1,1,1],'MarkerSize',ms);
|
|
||||||
plot(x,y4,'LineWidth',lw,'Color',cmap(4,:),'Marker','o','MarkerEdgeColor',cmap(4,:),'MarkerFaceColor',[1,1,1],'MarkerSize',ms);
|
|
||||||
yline(3.8e-3,'HandleVisibility','off')
|
|
||||||
|
|
||||||
grid on
|
|
||||||
xlabel('Input power [dBm]')
|
|
||||||
ylabel('NSD ($\%$)')
|
|
||||||
legend({'Dispersion','NLPN','RP','RP on $\beta_2$'}, ...
|
|
||||||
'Location','best')
|
|
||||||
|
|
||||||
grid off
|
|
||||||
set(gca,'MinorGridLineWidth',0.5);
|
|
||||||
set(gca,'GridLineWidth',0.5,'GridLineStyle','--','GridColor',[0.9,0.9,0.9]);
|
|
||||||
|
|
||||||
set(gca,'FontSize',12,'YScale','log');
|
|
||||||
ylim([1e-6 1e3])
|
|
||||||
xlim([-10 23])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fig_path = 'C:\Users\Silas\Documents\Dissertation\00_Examples\tikz\textfig.tikz';
|
|
||||||
matlab2tikz(fig_path, ...
|
|
||||||
'width','\fwidth', ...
|
|
||||||
'height','\fheight', ...
|
|
||||||
'showInfo',false, ...
|
|
||||||
'extraAxisOptions',{ ...
|
|
||||||
'legend style={font=\footnotesize}', ...
|
|
||||||
'xlabel style={font=\color{white!15!black},font=\small},',...
|
|
||||||
'ylabel style={font=\color{white!15!black},font=\small},',...
|
|
||||||
'legend columns=1', ...
|
|
||||||
'every axis/.append style={font=\scriptsize}',...
|
|
||||||
'legend columns=2',...
|
|
||||||
'legend style={at={(0.02,0.98)},font=\footnotesize,draw=black!60,rounded corners=2pt,inner sep=1pt,fill=white,column sep=6pt,anchor= north west}',...
|
|
||||||
});
|
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
% Define ranges for variables to iterate over
|
|
||||||
var1_range = [1, 2, 3, 4, 6];
|
|
||||||
var2_range = [10, 20];
|
|
||||||
var3_range = [100, 200];
|
|
||||||
|
|
||||||
% Prepare the parallel pool
|
|
||||||
if isempty(gcp('nocreate'))
|
|
||||||
parpool; % Start a parallel pool if not already running
|
|
||||||
end
|
|
||||||
|
|
||||||
% Array to hold measurement futures
|
|
||||||
measurements = parallel.FevalFuture.empty();
|
|
||||||
|
|
||||||
% Array to hold DSP results
|
|
||||||
dsp_results = parallel.Future.empty();
|
|
||||||
|
|
||||||
% Nested for loops for all parameter combinations
|
|
||||||
lin_idx = 1;
|
|
||||||
for v1 = var1_range
|
|
||||||
for v2 = var2_range
|
|
||||||
for v3 = var3_range
|
|
||||||
% Construct the struct of optional variables for this iteration
|
|
||||||
optionalVars = struct('var_4', v1, 'var_5', v2, 'var_6', v3);
|
|
||||||
|
|
||||||
% Submit the measurement function to the parallel pool
|
|
||||||
measurements(lin_idx) = parfeval(@measurement, 1, optionalVars);
|
|
||||||
|
|
||||||
% Link DSP function to run after measurement completes
|
|
||||||
dsp_results(lin_idx) = afterEach(measurements(lin_idx), @(output) rundsp(output, optionalVars), 1);
|
|
||||||
|
|
||||||
lin_idx = lin_idx + 1; % Increment linear index
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
% Fetch and display DSP results
|
|
||||||
final_results = cell(numel(dsp_results), 1);
|
|
||||||
for i = 1:numel(dsp_results)
|
|
||||||
fprintf('Fetching DSP result for job %d...\n', i);
|
|
||||||
final_results{i} = fetchOutputs(dsp_results(i)); % Fetch each DSP result individually
|
|
||||||
end
|
|
||||||
|
|
||||||
fprintf('All DSP evaluations completed.\n');
|
|
||||||
disp('Final Results:');
|
|
||||||
disp(final_results);
|
|
||||||
|
|
||||||
% --- Measurement Function ---
|
|
||||||
function output = measurement(varargin)
|
|
||||||
|
|
||||||
% Default values for optional variables
|
|
||||||
var_1 = 1;
|
|
||||||
var_2 = 2;
|
|
||||||
var_4 = 10; % Default value for var4
|
|
||||||
var_5 = 20; % Default value for var5
|
|
||||||
var_6 = 30; % Default value for var6
|
|
||||||
var_7 = 40; % Default value for var7
|
|
||||||
var_8 = 50; % Default value for var8
|
|
||||||
var_9 = 60; % Default value for var9
|
|
||||||
var_10 = 70; % Default value for var10
|
|
||||||
|
|
||||||
% Parse optional input arguments
|
|
||||||
if ~isempty(varargin)
|
|
||||||
var_s = varargin{1};
|
|
||||||
if isstruct(var_s)
|
|
||||||
fields = fieldnames(var_s);
|
|
||||||
for i = 1:numel(fields)
|
|
||||||
eval([fields{i}, ' = ', num2str( var_s.(fields{i}) ), ';']);
|
|
||||||
fprintf("%s <-- %.2f \n", fields{i}, var_s.(fields{i}));
|
|
||||||
end
|
|
||||||
else
|
|
||||||
error('Optional variables should be passed as a struct.');
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
% Simulate output with a random delay
|
|
||||||
output = randi(5); % Random result
|
|
||||||
pause(output); % Simulate processing time
|
|
||||||
end
|
|
||||||
|
|
||||||
% --- DSP Function ---
|
|
||||||
function output = rundsp(measurement_output, varargin)
|
|
||||||
|
|
||||||
% Parse optional input arguments
|
|
||||||
if ~isempty(varargin)
|
|
||||||
var_s = varargin{1};
|
|
||||||
if isstruct(var_s)
|
|
||||||
fields = fieldnames(var_s);
|
|
||||||
for i = 1:numel(fields)
|
|
||||||
eval([fields{i}, ' = ', num2str( var_s.(fields{i}) ), ';']);
|
|
||||||
fprintf("%s <-- %.2f \n", fields{i}, var_s.(fields{i}));
|
|
||||||
end
|
|
||||||
else
|
|
||||||
error('Optional variables should be passed as a struct.');
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
% Simulate DSP processing based on measurement output
|
|
||||||
output = measurement_output + 10; % Add 10 to measurement output
|
|
||||||
pause(measurement_output); % Simulate DSP processing time
|
|
||||||
end
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
classdef test_modulation < matlab.unittest.TestCase
|
|
||||||
|
|
||||||
properties
|
|
||||||
Tx_bits
|
|
||||||
Digi_Mod
|
|
||||||
end
|
|
||||||
|
|
||||||
properties (MethodSetupParameter)
|
|
||||||
% Define method-level parameters for PRBS and bit pattern
|
|
||||||
useprbs = struct('false', 0, 'true', 1); % variations: {0, 1}
|
|
||||||
M = struct('M2', 2, 'M4', 4, 'M6', 6, 'M8', 8); % variations: {2, 4, 6, 8}
|
|
||||||
O = struct('O10', 10, 'O15', 15, 'O17', 17); % variations: {10, 15, 17}
|
|
||||||
end
|
|
||||||
|
|
||||||
properties (TestParameter)
|
|
||||||
% Define test-level parameters for M and O
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
methods (TestMethodSetup)
|
|
||||||
|
|
||||||
function setupModulation(testCase, useprbs, M, O)
|
|
||||||
% Setup PRBS and bit pattern for the test case using parameters
|
|
||||||
|
|
||||||
% Setup PRBS parameters
|
|
||||||
N = 2^(O-1); % Length of PRBS
|
|
||||||
randkey = 1; % Random key for random stream
|
|
||||||
|
|
||||||
[~, seed] = prbs(O, 1); % Initialize first seed of PRBS
|
|
||||||
bitpattern = [];
|
|
||||||
if useprbs
|
|
||||||
for i = 1:log2(M)
|
|
||||||
[bitpattern(:, i), seed] = prbs(O, N, seed);
|
|
||||||
end
|
|
||||||
else
|
|
||||||
s = RandStream('twister', 'Seed', randkey);
|
|
||||||
for i = 1:log2(M)
|
|
||||||
bitpattern(:, i) = randi(s, [0 1], N, 1);
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if M == 6
|
|
||||||
bitpattern = reshape(bitpattern, [], 1);
|
|
||||||
bitpattern = bitpattern(1:end-mod(length(bitpattern), 5));
|
|
||||||
end
|
|
||||||
|
|
||||||
testCase.Tx_bits = Informationsignal(bitpattern);
|
|
||||||
testCase.Digi_Mod = PAMmapper(M, 0);
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
methods (Test, ParameterCombination = 'sequential')
|
|
||||||
% Test with sequential combination of parameters
|
|
||||||
function testBackToBackMapping(testCase, M, useprbs, O)
|
|
||||||
% Test Bits -> Symbols -> Bits (Back-to-Back Mapping)
|
|
||||||
|
|
||||||
% Map bits to symbols
|
|
||||||
Symbols = testCase.Digi_Mod.map(testCase.Tx_bits);
|
|
||||||
|
|
||||||
% Demap symbols back to bits
|
|
||||||
Rx_bits = testCase.Digi_Mod.demap(Symbols);
|
|
||||||
|
|
||||||
% Validate BER is zero
|
|
||||||
[~, error_num, ber, ~] = calc_ber(testCase.Tx_bits.signal, Rx_bits.signal, ...
|
|
||||||
"skip_front", 0, "skip_end", 0, "returnErrorLocation", 1);
|
|
||||||
|
|
||||||
% Assert that BER is zero
|
|
||||||
testCase.verifyEqual(ber, 0, 'BER should be zero');
|
|
||||||
testCase.verifyEqual(error_num, 0, 'No errors should occur in the mapping process');
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
function tau_error = modifiedGodardTimingRecovery(rx, N, eta, beta)
|
|
||||||
% modifiedGodardTimingRecovery
|
|
||||||
%
|
|
||||||
% This function estimates the symbol timing error using the modified Godard
|
|
||||||
% approach in the frequency domain as described in:
|
|
||||||
%
|
|
||||||
% "Modified Godard Timing Recovery for Non-Integer Oversampling Receivers"
|
|
||||||
% Appl. Sci. 2017, 7, 655. :contentReference[oaicite:0]{index=0}​:contentReference[oaicite:1]{index=1}
|
|
||||||
%
|
|
||||||
% Inputs:
|
|
||||||
% rx - Received time-domain signal (vector)
|
|
||||||
% N - FFT size (should be an even integer)
|
|
||||||
% eta - Effective oversampling factor used for timing recovery (eta > 1)
|
|
||||||
% beta - Roll-off related parameter (0 < beta <= 1)
|
|
||||||
%
|
|
||||||
% Output:
|
|
||||||
% tau_error - Estimated timing error (in sample units)
|
|
||||||
%
|
|
||||||
% Implementation Notes:
|
|
||||||
% 1. The function computes an N-point FFT of the first N samples of rx.
|
|
||||||
% 2. It then determines an offset (Delta) defined as:
|
|
||||||
% offset = round((1 - 1/eta) * N)
|
|
||||||
% 3. To avoid index overflow, the summation is taken over indices k from 1 to
|
|
||||||
% floor(N/2) - offset.
|
|
||||||
% 4. The timing error is estimated as:
|
|
||||||
% tau_error = ( (1+beta)/(2*eta*N - 1) * sum(phase difference) ) / (2*pi)
|
|
||||||
% where the phase difference is (angle(R(k)) - angle(R(k+offset)))
|
|
||||||
%
|
|
||||||
% Make sure that the input signal rx contains at least N samples.
|
|
||||||
|
|
||||||
% Check input length
|
|
||||||
if length(rx) < N
|
|
||||||
error('Input signal length must be at least N.');
|
|
||||||
end
|
|
||||||
|
|
||||||
% Compute the N-point FFT of the first N samples of rx
|
|
||||||
R = fft(rx(1:N), N);
|
|
||||||
|
|
||||||
% Determine the offset based on the oversampling factor (eta)
|
|
||||||
offset = round((1 - 1/eta) * N);
|
|
||||||
|
|
||||||
% Define the summation range to avoid index overflow
|
|
||||||
k_min = 1;
|
|
||||||
k_max = floor(N/2) - offset;
|
|
||||||
if k_max < k_min
|
|
||||||
error('Chosen parameters result in an empty summation range. Adjust N, eta, or beta.');
|
|
||||||
end
|
|
||||||
|
|
||||||
% Compute the sum of phase differences over the selected frequency bins
|
|
||||||
phase_diff_sum = 0;
|
|
||||||
for k = k_min:k_max
|
|
||||||
phase_k = angle(R(k));
|
|
||||||
phase_k_offset = angle(R(k + offset));
|
|
||||||
phase_diff_sum = phase_diff_sum + (phase_k - phase_k_offset);
|
|
||||||
end
|
|
||||||
|
|
||||||
% Normalization factor as per the modified Godard algorithm
|
|
||||||
norm_factor = (1 + beta) / (2 * eta * N - 1);
|
|
||||||
|
|
||||||
% Estimate the timing error in sample units
|
|
||||||
tau_error = (norm_factor * phase_diff_sum) / (2 * pi);
|
|
||||||
end
|
|
||||||
BIN
projects/.DS_Store
vendored
BIN
projects/.DS_Store
vendored
Binary file not shown.
@@ -1,250 +0,0 @@
|
|||||||
|
|
||||||
%% Parameter to simulate and save
|
|
||||||
params = struct;
|
|
||||||
|
|
||||||
params.M = [4];
|
|
||||||
params.datarate = [224];
|
|
||||||
params.rop = [-12:-5];
|
|
||||||
|
|
||||||
precomp_mode = 0; %0=do nothing ; 1= measure; 2=precomp active
|
|
||||||
postfilter = 0; % noise whiten. approach -> Postfilter + MLSE
|
|
||||||
|
|
||||||
db_precode = 1;
|
|
||||||
db_encode = 0;
|
|
||||||
db_channelapproach = 1;
|
|
||||||
|
|
||||||
|
|
||||||
if ismac
|
|
||||||
precomp_path = "/Users/silasoettinghaus/Documents/MATLAB/imdd_simulation/projects/standard_system";
|
|
||||||
else
|
|
||||||
precomp_path = "C:\Users\sioe\Documents\MATLAB\imdd_simulation\projects\standard_system\";
|
|
||||||
end
|
|
||||||
|
|
||||||
precomp_fn = "400G_simulative_setup";
|
|
||||||
usemrds = 0;
|
|
||||||
|
|
||||||
name = ['wh_',strrep(num2str(now),'.','')];
|
|
||||||
|
|
||||||
wh = DataStorage(params);
|
|
||||||
|
|
||||||
wh.addStorage("Rx_Bits");
|
|
||||||
wh.addStorage("ber_ffe");
|
|
||||||
|
|
||||||
%% Init Params
|
|
||||||
link_length = 1000; %meter
|
|
||||||
pn_key = 2;
|
|
||||||
laser_linewidth = 0;
|
|
||||||
|
|
||||||
endcnt = prod(wh.dim);
|
|
||||||
cnt=0;
|
|
||||||
|
|
||||||
disp(['Start Simulation of ',num2str(endcnt),' loops...'])
|
|
||||||
tic
|
|
||||||
|
|
||||||
for M = wh.parameter.M.values
|
|
||||||
for datarate = wh.parameter.datarate.values
|
|
||||||
|
|
||||||
% SETUP HERE: %%
|
|
||||||
kover = 16;
|
|
||||||
M8199 = M8199B("kover",kover);
|
|
||||||
fdac = M8199.fdac;
|
|
||||||
fsym = round(datarate / log2(M)) * 1e9;
|
|
||||||
rrcalpha = 0.05;
|
|
||||||
Pform = Pulseformer("fsym",fsym,"fdac",4*fsym,"pulse","rrc","pulselength",16,"rrcalpha",rrcalpha);
|
|
||||||
|
|
||||||
% MAIN SIGNAL
|
|
||||||
|
|
||||||
%%%%% Symbol Generation %%%%%%
|
|
||||||
[Digi_sig,Symbols,Bits] = PAMsource("fsym",fsym,"M",M,"order",18,"useprbs",0,...
|
|
||||||
"fs_out",M8199.fdac,"applyclipping",1,"clipfactor",1.5,...
|
|
||||||
"applypulseform",0,"pulseformer",Pform,"randkey",pn_key,...
|
|
||||||
"db_precode",db_precode,"db_encode",db_encode,...
|
|
||||||
"mrds_code",usemrds,"mrds_blocklength",512).process();
|
|
||||||
|
|
||||||
% Digi_sig.eye(fsym,M);
|
|
||||||
Digi_sig.spectrum("fignum",123434,"displayname",'Digital Tx Signal');
|
|
||||||
|
|
||||||
if precomp_mode == 1
|
|
||||||
freqresp = ChannelFreqResp("Nacq",1024,"Navg",64,"Ncp",63,'f_ref',Digi_sig.fs);
|
|
||||||
Digi_sig = freqresp.buildOFDM();
|
|
||||||
elseif precomp_mode == 2
|
|
||||||
Digi_sig = ChannelFreqResp("Nacq",1024,"Navg",64,"Ncp",63,'f_ref',Digi_sig.fs).precomp(Digi_sig,'maxampdb',1,'loadPath',precomp_path,'fileName',precomp_fn);
|
|
||||||
Digi_sig.spectrum("fignum",11,"displayname",'after precomp');
|
|
||||||
end
|
|
||||||
|
|
||||||
%%%%% AWG %%%%%%
|
|
||||||
El_sig = M8199.process(Digi_sig);
|
|
||||||
|
|
||||||
% El_sig.spectrum("displayname",'el','fignum',123434);
|
|
||||||
|
|
||||||
% El_sig.signal = awgn(El_sig.signal,-3,'measured',pn_key);
|
|
||||||
|
|
||||||
%%%%% Lowpass el. components %%%%%%
|
|
||||||
El_sig = Filter('filtdegree',2,"f_cutoff",60e9,"fs",fdac*kover,"filterType",filtertypes.butterworth,"active",true).process(El_sig);
|
|
||||||
|
|
||||||
%%%%% Electrical Driver Amplifier %%%%%%
|
|
||||||
El_sig = Amplifier("amp_mode","ideal_no_noise","gain_mode","gain","amplification_db",3).process(El_sig);
|
|
||||||
% El_sig = El_sig.setPower(6,"dBm");
|
|
||||||
|
|
||||||
fprintf('Driver output power: %s dBm\n', num2str(El_sig.power));
|
|
||||||
fprintf('Driver output peak voltage: %s Vpp \n', num2str(max(El_sig.signal)-min(El_sig.signal)));
|
|
||||||
|
|
||||||
|
|
||||||
% MAIN SIGNAL
|
|
||||||
%%%%% MODULATE E/O CONVERSION %%%%%%
|
|
||||||
vbias_rel = 0.5;
|
|
||||||
u_pi = 2.9;
|
|
||||||
vbias = -vbias_rel*u_pi;
|
|
||||||
|
|
||||||
[Opt_sig] = EML("mode",eml_mode.im_cosinus,"power",3,"fsimu",El_sig.fs,"lambda",1290,"bias",vbias,"u_pi",u_pi,"linewidth",laser_linewidth,"randomkey",pn_key).process(El_sig);
|
|
||||||
|
|
||||||
% Opt_sig.eye(fsym,7);
|
|
||||||
%
|
|
||||||
% figure(10)
|
|
||||||
% hold on
|
|
||||||
% scatter(El_sig.signal(1:100000)+vbias,(abs(Opt_sig.signal(1:100000)).^2)*1e3,0.1,'.','DisplayName','Modulator TF')
|
|
||||||
% ylim([0 4]);
|
|
||||||
% xlim([-u_pi/2, u_pi/2]+vbias);
|
|
||||||
% xlabel('Input in V')
|
|
||||||
% ylabel('abs(Output) in mW')
|
|
||||||
|
|
||||||
Optfilter = Filter('filtdegree',6,"f_cutoff",fsym.*0.7,"fs",fdac*kover,"filterType",filtertypes.gaussian,"active",true);
|
|
||||||
Opt_sig = Optfilter.process(Opt_sig);
|
|
||||||
|
|
||||||
% Opt_sig.spectrum("fignum",122,"displayname",['Tx SPectrum; PAM ',num2str(M)]);
|
|
||||||
|
|
||||||
Opt_sig = Amplifier("amp_mode","ideal_no_noise","gain_mode","output_power","amplification_db",0).process(Opt_sig);
|
|
||||||
|
|
||||||
i_ = wh.parameter.rop.length;
|
|
||||||
|
|
||||||
ber_ffe=zeros(i_);
|
|
||||||
|
|
||||||
patten=zeros(i_);
|
|
||||||
|
|
||||||
%%%%% Interference Signal Fiber Prop %%%%%%
|
|
||||||
|
|
||||||
Opt_sig = Fiber("fsimu",Opt_sig.fs,"fiber_length",link_length/1000,"alpha",0.3,"D",0,"lambda0",1310,"gamma",0,"Dslope",0.07).process(Opt_sig);
|
|
||||||
|
|
||||||
% Receiver ROP curve
|
|
||||||
parfor i = 1:i_
|
|
||||||
rop=wh.parameter.rop.values(i);
|
|
||||||
|
|
||||||
% Set ROP
|
|
||||||
Rx_sig = Amplifier("amp_mode","ideal_no_noise","gain_mode","output_power","amplification_db",rop).process(Opt_sig);
|
|
||||||
patten(i) = Rx_sig.power;
|
|
||||||
|
|
||||||
%%%%%% Square Law %%%%%%
|
|
||||||
Rx_sig = Photodiode("fsimu",fdac*kover,"dark_current",2e-08,"responsivity",1,"temperature",20,"nep",1.8e-11).process(Rx_sig);
|
|
||||||
|
|
||||||
%%%%%% Lowpass PhDiode %%%%%%
|
|
||||||
Rx_sig = Filter('filtdegree',2,"f_cutoff",70e9,"fs",fdac*kover,"filterType",filtertypes.gaussian,"active",true).process(Rx_sig);
|
|
||||||
|
|
||||||
%%%%%% Scope %%%%%%
|
|
||||||
fadc = 256e9;
|
|
||||||
Lp_scpe = Filter('filtdegree',4,"f_cutoff",100e9,"fs",fadc,"filterType",filtertypes.butterworth,"active",true);
|
|
||||||
Scpe_sig = Scope("fsimu",fdac*kover,"fadc",fadc,...
|
|
||||||
"delay",0,"fixed_delay",0,"filtertype",filtertypes.butterworth,...
|
|
||||||
"samplingdelay",0,"rand_samplingdelay",0,"freq_offset",0,"samp_jitter",0,...
|
|
||||||
"adcresolution",10,"quantbuffer",0.1,'block_dc',1,'lpf_active',1,'H_lpf',Lp_scpe).process(Rx_sig);
|
|
||||||
|
|
||||||
if precomp_mode == 1
|
|
||||||
freqresp.estimate(Scpe_sig,"save",true,"savePath",precomp_path,"fileName",precomp_fn);
|
|
||||||
freqresp.plot();
|
|
||||||
end
|
|
||||||
|
|
||||||
Scpe_sig.spectrum("displayname",'After Scope','fignum',123434);
|
|
||||||
|
|
||||||
%%%%%% Sample to 2x fsym %%%%%%
|
|
||||||
Scpe_sig = Scpe_sig.resample("fs_in",fadc,"fs_out",2*fsym);
|
|
||||||
|
|
||||||
%%%%%% Sync Rx signal with reference %%%%%%
|
|
||||||
[Scpe_sig,S] = Scpe_sig.tsynch("reference",Symbols,"fs_ref",fsym);
|
|
||||||
|
|
||||||
%%%%% EQUALIZE %%%%%%
|
|
||||||
Eq = FFE("epochs_tr",5,"epochs_dd",5,"len_tr",4096*2,"mu_dd",1e-4,"mu_tr",0,"order",25,"sps",2,"decide",0);
|
|
||||||
%Eq = VNLE("epochs_tr",5,"epochs_dd",5,"len_tr",4096*2,"mu_dd",[0.0004 0.0005 0.0006],"mu_tr",0,"order",[50,7,7],"sps",2,"decide",1);
|
|
||||||
|
|
||||||
if db_channelapproach
|
|
||||||
% ref symbols and transm. sequence are precoded
|
|
||||||
[EQ_sig, Noi] = Eq.process(Scpe_sig,Duobinary().encode(Symbols));
|
|
||||||
else
|
|
||||||
[EQ_sig, Noi] = Eq.process(Scpe_sig,Symbols);
|
|
||||||
end
|
|
||||||
|
|
||||||
if db_encode || db_channelapproach
|
|
||||||
EQ_sig = MLSE("DIR",[1,1],"duobinary_output",1,"M",M,"trellis_states",PAMmapper(M,0).levels).process(EQ_sig);
|
|
||||||
EQ_sig = Duobinary().decode(EQ_sig);
|
|
||||||
end
|
|
||||||
|
|
||||||
if postfilter
|
|
||||||
% Noi.spectrum("displayname",'Noise Spectrum','fignum',1234);
|
|
||||||
% EQ_sig.spectrum("displayname","Signal Spectrum","fignum",1234);
|
|
||||||
|
|
||||||
nc = 2;
|
|
||||||
burg_coeff = arburg(Noi.signal,nc);
|
|
||||||
|
|
||||||
EQ_sig = EQ_sig.filter(burg_coeff,1);
|
|
||||||
|
|
||||||
% EQ_sig.spectrum("displayname","Signal Spectrum after Postfilter","fignum",1234);
|
|
||||||
tic
|
|
||||||
EQ_sig = MLSE("DIR",burg_coeff,"duobinary_output",0,"M",M,"trellis_states",PAMmapper(M,0).levels).process(EQ_sig);
|
|
||||||
toc
|
|
||||||
% EQ_sig.spectrum("displayname","Signal Spectrum after MLSE","fignum",1234);
|
|
||||||
|
|
||||||
if 1
|
|
||||||
Noi.spectrum('displayname','Noise PSD','fignum',123)
|
|
||||||
[h,w] = freqz(1,burg_coeff,length(Noi),"whole",Noi.fs);
|
|
||||||
h = h/max(abs(h));
|
|
||||||
hold on
|
|
||||||
w_ = (w - Noi.fs/2);
|
|
||||||
plot(w_.*1e-9,20*log10(fftshift(h)),'DisplayName',['', num2str(nc), ' coefficients for burg alg.']);
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Rx_bits(i) = PAMmapper(M,0).demap(EQ_sig);
|
|
||||||
[~,errors_bm,ber_ffe(i),errors] = calc_ber(Rx_bits.signal,Bits.signal,"skip_front",100,"skip_end",150,"returnErrorLocation",1);
|
|
||||||
disp(['BER: ',sprintf('%.1E',ber_ffe(i)),' - - ROP: ',num2str(patten(i)),'dBm - - PAM-',num2str(M),' - - ',num2str(fsym*1e-9),' GBd']);
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
for i = 1:i_
|
|
||||||
rop=wh.parameter.rop.values(i);
|
|
||||||
|
|
||||||
wh.addValueToStorage(ber_ffe(i),'ber_ffe',M,datarate,rop);
|
|
||||||
wh.addValueToStorage(Rx_bits(i),'Rx_Bits',M,datarate,rop);
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
toc
|
|
||||||
|
|
||||||
filename = 'bla3';
|
|
||||||
wh.save(['C:\Users\sioe\Documents\MATLAB\imdd_simulation\projects\MPI_August\auswertung\',filename]);
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
disp('Simulation Done!')
|
|
||||||
|
|
||||||
|
|
||||||
cols = linspecer(8);
|
|
||||||
|
|
||||||
%cnt = cnt+1;
|
|
||||||
ber_ffe = wh.getStoValue('ber_ffe',M,datarate,wh.parameter.rop.values);
|
|
||||||
|
|
||||||
% Create the initial plot
|
|
||||||
|
|
||||||
figure(44);
|
|
||||||
a = gca;
|
|
||||||
hold on; % Retain the plot so new points can be added without complete redraw
|
|
||||||
|
|
||||||
plot(wh.parameter.rop.values,ber_ffe,"LineWidth",0.5,"LineStyle","-","Marker",".","MarkerSize",15,"DisplayName","FFE only");
|
|
||||||
yline(3.8e-3,'DisplayName','HD-FEC','LineStyle','--','HandleVisibility','off');
|
|
||||||
xlabel('Received Optical Power (dBm)');
|
|
||||||
ylabel('Bit Error Rate (BER)');
|
|
||||||
title('Bit Error Rate vs. ROP');
|
|
||||||
set(gca,'yscale','log');
|
|
||||||
set(gca,'Box','on');
|
|
||||||
grid on;
|
|
||||||
grid minor
|
|
||||||
legend
|
|
||||||
@@ -1,247 +0,0 @@
|
|||||||
|
|
||||||
%% Parameter to simulate and save
|
|
||||||
params = struct;
|
|
||||||
|
|
||||||
params.M = [4];
|
|
||||||
params.datarate = [184];
|
|
||||||
params.rop = [-5];
|
|
||||||
|
|
||||||
precomp_mode = 1; %0=do nothing ; 1= measure; 2=precomp active
|
|
||||||
postfilter = 0; % noise whiten. approach -> Postfilter + MLSE
|
|
||||||
|
|
||||||
db_precode = 0;
|
|
||||||
db_encode = 0;
|
|
||||||
db_channelapproach = 0;
|
|
||||||
|
|
||||||
if ismac
|
|
||||||
precomp_path = "/Users/silasoettinghaus/Documents/MATLAB/imdd_simulation/projects/standard_system";
|
|
||||||
else
|
|
||||||
precomp_path = "C:\Users\sioe\Documents\MATLAB\imdd_simulation\projects\standard_system\";
|
|
||||||
end
|
|
||||||
|
|
||||||
precomp_fn = "400G_simulative_setup";
|
|
||||||
usemrds = 0;
|
|
||||||
|
|
||||||
name = ['wh_',strrep(num2str(now),'.','')];
|
|
||||||
|
|
||||||
wh = DataStorage(params);
|
|
||||||
|
|
||||||
wh.addStorage("ber_ffe");
|
|
||||||
|
|
||||||
%% Init Params
|
|
||||||
link_length = 10000; %meter
|
|
||||||
pn_key = 2;
|
|
||||||
laser_linewidth = 0;
|
|
||||||
|
|
||||||
endcnt = prod(wh.dim);
|
|
||||||
cnt=0;
|
|
||||||
|
|
||||||
disp(['Start Simulation of ',num2str(endcnt),' loops...'])
|
|
||||||
tic
|
|
||||||
|
|
||||||
for M = wh.parameter.M.values
|
|
||||||
for datarate = wh.parameter.datarate.values
|
|
||||||
|
|
||||||
% SETUP HERE: %%
|
|
||||||
kover = 16;
|
|
||||||
Awg = M8196A("kover",kover);
|
|
||||||
fdac = Awg.fdac;
|
|
||||||
fsym = round(datarate / log2(M)) * 1e9;
|
|
||||||
rrcalpha = 0.05;
|
|
||||||
Pform = Pulseformer("fsym",fsym,"fdac",4*fsym,"pulse","rrc","pulselength",16,"rrcalpha",rrcalpha);
|
|
||||||
|
|
||||||
% MAIN SIGNAL
|
|
||||||
|
|
||||||
%%%%% Symbol Generation %%%%%%
|
|
||||||
[Digi_sig,Symbols,Bits] = PAMsource("fsym",fsym,"M",M,"order",18,"useprbs",0,...
|
|
||||||
"fs_out",Awg.fdac,"applyclipping",1,"clipfactor",1.5,...
|
|
||||||
"applypulseform",0,"pulseformer",Pform,"randkey",pn_key,...
|
|
||||||
"db_precode",db_precode,"db_encode",db_encode,...
|
|
||||||
"mrds_code",usemrds,"mrds_blocklength",512).process();
|
|
||||||
|
|
||||||
% Digi_sig.eye(fsym,M);
|
|
||||||
Digi_sig.spectrum("fignum",123434,"displayname",'Digital Tx Signal');
|
|
||||||
|
|
||||||
if precomp_mode == 1
|
|
||||||
freqresp = ChannelFreqResp("Nacq",1024,"Navg",64,"Ncp",63,'f_ref',Digi_sig.fs);
|
|
||||||
Digi_sig = freqresp.buildOFDM();
|
|
||||||
elseif precomp_mode == 2
|
|
||||||
Digi_sig = ChannelFreqResp("Nacq",1024,"Navg",64,"Ncp",63,'f_ref',Digi_sig.fs).precomp(Digi_sig,'maxampdb',1,'loadPath',precomp_path,'fileName',precomp_fn);
|
|
||||||
Digi_sig.spectrum("fignum",11,"displayname",'after precomp');
|
|
||||||
end
|
|
||||||
|
|
||||||
%%%%% AWG %%%%%%
|
|
||||||
El_sig = Awg.process(Digi_sig);
|
|
||||||
|
|
||||||
% El_sig.spectrum("displayname",'el','fignum',123434);
|
|
||||||
|
|
||||||
% El_sig.signal = awgn(El_sig.signal,-3,'measured',pn_key);
|
|
||||||
|
|
||||||
%%%%% Lowpass el. components %%%%%%
|
|
||||||
El_sig = Filter('filtdegree',2,"f_cutoff",60e9,"fs",fdac*kover,"filterType",filtertypes.butterworth,"active",true).process(El_sig);
|
|
||||||
|
|
||||||
%%%%% Electrical Driver Amplifier %%%%%%
|
|
||||||
El_sig = Amplifier("amp_mode","ideal_no_noise","gain_mode","gain","amplification_db",3).process(El_sig);
|
|
||||||
% El_sig = El_sig.setPower(6,"dBm");
|
|
||||||
|
|
||||||
fprintf('Driver output power: %s dBm\n', num2str(El_sig.power));
|
|
||||||
fprintf('Driver output peak voltage: %s Vpp \n', num2str(max(El_sig.signal)-min(El_sig.signal)));
|
|
||||||
|
|
||||||
|
|
||||||
% MAIN SIGNAL
|
|
||||||
%%%%% MODULATE E/O CONVERSION %%%%%%
|
|
||||||
vbias_rel = 0.5;
|
|
||||||
u_pi = 2.9;
|
|
||||||
vbias = -vbias_rel*u_pi;
|
|
||||||
|
|
||||||
[Opt_sig] = EML("mode",eml_mode.im_cosinus,"power",3,"fsimu",El_sig.fs,"lambda",1290,"bias",vbias,"u_pi",u_pi,"linewidth",laser_linewidth,"randomkey",pn_key).process(El_sig);
|
|
||||||
|
|
||||||
% Opt_sig.eye(fsym,7);
|
|
||||||
%
|
|
||||||
% figure(10)
|
|
||||||
% hold on
|
|
||||||
% scatter(El_sig.signal(1:100000)+vbias,(abs(Opt_sig.signal(1:100000)).^2)*1e3,0.1,'.','DisplayName','Modulator TF')
|
|
||||||
% ylim([0 4]);
|
|
||||||
% xlim([-u_pi/2, u_pi/2]+vbias);
|
|
||||||
% xlabel('Input in V')
|
|
||||||
% ylabel('abs(Output) in mW')
|
|
||||||
|
|
||||||
Optfilter = Filter('filtdegree',6,"f_cutoff",fsym.*0.7,"fs",fdac*kover,"filterType",filtertypes.gaussian,"active",true);
|
|
||||||
Opt_sig = Optfilter.process(Opt_sig);
|
|
||||||
|
|
||||||
% Opt_sig.spectrum("fignum",122,"displayname",['Tx SPectrum; PAM ',num2str(M)]);
|
|
||||||
|
|
||||||
Opt_sig = Amplifier("amp_mode","ideal_no_noise","gain_mode","output_power","amplification_db",0).process(Opt_sig);
|
|
||||||
|
|
||||||
i_ = wh.parameter.rop.length;
|
|
||||||
|
|
||||||
ber_ffe=zeros(i_);
|
|
||||||
|
|
||||||
patten=zeros(i_);
|
|
||||||
|
|
||||||
%%%%% Interference Signal Fiber Prop %%%%%%
|
|
||||||
|
|
||||||
Opt_sig = Fiber("fsimu",Opt_sig.fs,"fiber_length",link_length/1000,"alpha",0.3,"D",0,"lambda0",1310,"gamma",0,"Dslope",0.07).process(Opt_sig);
|
|
||||||
|
|
||||||
% Receiver ROP curve
|
|
||||||
for i = 1:i_
|
|
||||||
|
|
||||||
rop=wh.parameter.rop.values(i);
|
|
||||||
|
|
||||||
% Set ROP
|
|
||||||
Rx_sig = Amplifier("amp_mode","ideal_no_noise","gain_mode","output_power","amplification_db",rop).process(Opt_sig);
|
|
||||||
patten(i) = Rx_sig.power;
|
|
||||||
|
|
||||||
%%%%%% Square Law %%%%%%
|
|
||||||
Rx_sig = Photodiode("fsimu",fdac*kover,"dark_current",2e-08,"responsivity",1,"temperature",20,"nep",1.8e-11).process(Rx_sig);
|
|
||||||
|
|
||||||
%%%%%% Lowpass PhDiode %%%%%%
|
|
||||||
Rx_sig = Filter('filtdegree',2,"f_cutoff",70e9,"fs",fdac*kover,"filterType",filtertypes.gaussian,"active",true).process(Rx_sig);
|
|
||||||
|
|
||||||
%%%%%% Scope %%%%%%
|
|
||||||
fadc = 160e9;
|
|
||||||
Lp_scpe = Filter('filtdegree',4,"f_cutoff",63e9,"fs",fadc,"filterType",filtertypes.butterworth,"active",true);
|
|
||||||
Scpe_sig = Scope("fsimu",fdac*kover,"fadc",fadc,...
|
|
||||||
"delay",0,"fixed_delay",0,"filtertype",filtertypes.butterworth,...
|
|
||||||
"samplingdelay",0,"rand_samplingdelay",0,"freq_offset",0,"samp_jitter",0,...
|
|
||||||
"adcresolution",5.5,"quantbuffer",0.1,'block_dc',1,'lpf_active',1,'H_lpf',Lp_scpe).process(Rx_sig);
|
|
||||||
|
|
||||||
if precomp_mode == 1
|
|
||||||
freqresp.estimate(Scpe_sig,"save",true,"savePath",precomp_path,"fileName",precomp_fn);
|
|
||||||
freqresp.plot();
|
|
||||||
end
|
|
||||||
|
|
||||||
Scpe_sig.spectrum("displayname",'After Scope','fignum',123434);
|
|
||||||
|
|
||||||
%%%%%% Sample to 2x fsym %%%%%%
|
|
||||||
Scpe_sig = Scpe_sig.resample("fs_in",fadc,"fs_out",2*fsym);
|
|
||||||
|
|
||||||
%%%%%% Sync Rx signal with reference %%%%%%
|
|
||||||
[Scpe_sig,S] = Scpe_sig.tsynch("reference",Symbols,"fs_ref",fsym);
|
|
||||||
|
|
||||||
%%%%% EQUALIZE %%%%%%
|
|
||||||
Eq = FFE("epochs_tr",5,"epochs_dd",5,"len_tr",4096*2,"mu_dd",1e-4,"mu_tr",0,"order",25,"sps",2,"decide",0);
|
|
||||||
%Eq = VNLE("epochs_tr",5,"epochs_dd",5,"len_tr",4096*2,"mu_dd",[0.0004 0.0005 0.0006],"mu_tr",0,"order",[50,7,7],"sps",2,"decide",1);
|
|
||||||
|
|
||||||
if db_channelapproach
|
|
||||||
% ref symbols and transm. sequence are precoded
|
|
||||||
[EQ_sig, Noi] = Eq.process(Scpe_sig,Duobinary().encode(Symbols));
|
|
||||||
else
|
|
||||||
[EQ_sig, Noi] = Eq.process(Scpe_sig,Symbols);
|
|
||||||
end
|
|
||||||
|
|
||||||
if db_encode || db_channelapproach
|
|
||||||
EQ_sig = MLSE("DIR",[1,1],"duobinary_output",1,"M",M,"trellis_states",PAMmapper(M,0).levels).process(EQ_sig);
|
|
||||||
EQ_sig = Duobinary().decode(EQ_sig);
|
|
||||||
end
|
|
||||||
|
|
||||||
if postfilter
|
|
||||||
% Noi.spectrum("displayname",'Noise Spectrum','fignum',1234);
|
|
||||||
% EQ_sig.spectrum("displayname","Signal Spectrum","fignum",1234);
|
|
||||||
|
|
||||||
nc = 2;
|
|
||||||
burg_coeff = arburg(Noi.signal,nc);
|
|
||||||
|
|
||||||
EQ_sig = EQ_sig.filter(burg_coeff,1);
|
|
||||||
|
|
||||||
% EQ_sig.spectrum("displayname","Signal Spectrum after Postfilter","fignum",1234);
|
|
||||||
tic
|
|
||||||
EQ_sig = MLSE("DIR",burg_coeff,"duobinary_output",0,"M",M,"trellis_states",PAMmapper(M,0).levels).process(EQ_sig);
|
|
||||||
toc
|
|
||||||
% EQ_sig.spectrum("displayname","Signal Spectrum after MLSE","fignum",1234);
|
|
||||||
|
|
||||||
if 1
|
|
||||||
Noi.spectrum('displayname','Noise PSD','fignum',123)
|
|
||||||
[h,w] = freqz(1,burg_coeff,length(Noi),"whole",Noi.fs);
|
|
||||||
h = h/max(abs(h));
|
|
||||||
hold on
|
|
||||||
w_ = (w - Noi.fs/2);
|
|
||||||
plot(w_.*1e-9,20*log10(fftshift(h)),'DisplayName',['', num2str(nc), ' coefficients for burg alg.']);
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Rx_bits = PAMmapper(M,0).demap(EQ_sig);
|
|
||||||
[~,errors_bm,ber_ffe(i),errors] = calc_ber(Rx_bits.signal,Bits.signal,"skip_front",100,"skip_end",150,"returnErrorLocation",1);
|
|
||||||
disp(['BER: ',sprintf('%.1E',ber_ffe(i)),' - - ROP: ',num2str(patten(i)),'dBm - - PAM-',num2str(M),' - - ',num2str(fsym*1e-9),' GBd']);
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
for i = 1:i_
|
|
||||||
rop=wh.parameter.rop.values(i);
|
|
||||||
|
|
||||||
wh.addValueToStorage(ber_ffe(i),'ber_ffe',M,datarate,rop);
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
toc
|
|
||||||
|
|
||||||
% wh.save('C:\Users\Silas\Documents\MATLAB\imdd_simulation\projects\MPI_August\auswertung\')
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
disp('Simulation Done!')
|
|
||||||
|
|
||||||
|
|
||||||
cols = linspecer(8);
|
|
||||||
|
|
||||||
%cnt = cnt+1;
|
|
||||||
ber_ffe = wh.getStoValue('ber_ffe',M,datarate,wh.parameter.rop.values);
|
|
||||||
|
|
||||||
% Create the initial plot
|
|
||||||
|
|
||||||
figure(44);
|
|
||||||
a = gca;
|
|
||||||
hold on; % Retain the plot so new points can be added without complete redraw
|
|
||||||
|
|
||||||
plot(wh.parameter.rop.values,ber_ffe,"LineWidth",0.5,"LineStyle","-","Marker",".","MarkerSize",15,"DisplayName","FFE only");
|
|
||||||
yline(3.8e-3,'DisplayName','HD-FEC','LineStyle','--','HandleVisibility','off');
|
|
||||||
xlabel('Received Optical Power (dBm)');
|
|
||||||
ylabel('Bit Error Rate (BER)');
|
|
||||||
title('Bit Error Rate vs. ROP');
|
|
||||||
set(gca,'yscale','log');
|
|
||||||
set(gca,'Box','on');
|
|
||||||
grid on;
|
|
||||||
grid minor
|
|
||||||
legend
|
|
||||||
@@ -1,383 +0,0 @@
|
|||||||
|
|
||||||
%% Parameter to simulate and save
|
|
||||||
params = struct;
|
|
||||||
|
|
||||||
params.M = [4];
|
|
||||||
params.datarate = [448];
|
|
||||||
params.rop = [0];
|
|
||||||
params.sir = 45;
|
|
||||||
params.random_key_laser_phase = 10:20;
|
|
||||||
|
|
||||||
precomp_mode = 0; %0=do nothing ; 1= measure; 2=precomp active
|
|
||||||
postfilter = 1; % noise whiten. approach -> Postfilter + MLSE
|
|
||||||
|
|
||||||
db_precode = 0;
|
|
||||||
db_encode = 0;
|
|
||||||
db_channelapproach = 0;
|
|
||||||
|
|
||||||
laser_linewidth = 5e5;
|
|
||||||
random_key_sequence = 15;
|
|
||||||
random_key_laser_phase = 66;
|
|
||||||
sir = 20;
|
|
||||||
|
|
||||||
if ismac
|
|
||||||
precomp_path = "/Users/silasoettinghaus/Documents/MATLAB/imdd_simulation/projects/standard_system";
|
|
||||||
else
|
|
||||||
precomp_path = "C:\Users\Silas\Documents\MATLAB\imdd_simulation\projects\standard_system\";
|
|
||||||
end
|
|
||||||
|
|
||||||
precomp_fn = "400G_simulative_setup";
|
|
||||||
|
|
||||||
usemrds = 0;
|
|
||||||
|
|
||||||
name = ['wh_',strrep(num2str(now),'.','')];
|
|
||||||
|
|
||||||
wh = DataStorage(params);
|
|
||||||
|
|
||||||
wh.addStorage("ber_vnle");
|
|
||||||
wh.addStorage("ber_mlse");
|
|
||||||
|
|
||||||
%% Init Params
|
|
||||||
link_length = 1000; %meter
|
|
||||||
|
|
||||||
endcnt = prod(wh.dim);
|
|
||||||
cnt=0;
|
|
||||||
|
|
||||||
disp(['Start Simulation of ',num2str(endcnt),' loops...'])
|
|
||||||
tic
|
|
||||||
|
|
||||||
for random_key_laser_phase = wh.parameter.random_key_laser_phase.values
|
|
||||||
for M = wh.parameter.M.values
|
|
||||||
for datarate = wh.parameter.datarate.values
|
|
||||||
|
|
||||||
% SETUP HERE: %%
|
|
||||||
kover = 16;
|
|
||||||
M8199 = M8199B("kover",kover);
|
|
||||||
fdac = M8199.fdac;
|
|
||||||
fsym = round(datarate / log2(M)) * 1e9;
|
|
||||||
rrcalpha = 0.05;
|
|
||||||
Pform = Pulseformer("fsym",fsym,"fdac",4*fsym,"pulse","rrc","pulselength",16,"rrcalpha",rrcalpha);
|
|
||||||
|
|
||||||
% MAIN SIGNAL
|
|
||||||
|
|
||||||
%%%%% Symbol Generation MAIN %%%%%%
|
|
||||||
[Digi_sig,Symbols,Bits] = PAMsource("fsym",fsym,"M",M,"order",19,"useprbs",1,...
|
|
||||||
"fs_out",M8199.fdac,"applyclipping",0,"clipfactor",1.5,...
|
|
||||||
"applypulseform",0,"pulseformer",Pform,"randkey",random_key_sequence,...
|
|
||||||
"db_precode",db_precode,"db_encode",db_encode,...
|
|
||||||
"mrds_code",usemrds,"mrds_blocklength",512).process();
|
|
||||||
|
|
||||||
%%%%% Symbol Generation INTERFERENCE %%%%%%
|
|
||||||
[Digi_sig_I,Symbols_I,Bits_I] = PAMsource("fsym",fsym,"M",M,"order",19,"useprbs",0,...
|
|
||||||
"fs_out",M8199.fdac,"applyclipping",0,"clipfactor",1.5,...
|
|
||||||
"applypulseform",0,"pulseformer",Pform,"randkey",random_key_sequence+1,...
|
|
||||||
"db_precode",db_precode,"db_encode",db_encode,...
|
|
||||||
"mrds_code",usemrds,"mrds_blocklength",512).process();
|
|
||||||
|
|
||||||
% Digi_sig.eye(fsym,M);
|
|
||||||
% Digi_sig.normalize("mode","rms").spectrum("displayname",'Tx Signal','fignum',10);
|
|
||||||
|
|
||||||
if precomp_mode == 1 %measure
|
|
||||||
freqresp = ChannelFreqResp("Nacq",1024,"Navg",64,"Ncp",63,'f_ref',Digi_sig.fs);
|
|
||||||
Digi_sig = freqresp.buildOFDM();
|
|
||||||
Digi_sig_I = freqresp.buildOFDM();
|
|
||||||
elseif precomp_mode == 2 %apply
|
|
||||||
Digi_sig = ChannelFreqResp("Nacq",1024,"Navg",64,"Ncp",63,'f_ref',Digi_sig.fs).precomp(Digi_sig,'maxampdb',3,'loadPath',precomp_path,'fileName',precomp_fn);
|
|
||||||
Digi_sig_I = ChannelFreqResp("Nacq",1024,"Navg",64,"Ncp",63,'f_ref',Digi_sig_I.fs).precomp(Digi_sig_I,'maxampdb',3,'loadPath',precomp_path,'fileName',precomp_fn);
|
|
||||||
Digi_sig.spectrum("fignum",11,"displayname",'after precomp');
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%%%%% AWG MAIN %%%%%%
|
|
||||||
El_sig = M8199.process(Digi_sig);
|
|
||||||
|
|
||||||
%%%%% Lowpass el. components %%%%%%
|
|
||||||
El_sig = Filter('filtdegree',2,"f_cutoff",100e9,"fs",fdac*kover,"filterType",filtertypes.butterworth,"active",true).process(El_sig);
|
|
||||||
|
|
||||||
%%%%% Electrical Driver Amplifier %%%%%%
|
|
||||||
El_sig = Amplifier("amp_mode","ideal_no_noise","gain_mode","gain","amplification_db",3).process(El_sig);
|
|
||||||
|
|
||||||
fprintf('Driver output power: %s dBm\n', num2str(El_sig.power));
|
|
||||||
fprintf('Driver output peak voltage: %s Vpp \n', num2str(max(El_sig.signal)-min(El_sig.signal)));
|
|
||||||
|
|
||||||
% El_sig.spectrum("displayname",'Transmit PDS','fignum',10);
|
|
||||||
|
|
||||||
%%%%% AWG INTERFERENCE %%%%%%
|
|
||||||
El_sig_I = M8199.process(Digi_sig_I);
|
|
||||||
|
|
||||||
%%%%% Lowpass el. components %%%%%%
|
|
||||||
El_sig_I = Filter('filtdegree',3,"f_cutoff",100e9,"fs",fdac*kover,"filterType",filtertypes.butterworth,"active",true).process(El_sig_I);
|
|
||||||
|
|
||||||
%%%%% Electrical Driver Amplifier %%%%%%
|
|
||||||
El_sig_I = Amplifier("amp_mode","ideal_no_noise","gain_mode","gain","amplification_db",3).process(El_sig_I);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
% MAIN SIGNAL
|
|
||||||
%%%%% MODULATE E/O CONVERSION %%%%%%
|
|
||||||
vbias_rel = 0.5;
|
|
||||||
u_pi = 2.9;
|
|
||||||
vbias = -vbias_rel*u_pi;
|
|
||||||
|
|
||||||
[Opt_sig] = EML("mode",eml_mode.im_cosinus,"power",3,"fsimu",El_sig.fs,"lambda",1290,"bias",vbias,"u_pi",u_pi,"linewidth",laser_linewidth,"randomkey",random_key_laser_phase).process(El_sig);
|
|
||||||
Optfilter = Filter('filtdegree',3,"f_cutoff",110e9,"fs",fdac*kover,"filterType",filtertypes.gaussian,"active",true);
|
|
||||||
Opt_sig = Optfilter.process(Opt_sig);
|
|
||||||
Opt_sig = Amplifier("amp_mode","ideal_no_noise","gain_mode","output_power","amplification_db",0).process(Opt_sig);
|
|
||||||
|
|
||||||
[Opt_sig_I] = EML("mode",eml_mode.im_cosinus,"power",3,"fsimu",El_sig_I.fs,"lambda",1290,"bias",vbias,"u_pi",u_pi,"linewidth",laser_linewidth,"randomkey",random_key_laser_phase+1).process(El_sig_I);
|
|
||||||
Optfilter = Filter('filtdegree',3,"f_cutoff",110e9,"fs",fdac*kover,"filterType",filtertypes.gaussian,"active",true);
|
|
||||||
Opt_sig_I = Optfilter.process(Opt_sig_I);
|
|
||||||
Opt_sig_I = Amplifier("amp_mode","ideal_no_noise","gain_mode","output_power","amplification_db",0).process(Opt_sig_I);
|
|
||||||
|
|
||||||
|
|
||||||
%%%%% Interference Signal Fiber Prop 2x fiber length %%%%%%
|
|
||||||
Opt_sig_I = Fiber("fsimu",Opt_sig_I.fs,"fiber_length",2*link_length/1000,"alpha",0.3,"D",0,"lambda0",1310,"gamma",0,"Dslope",0.07).process(Opt_sig_I);
|
|
||||||
|
|
||||||
% ber=zeros(i_);
|
|
||||||
% patten=zeros(i_);
|
|
||||||
i_ = wh.parameter.rop.length;
|
|
||||||
j_ = wh.parameter.sir.length;
|
|
||||||
|
|
||||||
ber_vnle=zeros(i_,j_);
|
|
||||||
ber_mlse=zeros(i_,j_,3);
|
|
||||||
|
|
||||||
for j = 1:j_
|
|
||||||
|
|
||||||
sir = wh.parameter.sir.values(j);
|
|
||||||
|
|
||||||
%%%%% Set SIR %%%%%%
|
|
||||||
Opt_sig_I_atten = Amplifier("amp_mode","ideal_no_noise","gain_mode","output_power","amplification_db",Opt_sig.power-sir).process(Opt_sig_I);
|
|
||||||
|
|
||||||
%%%%% ADD Interference and Main Signal %%%%%%
|
|
||||||
Opt_sig_MPI = Opt_sig_I_atten + Opt_sig;
|
|
||||||
|
|
||||||
%%%%% Interference Signal Fiber Prop %%%%%%
|
|
||||||
Opt_sig_MPI = Fiber("fsimu",Opt_sig.fs,"fiber_length",link_length/1000,"alpha",0.3,"D",0,"lambda0",1310,"gamma",0,"Dslope",0.07).process(Opt_sig_MPI);
|
|
||||||
|
|
||||||
|
|
||||||
% Receiver ROP curve
|
|
||||||
for i = 1:i_
|
|
||||||
rop=wh.parameter.rop.values(i);
|
|
||||||
|
|
||||||
% Set ROP
|
|
||||||
Rx_sig = Amplifier("amp_mode","ideal_no_noise","gain_mode","output_power","amplification_db",rop).process(Opt_sig_MPI);
|
|
||||||
% patten(i) = Rx_sig.power;
|
|
||||||
|
|
||||||
%%%%%% Square Law %%%%%%
|
|
||||||
Rx_sig = Photodiode("fsimu",fdac*kover,"dark_current",2e-08,"responsivity",1,"temperature",20,"nep",1.8e-11).process(Rx_sig);
|
|
||||||
|
|
||||||
%%%%%% Lowpass PhDiode %%%%%%
|
|
||||||
Rx_sig = Filter('filtdegree',2,"f_cutoff",70e9,"fs",fdac*kover,"filterType",filtertypes.gaussian,"active",true).process(Rx_sig);
|
|
||||||
|
|
||||||
%%%%%% Scope %%%%%%
|
|
||||||
fadc = 256e9;
|
|
||||||
Lp_scpe = Filter('filtdegree',4,"f_cutoff",100e9,"fs",fadc,"filterType",filtertypes.butterworth,"active",true);
|
|
||||||
Scpe_sig = Scope("fsimu",fdac*kover,"fadc",fadc,...
|
|
||||||
"delay",0,"fixed_delay",0,"filtertype",filtertypes.butterworth,...
|
|
||||||
"samplingdelay",0,"rand_samplingdelay",0,"freq_offset",0,"samp_jitter",0,...
|
|
||||||
"adcresolution",10,"quantbuffer",0.1,'block_dc',1,'lpf_active',1,'H_lpf',Lp_scpe).process(Rx_sig);
|
|
||||||
|
|
||||||
if precomp_mode == 1
|
|
||||||
freqresp.estimate(Scpe_sig,"save",true,"savePath",precomp_path,"fileName",precomp_fn);
|
|
||||||
freqresp.plot();
|
|
||||||
end
|
|
||||||
|
|
||||||
% Scpe_sig_normalized = Scpe_sig.normalize("mode","rms");
|
|
||||||
%
|
|
||||||
% Scpe_sig_normalized.normalize("mode","rms").spectrum("displayname",'After Scope','fignum',23);
|
|
||||||
|
|
||||||
%%%%%% Sample to 2x fsym %%%%%%
|
|
||||||
Scpe_sig = Scpe_sig.resample("fs_in",fadc,"fs_out",2*fsym);
|
|
||||||
|
|
||||||
%%%%%% Sync Rx signal with reference %%%%%%
|
|
||||||
[Scpe_sig,S] = Scpe_sig.tsynch("reference",Symbols,"fs_ref",fsym);
|
|
||||||
|
|
||||||
%%%%% EQUALIZE %%%%%%
|
|
||||||
Eq = FFE("epochs_tr",5,"epochs_dd",5,"len_tr",4096*2,"mu_dd",1e-4,"mu_tr",0,"order",25,"sps",2,"decide",0);
|
|
||||||
% Eq = VNLE("epochs_tr",5,"epochs_dd",5,"len_tr",4096*2,"mu_dd",[0.0004 0.0005 0.0006],"mu_tr",0,"order",[50,7,7],"sps",2,"decide",1);
|
|
||||||
|
|
||||||
% Eq = EQ("Ne",[50,7,7],"Nb",[0,0,0],"training_length",4096*2,"training_loops",5,"dd_loops",5,"K",2,"DCmu",0.0,"DDmu",[0.0004 0.0004 0.0004 0.0004 ],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",1);
|
|
||||||
|
|
||||||
% Eq = FFE_Kalman("epochs_tr",5,"epochs_dd",5,"len_tr",4096*2,"mu_dd",1e-4,"mu_tr",0,"order",25,"sps",2,"decide",0);
|
|
||||||
|
|
||||||
% Eq = FFE_Kalman_Feedback("epochs_tr",5,"epochs_dd",5,"len_tr",4096*2,"mu_dd",1e-4,"mu_tr",0,"order",25,"sps",2,"decide",0);
|
|
||||||
|
|
||||||
% Eq = FFE_adaptive_decision("epochs_tr",5,"epochs_dd",5,"len_tr",4096*2,"mu_dd",1e-4,"mu_tr",0,"order",25,"sps",2,"decide",1,"buffer_length",80);
|
|
||||||
|
|
||||||
% Eq = FFE_DCremoval("epochs_tr",5,"epochs_dd",5,"len_tr",4096*2,"mu_dd",1e-4,"mu_tr",0,"order",25,"sps",2,"decide",0,"mu_dc",0.05,"dc_buffer_len",100);
|
|
||||||
%
|
|
||||||
% Eq = EQ("Ne",[50,7,7],"Nb",[0,0,0],"training_length",4096*2,"training_loops",5,"dd_loops",5,"K",2,"DCmu",0.0,"DDmu",[0.0004 0.0004 0.0004 0.0004 ],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",1);
|
|
||||||
|
|
||||||
if db_channelapproach
|
|
||||||
% ref symbols and transm. sequence are precoded
|
|
||||||
[EQ_sig, Noi] = Eq.process(Scpe_sig,Duobinary().encode(Symbols));
|
|
||||||
|
|
||||||
EQ_sig = MLSE("DIR",[1,1],"duobinary_output",1,"M",M,"trellis_states",PAMmapper(M,0).levels).process(EQ_sig);
|
|
||||||
EQ_sig = Duobinary().decode(EQ_sig);
|
|
||||||
Rx_bits = PAMmapper(M,0).demap(EQ_sig);
|
|
||||||
[~,~,ber_vnle(i,j),~] = calc_ber(Rx_bits.signal,Bits.signal,"skip_front",100,"skip_end",150,"returnErrorLocation",1);
|
|
||||||
|
|
||||||
|
|
||||||
EQ_sig.spectrum('displayname','EQ DB Out','fignum',12345,'normalizeTo0dB',0,'normalizeToNyquist',0,'color',cols(3,:));
|
|
||||||
Noi.spectrum('displayname','Noise PSD optimal','fignum',1234,'normalizeTo0dB',0,'normalizeToNyquist',0,'color',cols(4,:));
|
|
||||||
|
|
||||||
|
|
||||||
elseif db_encode
|
|
||||||
|
|
||||||
[EQ_sig, Noi] = Eq.process(Scpe_sig,Symbols);
|
|
||||||
EQ_sig = MLSE("DIR",[1,1],"duobinary_output",1,"M",M,"trellis_states",PAMmapper(M,0).levels).process(EQ_sig);
|
|
||||||
EQ_sig = Duobinary().decode(EQ_sig);
|
|
||||||
|
|
||||||
elseif postfilter
|
|
||||||
|
|
||||||
[EQ_sig, Noi] = Eq.process(Scpe_sig,Symbols);
|
|
||||||
|
|
||||||
%%% REMOVE DC peak from Noi PSD
|
|
||||||
S = Noi.signal;
|
|
||||||
N1 = 1001;
|
|
||||||
|
|
||||||
% recursion
|
|
||||||
% Initialize the moving sum for the first window
|
|
||||||
half_window = (N1 - 1) / 2;
|
|
||||||
moving_sum = sum(S(1:N1));
|
|
||||||
|
|
||||||
% Calculate the first element of R1
|
|
||||||
S_(1:half_window+1) = S(1:half_window+1) - (moving_sum / N1);
|
|
||||||
|
|
||||||
% Loop over the signal and apply the recursive moving average subtraction
|
|
||||||
for n = (half_window+2):(length(S)-half_window)
|
|
||||||
% Update the moving sum by subtracting the oldest value and adding the new one
|
|
||||||
moving_sum = moving_sum - S(n-half_window-1) + S(n+half_window);
|
|
||||||
|
|
||||||
% Calculate the new value of R1
|
|
||||||
S_(n) = S(n) - (moving_sum / N1);
|
|
||||||
end
|
|
||||||
|
|
||||||
S_(n+1:length(S)) = S(n+1:end) - (moving_sum / N1);
|
|
||||||
Noi.signal = S_;
|
|
||||||
%%% END REMOVE DC PEAK %%%
|
|
||||||
|
|
||||||
Rx_bits = PAMmapper(M,0).demap(EQ_sig);
|
|
||||||
[~,~,ber_vnle(i,j),~] = calc_ber(Rx_bits.signal,Bits.signal,"skip_front",100,"skip_end",150,"returnErrorLocation",1);
|
|
||||||
|
|
||||||
EQ_sig.spectrum('displayname','EQ Out','fignum',12345,'normalizeTo0dB',0,'normalizeToNyquist',0,'color',cols(1,:));
|
|
||||||
|
|
||||||
|
|
||||||
Noi.spectrum('displayname','Noise PSD optimal','fignum',22,'normalizeTo0dB',1,'normalizeToNyquist',0,'color',cols(2,:));
|
|
||||||
|
|
||||||
for nc = 1:3
|
|
||||||
|
|
||||||
burg_coeff = arburg(Noi.signal,nc);
|
|
||||||
|
|
||||||
EQ_sig_filt = EQ_sig.filter(burg_coeff,1);
|
|
||||||
|
|
||||||
% EQ_sig.spectrum("displayname","Signal Spectrum after Postfilter","fignum",1234);
|
|
||||||
|
|
||||||
EQ_sig_mlse = MLSE("DIR",burg_coeff,"duobinary_output",0,"M",M,"trellis_states",PAMmapper(M,0).levels).process(EQ_sig_filt);
|
|
||||||
|
|
||||||
% EQ_sig.spectrum("displayname","Signal Spectrum after MLSE","fignum",1234);
|
|
||||||
|
|
||||||
if 1
|
|
||||||
cols = linspecer(12);
|
|
||||||
|
|
||||||
% EQ_sig_filt.normalize('mode','rms').spectrum('displayname','Noise PSD','fignum',1234,'normalizeTo0dB',1,'normalizeToNyquist',0,'color',cols(nc+2,:));
|
|
||||||
|
|
||||||
[h,w] = freqz(1,burg_coeff,length(Noi),"whole",Noi.fs);
|
|
||||||
% h = 1./h;
|
|
||||||
h = h/max(abs(h));
|
|
||||||
hold on
|
|
||||||
w_ = (w - Noi.fs/2);
|
|
||||||
figure(22)
|
|
||||||
plot(w_.*1e-9,20*log10(fftshift(h)),'DisplayName',['', num2str(nc), ' coefficients for burg alg.']);
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
Rx_bits = PAMmapper(M,0).demap(EQ_sig_mlse);
|
|
||||||
[~,errors_bm,ber_mlse(i,j,nc),errors] = calc_ber(Rx_bits.signal,Bits.signal,"skip_front",100,"skip_end",150,"returnErrorLocation",1);
|
|
||||||
% disp(['BER: ',sprintf('%.1E',ber_mlse(i,j)),' - - ROP: ',num2str(patten(i)),'dBm - - PAM-',num2str(M),' - - ',num2str(fsym*1e-9),' GBd']);
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[EQ_sig, Noi] = Eq.process(Scpe_sig,Symbols);
|
|
||||||
|
|
||||||
if 0
|
|
||||||
Noi.spectrum('displayname','Noise PSD','fignum',123,'normalizeTo0dB',1,'normalizeToNyquist',1);
|
|
||||||
EQ_sig.plot("displayname",'After EQ','fignum',1113);
|
|
||||||
end
|
|
||||||
%
|
|
||||||
Rx_bits = PAMmapper(M,0).demap(EQ_sig);
|
|
||||||
[~,errors_bm,ber_vnle(i,j),errors] = calc_ber(Rx_bits.signal,Bits.signal,"skip_front",100,"skip_end",150,"returnErrorLocation",1);
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
for j = 1:j_
|
|
||||||
sir = wh.parameter.sir.values(j);
|
|
||||||
for i = 1:i_
|
|
||||||
rop=wh.parameter.rop.values(i);
|
|
||||||
|
|
||||||
wh.addValueToStorage(ber_vnle(i,j),'ber_vnle',M,datarate,rop,sir,random_key_laser_phase);
|
|
||||||
wh.addValueToStorage(ber_mlse(i,j,:),'ber_mlse',M,datarate,rop,sir,random_key_laser_phase);
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
toc
|
|
||||||
|
|
||||||
% wh.save('C:\Users\Silas\Documents\MATLAB\imdd_simulation\projects\MPI_August\auswertung\')
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
disp('Simulation Done!')
|
|
||||||
|
|
||||||
ber_mlse=[];
|
|
||||||
ber_vnle=[];
|
|
||||||
cols = linspecer(8);
|
|
||||||
random_key_laser_phase_ = wh.parameter.random_key_laser_phase.values;
|
|
||||||
cnt = 0;
|
|
||||||
for r = random_key_laser_phase_
|
|
||||||
cnt = cnt+1;
|
|
||||||
ber_mlse(cnt,:,1:3) = wh.getStoValue('ber_mlse',M,datarate,wh.parameter.rop.values(1),wh.parameter.sir.values,r);
|
|
||||||
ber_vnle(cnt,:,1) = wh.getStoValue('ber_vnle',M,datarate,wh.parameter.rop.values(1),wh.parameter.sir.values,r);
|
|
||||||
end
|
|
||||||
|
|
||||||
ber_mlse=squeeze(mean(ber_mlse,1));
|
|
||||||
ber_vnle = mean(ber_vnle,1);
|
|
||||||
% Create the initial plot
|
|
||||||
|
|
||||||
figure(466);
|
|
||||||
a = gca;
|
|
||||||
hold on; % Retain the plot so new points can be added without complete redraw
|
|
||||||
|
|
||||||
dispname = ['Lw: ',num2str(laser_linewidth.*1e-6),' MHz'];
|
|
||||||
cols = linspecer(6);
|
|
||||||
plot(wh.parameter.sir.values,ber_vnle,"LineWidth",0.5,"LineStyle","--","Marker",".","MarkerSize",15,"DisplayName",['PAM',num2str(M),' VNLE ',dispname],'Color',cols(1,:));
|
|
||||||
plot(wh.parameter.sir.values,ber_mlse(:,1),"LineWidth",0.5,"LineStyle","--","Marker",".","MarkerSize",15,"DisplayName",['PAM',num2str(M),'MLSE 1 ',dispname],'Color',cols(2,:));
|
|
||||||
plot(wh.parameter.sir.values,ber_mlse(:,2),"LineWidth",0.5,"LineStyle","--","Marker",".","MarkerSize",15,"DisplayName",['PAM',num2str(M),'MLSE 2',dispname],'Color',cols(3,:));
|
|
||||||
plot(wh.parameter.sir.values,ber_mlse(:,3),"LineWidth",0.5,"LineStyle","--","Marker",".","MarkerSize",15,"DisplayName",['PAM',num2str(M),'MLSE 3',dispname],'Color',cols(4,:));
|
|
||||||
|
|
||||||
yline(3.8e-3,'DisplayName','HD-FEC','LineStyle','--','HandleVisibility','off');
|
|
||||||
xlabel('Received Optical Power (dBm)');
|
|
||||||
ylabel('Bit Error Rate (BER)');
|
|
||||||
title('Bit Error Rate vs. ROP');
|
|
||||||
set(gca,'yscale','log');
|
|
||||||
set(gca,'Box','on');
|
|
||||||
grid on;
|
|
||||||
grid minor
|
|
||||||
legend
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user