5#include "nr-pm-search.h"
12NS_LOG_COMPONENT_DEFINE(
"NrPmSearch");
13NS_OBJECT_ENSURE_REGISTERED(NrPmSearch);
19 TypeId(
"ns3::NrPmSearch")
21 .AddAttribute(
"RankLimit",
22 "Max MIMO rank is minimum of num UE ports, num gNB ports, and RankLimit",
23 UintegerValue(UINT8_MAX),
25 MakeUintegerChecker<uint8_t>(1, UINT8_MAX))
26 .AddAttribute(
"SubbandSize",
27 "Size of subband in PRBs for downsampling",
30 MakeUintegerChecker<uint8_t>(1, 32))
32 "DownsamplingTechnique",
33 "Algorithm used to downsample PRBs into SBs",
46 : m_downsamplingUniRand(CreateObject<UniformRandomVariable>())
59 m_nGnbPorts = isDualPol ? 2 * numHPorts * numVPorts : numHPorts * numVPorts;
86 size_t prbs = channelMatrix.GetNumPages();
92 "Bandwidth parts with less than 24 PRBs should have subbands of size 1");
95 else if (prbs >= 24 && prbs <= 72)
98 "Bandwidth parts with 24<=x<=72 PRBs should have subbands of size 4 or 8");
100 else if (prbs >= 73 && prbs <= 144)
103 "Bandwidth parts with 73<=x<=144 PRBs should have subbands of size 8 or 16");
105 else if (prbs >= 145 && prbs <= 275)
109 "Bandwidth parts with 145<=x<=275 PRBs should have subbands of size 16 or 32");
113 NS_ABORT_MSG(
"Unsupported subband size");
117 size_t nSubbands = GetNumSubbands(channelMatrix);
120 ComplexMatrixArray subbandChannelMatrix(channelMatrix.GetNumRows(),
121 channelMatrix.GetNumCols(),
127 GetSubbandDownsampleFirstPrb(channelMatrix, subbandChannelMatrix);
130 GetSubbandDownsampleRandomPrb(channelMatrix, subbandChannelMatrix);
133 GetSubbandDownsampleAveragePrb(channelMatrix, subbandChannelMatrix);
136 NS_ABORT_MSG(
"Unknown downsampling algorithm");
138 return subbandChannelMatrix;
144 size_t prbs = chanMat.GetNumPages();
147 nSubbands += prbsLastSubband > 0;
152NrPmSearch::GetSubbandDownsampleFirstPrb(
const NrIntfNormChanMat& chanMat,
153 ComplexMatrixArray& downsampledChanMat)
const
155 size_t matSize = chanMat.GetNumRows() * chanMat.GetNumCols();
156 size_t nSubbands = downsampledChanMat.GetNumPages();
157 for (
size_t page = 0; page < nSubbands; page++)
159 auto sbPage = downsampledChanMat.GetPagePtr(page);
161 for (
size_t i = 0; i < matSize; i++)
163 sbPage[i] = prbPage[i];
169NrPmSearch::GetSubbandDownsampleRandomPrb(
const NrIntfNormChanMat& chanMat,
170 ComplexMatrixArray& downsampledChanMat)
const
172 size_t matSize = chanMat.GetNumRows() * chanMat.GetNumCols();
173 size_t nSubbands = downsampledChanMat.GetNumPages();
174 size_t prbsLastSubband = chanMat.GetNumPages() %
m_subbandSize;
175 for (
size_t page = 0; page < nSubbands; page++)
177 auto sbPage = downsampledChanMat.GetPagePtr(page);
178 bool lastPageIsSmaller = prbsLastSubband && page == nSubbands - 1;
179 auto prbsInSubband = lastPageIsSmaller ? prbsLastSubband :
m_subbandSize;
181 auto prbPage = chanMat.GetPagePtr(page *
m_subbandSize + randomPrb);
182 for (
size_t i = 0; i < matSize; i++)
184 sbPage[i] = prbPage[i];
190NrPmSearch::GetSubbandDownsampleAveragePrb(
const NrIntfNormChanMat& chanMat,
191 ComplexMatrixArray& downsampledChanMat)
const
193 size_t matSize = chanMat.GetNumRows() * chanMat.GetNumCols();
194 size_t nSubbands = downsampledChanMat.GetNumPages();
195 size_t prbsLastSubband = chanMat.GetNumPages() %
m_subbandSize;
197 for (
size_t page = 0; page < nSubbands; page++)
200 if (page == (nSubbands - 1) && prbsLastSubband)
202 bandSize = prbsLastSubband;
205 auto sbPage = downsampledChanMat.GetPagePtr(page);
206 for (
size_t sbPrb = 0; sbPrb < bandSize; sbPrb++)
209 auto prbPage = chanMat.GetPagePtr(page *
m_subbandSize + sbPrb);
210 for (
size_t i = 0; i < matSize; i++)
212 sbPage[i] += prbPage[i];
216 for (
size_t i = 0; i < matSize; i++)
218 sbPage[i] /= bandSize;
230 auto upsampledMatrix = ComplexMatrixArray(precMat.GetNumRows(), precMat.GetNumCols(), numPrbs);
232 for (
size_t rb = 0; rb < numPrbs; rb++)
234 auto rbPage = upsampledMatrix.GetPagePtr(rb);
237 for (
size_t i = 0; i < upsampledMatrix.GetNumRows() * upsampledMatrix.GetNumCols(); i++)
239 rbPage[i] = sbPage[i];
242 return upsampledMatrix;
static TypeId GetTypeId()
Get TypeId.
int64_t AssignStreams(int64_t stream)
size_t GetSubbandSize() const
void SetSubbandSize(size_t subbandSize)
Set the subband size (in number of RBs)
Ptr< UniformRandomVariable > m_downsamplingUniRand
Uniform variable stream used to downsample PRBs.
NrPmSearch()
Default constructor.
void SetGnbParams(bool isDualPol, size_t numHPorts, size_t numVPorts)
Set the antenna parameters of the gNB antenna.
@ FirstPRB
Downsample m_subbandSize samples to bands based on the first PRB.
@ AveragePRB
Downsample m_subbandSize samples to bands based on the average of PRBs.
@ RandomPRB
Downsample m_subbandSize samples to bands based on a random PRB.
uint8_t m_rankLimit
Limit the UE's maximum supported rank.
enum DownsamplingTechnique m_downsamplingTechnique
Technique used to downsample PRBs.
void SetUeParams(size_t numTotalPorts)
Set the antenna parameters of the UE antenna.
size_t m_nRxPorts
Number of receive ports at this UE.
size_t m_nGnbHPorts
Number of horizontal ports in the gNB antenna array.
Ptr< const NrAmc > m_amc
The NrAmc to be used for computing TB size and MCS.
size_t m_nGnbPorts
Total number of ports in the gNB antenna array.
virtual NrIntfNormChanMat SubbandUpsampling(const NrIntfNormChanMat &precMat, size_t numPrbs) const
Upsample the input per-subband precoding matrix into a per-PRB precoding matrix.
bool m_isGnbDualPol
True when gNB has a dual-polarized antenna array.
virtual NrIntfNormChanMat SubbandDownsampling(const NrIntfNormChanMat &channelMatrix)
Downsample the input channel matrix into bins of at most m_subbandSize PRBs.
void SetAmc(Ptr< const NrAmc > amc)
Set the AMC object to be used for MCS and TB size calculation.
size_t m_subbandSize
Size of each subband (in number of RBs)
size_t m_nGnbVPorts
Number of vertical ports in the gNB antenna array.