SRS-Resource ::= SEQUENCE {
srs-ResourceId SRS-ResourceId,
nrofSRS-Ports ENUMERATED {port1, ports2, ports4},
ptrs-PortIndex ENUMERATED {n0, n1 } OPTIONAL, -- Need R
transmissionComb CHOICE {
n2 SEQUENCE {
combOffset-n2 INTEGER (0..1),
cyclicShift-n2 INTEGER (0..7)
},
n4 SEQUENCE {
combOffset-n4 INTEGER (0..3),
cyclicShift-n4 INTEGER (0..11)
}
},
resourceMapping SEQUENCE {
startPosition INTEGER (0..5),
nrofSymbols ENUMERATED {n1, n2, n4},
repetitionFactor ENUMERATED {n1, n2, n4}
},
freqDomainPosition INTEGER (0..67),
freqDomainShift INTEGER (0..268),
freqHopping SEQUENCE {
c-SRS INTEGER (0..63),
b-SRS INTEGER (0..3),
b-hop INTEGER (0..3)
},
groupOrSequenceHopping ENUMERATED { neither, groupHopping, sequenceHopping },
resourceType CHOICE {
aperiodic SEQUENCE {
...
},
semi-persistent SEQUENCE {
periodicityAndOffset-sp SRS-PeriodicityAndOffset,
...
},
periodic SEQUENCE {
periodicityAndOffset-p SRS-PeriodicityAndOffset,
...
}
},
sequenceId INTEGER (0..1023),
spatialRelationInfo SRS-SpatialRelationInfo OPTIONAL, -- Need R
...,
[[
resourceMapping-r16 SEQUENCE {
startPosition-r16 INTEGER (0..13),
nrofSymbols-r16 ENUMERATED {n1, n2, n4},
repetitionFactor-r16 ENUMERATED {n1, n2, n4}
} OPTIONAL -- Need R
]]
}
function [csrs,bsrs] = hSRSBandwidthConfiguration(srs, NRB)
% [CSRS,BSRS] = hBandwidthConfiguration(SRS, NRB) returns the SRS
% bandwidth configuration parameters CSRS and BSRS required to transmit an
% SRS in a bandwidth specified by NRB. The function calculates CSRS and
% BSRS considering the SRS properties FrequencyStart and NRRC, so the
% available bandwidth NRB is reduced by the frequency origin of the SRS.
% For frequency hopping cases, the value of BSRS returned is equal to that
% of the BSRS property in the input SRS configuration object.
f0 = hSRSFrequencyOrigin(srs);
error('The available bandwidth is not sufficient to allocate an SRS transmission. Increase the carrier bandwidth or configure the SRS in a lower frequency.' )
% For frequency hopping configurations
if srs.BHop >= srs.BSRS && nargout == 2 % No frequency hopping and BSRS is requested
% Initialize gap between SRS frequency allocation and carrier bandwidth
% Find the appropriate CSRS for each BSRS that minimizes the gap only
% in non-hopping cases. For freq. hopping, find the value of CSRS only.
% NRB allocated to the SRS for BSRS = b and all CSRS
srsNRBb = srs.BandwidthConfigurationTable{:,2*(b+1)};
mSRSbMax = max( srsNRBb( srsNRBb <= NRB ));
% Calculate gap between SRS allocation and carrier bandwidth
csrs = srs.BandwidthConfigurationTable{ srsNRBb == mSRSbMax ,1};
function out = hSRSNumberOfSubbandsOrHoppingPatterns(srs)
% N = hSRSNumberOfSubbandsOrHoppingPatterns(SRS) returns the number of
% unique SRS subbands or frequency-hopping patterns N configurable by the
% SRS property NRRC. An SRS subband is the frequency band allocated for SRS
% in a given OFDM symbol (See SRS property NRBPerTransmission). N is
% calculated using TS 38.211 Table 6.4.1.4.3-1 for the bandwidth
% configuration parameters CSRS, BSRS, and BHop specified in the SRS
% configuration object SRS.
bwct = nrSRSConfig.BandwidthConfigurationTable{:,:};
if srs.BHop < srs.BSRS % Number of unique frequency-hopping patterns
else % Number of unique SRS subbands
out = prod(bwct(srs.CSRS+1,2*(b0:srs.BSRS)+3));
function [Grid,dispGrid] = hSRSGrid(carrier,srs,Duration,displayGrid,chplevels)
% [GRID,DISPGRID] = hSRSGrid(CARRIER,SRS,DURATION,DISPLAYGRID,CHPLEVELS)
% returns a multi-slot OFDM resource grid GRID containing a set of sounding
% reference signals in a carrier, as specified by the configuration objects
% CARRIER and SRS. This function also returns a scaled version of the grid
% used for display purposes. The optional input DURATION (Default 1)
% specifies the number of slots of the generated grid. The resource grid
% can be displayed using the optional input DISPLAYGRID (Default false).
% CHPLEVELS specifies the channel power levels for display purposes only
% and it must be of the same size as SRS.
chplevels = 1:-1/numSRS:1/numSRS;
SymbolsPerSlot = carrier.SymbolsPerSlot;
emptySlotGrid = nrResourceGrid(carrier,max([srs(:).NumSRSPorts])); % Initialize slot grid
% Create the SRS symbols and indices and populate the grid with the SRS symbols
Grid = repmat(emptySlotGrid,1,Duration);
dispGrid = repmat(emptySlotGrid,1,Duration); % Frame-size grid for display
slotGrid = emptySlotGrid;
dispSlotGrid = emptySlotGrid; % Slot-size grid for display
srsIndices = nrSRSIndices(carrier,srs(ich));
srsSymbols = nrSRS(carrier,srs(ich));
slotGrid(srsIndices) = srsSymbols;
dispSlotGrid(srsIndices) = chplevels(ich)*srsSymbols; % Scale the SRS for display only
OFDMSymIdx = ns*SymbolsPerSlot + (1:SymbolsPerSlot);
Grid(:,OFDMSymIdx,:) = slotGrid;
dispGrid(:,OFDMSymIdx,:) = dispSlotGrid;
carrier.NSlot = carrier.NSlot+1;
plotGrid(dispGrid(:,:,1),chplevels,"SRS " + (1:numSRS)');
function varargout = plotGrid(Grid,chplevels,leg)
% plotGrid(GRID, CHPLEVEL,LEG) displays a resource grid GRID containing
% channels or signals at different power levels CHPLEVEL and create a
% legend for these using a cell array of character vector LEG
chpscale = length(cmap); % Scaling factor
image(0:size(Grid,2)-1,(0:size(Grid,1)-1)/12,chpscale*abs(Grid(:,:,1))); % Multiplied with scaling factor for better visualization
title('Carrier Grid Containing SRS')
xlabel('OFDM Symbol'); ylabel('RB');
clevels = chpscale*chplevels(:);
L = line(ones(N),ones(N),'LineWidth',8); % Generate lines
% Index the color map and associate the selected colors with the lines
set(L,{'color'},mat2cell(cmap( min(1+fix(clevels),length(cmap) ),:),ones(1,N),3)); % Set the colors according to cmap
function hSRSAnnotations(carrier,srs)
% hSRSAnnotations(carrier,srs) adds annotation to the current figure
% indicating the frequency origin of the SRS and the number of RB used per
% OFDM symbol for the configuration objects CARRIER and SRS.
% Calculate the frequency origin of the first SRS symbol
f0 = hSRSFrequencyOrigin(srs);
set(hfig,'Units','Normalized');
Sym0 = srs.SymbolStart-0.5;
if isnumeric(srs.SRSPeriod)
Sym0 = srs.SRSPeriod(2)*carrier.SymbolsPerSlot + srs.SymbolStart-0.5;
IP = get(gca,'Position');
% Y-coordinate in the current axes of the SRS freq position f0
Yf0 = f0/carrier.NSizeGrid*IP(4)+IP(2);
Xc = Sym0/((carrier.NSlot+1)*carrier.SymbolsPerSlot)*IP(3)+IP(1);
% Add annotation to the figure including f0 in RB
if f0/carrier.NSizeGrid > 0.08 % Only plot f0 when there is enough space in the y-axis
% Create doublearrow for F0
annotation(hfig,'doublearrow',Xc*[1 1], [YMin Yf0],...
str = sprintf('$$F_0 = %d $$ RB', f0);
Ystr = f0/carrier.NSizeGrid/2;
text(gca,(Xc-IP(1))/IP(3)-0.25, Ystr,str,...
'Color',[1 0.4 0.15],'FontSize',14, ...
'Units','Normalized','Interpreter','latex');
% Create doublearrow from f0 and spanning the SRS bandwidth
Yf1 = Yf0 + srs.NRBPerTransmission/carrier.NSizeGrid*IP(4);
annotation(hfig,'doublearrow',Xc*[1 1], [Yf0 Yf1],...
str = sprintf('$$\\textrm{NRB}_T = %d $$ RB', srs.NRBPerTransmission);
Ystr = (f0 + 0.5*srs.NRBPerTransmission)/carrier.NSizeGrid;
text(gca,(Xc-IP(1))/IP(3)-0.32, Ystr ,str,...
'Color',[1 0.4 0.15],'FontSize',14, ...
'Units','Normalized','Interpreter','latex');
function f0 = hSRSFrequencyOrigin(srs)
% Calculate the frequency origin of the first SRS symbol in a slot
NSBTable = hSRSNumberOfSubbandsOrHoppingPatterns(srs);
NRBt = srs.NRBPerTransmission;
% Origin of the SRS in frequency in RB
f0 = srs.FrequencyStart + NRBt*mod(floor(4*srs.NRRC/NRBt),NSBTable);
function [NRRC,NRB] = hNRRCSet(srs)
% Calculate the values of NRRC that generate a unique set of orthogonal SRS in frequency
if srs.BHop < srs.BSRS % Frequency-hopping cases
NRB = srs(1).NRB; % Hopping bandwidth
NRB = nrSRSConfig.BandwidthConfigurationTable{srs(1).CSRS+1,2};
% Number of frequency-hopping patterns or SRS subbands depending on the values of BSRS and BHop
N = hSRSNumberOfSubbandsOrHoppingPatterns(srs);