資源簡介
本資源給出了bch碼的編譯碼的c語言代碼,可以通用
代碼片段和文件信息
//?------------------------------------------------------------------------
//????????File:?bch_bm.c
//????????Date:?April?3?2002
//?Description:?An?encoder/decoder?for?binary?BCH?codes
//??????????????Error?correction?using?the?BERLEKAMP-MASSEY?ALGORITHM
//?------------------------------------------------------------------------
//?This?program?is?complementary?material?for?the?book:
//
//?R.H.?Morelos-Zaragoza?The?Art?of?Error?Correcting?Coding?Wiley?2002.
//
//?ISBN?0471?49581?6
//
//?This?and?other?programs?are?available?at?http://the-art-of-ecc.com
//
//?You?may?use?this?program?for?academic?and?personal?purposes?only.?
//?If?this?program?is?used?to?perform?simulations?whose?results?are?
//?published?in?a?journal?or?book?please?refer?to?the?book?above.
//
//?The?use?of?this?program?in?a?commercial?product?requires?explicit?
//?written?permission?from?the?author.?The?author?is?not?responsible?or?
//?liable?for?damage?or?loss?that?may?be?caused?by?the?use?of?this?program.?
//
//?Copyright?(c)?2002.?Robert?H.?Morelos-Zaragoza.?All?rights?reserved.
//?------------------------------------------------------------------------
#include?
#include?
int?????????????m?n?length?k?t?d;
int?????????????p[21];
int?????????????alpha_to[1048576]?index_of[1048576]?g[548576];
int?????????????recd[1048576]?data[1048576]?bb[548576];
int?????????????seed;
int?????????????numerr?errpos[1024]?decerror?=?0;
void?
read_p()
/*
?* Read?m?the?degree?of?a?primitive?polynomial?p(x)?used?to?compute?the
?* Galois?field?GF(2**m).?Get?precomputed?coefficients?p[]?of?p(x).?Read
?* the?code?length.
?*/
{
int i?ninf;
printf(“\nEnter?a?value?of?m?such?that?the?code?length?is\n“);
printf(“2**(m-1)?-?1?????do?{
???printf(“Enter?m?(between?2?and?20):?“);
???scanf(“%d“?&m);
????}?while?(?!(m>1)?||?!(m<21)?);
for?(i=1;?i p[i]?=?0;
p[0]?=?p[m]?=?1;
if?(m?==?2) p[1]?=?1;
else?if?(m?==?3) p[1]?=?1;
else?if?(m?==?4) p[1]?=?1;
else?if?(m?==?5) p[2]?=?1;
else?if?(m?==?6) p[1]?=?1;
else?if?(m?==?7) p[1]?=?1;
else?if?(m?==?8) p[4]?=?p[5]?=?p[6]?=?1;
else?if?(m?==?9) p[4]?=?1;
else?if?(m?==?10) p[3]?=?1;
else?if?(m?==?11) p[2]?=?1;
else?if?(m?==?12) p[3]?=?p[4]?=?p[7]?=?1;
else?if?(m?==?13) p[1]?=?p[3]?=?p[4]?=?1;
else?if?(m?==?14) p[1]?=?p[11]?=?p[12]?=?1;
else?if?(m?==?15) p[1]?=?1;
else?if?(m?==?16) p[2]?=?p[3]?=?p[5]?=?1;
else?if?(m?==?17) p[3]?=?1;
else?if?(m?==?18) p[7]?=?1;
else?if?(m?==?19) p[1]?=?p[5]?=?p[6]?=?1;
else?if?(m?==?20) p[3]?=?1;
printf(“p(x)?=?“);
????n?=?1;
for?(i?=?0;?i?<=?m;?i++)?{
????????n?*=?2;
printf(“%1d“?p[i]);
????????}
printf(“\n“);
n?=?n?/?2?-?1;
ninf?=?(n?+?1)?/?2?-?1;
do??{
printf(“Enter?code?length?(%d? scanf(“%d“?&length);
}?while?(?!((length?<=?n)&&(length>ninf))?);
}
void?
generate_gf()
/*
?*?Generate?field?GF(2*
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????15015??2009-05-25?10:39??bch\bch_bm.c
- 上一篇:SM2算法C語言實現
- 下一篇:基于51單片機的c語言程序 電機轉速測量與PWM控制
評論
共有 條評論