大家好,欢迎来到IT知识分享网。
GPS L5C信号卷积编码实现:
# here put the import lib import numpy as np # (2,1,6)卷积码 # 卷积编码 def encode_conv(x): # 存储编码信息 y = [] # 两个寄存器u_1 u_2初始化为0 reg = np.zeros((6, ), dtype = np.uint8) for j in x: c_1 = j ^ reg[0] ^ reg[1] ^ reg[2] ^ reg[5] c_2 = j ^ reg[1] ^ reg[2] ^ reg[4] ^ reg[5] y.append(c_1) y.append(c_2) # 更新寄存器 reg = np.hstack((j, reg[0: -1])) print(x,"编码为:",y) return y # 测试代码 if __name__ == '__main__': encode_conv([1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1])
维特比译码实现:
# here put the import lib import numpy as np def EnCodeOut(state, inBit): g1Out = [0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0] g2Out = [0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0] ''' #lit = [0, 1, 2, 5] lit = [1, 2, 4, 5] r = [] for i in range(64): tmp = 0 for j in lit: tmp^= (i >> j) & 0x1 r.append(tmp) print(r) ''' return g1Out[state]^inBit, g2Out[state]^inBit # (2,1,6)卷积译码 regBit = 6 stateNum = (1 << regBit) def Decode(inData): t = len(inData) >> 1 score = np.zeros((stateNum, ), dtype=np.uint32) valid = np.ones((stateNum, ), dtype=np.uint8) path = np.zeros((t, stateNum), dtype=np.uint8) for i in range(t): # 遍历输入数据的时刻 tmp1 = np.ones((stateNum, ), dtype=np.uint32) * 10000 tmp2 = np.zeros((stateNum, ), dtype=np.uint8) for j in range(stateNum): # 遍历各个状态 if valid[j] == False: continue # 输入bit 0 g1, g2 = EnCodeOut(j, 0) tmpIdx = (i << 1) tmpState = (j << 1) & 0x3E dis = (inData[tmpIdx] ^ g1) + (inData[tmpIdx + 1] ^ g2) if dis < tmp1[tmpState]: tmp1[tmpState] = score[j] + dis tmp2[tmpState] = True path[i][tmpState] = j # 输入bit 1 g1, g2 = EnCodeOut(j, 1) tmpIdx = (i << 1) tmpState = ((j << 1) & 0x3F) | 0x1 dis = (inData[tmpIdx] ^ g1) + (inData[tmpIdx + 1] ^ g2) if dis < tmp1[tmpState]: tmp1[tmpState] = score[j] + dis tmp2[tmpState] = True path[i][tmpState] = j + 0x80 score = tmp1 valid = tmp2 tmp = np.argmin(score) if score[tmp]: print("decode failed", score) else: inBit = [] for i in range(t): tmpIdx = t - i - 1 inBit.append((path[tmpIdx][tmp] >> 7) & 0x1) tmp = path[tmpIdx][tmp] & 0x3F print(list(reversed(inBit))) if __name__ == '__main__': Decode([1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1])
E1B viterbi 译码性能测试结果:
GAL E1信号 CBOC 跟踪曲线:
GAL E1信号 BOC 跟踪曲线:
参考链接
翻译 | 卷积码的维特比(Viterbi)译码 (比较详细)
BLE(3) —卷积编码与viterbi译码
卷积编码–维特比译码
翻译 | 卷积码的维特比(Viterbi)译码
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/33795.html