看不懂这个汉明码 解码器代码?
<p>疑惑如<span style="color:#c0392b;">红色字体</span>注释,非常需要大家的帮助,谢谢了。</p><p> </p>
<p>module Vrhamcorr64(DU, DC, NOERROR, UCERR);<br />
input DU;<br />
output reg DC;<br />
output reg NOERROR, UCERR;<br />
integer syndrome ;<br />
<br />
reg C ; // Constants for parity-check matrix<br />
integer b, e, i, col;<br />
reg syn;<br />
reg SYND;</p>
<p>initial begin<br />
C = 72'h80000000000000007f; C = 72'h400000003fffffff80; <span style="color:#c0392b;">C应该是校验矩阵</span><br />
C = 72'h20001fffc0007fff80; C = 72'h100fe03fc07f807f80;<br />
C = 72'h0871e3c3c78787878f; C = 72'h04b66cccd9999999b3;<br />
C = 72'h02dab5556aaaaaaad5; C = 72'hffffffffffffffffff;<br />
for (i=0; i<=255; i=i+1) syndrome = -1; // Initialize syndrome array to invalid <span style="color:#c0392b;">syndrome是一个变量么?比如说和输入A,B差不多,但是syndrome有syndrome,syndrome,syndrome,一般来说变量位数是固定的,不懂为什么syndrome有3种?=-1也不是很理解。</span><br />
for (col=0; col<=71; col=col+1) begin // Populate valid syndromes <span style="color:#c0392b;">不是很懂initial语句,定义常数矩阵如上面那样列出来应该可以了吧,而且涉及的变量也很多,不知道这两个for语句是拿来干嘛的?</span><br />
for (e=1; e<=8; e=e+1) syn = C; <span style="color:#c0392b;">没见过变量后面跟两个[],不知道是什么东东?</span> <br />
syndrome = col; <span style="color:#c0392b;">syndrome和syndrome有什么关系么,下面的语句好像没用到syndrome?<br />
</span> end<br />
end</p>
<p>always @ (DU) begin<br />
DC = DU;<br />
for (b=0; b<=7; b=b+1) SYND = ^(C & DU); // Calculate received syndrome <span style="color:#c0392b;">应该是输出码字*校验矩阵,然后异或,得出8个等于0的等式</span><br />
NOERROR = 1'b1; UCERR = 1'b0; // Default values, no errors<br />
if (SYND==8'b0) ; // No errors<br />
else if (syndrome<0) begin NOERROR = 1'b0; UCERR = 1'b1; end // Uncorrectable <span style="color:#c0392b;">对syndrome已经懵圈,二进制计算怎么会<0呢?虽然说上面那个是定义=-1。如果纠不了错,应该是出现2位以上的错,SYND[]出现了和1位出错一样的数(或者说是SYND[]还是等于0),这条语句是怎么分辨出是1位出错还是多位出错的?</span><br />
else if (SYND!=1'b1) begin NOERROR = 1'b0; UCERR = 1'b1; end // Uncorrectable <span style="color:#c0392b;">SYND应该是全奇偶校验位,=1的时候只能指示每一位都可能是出错位,但不能纠错</span><br />
else begin NOERROR = 1'b0; DC] = ~DU]; end // Correctable<span style="color:#c0392b;">剩下应该是其他1位出错的,找到出错位然后按位取反纠错。</span><br />
end<br />
endmodule</p>
<p>汉明码很久以前明白过</p>
<p>verlong稍微懂一点</p>
huo_hu 发表于 2023-3-22 13:36
汉明码很久以前明白过
verlong稍微懂一点
<p>纠一位出错可以理解,else if (syndrome<0) begin NOERROR = 1'b0; UCERR = 1'b1; end // Uncorrectable你帮忙看一下这条语句是怎么分辨出是非1位出错的,因为SYND计算我觉得是不可能=-1的,说一下具体流程。</p>
页:
[1]