📄 forney.v
字号:
//---------------------------------------
// Iterative computaion of error_value
// e = α^i*ω(α^-I)/Λ`(α^-i)^2
//---------------------------------------
module error_valuator(clk, init, s,
Lmd0, Lmd1, Lmd2, Lmd3, Lmd4, Lmd5, Lmd6, Lmd7, Lmd8,
ErrorValue);
parameter t = 8, // t--The total number of errors that can be corrected
N = 204, // N--Codeword length
m = 8; // m--Extension of GF(2)
input clk, init;
input [m-1:0] s, Lmd0, Lmd1, Lmd2, Lmd3, Lmd4, Lmd5, Lmd6, Lmd7, Lmd8;
output [m-1:0] ErrorValue;
wire [m-1:0] InvDifLmdA;
//-----------------------------------------------
// Convolutional computaion of coefficient of Ωi
//-----------------------------------------------
reg [m-1:0] OmegaC[t*2-1:0], SyndromeSR[t+1:1], LmdC[t:0];
wire[m-1:0] sLmdC[t:0];
integer counter1;
always @(posedge clk)begin:OMEGA_COEEFICIENT
integer j;
if(init)begin
for(j=2; j<=t+1; j=j+1) // Load syndrome sequences (from 1 to t*2)
SyndromeSR[j] <= 0;
SyndromeSR[1] <= s;
// Load error-locator polynomial coefficients Ω(x)
LmdC[0] <= Lmd0; LmdC[1] <= Lmd1; LmdC[2] <= Lmd2;
LmdC[3] <= Lmd3; LmdC[4] <= Lmd4; LmdC[5] <= Lmd5;
LmdC[6] <= Lmd6; LmdC[7] <= Lmd7; LmdC[8] <= Lmd8;
for(j=0; j<=t*2-1; j=j+1) // Initiate OmegaC[j] registers
OmegaC[j] <= 0;
counter1 <= 1;
end
else if((0<counter1) && (counter1 <= t*2))begin // Computation of Ω0、Ω1、Ω2、Ω3
for(j=1; j<=t; j=j+1)
SyndromeSR[j+1] <= SyndromeSR[j];
SyndromeSR[1] <= s;
for(j=0; j<t*2-1; j=j+1)
OmegaC[j] <= OmegaC[j+1];
OmegaC[t*2-1] <= (sLmdC[0]^sLmdC[1])^(sLmdC[2]^sLmdC[3])
^(sLmdC[4]^sLmdC[5])^(sLmdC[6]^sLmdC[7])^sLmdC[8];
counter1 <= counter1 + 1;
end
else
counter1 <= 0;
end
FF_Mul s_x_Lmdc0(.A(SyndromeSR[1]), .B(LmdC[0]), .P(sLmdC[0]));
FF_Mul s_x_Lmdc1(.A(SyndromeSR[2]), .B(LmdC[1]), .P(sLmdC[1]));
FF_Mul s_x_Lmdc2(.A(SyndromeSR[3]), .B(LmdC[2]), .P(sLmdC[2]));
FF_Mul s_x_Lmdc3(.A(SyndromeSR[4]), .B(LmdC[3]), .P(sLmdC[3]));
FF_Mul s_x_Lmdc4(.A(SyndromeSR[5]), .B(LmdC[4]), .P(sLmdC[4]));
FF_Mul s_x_Lmdc5(.A(SyndromeSR[6]), .B(LmdC[5]), .P(sLmdC[5]));
FF_Mul s_x_Lmdc6(.A(SyndromeSR[7]), .B(LmdC[6]), .P(sLmdC[6]));
FF_Mul s_x_Lmdc7(.A(SyndromeSR[8]), .B(LmdC[7]), .P(sLmdC[7]));
FF_Mul s_x_Lmdc8(.A(SyndromeSR[9]), .B(LmdC[8]), .P(sLmdC[8]));
reg Comput_Err, Load_Lmd; // Start signal of computation the Ω(a^i)
always @(counter1)begin
if(counter1 == (t*2+1) ) Comput_Err = 1;
else Comput_Err = 0;
end
//---------------------------------------------------
// Convolutional computaion of coefficient of Ω(a^i)
//---------------------------------------------------
reg [m-1:0] OmegaIR[t*2-1:0], OmegaA;
wire[m-1:0] aOmegaIR[t*2-1:1], a52OmegaC[t*2-1:1];
always @(posedge clk)begin:OMEGA_ALPHA
integer j;
if(Comput_Err)begin
for(j=1; j<=t*2-1; j=j+1) // Load the OmegaIR[j] registers
//OmegaIR[j] <= OmegaC[j]; // Used in RS(7,3)
OmegaIR[j] <= a52OmegaC[j];
OmegaIR[0] <= OmegaC[0];
end
else begin // Stage--computation of Ω(a^i)
for(j=1; j<=t*2-1; j=j+1)
OmegaIR[j] <= aOmegaIR[j];
OmegaIR[0] <= OmegaIR[0];
end
end
ff_const_mul a1_x_OmegaIR1(.din(OmegaIR[1]), .dout(aOmegaIR[1])); // a^1*Ω1
ff_const_mul a2_x_OmegaIR2(.din(OmegaIR[2]), .dout(aOmegaIR[2])); // a^2*Ω2
ff_const_mul a3_x_OmegaIR3(.din(OmegaIR[3]), .dout(aOmegaIR[3])); // a^3*Ω3
ff_const_mul a4_x_OmegaIR4(.din(OmegaIR[4]), .dout(aOmegaIR[4])); // a^4*Ω4
ff_const_mul a5_x_OmegaIR5(.din(OmegaIR[5]), .dout(aOmegaIR[5])); // a^5*Ω5
ff_const_mul a6_x_OmegaIR6(.din(OmegaIR[6]), .dout(aOmegaIR[6])); // a^6*Ω6
ff_const_mul a7_x_OmegaIR7(.din(OmegaIR[7]), .dout(aOmegaIR[7])); // a^7*Ω7
ff_const_mul a8_x_OmegaIR8(.din(OmegaIR[8]), .dout(aOmegaIR[8])); // a^8*Ω8
ff_const_mul a9_x_OmegaIR9(.din(OmegaIR[9]), .dout(aOmegaIR[9])); // a^9*Ω9
ff_const_mul a10_x_OmegaIR10(.din(OmegaIR[10]), .dout(aOmegaIR[10])); // a^10*Ω10
ff_const_mul a11_x_OmegaIR11(.din(OmegaIR[11]), .dout(aOmegaIR[11])); // a^11*Ω11
ff_const_mul a12_x_OmegaIR12(.din(OmegaIR[12]), .dout(aOmegaIR[12])); // a^12*Ω12
ff_const_mul a13_x_OmegaIR13(.din(OmegaIR[13]), .dout(aOmegaIR[13])); // a^13*Ω13
ff_const_mul a14_x_OmegaIR14(.din(OmegaIR[14]), .dout(aOmegaIR[14])); // a^14*Ω14
ff_const_mul a15_x_OmegaIR15(.din(OmegaIR[15]), .dout(aOmegaIR[15])); // a^15*Ω15
defparam a1_x_OmegaIR1.CONST = 15'h6202, a2_x_OmegaIR2.CONST = 15'h7101,
a3_x_OmegaIR3.CONST = 15'h3880, a4_x_OmegaIR4.CONST = 15'h1C40,
a5_x_OmegaIR5.CONST = 15'h0E20, a6_x_OmegaIR6.CONST = 15'h4710,
a7_x_OmegaIR7.CONST = 15'h2388, a8_x_OmegaIR8.CONST = 15'h11C4,
a9_x_OmegaIR9.CONST = 15'h48E2, a10_x_OmegaIR10.CONST = 15'h2471,
a11_x_OmegaIR11.CONST = 15'h5238, a12_x_OmegaIR12.CONST = 15'h691C,
a13_x_OmegaIR13.CONST = 15'h748E, a14_x_OmegaIR14.CONST = 15'h3A47,
a15_x_OmegaIR15.CONST = 15'h1D23;
ff_const_mul a52_x_OmegaC1(.din(OmegaC[1]), .dout(a52OmegaC[1])); // a^52*Ω1
ff_const_mul a52_x_OmegaC2(.din(OmegaC[2]), .dout(a52OmegaC[2])); // a^104*Ω2
ff_const_mul a52_x_OmegaC3(.din(OmegaC[3]), .dout(a52OmegaC[3])); // a^156*Ω3
ff_const_mul a52_x_OmegaC4(.din(OmegaC[4]), .dout(a52OmegaC[4])); // a^208*Ω4
ff_const_mul a52_x_OmegaC5(.din(OmegaC[5]), .dout(a52OmegaC[5])); // a^260*Ω5
ff_const_mul a52_x_OmegaC6(.din(OmegaC[6]), .dout(a52OmegaC[6])); // a^312*Ω6
ff_const_mul a52_x_OmegaC7(.din(OmegaC[7]), .dout(a52OmegaC[7])); // a^364*Ω7
ff_const_mul a52_x_OmegaC8(.din(OmegaC[8]), .dout(a52OmegaC[8])); // a^161*Ω8
ff_const_mul a52_x_OmegaC9(.din(OmegaC[9]), .dout(a52OmegaC[9])); // a^213*Ω9
ff_const_mul a52_x_OmegaC10(.din(OmegaC[10]), .dout(a52OmegaC[10]));// a^10*Ω10
ff_const_mul a52_x_OmegaC11(.din(OmegaC[11]), .dout(a52OmegaC[11]));// a^62*Ω11
ff_const_mul a52_x_OmegaC12(.din(OmegaC[12]), .dout(a52OmegaC[12]));// a^114*Ω12
ff_const_mul a52_x_OmegaC13(.din(OmegaC[13]), .dout(a52OmegaC[13]));// a^166*Ω13
ff_const_mul a52_x_OmegaC14(.din(OmegaC[14]), .dout(a52OmegaC[14]));// a^218*Ω14
ff_const_mul a52_x_OmegaC15(.din(OmegaC[15]), .dout(a52OmegaC[15]));// a^15*Ω15
defparam a52_x_OmegaC1.CONST = 15'h6D41, a52_x_OmegaC2.CONST = 15'h0D84,
a52_x_OmegaC3.CONST = 15'h1BB9, a52_x_OmegaC4.CONST = 15'h1F55,
a52_x_OmegaC5.CONST = 15'h0E20, a52_x_OmegaC6.CONST = 15'h6B6A,
a52_x_OmegaC7.CONST = 15'h3C6C, a52_x_OmegaC8.CONST = 15'h3CDD,
a52_x_OmegaC9.CONST = 15'h14FA, a52_x_OmegaC10.CONST = 15'h2471,
a52_x_OmegaC11.CONST = 15'h535B, a52_x_OmegaC12.CONST = 15'h39E3,
a52_x_OmegaC13.CONST = 15'h7DE6, a52_x_OmegaC14.CONST = 15'h10A7,
a52_x_OmegaC15.CONST = 15'h1D23;
//------------------------------------------------------
// Convolutional computaion of coefficient of Λ`(α^-i)
//------------------------------------------------------
reg [m-1:0] DifLmdIR[3:0], DifLmdA;
wire[m-1:0] aDifLmdIR[3:1], a52LmdC[3:1];
always @(posedge clk)begin
if(Comput_Err)begin // Computation cofficients of Λ`(x)
DifLmdIR[0] <= LmdC[1]; DifLmdIR[1] <= a52LmdC[1];
DifLmdIR[2] <= a52LmdC[2]; DifLmdIR[3] <= a52LmdC[3];
end
else begin // Error Comput_Err output of codeword
DifLmdIR[1] <= aDifLmdIR[1];
DifLmdIR[2] <= aDifLmdIR[2];
DifLmdIR[3] <= aDifLmdIR[3];
end
end
ff_const_mul a2_x_DifLmdIR1(.din(DifLmdIR[1]), .dout(aDifLmdIR[1])); // a^2*Ω1
ff_const_mul a4_x_DifLmdIR2(.din(DifLmdIR[2]), .dout(aDifLmdIR[2])); // a^4*Ω1
ff_const_mul a6_x_DifLmdIR3(.din(DifLmdIR[3]), .dout(aDifLmdIR[3])); // a^6*Ω1
defparam a2_x_DifLmdIR1.CONST = 15'h7101, a4_x_DifLmdIR2.CONST = 15'h1C40,
a6_x_DifLmdIR3.CONST = 15'h4710;
ff_const_mul a52_x_LmdC3(.din(LmdC[3]), .dout(a52LmdC[1])); // a^104*Ω1
ff_const_mul a52_x_LmdC5(.din(LmdC[5]), .dout(a52LmdC[2])); // a^208*Ω2
ff_const_mul a52_x_LmdC7(.din(LmdC[7]), .dout(a52LmdC[3])); // a^312*Ω3
defparam a52_x_LmdC3.CONST = 15'h0D84, a52_x_LmdC5.CONST = 15'h1F55,
a52_x_LmdC7.CONST = 15'h6B6A;
// Generation power of α^i
reg [m-1:0] ExpIndex;
always @(posedge clk)begin
if(Comput_Err) ExpIndex <= 203;
else ExpIndex <= ExpIndex - 1;
end
always @(posedge clk)begin
OmegaA <= (OmegaIR[0] ^ OmegaIR[1]) ^ (OmegaIR[2] ^ OmegaIR[3])
^(OmegaIR[4] ^ OmegaIR[5]) ^ (OmegaIR[6] ^ OmegaIR[7])
^(OmegaIR[8] ^ OmegaIR[9]) ^ (OmegaIR[10]^ OmegaIR[11])
^(OmegaIR[12]^ OmegaIR[13])^ (OmegaIR[14]^ OmegaIR[15]);
DifLmdA <= DifLmdIR[0]^DifLmdIR[1]^DifLmdIR[2]^DifLmdIR[3];
end
// Computation of α^i * Ω(α^-i)
wire [m-1:0] AlphaPower, OmegaAlpha;
FF_Mul_R Omega_x_AlphaPower(.clk(clk),
.A(OmegaA),
.B(AlphaPower),
.P(OmegaAlpha));
// Computation of error_pattern = α^i*Ω(α^-i)/ Λ`(α^-i)-i)
FF_Mul_R OmegaAlpha_x_InvDifC(.clk(clk),
.A(OmegaAlpha),
.B(InvDifLmdA),
.P(ErrorValue));
// Inversion of Λ`(α^-i)
rom_inv DifC_Inv(.clock(clk), .address(DifLmdA), .q(InvDifLmdA));
// Consectively output the α^i
rom_power Alpha_Power(.clock(clk), .address(ExpIndex), .q(AlphaPower));
endmodule
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -