| 1 |
2 |
farooq21 |
// This is a verilog File Generated
|
| 2 |
|
|
// By The C++ program That Generates
|
| 3 |
|
|
// Reed Solomon Controller
|
| 4 |
|
|
// Barlekamp Messay Controller
|
| 5 |
|
|
|
| 6 |
|
|
module RS8FreqDecode(clk_i, rst_i,
|
| 7 |
|
|
valid_i, // input valid signal
|
| 8 |
|
|
enc_data_i, // encoded data
|
| 9 |
|
|
dec_data_o, // decoded output
|
| 10 |
|
|
valid_o, // decoded output
|
| 11 |
|
|
busy_o
|
| 12 |
|
|
);
|
| 13 |
|
|
// Declaration of the inputs
|
| 14 |
|
|
input clk_i, rst_i;
|
| 15 |
|
|
input valid_i;
|
| 16 |
|
|
input [7:0] enc_data_i;
|
| 17 |
|
|
output wire [7:0] dec_data_o;
|
| 18 |
|
|
output wire valid_o;
|
| 19 |
|
|
output wire busy_o;
|
| 20 |
|
|
|
| 21 |
|
|
|
| 22 |
|
|
// Declaration of Wires And Register are here
|
| 23 |
|
|
// Control Signal To Calculate S_0
|
| 24 |
|
|
wire calc_S_0;
|
| 25 |
|
|
|
| 26 |
|
|
// Control signals To Calculate fourier transforms
|
| 27 |
|
|
wire [1:0] dft_sel; // select signal tells to calculate DFT or IDFT
|
| 28 |
|
|
wire dft_calc; // enable signal
|
| 29 |
|
|
|
| 30 |
|
|
// Control Signal to Calculate DELTA;
|
| 31 |
|
|
wire en_fir;
|
| 32 |
|
|
wire fir_sel;
|
| 33 |
|
|
|
| 34 |
|
|
// Control Signal for errolocpoly;
|
| 35 |
|
|
wire calc_bm_step;
|
| 36 |
|
|
wire [7:0] step;
|
| 37 |
|
|
wire done_bm_step;
|
| 38 |
|
|
|
| 39 |
|
|
wire push_zero;
|
| 40 |
|
|
|
| 41 |
|
|
// MEMORY CONTROL SIGNAL
|
| 42 |
|
|
wire wren;
|
| 43 |
|
|
wire [7:0] mem_address;
|
| 44 |
|
|
wire busy;
|
| 45 |
|
|
|
| 46 |
|
|
// MEMORY DATA SIGNAL
|
| 47 |
|
|
wire [7:0] mem_data;
|
| 48 |
|
|
|
| 49 |
|
|
// IDFT Zero Value CONTROL SIGNALS
|
| 50 |
|
|
wire load_last;
|
| 51 |
|
|
wire load_sel_out;
|
| 52 |
|
|
wire done_dec;
|
| 53 |
|
|
|
| 54 |
|
|
// Data Signal
|
| 55 |
|
|
wire [71:0] sigma; // original error loc poly
|
| 56 |
|
|
wire [71:0] sigma_0; // error loc poly with shifted right 8 bit and inv(sigma(0)) in the end
|
| 57 |
|
|
wire [71:0] sigma_last; // error loc poly with sigma(0) inversed
|
| 58 |
|
|
|
| 59 |
|
|
wire [71:0] fir_i_sigma;
|
| 60 |
|
|
wire [7:0] synd;
|
| 61 |
|
|
wire [7:0] fir_o;
|
| 62 |
|
|
wire [7:0] add_res;
|
| 63 |
|
|
wire [7:0] dft_all_in;
|
| 64 |
|
|
wire [7:0] dft_in;
|
| 65 |
|
|
wire [7:0] mem_data_o;
|
| 66 |
|
|
|
| 67 |
|
|
// R 0 Calculator Signals
|
| 68 |
|
|
wire [7:0] mem_loc; // mem address from the R_0 module is enabled when r_calc_sel is set to high
|
| 69 |
|
|
wire r_calc_sel; // R_0_calculate Control signal from the controller to select R0 memmory address
|
| 70 |
|
|
wire r_calc_done; // R_0_calculate control signal to the controller
|
| 71 |
|
|
wire r_calc; // enable signal to calculate R0
|
| 72 |
|
|
// R 0 Data signals
|
| 73 |
|
|
wire [7:0] R_0;
|
| 74 |
|
|
|
| 75 |
|
|
// Registers
|
| 76 |
|
|
reg [7:0] delta;
|
| 77 |
|
|
reg [7:0] last_in;
|
| 78 |
|
|
reg [7:0] S_0;
|
| 79 |
|
|
|
| 80 |
|
|
// mem address and control signal from the controler
|
| 81 |
|
|
wire [7:0] mem_addr;
|
| 82 |
|
|
wire mem_in;
|
| 83 |
|
|
|
| 84 |
|
|
assign busy_o = busy;
|
| 85 |
|
|
assign add_res = delta^synd;
|
| 86 |
|
|
|
| 87 |
|
|
// Decoder output
|
| 88 |
|
|
assign dec_data_o = load_sel_out?last_in:synd;
|
| 89 |
|
|
// MUX TO INPUT SIGMA OR SIGMA_O DEPENDING ON OPERATION
|
| 90 |
|
|
assign fir_i_sigma = fir_sel ? sigma_0: sigma;
|
| 91 |
|
|
// MUX FOR THE INPUT OF DFT_IDFT BLOCK
|
| 92 |
|
|
assign dft_in = dft_sel[1] ? mem_data_o:enc_data_i;
|
| 93 |
|
|
assign dft_all_in = push_zero ? 8'b00000000:dft_in;
|
| 94 |
|
|
|
| 95 |
|
|
// MEMORY MUXES
|
| 96 |
|
|
assign mem_address = r_calc_sel ? mem_loc:mem_addr;
|
| 97 |
|
|
assign mem_data = mem_in ? synd:add_res; //input first 16 syndrom of add_res
|
| 98 |
|
|
|
| 99 |
|
|
|
| 100 |
|
|
// SEQUENTIAL BODY
|
| 101 |
|
|
always @(posedge clk_i) begin
|
| 102 |
|
|
if((rst_i)||(done_dec))begin
|
| 103 |
|
|
S_0 <= 0;
|
| 104 |
|
|
end
|
| 105 |
|
|
else if (calc_S_0) begin
|
| 106 |
|
|
S_0 <= S_0^enc_data_i;
|
| 107 |
|
|
end
|
| 108 |
|
|
end
|
| 109 |
|
|
|
| 110 |
|
|
always @(posedge clk_i) begin
|
| 111 |
|
|
if((rst_i)||(done_dec))begin
|
| 112 |
|
|
last_in <= 0;
|
| 113 |
|
|
end
|
| 114 |
|
|
else if (load_last) begin
|
| 115 |
|
|
last_in <= last_in^add_res;
|
| 116 |
|
|
end
|
| 117 |
|
|
end
|
| 118 |
|
|
|
| 119 |
|
|
always @(posedge clk_i) begin
|
| 120 |
|
|
if ((rst_i)||(done_dec))
|
| 121 |
|
|
delta <= 0;
|
| 122 |
|
|
else
|
| 123 |
|
|
delta <= fir_o;
|
| 124 |
|
|
end
|
| 125 |
|
|
|
| 126 |
|
|
|
| 127 |
|
|
// STRUCTURAL MODEL OF RS DECODER
|
| 128 |
|
|
// MEMORY EVALUALTOR
|
| 129 |
|
|
Memmory EVALMEM(
|
| 130 |
|
|
.clk (clk_i),
|
| 131 |
|
|
.addr (mem_address),
|
| 132 |
|
|
.data (mem_data),
|
| 133 |
|
|
.we (wren),
|
| 134 |
|
|
.q ( mem_data_o )
|
| 135 |
|
|
);
|
| 136 |
|
|
|
| 137 |
|
|
GF8Dft_Idft DFTIDFT(.clk_i(clk_i), .rst_i(rst_i),
|
| 138 |
|
|
.dft_sel_i(dft_sel[0]), // Control Signal calculates dft if dft_idft = 0 else idft if dft_idft = 1
|
| 139 |
|
|
.en_i(dft_calc), // Control Signal
|
| 140 |
|
|
.dft_i(dft_all_in), // Gallios Field Register input 1
|
| 141 |
|
|
.dft_o(synd) // Gallios Field Register output
|
| 142 |
|
|
);
|
| 143 |
|
|
|
| 144 |
|
|
RS8Controller CNTRLER(.clk_i(clk_i),.rst_i(rst_i),
|
| 145 |
|
|
.valid_i(valid_i), // Controller input valid
|
| 146 |
|
|
.calc_S_0_o(calc_S_0), // Control Signal to Calculate S_0
|
| 147 |
|
|
.dft_sel_o(dft_sel), // select FFT or IFFT
|
| 148 |
|
|
.dft_calc_o(dft_calc), // calculate fourier transform
|
| 149 |
|
|
.mem_in_o(mem_in), // memory data selection control signal
|
| 150 |
|
|
.en_fir_o(en_fir), // calculate new delta
|
| 151 |
|
|
.fir_sel_o(fir_sel), // calculate new delta
|
| 152 |
|
|
.calc_bm_step_o(calc_bm_step), // Calculate BM Step
|
| 153 |
|
|
.step_o(step), // current_step
|
| 154 |
|
|
.done_bm_step_i(done_bm_step), // update from BM circuit
|
| 155 |
|
|
.elp_busy_i(elp_busy), // Controller input busy signal from error loc poly
|
| 156 |
|
|
.r_calc_o(r_calc), // TO Enable R0 calculator
|
| 157 |
|
|
.r_calc_sel_o(r_calc_sel), // To selsect R0 MEMORY ADDRESS
|
| 158 |
|
|
.r_calc_done_i(r_calc_done), // When R0 has completed the operation
|
| 159 |
|
|
.push_o(push_zero), // push data in syndrom
|
| 160 |
|
|
.mem_addr_o(mem_addr), // Memmory Address
|
| 161 |
|
|
.wren_o(wren), // Write Data IN memmory
|
| 162 |
|
|
.load_last_o(load_last), // Load Last
|
| 163 |
|
|
.last_in_sel_o(load_sel_out), // ouput data 0
|
| 164 |
|
|
.valid_o_o(valid_o), // Output from the Decode
|
| 165 |
|
|
.busy_o(busy), // Output from the Decoder
|
| 166 |
|
|
.done_dec_o(done_dec) // When The Complete Decoding is done
|
| 167 |
|
|
);
|
| 168 |
|
|
|
| 169 |
|
|
RS8ErrLocPoly8t CALCERRLOCPOLY(.clk_i(clk_i),.rst_i(rst_i),
|
| 170 |
|
|
.valid_i(calc_bm_step), // input 1
|
| 171 |
|
|
.delta_i(delta), // input 1
|
| 172 |
|
|
.step_i(step), // input 1
|
| 173 |
|
|
.done_dec_i(done_dec), // input 1
|
| 174 |
|
|
.valid_o(done_bm_step), // output
|
| 175 |
|
|
.sigma_0_o(sigma_0), // output
|
| 176 |
|
|
.sigma_o(sigma), // output
|
| 177 |
|
|
.sigma_last_o(sigma_last), // output
|
| 178 |
|
|
.busy_o(elp_busy) // Busy signal indication for processing
|
| 179 |
|
|
);
|
| 180 |
|
|
|
| 181 |
|
|
GF8Fir8t CALCDELTARE(
|
| 182 |
|
|
.clk_i(clk_i),.rst_i(rst_i),
|
| 183 |
|
|
.en_i(en_fir), // Gallios Field FIR Filter enable 1
|
| 184 |
|
|
.fir_i(synd), // Gallios Field FIR Filter input 1
|
| 185 |
|
|
.sel_i(fir_sel), // Gallios Field FIR Filter input 1
|
| 186 |
|
|
.coeff_i(fir_i_sigma), // Gallios Field FIR Coefficient input 1
|
| 187 |
|
|
.fir_o(fir_o), // Gallios Field FIR out
|
| 188 |
|
|
.done_dec_i(done_dec) // This is to clear every thing in this module
|
| 189 |
|
|
);
|
| 190 |
|
|
|
| 191 |
|
|
RS8CALCR08 R0CALC(.clk_i(clk_i), .rst_i(rst_i),
|
| 192 |
|
|
.en_i(r_calc), // Enable Signal
|
| 193 |
|
|
.sigma_i(sigma_last), // sigma value in to calculate R0
|
| 194 |
|
|
.syndrom_i(mem_data_o), // Syndrom value from the memory
|
| 195 |
|
|
.loc_o(mem_loc), // mem_address
|
| 196 |
|
|
.R_0_o(R_0), // Valid R_o when valid_o == 1
|
| 197 |
|
|
.valid_o(r_calc_done), // When processing done
|
| 198 |
|
|
.done_dec_i(done_dec) // input to clear all the registers
|
| 199 |
|
|
);
|
| 200 |
|
|
|
| 201 |
|
|
|
| 202 |
|
|
endmodule
|