@@ -31,9 +31,22 @@ class LowerMac {
31
31
std::optional<uint32_t > scrambling_code = std::nullopt);
32
32
~LowerMac () = default ;
33
33
34
+ // / Get the correct viterbi decoder either for hard decision for bit or soft decision for soft bits.
35
+ // / \targ DataType with bool (bits) the hard decision decoder is returned, with int16_t we have soft bits and return
36
+ // / the soft decision decoder
37
+ template <typename DataType> [[nodiscard]] auto getViterbi () const -> const ViterbiCodec& {
38
+ if constexpr (std::is_same_v<DataType, bool >) {
39
+ return viter_bi_codec_1614_hard_decision_;
40
+ }
41
+ if constexpr (std::is_same_v<DataType, int16_t >) {
42
+ return viter_bi_codec_1614_soft_decision_;
43
+ }
44
+ assert (false && " Compiling descramble with template paramater not bool or int16_t" );
45
+ }
46
+
34
47
// / handles the decoding of the synchronization bursts and once synchronized passes the data to the decoding of the
35
48
// / channels. keeps track of the current network time
36
- // / \targ DataType with bool is selected we have bits, with int16_t we have symbols
49
+ // / \targ DataType with bool is selected we have bits, with int16_t we have soft bits
37
50
template <typename DataType>
38
51
[[nodiscard]] auto process (std::vector<DataType> frame, BurstType burst_type) -> return_type {
39
52
// Set to true if there was some decoding error in the lower MAC
@@ -61,8 +74,8 @@ class LowerMac {
61
74
};
62
75
63
76
auto sb_bits = LowerMacCoding::viter_bi_decode_1614 (
64
- viter_bi_codec_1614_ , LowerMacCoding::depuncture23 (LowerMacCoding::deinterleave (
65
- LowerMacCoding::descramble (sb_input, 0x0003 ), 11 )));
77
+ getViterbi<DataType>() , LowerMacCoding::depuncture23 (LowerMacCoding::deinterleave (
78
+ LowerMacCoding::descramble (sb_input, 0x0003 ), 11 )));
66
79
67
80
if (LowerMacCoding::check_crc_16_ccitt<76 >(sb_bits)) {
68
81
current_sync = BroadcastSynchronizationChannel (
@@ -140,8 +153,8 @@ class LowerMac {
140
153
}
141
154
142
155
auto bkn2_bits = LowerMacCoding::viter_bi_decode_1614 (
143
- viter_bi_codec_1614_ , LowerMacCoding::depuncture23 (LowerMacCoding::deinterleave (
144
- LowerMacCoding::descramble (bkn2_input, bsc.scrambling_code ), 101 )));
156
+ getViterbi<DataType>() , LowerMacCoding::depuncture23 (LowerMacCoding::deinterleave (
157
+ LowerMacCoding::descramble (bkn2_input, bsc.scrambling_code ), 101 )));
145
158
146
159
slots = Slots (burst_type, SlotType::kOneSubslot ,
147
160
Slot (LogicalChannelDataAndCrc{
@@ -174,7 +187,7 @@ class LowerMac {
174
187
auto bkn1_descrambled_bits = LowerMacCoding::softbits_to_bits (bkn1_descrambled);
175
188
176
189
auto bkn1_bits = LowerMacCoding::viter_bi_decode_1614 (
177
- viter_bi_codec_1614_ ,
190
+ getViterbi<DataType>() ,
178
191
LowerMacCoding::depuncture23 (LowerMacCoding::deinterleave (bkn1_descrambled, 103 )));
179
192
180
193
if (aach.downlink_usage == DownlinkUsage::Traffic) {
@@ -216,8 +229,8 @@ class LowerMac {
216
229
};
217
230
218
231
auto bkn1_bits = LowerMacCoding::viter_bi_decode_1614 (
219
- viter_bi_codec_1614_ , LowerMacCoding::depuncture23 (LowerMacCoding::deinterleave (
220
- LowerMacCoding::descramble (bkn1_input, bsc.scrambling_code ), 101 )));
232
+ getViterbi<DataType>() , LowerMacCoding::depuncture23 (LowerMacCoding::deinterleave (
233
+ LowerMacCoding::descramble (bkn1_input, bsc.scrambling_code ), 101 )));
221
234
222
235
std::array<DataType, 216 > bkn2_input{};
223
236
for (auto i = 0 ; i < 216 ; i++) {
@@ -227,7 +240,7 @@ class LowerMac {
227
240
auto bkn2_deinterleaved =
228
241
LowerMacCoding::deinterleave (LowerMacCoding::descramble (bkn2_input, bsc.scrambling_code ), 101 );
229
242
auto bkn2_deinterleaved_bits = LowerMacCoding::softbits_to_bits (bkn2_deinterleaved);
230
- auto bkn2_bits = LowerMacCoding::viter_bi_decode_1614 (viter_bi_codec_1614_ ,
243
+ auto bkn2_bits = LowerMacCoding::viter_bi_decode_1614 (getViterbi<DataType>() ,
231
244
LowerMacCoding::depuncture23 (bkn2_deinterleaved));
232
245
233
246
// Half slot traffic channel defines type 3 bits (deinterleaved)
@@ -274,8 +287,8 @@ class LowerMac {
274
287
};
275
288
276
289
auto cb_bits = LowerMacCoding::viter_bi_decode_1614 (
277
- viter_bi_codec_1614_ , LowerMacCoding::depuncture23 (LowerMacCoding::deinterleave (
278
- LowerMacCoding::descramble (cb_input, bsc.scrambling_code ), 13 )));
290
+ getViterbi<DataType>() , LowerMacCoding::depuncture23 (LowerMacCoding::deinterleave (
291
+ LowerMacCoding::descramble (cb_input, bsc.scrambling_code ), 13 )));
279
292
280
293
// SCH/HU
281
294
slots = Slots (burst_type, SlotType::kOneSubslot ,
@@ -297,7 +310,7 @@ class LowerMac {
297
310
auto bkn1_descrambled_bits = LowerMacCoding::softbits_to_bits (bkn1_descrambled);
298
311
299
312
auto bkn1_bits = LowerMacCoding::viter_bi_decode_1614 (
300
- viter_bi_codec_1614_ ,
313
+ getViterbi<DataType>() ,
301
314
LowerMacCoding::depuncture23 (LowerMacCoding::deinterleave (bkn1_descrambled, 103 )));
302
315
303
316
slots = Slots (
@@ -321,8 +334,8 @@ class LowerMac {
321
334
}
322
335
323
336
auto bkn1_bits = LowerMacCoding::viter_bi_decode_1614 (
324
- viter_bi_codec_1614_ , LowerMacCoding::depuncture23 (LowerMacCoding::deinterleave (
325
- LowerMacCoding::descramble (bkn1_input, bsc.scrambling_code ), 101 )));
337
+ getViterbi<DataType>() , LowerMacCoding::depuncture23 (LowerMacCoding::deinterleave (
338
+ LowerMacCoding::descramble (bkn1_input, bsc.scrambling_code ), 101 )));
326
339
327
340
std::array<DataType, 216 > bkn2_input{};
328
341
for (auto i = 0 ; i < 216 ; i++) {
@@ -332,7 +345,7 @@ class LowerMac {
332
345
auto bkn2_deinterleaved =
333
346
LowerMacCoding::deinterleave (LowerMacCoding::descramble (bkn2_input, bsc.scrambling_code ), 101 );
334
347
auto bkn2_deinterleaved_bits = LowerMacCoding::softbits_to_bits (bkn2_deinterleaved);
335
- auto bkn2_bits = LowerMacCoding::viter_bi_decode_1614 (viter_bi_codec_1614_ ,
348
+ auto bkn2_bits = LowerMacCoding::viter_bi_decode_1614 (getViterbi<DataType>() ,
336
349
LowerMacCoding::depuncture23 (bkn2_deinterleaved));
337
350
338
351
// STCH + TCH
@@ -361,7 +374,8 @@ class LowerMac {
361
374
return *slots;
362
375
}
363
376
364
- const ViterbiCodec viter_bi_codec_1614_;
377
+ const ViterbiCodecHardDecision viter_bi_codec_1614_hard_decision_;
378
+ const ViterbiCodecSoftDecision viter_bi_codec_1614_soft_decision_;
365
379
366
380
std::unique_ptr<LowerMacMetrics> metrics_;
367
381
0 commit comments