gNB.NDLRB = 20;
gNB.SubcarrierSpacing = 30; % 15, 30, 60, 120, 240, 480 (kHz)
gNB.WaveformType = 'CP-OFDM'; % 'CP-OFDM', 'W-OFDM' or 'F-OFDM'
gNB.CyclicPrefix = 'Normal'; % 'Normal' or 'Extended'
gNB.UseDCSubcarrier = 'On'; % 'On' or 'Off'
gNB.NCellID = 1; % Cell identity
% DL-SCH/PDSCH parameters ----------------------------------------
gNB.PDSCH.TargetCodeRate = 0.5; % Code rate used to calculate transport block sizes
gNB.PDSCH.CodingType = 'LDPC'; % Set to 'LDPC' for 5G DL-SCH or 'Turbo' for LTE DL-SCH
gNB.PDSCH.PRBSet = 0:0; % PDSCH PRB allocation
gNB.PDSCH.SymbolSet = 0:13; % PDSCH symbol allocation in slot
gNB.PDSCH.Modulation = '16QAM'; % 'QPSK', '16QAM', '64QAM', '256QAM'
gNB.PDSCH.NLayers = 2; % Number of PDSCH layers
gNB.PDSCH.NTxAnts = 8; % Number of PDSCH transmission antennas
gNB.PDSCH.EnableHARQ = true; % Enable/disable HARQ, if disabled, single transmission with
% RV=0, i.e. no retransmissions
% DM-RS configuration (TS 38.211 section 7.4.1.1) ---------------------
gNB.PDSCH.PortSet = [0,2]; % DM-RS ports to use for the layers
gNB.PDSCH.PDSCHMappingType = 'A'; % PDSCH mapping type ('A'(slot-wise),'B'(non slot-wise))
gNB.PDSCH.DL_DMRS_typeA_pos = 2; % Mapping type A only. First DM-RS symbol position (2,3)
gNB.PDSCH.DL_DMRS_max_len = 1; % Number of front-loaded DM-RS symbols
% (1(single symbol),2(double symbol))
gNB.PDSCH.DL_DMRS_add_pos = 0; % Additional DM-RS symbol positions (max range 0...3)
gNB.PDSCH.DL_DMRS_config_type = 2; % DM-RS configuration type (1,2)
gNB.PDSCH.NIDNSCID = 1; % Scrambling identity (0...65535)
gNB.PDSCH.NSCID = 0; % Scrambling initialization (0,1)
% SS burst configuration -------------------------------------------
gNB.SSBurst.BurstType = 'CaseB'; % 30kHz subcarrier spacing
gNB.SSBurst.SSBTransmitted = [0 0 0 0 0 0 0 0]; % Bitmap indicating blocks transmitted
%
in the burst. I disabled all SSB transmission
%
just to simplify the PDSCH/DMRS resource mapping
gNB.SSBurst.SSBPeriodicity = 10; % SS burst set periodicity in ms (5, 10, 20, 40, 80, 160)
gNB.SSBurst.SubcarrierOffset = 0; % SSB location in frequency domain
pdsch = gNB.PDSCH;
% Create SS burst waveform and information structure and display a plot -------------------
ssburst = gNB.SSBurst;
ssburst.DisplayBurst = false;
[ssbWaveform,~,ssbInfo] = h5gSSBurst(gNB,ssburst);
% Demodulate SS burst waveform using data numerology - note that depending
% on subcarrier spacings, the SS burst content may not be orthogonal with
% the data subcarriers
ssbGrid = h5gOFDMDemodulate(gNB,ssbWaveform);
waveformInfo = h5gOFDMInfo(gNB);
grid = zeros(waveformInfo.NSubcarriers,waveformInfo.SymbolsPerSlot,pdsch.NLayers);
% Create PDSCH and PDSCH DM-RS indices
[pdschIndices,pdschDmrsIndices,dmrsSymbols] = h5gPDSCHResources(gNB,pdsch);
% this is just to print out dmrs symbol and dmrs location (RE index)
pdschDmrsIndices
dmrsSymbols
% Mark PDSCH and PDSCH DM-RS positions in the grid
grid(pdschIndices) = 2;
grid(pdschDmrsIndices) = 3;
% Mark SS burst positions in the grid
grid(abs(ssbGrid)>=0.5) = grid(abs(ssbGrid)>=0.5) + 1;
grid(abs(ssbGrid)<0.5 & abs(ssbGrid)>=0.1) = grid(abs(ssbGrid)<0.5 & abs(ssbGrid)>=0.1) + 0.3;
grid(abs(ssbGrid)<0.1 & abs(ssbGrid)>0.03) = grid(abs(ssbGrid)<0.1 & abs(ssbGrid)>0.03) + 0.1;
% Plot DMRS in the full grid and magnified (PDSCH/DMRS only) grid
subplot(2,2,1);
imagesc(abs(grid(:,:,1)));
axis xy;
set(gca,'xticklabel',{'1','3','5','7','9','11','13'});
% Create a legend for the different channels / signals, this is
% achieved by drawing off-plot patches with the appropriate colors
% then adding a legend
hold on;
patch([-2 -3 -3 -2],[-2 -2 -3 -3],1);
patch([-2 -3 -3 -2],[-2 -2 -3 -3],2);
patch([-2 -3 -3 -2],[-2 -2 -3 -3],3);
legend('SS burst','PDSCH','PDSCH DM-RS');
% Add axis labels and title
ylabel('Subcarriers');
xlabel('OFDM symbols');
title(sprintf('Resource Grid Layer 0 \n SCS=%dkHz, NDLRB=%d, Port=%d',...
gNB.SubcarrierSpacing,gNB.NDLRB,1000 + pdsch.PortSet(1)));
subplot(2,2,2);
imagesc(abs(grid(:,:,1)));
axis xy;
ylim([pdsch.PRBSet(1) pdsch.PRBSet(end)+1]*12);
set(gca,'xtick',1:14);
set(gca,'xticklabel',{'0','1','2','3','4','5','6','7','8','9','10','11','12','13'});
title('PDSCH/DMRS Only');
subplot(2,2,3);
imagesc(abs(grid(:,:,2)));
axis xy;
set(gca,'xticklabel',{'1','3','5','7','9','11','13'});
% Create a legend for the different channels / signals, this is
% achieved by drawing off-plot patches with the appropriate colors
% then adding a legend
hold on;
patch([-2 -3 -3 -2],[-2 -2 -3 -3],1);
patch([-2 -3 -3 -2],[-2 -2 -3 -3],2);
patch([-2 -3 -3 -2],[-2 -2 -3 -3],3);
legend('SS burst','PDSCH','PDSCH DM-RS');
% Add axis labels and title
ylabel('Subcarriers');
xlabel('OFDM symbols');
title(sprintf('Resource Grid Layer 1 \n SCS=%dkHz, NDLRB=%d, Port=%d',...
gNB.SubcarrierSpacing,gNB.NDLRB,1000 + pdsch.PortSet(1)));
subplot(2,2,4);
imagesc(abs(grid(:,:,2)));
axis xy;
ylim([pdsch.PRBSet(1) pdsch.PRBSet(end)+1]*12);
set(gca,'xtick',1:14);
set(gca,'xticklabel',{'0','1','2','3','4','5','6','7','8','9','10','11','12','13'});
title('PDSCH/DMRS Only');
drawnow;
set(gcf, 'Position', [200, 200, 700, 700])
|