-
Notifications
You must be signed in to change notification settings - Fork 44
/
bch_error_one.v
61 lines (52 loc) · 1.25 KB
/
bch_error_one.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* BCH Encode/Decoder Modules
*
* Copyright 2015 - Russ Dill <[email protected]>
* Distributed under 2-clause BSD license as contained in COPYING file.
*/
`timescale 1ns / 1ps
`include "config.vh"
`include "bch_defs.vh"
/* Reduced chien search for cases with only 1 bit error */
module bch_error_one #(
parameter [`BCH_PARAM_SZ-1:0] P = `BCH_SANE,
parameter BITS = 1,
parameter PIPELINE_STAGES = 0
) (
input clk,
input start, /* Latch inputs, start calculating */
input [`BCH_M(P)*2-1:0] sigma,
output first, /* First valid output data */
output [BITS-1:0] err
);
`include "bch.vh"
localparam TCQ = 1;
localparam M = `BCH_M(P);
localparam SKIP = `BCH_DATA_BITS(P) - `BCH_K(P) + `BCH_N(P);
wire [BITS-1:0] err_raw;
wire [M-1:0] chien;
if (`BCH_T(P) == 1)
one_does_not_support_sec u_odnss();
bch_chien_reg #(M, 1, 0, BITS) u_chien_reg(
.clk(clk),
.start(start),
.in(sigma[M+:M]),
.out(chien)
);
genvar b;
generate
for (b = 0; b < BITS; b = b + 1) begin : BIT
assign err_raw[b] = chien == lpow(M, SKIP + b);
end
endgenerate
pipeline #(2 + PIPELINE_STAGES) u_first_pipeline (
.clk(clk),
.i(start),
.o(first)
);
pipeline #(PIPELINE_STAGES) u_out_pipeline [BITS-1:0] (
.clk(clk),
.i(err_raw),
.o(err)
);
endmodule