From 99ca4ddb3ddc89e9525e2fa3f64cbb06dfbd1e58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xiaoyu=20Hong=EF=BC=88=E6=B4=AA=E5=95=B8=E5=AE=87=EF=BC=89?= Date: Tue, 27 Dec 2022 14:19:30 +0800 Subject: [PATCH] fix syndrome matrix decode bug --- hamming_producer.m | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/hamming_producer.m b/hamming_producer.m index e29fbc7..1d0e8d4 100644 --- a/hamming_producer.m +++ b/hamming_producer.m @@ -12,7 +12,7 @@ clear all -K = 4; % data bits +K = 64; % data bits USE_POLY = 0; POLY = [0 1 0 0 1]; @@ -20,7 +20,7 @@ % calculate correction bits % 1.25 - still magic numbers -m = ceil(log2(1.25*K)); +m = log2(K)+1;%ceil(log2(1.25*K)); if USE_POLY == 1 [h,g,n,k] = hammgen(m, POLY); @@ -93,7 +93,8 @@ fprintf(fid,'\n'); for kk = 1:K - fprintf(fid,' assign DOUT[%02d] = D[%02d] ^',kk-1,kk-1); + fprintf(fid,' assign DOUT[%02d] = D[%02d] ^(',kk-1,kk-1); + %fprintf(fid,'(S==%02d%''h%X); ',m,g(kk)); and_flag = 0; for mm = 1:m if g(kk,mm) == 1 @@ -102,11 +103,18 @@ else fprintf(fid,' & '); end - if kk<11 fprintf(fid,' '); end - fprintf(fid,'S[%d]',mm-1); + else + if and_flag == 0 + fprintf(fid,'!'); + and_flag = 1; + else + fprintf(fid,' & !'); + end end + if kk<11 fprintf(fid,' '); end + fprintf(fid,'S[%d]',mm-1); end - fprintf(fid,';\n'); + fprintf(fid,');\n'); end fprintf(fid,'\n'); @@ -118,4 +126,4 @@ fclose(fid); -quit +%quit