有时看问题时,需要确认下行NPDCCH是否有漏解周期的情况,手动计算时间稍有麻烦,所以搞了个python脚本来产生NPDCCH的解码周期,没考虑映射到非锚载波上的情形。
NPDCCH的子帧计算是根据配置的Rmax、周期,并排除周期内的公共子帧来得到。亦即NPDCCH按照周期映射到除了同步信号、MIB、SIB1、SI以外的子帧上。
产生方式:修改脚本中公共信道信息,运行后产生txt文件
class cellInfoClass:
def __init__(self):
self.cellId = 32
self.valueOfSchedule = 2 # sechudle value % 3 = 0,1,2 equal to 4,8,16
self.SI_WinLen = 64 #in frames
self.SI_Offset = 3 #in frames
self.SI_ListCnt = 2
self.SI_Period = [512,512] #radio frames
self.SI_RepeatPatter = [8,8] #radioframes
self.SI_TbSize = [680,680]
self.npdcchRmax = 8
self.startSF = 2
self.npdcchPeriod = self.npdcchRmax*self.startSF
self.npdcchOffset = self.npdcchPeriod/8 #1/8
subTypeHash = {}
subDpcchPerHash = {}
subDpcchDataHash = {}
def genSubframeFormat(cellInfo):
npdcchR = cellInfo.npdcchRmax #64 #1
startSF = cellInfo.startSF #1.5
npdcchPeriod = npdcchR*startSF #8
npdcchOffset = cellInfo.npdcchOffset
print("npdcch Rmax:%d,G:%f,Peroid:%f,offset:%f",npdcchR,startSF,npdcchPeriod,npdcchOffset)
#change configuration here
cellId = cellInfo.cellId #260
#SIB1 configuration
SIB1_RepeatNum = cellInfo.valueOfSchedule<<(2+cellInfo.valueOfSchedule%3) # 4 or 8 or 16
startFrameNumber = 0
if(SIB1_RepeatNum == 4):
mod4CellId = cellId%4
sfnForSIB1 = mod4CellId
startFrameNumber = mod4CellId * 16
else:
mod2CellId = cellId%2
if(SIB1_RepeatNum == 8):
startFrameNumber = mod2CellId * 16
else: #16
startFrameNumber = mod2CellId
sfnForSIB1 = mod2CellId
# repeat number is equal to 8 or 16
tbSizeTable = [208,328,440,680] #index is int(valueOfSchedule/3)
#SIB1 configuration table
#value repeat TbSize -- 26.213
#SI configuration
SI_WinLen = cellInfo.SI_WinLen
SI_Offset = cellInfo.SI_Offset
SI_Period = cellInfo.SI_Period
SI_Tbsize = cellInfo.SI_TbSize
SI_RepeatPattern = cellInfo.SI_RepeatPatter
SI_Number = cellInfo.SI_ListCnt
#every 8th frames 56\120 uses 2RUs and other use 8 RUs
#standalone mode
#NRS even sfn 0x1df odd sfn 0x3df
#schedulingInfoSIB1-r13 ::= 2 => 36.213 repeat 16 cycle 16
# cellId mod 2 = 0
#SI schedule: periodicity rf 64 windowlength 160ms offset =0
#repetitionPattern every8thRF bit 552 8 RU
formatFileHandle = open('format.txt','w')
#SIB1 configuration
SIB1_period = 256/SIB1_RepeatNum
startSFNMod256 = startFrameNumber
SIB1Cnt = 0
SIB1Flg = 0
#SI configuration
SIRuNum = [0,0,0,0,0,0,0,0,0]
SICnt = [0,0,0,0,0,0,0,0,0]
SIFlg = [0,0,0,0,0,0,0,0,0]
for index in range(0,SI_Number):
if(SI_Tbsize[index] > 120):
SIRuNum[index] = 8
else:
SIRuNum[index] = 2
dpcchPeriodMark = 0
dataSF = 0
findDpcch = 0
dpcchRUnum = 0
#always count from 0
for sfnIdx in range(0,1024):
for subFrameIdx in range(0,10):
formatFileHandle.write('%-5d '%sfnIdx)
formatFileHandle.write('%-2d '%subFrameIdx)
dataSF = 0
if((sfnIdx%SIB1_period) == startSFNMod256):
SIB1Flg = 1
for index in range(0,SI_Number):
sfnModPeriod = sfnIdx % SI_Period[index]
if(sfnModPeriod>=(SI_Offset+index*SI_WinLen))and(sfnModPeriod<(SI_Offset+(index+1)*SI_WinLen)):
if((sfnModPeriod-(SI_Offset+index*SI_WinLen))&(SI_RepeatPattern[index]-1) == 0):
SIFlg[index] = 1
break
typeStr = ''
if(subFrameIdx==0):
typeStr = 'NPBCH'
formatFileHandle.write('%-6s'%'NPBCH')
elif(subFrameIdx==5):
typeStr = 'NPSS'
formatFileHandle.write('%-6s'%'NPSS')
elif((subFrameIdx==9)and(0==(sfnIdx & 0x1))):
typeStr = 'NSSS'
formatFileHandle.write('%-6s'%'NSSS')
elif((1 == SIB1Flg)and((sfnIdx & 0x1)==(sfnForSIB1 & 0x1))and(4 == subFrameIdx)):
SIB1Cnt = SIB1Cnt+1
typeStr = 'NSIB1'
formatFileHandle.write('%-6s'%'NSIB1')
if(8 == SIB1Cnt):
SIB1Flg = 0
SIB1Cnt = 0
#for SIB1
elif(0<sum(SIFlg)):
for SIIdx in range(0,SI_Number):
if(SIFlg[SIIdx] != 0):
break
SICnt[SIIdx] = SICnt[SIIdx] + 1
typeStr = 'NSI%d'%SIIdx
formatFileHandle.write('%-6s'%typeStr)
if(SIRuNum[SIIdx] ==SICnt[SIIdx]):
SIFlg[SIIdx] = 0
SICnt[SIIdx] = 0
else:
typeStr = 'NDATA'
formatFileHandle.write('%-6s'%'NDATA')
dataSF = 1
subFrameIdx = sfnIdx*10+subFrameIdx
if((subFrameIdx % npdcchPeriod) == npdcchOffset):
dpcchPeriodMark = 1 - dpcchPeriodMark
findDpcch = 1
dpcchRUnum = 0
formatFileHandle.write('%-2d'%dpcchPeriodMark)
dpcchMark = 0
if((1==findDpcch)and(1==dataSF)):
if (dpcchRUnum == npdcchR):
findDpcch = 0
dpcchRUnum = 0
else:
dpcchRUnum = dpcchRUnum + 1
dpcchMark = dpcchRUnum
formatFileHandle.write('%-2d'%dpcchMark)
subTypeHash[subFrameIdx] = typeStr
subDpcchPerHash[subFrameIdx] = dpcchPeriodMark
subDpcchDataHash[subFrameIdx] = dpcchMark
formatFileHandle.write('\n')
#subframeType = 0
#if(subframeType)
formatFileHandle.close()
pass
if __name__ == '__main__':
curCellInfo = cellInfoClass()
genSubframeFormat(curCellInfo)