constituent_decoder_logmap.m
上传用户:hnyfjx
上传日期:2013-06-30
资源大小:2149k
文件大小:6k
源码类别:

传真(Fax)编程

开发平台:

Matlab

  1. function [soft_out,ex_info]=constituent_decoder_logmap(in,app)
  2. %****************************************************************
  3. % 内容概述:子译码器。
  4. %          利用硬件化的方式实现TURBO码的MAX-LOG-MAP译码
  5. %          生成矩阵按照3GPP标准为[1 1 0 1;1 0 1 1]
  6. %          输入为经过高斯信道的RSC软输入,而输出为软输出和外部信息
  7. % 创 建 人:朱殿荣/QQ:235347/MSN:njzdr@msn.com
  8. % 单    位:南京邮电大学,通信工程系
  9. % 创建时间:2005年7月23日
  10. % 修改时间:
  11. % 参考文献:《数字通信--基础与应用》
  12. %          《改进的Turbo码算法及其FPGA实现过程的研究》,天津大学,张宁,赵雅兴
  13. % 版权声明:任何人均可复制、传播、修改此文件,同时需保留原始版权信息。
  14. %****************************************************************
  15.  
  16. x=in(1,:);              %输入系统位
  17. y=in(2,:);              %输入校验位
  18. in_length=length(in);
  19. %---初始化&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  20. Infty = -128;
  21. d=zeros(8,2,in_length);     %分支量度,8种可能状态,输入为0或者1
  22.                             %D(S,i,k)
  23. a=Infty*ones(8,in_length);  %前向分支量度,A(S,k)
  24. a(1,1)=0;                   %寄存器状态由全零开始
  25. b=Infty*ones(8,in_length+1);%后向分支量度,B(S,k)
  26. b(1,in_length)=0;           %寄存器状态由全零结束
  27. %---计算度量和LLR&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  28. for k=1:in_length
  29.     d(1,2,k)=x(k)+y(k)+app(k);
  30.     d(2,2,k)=d(1,2,k);
  31.     d(7,2,k)=d(1,2,k);
  32.     d(8,2,k)=d(1,2,k);
  33.     
  34.     d(3,2,k)=x(k)+app(k);
  35.     d(4,2,k)=d(3,2,k);
  36.     d(5,2,k)=d(3,2,k);
  37.     d(6,2,k)=d(3,2,k);
  38.     d(3,1,k)=y(k);
  39.     d(4,1,k)=d(3,1,k);
  40.     d(5,1,k)=d(3,1,k);
  41.     d(6,1,k)=d(3,1,k);
  42.     
  43.     if k>1
  44.         a(1,k)=max(a(1,k-1),(a(2,k-1)+d(2,2,k-1)))...
  45.             +log(1+exp(-abs(a(1,k-1)-(a(2,k-1)+d(2,2,k-1)))));
  46.         a(2,k)=max((a(4,k-1)+d(4,1,k-1)),(a(3,k-1)+d(3,2,k-1)))...
  47.             +log(1+exp(-abs((a(4,k-1)+d(4,1,k-1))-(a(3,k-1)+d(3,2,k-1)))));
  48.         a(3,k)=max((a(5,k-1)+d(5,1,k-1)),(a(6,k-1)+d(6,2,k-1)))...
  49.             +log(1+exp(-abs((a(5,k-1)+d(5,1,k-1))-(a(6,k-1)+d(6,2,k-1)))));
  50.         a(4,k)=max(a(8,k-1),(a(7,k-1)+d(7,2,k-1)))...
  51.             +log(1+exp(-abs(a(8,k-1)-(a(7,k-1)+d(7,2,k-1)))));
  52.         a(5,k)=max(a(2,k-1),(a(1,k-1)+d(1,2,k-1)))...
  53.             +log(1+exp(-abs(a(2,k-1)-(a(1,k-1)+d(1,2,k-1)))));
  54.         a(6,k)=max((a(3,k-1)+d(3,1,k-1)),(a(4,k-1)+d(4,2,k-1)))...
  55.             +log(1+exp(-abs((a(3,k-1)+d(3,1,k-1))-(a(4,k-1)+d(4,2,k-1)))));
  56.         a(7,k)=max((a(6,k-1)+d(6,1,k-1)),(a(5,k-1)+d(5,2,k-1)))...
  57.             +log(1+exp(-abs((a(6,k-1)+d(6,1,k-1))-(a(5,k-1)+d(5,2,k-1)))));
  58.         a(8,k)=max(a(7,k-1),(a(8,k-1)+d(8,2,k-1)))...
  59.             +log(1+exp(-abs(a(7,k-1)-(a(8,k-1)+d(8,2,k-1)))));
  60.     end
  61.     
  62.     if k==in_length
  63.         b(1,k)=max(b(1,k+1),(b(5,k+1)+d(1,2,k)))...
  64.             +log(1+exp(-abs(b(1,k+1)-(b(5,k+1)+d(1,2,k)))));
  65.         b(2,k)=max(b(5,k+1),(b(1,k+1)+d(2,2,k)))...
  66.             +log(1+exp(-abs(b(5,k+1)-(b(1,k+1)+d(2,2,k)))));
  67.         b(3,k)=max((b(6,k+1)+d(3,1,k)),(b(2,k+1)+d(3,2,k)))...
  68.             +log(1+exp(-abs((b(6,k+1)+d(3,1,k))-(b(2,k+1)+d(3,2,k)))));
  69.         b(4,k)=max((b(2,k+1)+d(4,1,k)),(b(6,k+1)+d(4,2,k)))...
  70.             +log(1+exp(-abs((b(2,k+1)+d(4,1,k))-(b(6,k+1)+d(4,2,k)))));
  71.         b(5,k)=max((b(3,k+1)+d(5,1,k)),(b(7,k+1)+d(5,2,k)))...
  72.             +log(1+exp(-abs((b(3,k+1)+d(5,1,k))-(b(7,k+1)+d(5,2,k)))));
  73.         b(6,k)=max((b(7,k+1)+d(6,1,k)),(b(3,k+1)+d(6,2,k)))...
  74.             +log(1+exp(-abs((b(7,k+1)+d(6,1,k))-(b(3,k+1)+d(6,2,k)))));
  75.         b(7,k)=max(b(8,k+1),(b(4,k+1)+d(7,2,k)))...
  76.             +log(1+exp(-abs(b(8,k+1)-(b(4,k+1)+d(7,2,k)))));
  77.         b(8,k)=max(b(4,k+1),(b(8,k+1)+d(8,2,k)))...
  78.             +log(1+exp(-abs(b(4,k+1)-(b(8,k+1)+d(8,2,k)))));
  79.         %计算LLR--------------------------------------
  80.         l(k)=max([...
  81.             (a(1,k)+d(1,2,k)+b(5,k+1)),(a(2,k)+d(2,2,k)+b(1,k+1)),...
  82.             (a(3,k)+d(3,2,k)+b(2,k+1)),(a(4,k)+d(4,2,k)+b(6,k+1)),...
  83.             (a(5,k)+d(5,2,k)+b(7,k+1)),(a(6,k)+d(6,2,k)+b(3,k+1)),...
  84.             (a(7,k)+d(7,2,k)+b(4,k+1)),(a(8,k)+d(8,2,k)+b(8,k+1))...
  85.             ])-max([...
  86.             (a(1,k)+b(1,k+1)),(a(2,k)+b(5,k+1)),...
  87.             (a(3,k)+d(3,1,k)+b(6,k+1)),(a(4,k)+d(4,1,k)+b(2,k+1)),...
  88.             (a(5,k)+d(5,1,k)+b(3,k+1)),(a(6,k)+d(6,1,k)+b(7,k+1)),...
  89.             (a(7,k)+b(8,k+1)),(a(8,k)+b(4,k+1))...
  90.             ]);
  91.     end
  92. end
  93. for k=in_length-1:-1:1
  94.         b(1,k)=max(b(1,k+1),(b(5,k+1)+d(1,2,k)))...
  95.             +log(1+exp(-abs(b(1,k+1)-(b(5,k+1)+d(1,2,k)))));
  96.         b(2,k)=max(b(5,k+1),(b(1,k+1)+d(2,2,k)))...
  97.             +log(1+exp(-abs(b(5,k+1)-(b(1,k+1)+d(2,2,k)))));
  98.         b(3,k)=max((b(6,k+1)+d(3,1,k)),(b(2,k+1)+d(3,2,k)))...
  99.             +log(1+exp(-abs((b(6,k+1)+d(3,1,k))-(b(2,k+1)+d(3,2,k)))));
  100.         b(4,k)=max((b(2,k+1)+d(4,1,k)),(b(6,k+1)+d(4,2,k)))...
  101.             +log(1+exp(-abs((b(2,k+1)+d(4,1,k))-(b(6,k+1)+d(4,2,k)))));
  102.         b(5,k)=max((b(3,k+1)+d(5,1,k)),(b(7,k+1)+d(5,2,k)))...
  103.             +log(1+exp(-abs((b(3,k+1)+d(5,1,k))-(b(7,k+1)+d(5,2,k)))));
  104.         b(6,k)=max((b(7,k+1)+d(6,1,k)),(b(3,k+1)+d(6,2,k)))...
  105.             +log(1+exp(-abs((b(7,k+1)+d(6,1,k))-(b(3,k+1)+d(6,2,k)))));
  106.         b(7,k)=max(b(8,k+1),(b(4,k+1)+d(7,2,k)))...
  107.             +log(1+exp(-abs(b(8,k+1)-(b(4,k+1)+d(7,2,k)))));
  108.         b(8,k)=max(b(4,k+1),(b(8,k+1)+d(8,2,k)))...
  109.             +log(1+exp(-abs(b(4,k+1)-(b(8,k+1)+d(8,2,k)))));
  110.         %计算LLR--------------------------------------
  111.         l(k)=max([...
  112.             (a(1,k)+d(1,2,k)+b(5,k+1)),(a(2,k)+d(2,2,k)+b(1,k+1)),...
  113.             (a(3,k)+d(3,2,k)+b(2,k+1)),(a(4,k)+d(4,2,k)+b(6,k+1)),...
  114.             (a(5,k)+d(5,2,k)+b(7,k+1)),(a(6,k)+d(6,2,k)+b(3,k+1)),...
  115.             (a(7,k)+d(7,2,k)+b(4,k+1)),(a(8,k)+d(8,2,k)+b(8,k+1))...
  116.             ])-max([...
  117.             (a(1,k)+b(1,k+1)),(a(2,k)+b(5,k+1)),...
  118.             (a(3,k)+d(3,1,k)+b(6,k+1)),(a(4,k)+d(4,1,k)+b(2,k+1)),...
  119.             (a(5,k)+d(5,1,k)+b(3,k+1)),(a(6,k)+d(6,1,k)+b(7,k+1)),...
  120.             (a(7,k)+b(8,k+1)),(a(8,k)+b(4,k+1))...
  121.             ]);
  122. end
  123. soft_out=l;
  124. ex_info=soft_out-app-x;