本文主要是关于卷积编码的相关介绍,并就卷积编码简述了基于c语言的卷积编码实现方法,最后着重阐述了卷积和滤波的区别。
卷积编码
在信道编码研究的初期,人们探索、研究出各种各样的编码构造方法,其中包括卷积码。早在1955年,p.elias首先提出了卷积码。但是它又经历了十几年的研究以后,才开始具备应用价值。在这十几年期间,j.m.wozencraft提出了适合大编码约束度的卷积码的序列译码,j.l.massey提出了实现简单的门限译码,a.j.viterbi提出了适合小编码约束度的卷积码viterbi算法。20年后,即1974年,l.r.bahl等人又提出一种支持软输入软输出(siso,soft-input soft-output)的最大后验概率(map,maximum a posteriori)译码——bcjr算法。其中,viterbi算法有力地推动了卷积码的广泛应用,bcjr算法为后续turbo码的发现奠定了基础。
基于c语言的卷积编码实现
实现(2, 1, 7)卷积码编码
信息序列1001 1010 1111 1100
生成序列g1 = 1011011;g2 = 1111001
初始状态全0.
以上参数可自行在main中修改。
/***this is an simple example program of convolutional encoder.
*the information sequence, the register initial states and the generation sequence
* can all be modified in the main function.
*/
#include《stdio.h》
#define len(array, len){len=sizeof(array)/sizeof(array[0]);}//size of array
int encoder(int **gen, int n, int l, int reg[], int m, int inf[], int inf_len, int output[])
/*encoder(int **gen, int n, int l, int reg[], int m, int inf[], int inf_len, int output[])
*this function is a convolutional encoder.
*gen is the generation sequence, which is a two-dimension array,
and it is a two-dimension pointer,
*n is the number of bits out the encoder at each clock cycle,
*l is for the constraight length,
*reg is for the shift registers,
*m is for the number of registers,
*inf is for the information sequence,
*inf_len is for the inf length,
*output is for the output code.
*/
{
int inf_ex[inf_len + m];
int i,j;//index
for (i=0;i 《 inf_len + m;i++)//extend the information sequence to include the last m bits
{
if(i 《 inf_len)
inf_ex[i] = inf[i];
else
inf_ex[i] = 0;
}
for (i=0;i 《 inf_len + m;i++)//foreach bit in extend information
{
for (j=0;j 《 n;j++)//output n bits at each clock cycle
{
int out_tem=0;//temp number
if (*(gen + l*j) == 1)//judge whether the next information bit should paticipate in the mod op
out_tem += inf_ex[i];
int k;
for (k=0;k 《 m;k++)//foreach registers
{
if (*(gen + l*j + k + 1) == 1)
out_tem += reg[k];//mod op according to the generation sequence
}
out_tem %= 2;//mod 2
output[i*n + j] = out_tem;
}
for (j=m - 1;j 》 0;j--)//register shift
{
reg[j] = reg[j - 1];
}
reg[0] = inf_ex[i];//input information bits into register
}
return 1;
}
main()
{
int inf[]={1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0};//information sequence
int inf_len;//information length
len(inf, inf_len);
int gen[2][7]={{1, 0, 1, 1, 0, 1, 1}, {1, 1, 1, 1, 0, 0, 1}};//generation sequence
int n;//the number of bits out the encoder at each clock cycle
int l;//constraight length
len(gen, n);
len(gen[0], l);
int m=l - 1;//the number of shift registers
int init_s[]={0, 0, 0, 0, 0, 0}; //initial states are all zero
int reg[m];//register
int i;//index
for (i=0;i 《 m;i++)
{
reg[i] = init_s[i];
}
int output_len=(inf_len + m)*n;//output length, every bit of input can generate n bits of output sequence
int output[(inf_len + m)*n];//output sequence
encoder(gen, n, l, reg, m, inf, inf_len, output);//encoder
for (i=0;i 《 output_len;i++)
{
printf(“%d”, output[i]);
}
system(“pause”);
}
卷积和滤波之区别
首先,从定义看,conv表示卷积,filter表示滤波。conv的定义公式如下:
y(n)=∑i=0n+m−1x(i)h(n−i)y(n)=∑i=0n+m−1x(i)h(n−i)
其中x(n)长度为n;h(n)长度为m;
fileter表示卷积,调用格式如下:
fileter(h,1,x);
h=[1,2,3];
123
表示差分方程:
y(n)=x(n)+2*x(n-1)+3*x(n-2);
12
即
y(n)=x(n)*h(0)+x(n-1)*h(1)。..+x(0)*h(n)
=x(0)*h(n)+x(1)*h(n-1)。..+x(n)*h(0)
123
即
y(n)=∑i=0nx(i)h(n−i)y(n)=∑i=0nx(i)h(n−i)
所以,除了物理意义的不同之外,二者在计算上只是长度不同。
卷积的计算:
x=[1,2,5,4,8];
h=[2,6,4];
1 2 5 4 8
2 6 4
__________
4 8 20 16 32
6 12 30 24 48
2 4 10 8 16
---------------------
2 10 26 46 60 64 32
可以看出卷积的结果是[2 10 26 46 60 64 32];
那么filter(滤波)的结果就是[2 10 26 46 60];
接下来用matlab程序验证我们的计算结果:
》》 h=[2 6 4];
》》 x=[1 2 5 4 8];
》》 y1=conv(h,x)
y1 =
2 10 26 46 60 64 32
》》 y2=filter(h,1,x)
y2 =
2 10 26 46 60
在用c语言等其他语言进行实现是可以采用定义,利用两个for循环完成代码。
卷积的列表法计算 :
结语
关于c语言下的卷积编码实现方法就介绍到这了,希望本文能让你对卷积编码有更深的认识。
相关阅读推荐:什么是卷积码
相关阅读推荐:什么是卷积
回顾集成电路的十年黄金时代分析
比亚迪获7419辆新能源车订单 占深圳纯电动市场一半市场份额
电气装置的接地与接零
人为操控单个粒子的量子状态,让单个粒子变得更“年轻”
2019年世界IGBT市场总值将达到48.4亿美元 同比增长2.8%
基于C语言的卷积编码实现 浅谈卷积和滤波之区别
环签名的关键技术以及原理解析
2022中国(深圳)集成电路峰会在深圳坪山隆重召开
现场风采|巴科以强大阵容参展ISE 2019
我国智能电网研究主要的十项关键技术
氢燃料电池车有望成为未来汽车的发展方向
当代5G用户的现状:从被5G到重返4G 适应需要过程
碳材料表面差异的各项因素以及造成的相应困境总结
小米平板3谍照曝光,配置消息汇总!携手小米6四月归来
好用的蓝牙耳机有哪些推荐?十大蓝牙耳机品牌
使用DDS芯片实现生物组织阻抗频谱测试仪的设计
伟创力携手意法半导体亮相CES展现下一代移动出行“黑科技”
可编程序控制器的五种标准编程语言
百度自研“图像超分辨技术”实现顶级峰会ECCV三连冠
荣耀、一加接连举办发布会,高通骁龙8Gen1或为大赢家