@@ -223,9 +223,10 @@ std::optional<unsigned> pucch_allocator_impl::alloc_common_and_ded_harq_res(cell
223223 return std::nullopt ;
224224 }
225225
226- const bool new_ue_grants_added = ue_grants_it == pucch_grants.end ();
226+ const bool new_ue_grant_added = ue_grants_it == pucch_grants.end ();
227227
228- if (new_ue_grants_added) {
228+ // Keep track of whether a new ue_grant has been added; in case the function fails, remove it before exiting.
229+ if (new_ue_grant_added) {
229230 pucch_grants.emplace_back (ue_grants{.rnti = rnti});
230231 }
231232
@@ -239,7 +240,7 @@ std::optional<unsigned> pucch_allocator_impl::alloc_common_and_ded_harq_res(cell
239240 return pucch_common_info.value ().pucch_res_indicator ;
240241 }
241242
242- if (new_ue_grants_added ) {
243+ if (new_ue_grant_added ) {
243244 pucch_grants.pop_back ();
244245 }
245246
@@ -1654,11 +1655,14 @@ pucch_allocator_impl::multiplex_resources(slot_point sl_tx,
16541655 const ue_cell_configuration& ue_cell_cfg,
16551656 bool preserve_res_indicator)
16561657{
1658+ // This function implements the multiplexing pseudo-code for PUCCH resources defined in Section 9.2.5, TS 38.213.
1659+ // Refer to paragraph starting as "Set Q to the set of resources for transmission of corresponding PUCCHs in a single
1660+ // slot without repetitions where".
16571661 pucch_grant_list mplexed_grants;
16581662
16591663 std::vector<pucch_grant> resource_set_q;
16601664
1661- // Build the resource set Q.
1665+ // Build the resource set Q. Refer to Section 9.2.5, TS 38.213.
16621666 if (candidate_grants.harq_resource .has_value ()) {
16631667 resource_set_q.emplace_back (candidate_grants.harq_resource .value ());
16641668 }
@@ -1680,7 +1684,7 @@ pucch_allocator_impl::multiplex_resources(slot_point sl_tx,
16801684
16811685 sort_res_set_q ();
16821686
1683- // This is the implementation of the sudo code for multiplexing the resources provided in Section 9.2.5, TS 38.213.
1687+ // This is the implementation of the pseudo- code for multiplexing the resources provided in Section 9.2.5, TS 38.213.
16841688 unsigned o_cnt = 0 ;
16851689 unsigned j_cnt = 0 ;
16861690 while (j_cnt < resource_set_q.size ()) {
@@ -1701,6 +1705,7 @@ pucch_allocator_impl::multiplex_resources(slot_point sl_tx,
17011705 return {};
17021706 }
17031707 // Remove the old resources that got merged from the set.
1708+ // TODO: check if, by using a different data structure, we can achive the deletion more efficiently.
17041709 resource_set_q.erase (resource_set_q.begin () + j_cnt - o_cnt, resource_set_q.begin () + j_cnt + 1 );
17051710
17061711 // Add the new resource (resulting from the previous merge) to the set.
@@ -1718,8 +1723,8 @@ pucch_allocator_impl::multiplex_resources(slot_point sl_tx,
17181723 }
17191724 }
17201725
1721- // The PUCCH resource multiplexing algorithm above is specified for the UE. In the GNB, we need to add an extra
1722- // resource Format 1 if slot there is a SR opportunity and HARQ bits to be reported with PUCCH Format 1.
1726+ // The PUCCH resource multiplexing algorithm above is specified from the UE's perspective . In the GNB, we need to add
1727+ // an extra resource Format 1 if slot there is a SR opportunity and HARQ bits to be reported with PUCCH Format 1.
17231728 if (resource_set_q.size () == 1 and resource_set_q.front ().get_format () == pucch_format::FORMAT_1 and
17241729 resource_set_q.front ().bits .harq_ack_nof_bits != 0 and
17251730 resource_set_q.front ().bits .sr_bits != sr_nof_bits::no_sr) {
@@ -1760,13 +1765,16 @@ pucch_allocator_impl::multiplex_and_allocate_pucch(cell_slot_resource_allocator&
17601765{
17611766 slot_point sl_ack = pucch_slot_alloc.slot ;
17621767
1763- // Find resource needed for the bits to be reported, assuming the resource is not multiplexed.
1768+ // Find the resources needed for the UCI bits to be reported, assuming the resources are not multiplexed.
17641769 std::optional<pucch_grant_list> candidate_resources =
17651770 get_pucch_res_pre_multiplexing (sl_ack, new_bits, current_grants, ue_cell_cfg);
17661771 if (not candidate_resources.has_value ()) {
17671772 return std::nullopt ;
17681773 }
17691774
1775+ // TODO: Implement optimization step to avoid the multiplexing process if the UCI bits results in the same PUCCH
1776+ // grants as the previous allocation.
1777+
17701778 // Multiplex the resources.
17711779 pucch_grant_list multiplexed_grants = multiplex_resources (
17721780 sl_ack, current_grants.rnti , candidate_resources.value (), ue_cell_cfg, preserve_res_indicator);
0 commit comments