Skip to content

Commit 87eeb47

Browse files
committed
add nrPDSCHMCSTables() and bump version to 0.5.1
1 parent 0757aed commit 87eeb47

File tree

4 files changed

+69
-1
lines changed

4 files changed

+69
-1
lines changed

py3gpp/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
from .nrPDSCHDecode import nrPDSCHDecode
4242
from .nrDLSCHInfo import nrDLSCHInfo
4343
from .nrPDSCHIndices import nrPDSCHIndices
44+
from .nrPDSCHMCSTables import nrPDSCHMCSTables
4445

4546
from .configs.nrCarrierConfig import nrCarrierConfig
4647
from .configs.nrNumerologyConfig import nrNumerologyConfig

py3gpp/nrPDSCHMCSTables.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import numpy as np
2+
3+
def qm_to_mod(qm):
4+
if qm == 1:
5+
return 'BPSK'
6+
if qm == 2:
7+
return 'QPSK'
8+
if qm == 4:
9+
return '16QAM'
10+
if qm == 6:
11+
return '64QAM'
12+
assert False, f'modulation order = {qm} is not supported'
13+
return 0
14+
15+
class qam16_table():
16+
def __init__(self):
17+
self._table = np.zeros((4, 29), int)
18+
self._table[0,:] = np.arange(self._table.shape[1])
19+
self._table[1,:] = np.array( [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6])
20+
self._table[2,:] = np.array([120,157,193,251,308,379,449,526,602,679,340,378,434,490,553,616,658,438,466,517,567,616,666,719,772,822,873,910,948])
21+
22+
def Qm(self, mcs):
23+
return self._table[1,mcs]
24+
25+
def Modulation(self, mcs):
26+
return qm_to_mod(self._table[1,mcs])
27+
28+
def Rate(self, mcs):
29+
return self._table[2,mcs] / 1024
30+
31+
32+
class pdsch_mcs_table_class():
33+
def __init__(self):
34+
self.QAM64Table = qam16_table()
35+
36+
def nrPDSCHMCSTables():
37+
return pdsch_mcs_table_class()
38+
39+
if __name__ == '__main__':
40+
table = nrPDSCHMCSTables().QAM64Table
41+
mcs = 0
42+
print(f'mcs = {mcs}, modulation = {table.Modulation(mcs)}, rate = {table.Rate(mcs)}')
43+
mcs = 16
44+
print(f'mcs = {mcs}, modulation = {table.Modulation(mcs)}, rate = {table.Rate(mcs)}')

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ build-backend = "setuptools.build_meta"
99
py3gpp = ["codes/*.csv"]
1010

1111
[project]
12-
version = "0.5.0"
12+
version = "0.5.1"
1313
authors = [
1414
{name = "Benjamin Menküc", email = "[email protected]"},
1515
]

tests/test_nrPDSCHMCSTables.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import numpy as np
2+
3+
from py3gpp.nrPDSCHMCSTables import nrPDSCHMCSTables
4+
5+
def test_nrPDSCHMCSTables():
6+
table = nrPDSCHMCSTables().QAM64Table
7+
mcs = 0
8+
assert table.Modulation(mcs) == 'QPSK'
9+
assert table.Qm(mcs) == 2
10+
assert table.Rate(mcs) == 120 / 1024
11+
12+
mcs = 15
13+
assert table.Modulation(mcs) == '16QAM'
14+
assert table.Qm(mcs) == 4
15+
assert table.Rate(mcs) == 616 / 1024
16+
17+
mcs = 16
18+
assert table.Modulation(mcs) == '16QAM'
19+
assert table.Qm(mcs) == 4
20+
assert table.Rate(mcs) == 658 / 1024
21+
22+
if __name__ == '__main__':
23+
test_nrPDSCHMCSTables()

0 commit comments

Comments
 (0)