当前位置:网站首页>SISO decoder for a general (n, n-1) SPC code (supplementary Chapter 3)

SISO decoder for a general (n, n-1) SPC code (supplementary Chapter 3)

2022-06-11 18:13:00 Bai Xiaosheng of Ming Dynasty

Preface :

            The earlier SPC(3,2) Here, expand to SPC(n,n-1)

The length of the data sent is n-1, after SPC The code formation length is n Of

codeword.

Catalog

   1: Overall process

   2: Simplify the algorithm

   3: code


One Overall process

I know before

intrinsic LLR

    L_i = \frac{2}{\sigma^2}r_i

   L_i = L_i+L_{ext,i}

Mainly in the calculation extrinsic LLR , stay SPC(3,2) in , With L1 For example

    sign(L_{ext,1})=sign(L_2)sign(L_3)

    |L_{ext,1}|=f(f(L_2)+f(L_3)) \approx min(|L_2|,|L_3|)

    f(x)=|log tan\frac{|x|}{2}|

  In the same way, we can get

   sign(L_{ext,1})=sign(L_2)sign(L_3)...sign(L_n)

   |L_{ext,1}|=min\begin{Bmatrix} |L_2|,|L_3|,...|L_n| \end{Bmatrix}

More commonly :

  L_{ext,i}=sign(L_1)sign(L_2)...sign(L_{i-1})sign(L_{i+1})..sign(L_{i})min\begin{Bmatrix} L_1,L_2,...L_{i-1},L_{i+1},..L_{n} \end{Bmatrix}

Method of proof : Through mathematical induction , Reference resources SPC(3,2), It's still a tanh Function multiplication  

 


Two Simplify the algorithm

   2.1 Symbolic calculation

    sgn= sgn(L_1)sgn(L_2)...sgn(L_n)

    sgn(L_i)=sgn(L_i)*sgn

   sgn=1: Corresponding c=0, Parity successful , keep L_i unchanged

   sgn=-1:  Corresponding c=1, Parity failed ,L_i  Flip

 2.2 Size calculation

      Follow SPC(3,2) equally , There is a simpler way to do this , You don't have to divide yourself every time

 

   


3、 ... and code 

# -*- coding: utf-8 -*-
"""
Created on Fri Jun 10 09:23:37 2022

@author: chengxf2
"""
import numpy as np

"""
AWGN: QPSK  After modulation , Add noise , It is assumed that all the messages sent are 1(0->1)
args
   std:  Standard deviation 
   mu:   mean value 
   n:  Number of samples 
"""
def sendmessage(mu=0,sigma=1.0,n=6):
    
    #np.random.seed(5)
    s = 1.0+ np.random.normal(mu, sigma, n)
    #sr = 1+std*np.random.randn(1,n)
    print("\n step1  send data : ", s)
    return s
    


'''
 obtain channel LLR, intrinsic
args
   rList:  From the channel itself LLR
   sigma:  variance 
   n:  Number of samples 
'''
def getIntrLLR(rList, sigma,n=6):
    
    left = 2.0/sigma
    llrList = []
    for r in rList:
        llr = np.round(left*r,2)
        llrList.append(llr)
        
    print("\n step2  intrinsic llr ",llrList)
    return llrList

'''
 Get symbolic function 
arg
  llr:  likelihood ratio 
return
    Symbol 
'''
def  sign(llr):
    if llr>0:
        return 1
    else:
        return -1


'''
 Get symbols ,hardDecsion  The process 
args 
   llrList
return
    sgn:  Overall sign
    sgnList:  For each sign
'''
def getSign(llrList):
    sgn = 1
    sgnList = []
    for llr in llrList:
        sgn_i = sign(llr)
        sgnList.append(sgn_i)
        sgn = sgn*sign(llr)
    print("\n step3  get sign",sgn,"\t sgnList ",sgnList)
    return sgn,sgnList

