2014

这篇文章主要介绍了利用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

#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");

}

卷积码 c语言编码,利用c语言实现卷积码编码器示例相关推荐

  1. c语言delay_利用C语言编程单片机,制作可以根据环境光照调整亮度的智能灯

    上一节,我们利用C语言编程单片机仿制了达文西的"古怪手电筒",达成了"在有光的时候就会亮,在没有光的情况下绝对不会亮!"的目标. 其实在此基础上,C语言还能做些 ...

  2. java设置语言编码_Java多语言编码问题解析

    1.Java编译器在对源文件编译前,会先把源文件转换为unicode编码,因为这个原因,我们在编译时一定要把源文件用的是什么编码方式正确无误的"告诉"编译器. 例如:我们的源文件是 ...

  3. 用C语言编码定积分,C语言__用六种方法求定积分C语言__用六种方法求定积分.doc...

    C语言__用六种方法求定积分C语言__用六种方法求定积分 描述问题 利用①左矩形公式,②中矩形公式,③右矩形公式 ,④梯形公式,⑤simpson公式,⑥Gauss积分公式求解定积分. 分析问题 2.1 ...

  4. clustMD r语言_利用R语言实现微阵列数据分析-聚类分析

    原文见:http://www.biostat.ucsf.edu/jean/Presentation/IMSLAB.pdf 为了方便大家学习,我将该文翻译成中文加上一些相关的简单介绍,经验尚浅,还请大家 ...

  5. c语言编码表白,C语言告白代码,一闪一闪亮晶晶~

    该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 #include #include #include #define I 20 #define R 340 int main() { int i,j,e; ...

  6. c语言 编码 乐学,c语言乐学作业

    2016-08-22 回答 语文的选择题自己做.二.古诗文阅读李姬传1.b2.d 3a4(1)王将军家境清贫,不是广交朋友的人,你何不问一问他呢?(2)而今如果未贫图钱财而赴约,那是我背叛了公子啊!( ...

  7. 【转载】Uber Go语言编码规范

    文章目录 Uber Go语言编码规范 一. 介绍 二. 指导原则 指向interface的指针 接收器(receiver)与接口 零值Mutex是有效的 在边界处拷贝Slices和Maps 接收Sli ...

  8. C语言编码助手 1.9发布

    重写了C语言语法解析器.打桩更智能.体验极速编码的快感~ C语言 编码助手 C语言编码助手  项目级C语言单元测试框架, 一键生成, 无代码侵入 支持gtest gmock语法, 支持桩函数开关,真实 ...

  9. 硬件描述语言与c语言函数,计算机硬件描述语言(VHDL)与编程语言(C语言)的区别及关系,...

    计算机硬件描述语言(VHDL)与编程语言(C语言)的区别及关系,以下文字资料是由(历史新知网www.lishixinzhi.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 计算机硬 ...

  10. 来自 Google 的 R 语言编码风格指南

    来自 Google 的 R 语言编码风格指南 R 语言是一门主要用于统计计算和绘图的高级编程语言. 这份 R 语言编码风格指南旨在让我们的 R 代码更容易阅读.分享和检查. 以下规则系与 Google ...

最新文章

  1. C#枚举系统安装的所有打印机
  2. netconf 网络配置协议 简介
  3. drozer与adb工具的安装与使用
  4. 八周二次课 rsync工具介绍,常用参数选项以及和ssh同步
  5. 使用ASP.NET Global.asax 文件
  6. SpringMVC(二)高级
  7. 自定义用户控件的使用
  8. asp.net 将此项目作为引用添加将导致循环依赖项
  9. UnityShader19.1:渲染纹理(下)之GrabPass
  10. 软件的工程化管理(二)(转)
  11. ImageNet 2012 中文标签(Chinese Labels)
  12. The APR based Apache Tomcat Native library which allows optimal performance in production environm
  13. ORA-01555错误解决
  14. 【游戏客户端】10分钟搞定红点系统
  15. 西工大计算机学院保研人数,陕西多所大学保研率超20%,西北工业大学27%,推免999人...
  16. 32位驱动模式写保护开关
  17. win732位升级64位教程
  18. 亚马逊儿童背包 CPSIA,CSPA邻苯二甲酸盐和镉 CPC测试
  19. 同济大学高等数学上册电子版_函数的凹凸性漫谈|高等数学漫步(二)
  20. 计算机5800计算道路标高程序,Casio fx-5800P计算器三个公路基本测量程序编写与应用...

热门文章

  1. MATLAB符号运算——极限
  2. android webview最新版下载,AndroidWebView
  3. 国产CI520 13.56MHz非接触式读写器NFC读卡芯片替代CV520
  4. 有替代CV520国产非接触式读写器读卡芯片CI520
  5. 医咖会免费SPSS教程学习笔记—非参数检验之两相关样本
  6. ruby入门教程:入门ruby的方法
  7. 2020年CISP线下考试逐渐恢复啦
  8. Ext JS 6学习文档–第1章–ExtJS入门指南
  9. 基于Tableau探索分析世界银行提供的关于科学技术的数据
  10. java 随机生成姓名_生成随机中文姓名java程序.pdf