NetSim Source Code Help v14.4
All 13 Components
 
Loading...
Searching...
No Matches
LTENR_CodeBlockSegmentation.c
1/************************************************************************************
2* Copyright (C) 2023 *
3* TETCOS, Bangalore. India *
4* *
5* Tetcos owns the intellectual property rights in the Product and its content. *
6* The copying, redistribution, reselling or publication of any or all of the *
7* Product or its content without express prior written consent of Tetcos is *
8* prohibited. Ownership and / or any other right relating to the software and all *
9* intellectual property rights therein shall remain at all times with Tetcos. *
10* *
11* This source code is licensed per the NetSim license agreement. *
12* *
13* No portion of this source code may be used as the basis for a derivative work, *
14* or used, for any purpose other than its intended use per the NetSim license *
15* agreement. *
16* *
17* This source code and the algorithms contained within it are confidential trade *
18* secrets of TETCOS and may not be used as the basis for any other software, *
19* hardware, product or service. *
20* *
21* Author: Shashi Kant Suman *
22* *
23* ----------------------------------------------------------------------------------*/
24
25#pragma region HEADER_FILES
26#include "stdafx.h"
27#include "LTENR_Spectrum.h"
28#include "LTENR_AMCTable.h"
29#include "LTENR_MAC.h"
30#include "LTENR_PHY.h"
31#include "LTENR_Multiplexing.h"
32#include "LTENR_Spectrum.h"
33#pragma endregion
34
35#pragma region CBSSIZE
36
37int LTENR_Mutiplexer_LDPC_SelectBaseGraph(double TBS, double R)
38{
39 if (TBS <= 292 || (TBS <= 3824 && R <= 0.67) || (R <= 0.25)) return 2;
40 return 1;
41}
42
43void LTENR_Multiplexer_ComputeCodeBlockSize(int LDPCG, UINT TBS, UINT* C, UINT* cbs, UINT* cbs_)
44{
45 UINT Kcb = 0;
46 double Kb = 0, K = 0.0, Zc = 384;
47 int L = 0;
48 if (LDPCG == 1)
49 {
50 Kcb = 8448;
51 Kb = 22;
52 }
53 else
54 {
55 Kcb = 3840;
56 if (TBS > 640) Kb = 10;
57 else if (TBS > 560) Kb = 9;
58 else if (TBS > 192) Kb = 8;
59 else Kb = 6;
60 }
61
62 if (TBS > Kcb)
63 {
64 L = 24;
65 *C = ceil(TBS * 1.0 / (Kcb - L));
66 TBS = TBS + (*C) * L;
67 }
68 else
69 *C = 1;
70
71 double K_ = (ceil(TBS / (8.0 * (*C)))) * 8.0;
72
73 int LDPC_len = sizeof LDPCLiftingSizeTable / sizeof LDPCLiftingSizeTable[0];
74 for (int i = 0; i < LDPC_len; i++)
75 {
76 if (Kb * (double)LDPCLiftingSizeTable[i].LiftingSize > K_)
77 {
78 Zc = LDPCLiftingSizeTable[i].LiftingSize;
79 break;
80 }
81 }
82
83 if (LDPCG == 1)
84 {
85 K = 22 * Zc;// Code Block Size
86 }
87 else {
88 K = 10 * Zc;// Code Block Size
89 }
90
91 *cbs = K;
92 *cbs_ = K_;
93}
94
95#pragma endregion