@@ -87,17 +87,6 @@ class pucch_allocator_impl final : public pucch_allocator
8787 unsigned r_pucch;
8888 };
8989
90- struct uci_bits {
91- unsigned harq_ack_bits = 0U ;
92- sr_nof_bits sr_bits = sr_nof_bits::no_sr;
93- unsigned csi_part1_bits = 0U ;
94-
95- [[nodiscard]] unsigned get_total_bits () const
96- {
97- return harq_ack_bits + sr_nof_bits_to_uint (sr_bits) + csi_part1_bits;
98- }
99- };
100-
10190 // At the moment, we only supports PUCCH resource set index 0 and 1.
10291 enum class pucch_res_set_idx : uint8_t { set_0 = 0 , set_1 };
10392
@@ -106,21 +95,31 @@ class pucch_allocator_impl final : public pucch_allocator
10695 uint8_t pucch_res_ind = 0 ;
10796 };
10897
98+ // / Defines the type of resource.
99+ // / HARQ indicates the HAR-ACK resource (it can carry HARQ-ACK and/or SR and/or CSI bits).
100+ // / SR indicates the resource dedicated for SR (it can carry SR and HARQ-ACK bits).
101+ // / CSI indicates the resource dedicated for CSI (it can carry CSI and SR bits).
109102 enum class pucch_grant_type { harq_ack, sr, csi };
110103
104+ // / \brief Defines a PUCCH grant (and its relevant information) currently allocated to a given UE.
105+ // / It is used internally to keep track of the UEs' allocations of the PUCCH grants with dedicated resources.
111106 class pucch_grant
112107 {
113108 public:
114109 pucch_grant_type type;
115110 // Only relevant for HARQ-ACK resources.
116111 harq_res_id harq_id;
117- pucch_format format;
118- uci_bits bits;
112+ pucch_uci_bits bits;
119113 const pucch_resource* pucch_res_cfg = nullptr ;
120114
115+ [[nodiscard]] pucch_format get_format () const
116+ {
117+ return pucch_res_cfg != nullptr ? pucch_res_cfg->format : pucch_format::NOF_FORMATS;
118+ }
121119 [[nodiscard]] ofdm_symbol_range get_symbols () const ;
122120 };
123121
122+ // / \brief List of possible PUCCH grants that allocated to a UE, at a given slot.
124123 class pucch_grant_list
125124 {
126125 public:
@@ -129,30 +128,31 @@ class pucch_allocator_impl final : public pucch_allocator
129128 std::optional<pucch_grant> csi_resource;
130129 unsigned nof_grants = 0 ;
131130
132- [[nodiscard]] uci_bits get_uci_bits () const ;
131+ [[nodiscard]] pucch_uci_bits get_uci_bits () const ;
132+ [[nodiscard]] bool is_emtpy () const ;
133133 };
134134
135135 // / Keeps track of the PUCCH grants (common + dedicated) for a given UE.
136136 struct ue_grants {
137137 rnti_t rnti;
138- bool has_common_pucch;
139-
138+ // Information about the common PUCCH grant.
139+ bool has_common_pucch = false ;
140+ // List of PUCCH grants with dedicated resources.
140141 pucch_grant_list pucch_grants;
141142 };
142143
143144 using slot_pucch_grants = static_vector<ue_grants, MAX_PUCCH_PDUS_PER_SLOT>;
144145
145- class res_manager_garbage_collector
146- {
147- public:
148- res_manager_garbage_collector (pucch_resource_manager& res_manager_) : res_manager(res_manager_){};
149-
146+ // / \brief Collects the information of what PUCCH cell resources have been allocated to a UE at given slot.
147+ // / This info is only used during the allocation, and the PUCCH allocator is called for a new UE or new allocation.
148+ struct res_manager_garbage_collector {
150149 bool harq_set_0 = false ;
151150 bool harq_set_1 = false ;
152151 bool csi = false ;
153152 bool sr = false ;
154153 pucch_resource_manager& res_manager;
155154
155+ res_manager_garbage_collector (pucch_resource_manager& res_manager_) : res_manager(res_manager_){};
156156 void reset ();
157157 void release_resource (slot_point slot_tx, rnti_t crnti, const ue_cell_configuration& ue_cell_cfg);
158158 };
@@ -168,7 +168,7 @@ class pucch_allocator_impl final : public pucch_allocator
168168 pucch_common_params pucch_params);
169169
170170 std::optional<pucch_common_params> find_common_and_ded_harq_res_available (cell_slot_resource_allocator& pucch_alloc,
171- ue_grants* existing_grants,
171+ ue_grants& existing_grants,
172172 rnti_t rnti,
173173 const ue_cell_configuration& ue_cell_cfg,
174174 const dci_context_information& dci_info);
@@ -184,34 +184,14 @@ class pucch_allocator_impl final : public pucch_allocator
184184 const ue_cell_configuration& ue_cell_cfg,
185185 unsigned csi_part1_bits);
186186
187- // Fills the PUCCH HARQ grant for common resources.
188- void fill_pucch_harq_common_grant (pucch_info& pucch_info, rnti_t rnti, const pucch_res_alloc_cfg& pucch_res);
189-
190- // Fills the PUCCH Format 1 grant.
191- void fill_pucch_ded_format1_grant (pucch_info& pucch_grant,
192- rnti_t crnti,
193- const pucch_resource& pucch_ded_res_cfg,
194- unsigned harq_ack_bits,
195- sr_nof_bits sr_bits);
196-
197- // Fills the PUCCH Format 2 grant.
198- void fill_pucch_format2_grant (pucch_info& pucch_grant,
199- rnti_t crnti,
200- const pucch_resource& pucch_ded_res_cfg,
201- const ue_cell_configuration& ue_cell_cfg,
202- unsigned nof_prbs,
203- unsigned harq_ack_bits,
204- sr_nof_bits sr_bits,
205- unsigned csi_part1_bits);
206-
207187 std::optional<unsigned > multiplex_and_allocate_pucch (cell_slot_resource_allocator& pucch_slot_alloc,
208- uci_bits new_bits,
188+ pucch_uci_bits new_bits,
209189 ue_grants& current_grants,
210190 const ue_cell_configuration& ue_cell_cfg,
211191 bool preserve_res_indicator = false );
212192
213193 std::optional<pucch_grant_list> get_pucch_res_pre_multiplexing (slot_point sl_tx,
214- uci_bits new_bits,
194+ pucch_uci_bits new_bits,
215195 ue_grants ue_current_grants,
216196 const ue_cell_configuration& ue_cell_cfg);
217197
@@ -233,6 +213,26 @@ class pucch_allocator_impl final : public pucch_allocator
233213 pucch_grant_list grants_to_tx,
234214 const ue_cell_configuration& ue_cell_cfg);
235215
216+ // Fills the PUCCH HARQ grant for common resources.
217+ void fill_pucch_harq_common_grant (pucch_info& pucch_info, rnti_t rnti, const pucch_res_alloc_cfg& pucch_res);
218+
219+ // Fills the PUCCH Format 1 grant.
220+ void fill_pucch_ded_format1_grant (pucch_info& pucch_grant,
221+ rnti_t crnti,
222+ const pucch_resource& pucch_ded_res_cfg,
223+ unsigned harq_ack_bits,
224+ sr_nof_bits sr_bits);
225+
226+ // Fills the PUCCH Format 2 grant.
227+ void fill_pucch_format2_grant (pucch_info& pucch_grant,
228+ rnti_t crnti,
229+ const pucch_resource& pucch_ded_res_cfg,
230+ const ue_cell_configuration& ue_cell_cfg,
231+ unsigned nof_prbs,
232+ unsigned harq_ack_bits,
233+ sr_nof_bits sr_bits,
234+ unsigned csi_part1_bits);
235+
236236 // / //////////// Private helpers //////////////
237237
238238 void remove_unsed_pucch_res (slot_point sl_tx,
0 commit comments