Skip to content

Commit

Permalink
add nrPDSCHMCSTables() and bump version to 0.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
catkira committed Apr 2, 2024
1 parent 0757aed commit 87eeb47
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 1 deletion.
1 change: 1 addition & 0 deletions py3gpp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from .nrPDSCHDecode import nrPDSCHDecode
from .nrDLSCHInfo import nrDLSCHInfo
from .nrPDSCHIndices import nrPDSCHIndices
from .nrPDSCHMCSTables import nrPDSCHMCSTables

from .configs.nrCarrierConfig import nrCarrierConfig
from .configs.nrNumerologyConfig import nrNumerologyConfig
Expand Down
44 changes: 44 additions & 0 deletions py3gpp/nrPDSCHMCSTables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import numpy as np

def qm_to_mod(qm):
if qm == 1:
return 'BPSK'
if qm == 2:
return 'QPSK'
if qm == 4:
return '16QAM'
if qm == 6:
return '64QAM'
assert False, f'modulation order = {qm} is not supported'
return 0

class qam16_table():
def __init__(self):
self._table = np.zeros((4, 29), int)
self._table[0,:] = np.arange(self._table.shape[1])
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])
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])

def Qm(self, mcs):
return self._table[1,mcs]

def Modulation(self, mcs):
return qm_to_mod(self._table[1,mcs])

def Rate(self, mcs):
return self._table[2,mcs] / 1024


class pdsch_mcs_table_class():
def __init__(self):
self.QAM64Table = qam16_table()

def nrPDSCHMCSTables():
return pdsch_mcs_table_class()

if __name__ == '__main__':
table = nrPDSCHMCSTables().QAM64Table
mcs = 0
print(f'mcs = {mcs}, modulation = {table.Modulation(mcs)}, rate = {table.Rate(mcs)}')
mcs = 16
print(f'mcs = {mcs}, modulation = {table.Modulation(mcs)}, rate = {table.Rate(mcs)}')
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build-backend = "setuptools.build_meta"
py3gpp = ["codes/*.csv"]

[project]
version = "0.5.0"
version = "0.5.1"
authors = [
{name = "Benjamin Menküc", email = "benjamin@menkuec.de"},
]
Expand Down
23 changes: 23 additions & 0 deletions tests/test_nrPDSCHMCSTables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import numpy as np

from py3gpp.nrPDSCHMCSTables import nrPDSCHMCSTables

def test_nrPDSCHMCSTables():
table = nrPDSCHMCSTables().QAM64Table
mcs = 0
assert table.Modulation(mcs) == 'QPSK'
assert table.Qm(mcs) == 2
assert table.Rate(mcs) == 120 / 1024

mcs = 15
assert table.Modulation(mcs) == '16QAM'
assert table.Qm(mcs) == 4
assert table.Rate(mcs) == 616 / 1024

mcs = 16
assert table.Modulation(mcs) == '16QAM'
assert table.Qm(mcs) == 4
assert table.Rate(mcs) == 658 / 1024

if __name__ == '__main__':
test_nrPDSCHMCSTables()

0 comments on commit 87eeb47

Please sign in to comment.