'''
 Find the minimum , And position ,  Find a small value 
'''
def minimum(llrList):
    
    
    #llrList.sort()
    print("\n step4 minimum",llrList)
    
    n = len(llrList)
    min1 = llrList[0]
    min2 = llrList[0]
    minpos = 0
   
    
    for i in range(1,n):
        llr = llrList[i]
        if llr<min1:
            min1 = llr
            minpos = i
        else:
            min2 = llr # Guarantee min2  It's definitely better than min1  Big enough 
    #print("\n min1: %4.2f  minpos: %d"%(min1,minpos))
    
    for j in range(n):
        llr = llrList[j]
        if j==minpos:
            continue
        
        if llr<min2:
            min2 = llr
    print("\n min1: %4.2f  minpos: %d  min2: %4.2f "%(min1,minpos,min2))
    return min1,min2, minpos
        
    
def getextrinsic(sgn, sgnList,min1,min2, minpos):
       n = len(sgnList)
       sgn_extrinsic = np.multiply(sgn, sgnList)
       print("\n sgn_extrinsic ",sgn_extrinsic,)
       
       extrinsicLLR =[]
       
       for i in range(n):
           if i == minpos:
               llr = min2
           else:
               llr = min1
           extrinsicLLR.append(llr)
           
       extLLR = np.multiply(sgn_extrinsic, extrinsicLLR)
       print("\n extLLR ",extLLR)
       return extLLR
       


'''
 to update llr
'''       
def updateLLR(intrinsicLLR, extrinsicLLR):

     llr = intrinsicLLR+extrinsicLLR
     print("\n llr ",llr)        
        
        
        
        
    
        

if __name__ =="__main__":
    
    sigma = 0.8**2
    
    s = sendmessage(0, sigma, 6)
    intLLR = getIntrLLR(s, sigma)
    sgn,sgnList = getSign(intLLR)
    absLLR = np.abs(intLLR)
    min1,min2, minpos =minimum(absLLR)
    
    extLLR =getextrinsic(sgn,sgnList,min1,min2, minpos)
    
    updateLLR(intLLR, extLLR)

   

 

 

# -*- coding: utf-8 -*-
"""
Created on Fri Jun 10 08:44:34 2022

@author: chengxf2
"""
#-*-coding:utf-8-*-
"""
python Draw a standard normal distribution curve 
"""
# ==============================================================
import numpy as np
import math
import matplotlib.pyplot as plt


def gd(x, mu=0, sigma=1.0):
  """ Generate the data 

  Argument:
    x: array
       input data ( The independent variables )
    mu: float
       mean value 
    sigma: float
     variance 
  """
  
  left = 1 / (np.sqrt(2 * math.pi) * np.sqrt(sigma))
  right = np.exp(-(x - mu)**2 / (2 * sigma))
  return left * right


if __name__ == '__main__':
  #  The independent variables 
  x = np.arange(-4, 5, 0.1)
  #  The dependent variable ( Different mean or variance )
  y_1 = gd(x, 0, 2.0)
  y_2 = gd(x, 0, 1.0)
  y_3 = gd(x, 0, 5.0)
  y_4 = gd(x, 0, 0.2)

  #  mapping 
  plt.plot(x, y_1, color='green')
  plt.plot(x, y_2, color='blue')
  plt.plot(x, y_3, color='yellow')
  plt.plot(x, y_4, color='red')
  #  Set the coordinate system 
  plt.xlim(-5.0, 5.0)
  plt.ylim(-0.2, 1)
  # because axes Four axes will be obtained , And we only need two axes , So we need to hide the other two axes , Set the color of the top and right axes to none, Will not show 
  ax = plt.gca()
  ax.spines['right'].set_color('none')
  ax.spines['top'].set_color('none')
  ax.xaxis.set_ticks_position('bottom')
  ax.spines['bottom'].set_position(('data', 0))
  ax.yaxis.set_ticks_position('left')
  ax.spines['left'].set_position(('data', 0))

  plt.legend(labels=['$\mu = 0, \sigma^2=2.0$', '$\mu = 0, \sigma^2=1.0$', '$\mu = 0, \sigma^2=5.0$', '$\mu = 0, \sigma^2=0.2$'])
  plt.show()

原网站

版权声明
本文为[Bai Xiaosheng of Ming Dynasty]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206111752137282.html