OpenCores
URL https://opencores.org/ocsvn/reed_solomon_coder/reed_solomon_coder/trunk

Subversion Repositories reed_solomon_coder

[/] [reed_solomon_coder/] [trunk/] [RS_decoder_top_modul.v] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 cau_sse
`timescale 1ns / 1ps
2
//////////////////////////////////////////////////////////////////////////////////
3
// Company: University of Hamburg, University of Kiel, Germany
4
// Engineer: Cagil Gümüs, Andreas Bahr
5
// 
6
// Create Date:    17:47:25 01/18/2016 
7
// Design Name: 
8
// Module Name:    top_module_RS 
9
// Project Name: 
10
// Target Devices: 
11
// Tool versions: 
12
// Description: 
13
//
14
// Dependencies: 
15
//
16
// Revision: 
17
// Revision 0.01 - File Created
18
// Additional Comments: 
19
//
20
//////////////////////////////////////////////////////////////////////////////////
21
module top_module_RS(
22
 
23
        input wire                              clk,
24
        input wire                              reset,
25
        input wire [35:0]                data_in,
26
        input wire                              global_start,
27
        input wire                              corrector_ready,
28
 
29
        output wire                     error,
30
        output wire [3:0]        errorlocation_1,
31
        output wire [3:0]                errorlocation_2,
32
        output wire [3:0]                errormagnitude_1,
33
        output wire [3:0]                errormagnitude_2,
34
        output reg                              global_ready,
35
        output reg                              decoding,
36
        output reg      [15:0]   number_of_errors,
37
        output reg      [15:0]   number_of_errors2,
38
        output reg      [15:0]   number_of_packets,
39
        output reg      [15:0]   number_of_packets2
40
    );
41
 
42
 
43
 
44
reg     go_BM_reg;              //Used to give go signal to BerlekampMassey block
45
reg     go_chien_reg;           //Used to give go signal to Chien Search block
46
reg     go_forney_reg;          //Used to give go signal to Forney block
47
reg     go_syndrome_reg;
48
 
49
reg job_done_reg;
50
 
51
 
52
wire    ready_BM_wire;          //Used to get the ready signal from BerlekampMassey block
53
wire    ready_chien_wire;       //Used to get the ready signal from Chien block
54
wire    ready_forney_wire;//Used to get the ready signal from Forney block
55
wire    ready_syndrome_wire;
56
 
57
wire [3:0] errorlocation_1_wire;
58
wire [3:0] errorlocation_2_wire;
59
wire [3:0] errormagnitude_1_wire;
60
wire [3:0] errormagnitude_2_wire;
61
 
62
wire no_errors_wire;
63
 
64
assign error = ~no_errors_wire;
65
 
66
        Middle middle1(
67
 
68
        .clk(clk),
69
        .reset(reset),
70
        .data_in(data_in),
71
 
72
        .go_BM(go_BM_reg),
73
        .go_chien(go_chien_reg),
74
        .go_forney(go_forney_reg),
75
        .go_syndrome(go_syndrome_reg),
76
 
77
        .ready_BM(ready_BM_wire),
78
        .ready_chien(ready_chien_wire),
79
        .ready_forney(ready_forney_wire),
80
        .ready_syndrome(ready_syndrome_wire),
81
 
82
        .errorlocation1(errorlocation_1),
83
        .errorlocation2(errorlocation_2),
84
 
85
        .errormagnitude1(errormagnitude_1),
86
        .errormagnitude2(errormagnitude_2),
87
 
88
        .no_errors(no_errors_wire),
89
 
90
        .job_done(job_done_reg),
91
        .errorlocator()
92
 
93
        );
94
 
95
 
96
 
97
//Finite State Machine Initialization
98
reg [3:0] state;
99
 
100
parameter [3:0] IDLE                                     = 4'b0000,
101
                                         SYNDROME                               = 4'b1111,
102
                                         BERLEKAMP                              = 4'b0001,
103
                                         CHIEN                                  = 4'b0010,
104
                                         FORNEY                                 = 4'b0011,
105
                                         CORRECTOR                              = 4'b0101,
106
                                         FINISH                                 = 4'b0111 ;
107
 
108
 
109
//Main Block
110
always @(posedge clk or negedge reset)
111
 
112
        begin
113
 
114
                if(!reset)
115
                        begin
116
 
117
 
118
 
119
                                state <= IDLE;
120
 
121
                                job_done_reg <= 0;
122
                                decoding                        <= 0;
123
                                global_ready            <= 0;
124
 
125
                                go_BM_reg                       <= 0;
126
                                go_chien_reg            <= 0;
127
                                go_forney_reg           <= 0;
128
                                go_syndrome_reg   <= 0;
129
 
130
 
131
                                number_of_errors        <= 0;
132
                                number_of_errors2 <= 0;
133
 
134
                                number_of_packets <= 0;
135
                                number_of_packets2<= 0;
136
 
137
                        end
138
 
139
                else
140
                        begin
141
 
142
                                case(state)
143
 
144
                                        IDLE:
145
                                                begin
146
 
147
 
148
 
149
                                                        global_ready <= 0;
150
 
151
                                                        decoding                        <= 0;
152
 
153
                                                        go_BM_reg               <= 0;
154
                                                        go_chien_reg    <= 0;
155
                                                        go_forney_reg   <= 0;
156
 
157
                                                        if(global_start)
158
                                                                begin
159
                                                                        job_done_reg <= 0;
160
                                                                        state <= SYNDROME;
161
 
162
                                                                end
163
                                                        else
164
                                                                begin
165
                                                                        state <= IDLE;
166
                                                                        job_done_reg <= 1;
167
                                                                end
168
                                                end
169
 
170
 
171
                                        SYNDROME:
172
                                                        begin
173
 
174
 
175
                                                                        go_syndrome_reg         <= 1;
176
                                                                        go_BM_reg                       <= 0;
177
                                                                        go_chien_reg            <= 0;
178
                                                                        go_forney_reg           <= 0;
179
 
180
                                                                        if(ready_syndrome_wire)
181
                                                                                begin
182
                                                                                        if(no_errors_wire)
183
                                                                                                begin
184
 
185
                                                                                                        state <= CORRECTOR;             //If all syndromes are zero skip to end state "FINISH" since there is no errors to compute.
186
 
187
                                                                                                        number_of_packets <= number_of_packets + 1;
188
                                                                                                        if(number_of_packets == 16'b1111_1111_1111_1111)
189
                                                                                                                number_of_packets2 <= number_of_packets2 + 1 ;
190
 
191
                                                                                                end
192
                                                                                        else
193
                                                                                                begin
194
                                                                                                        state <= BERLEKAMP;
195
 
196
                                                                                                        number_of_packets <= number_of_packets + 1;
197
                                                                                                        if(number_of_packets == 16'b1111_1111_1111_1111)
198
                                                                                                                number_of_packets2 <= number_of_packets2 + 1 ;
199
 
200
                                                                                                        number_of_errors <= number_of_errors + 1;
201
                                                                                                        if(number_of_errors == 16'b1111_1111_1111_1111)
202
                                                                                                                number_of_errors2 <= number_of_errors2 + 1 ;
203
 
204
                                                                                                end
205
                                                                                end
206
                                                                        else
207
                                                                                state <= SYNDROME;
208
 
209
 
210
 
211
                                                        end
212
 
213
 
214
                                        BERLEKAMP:
215
                                                        begin
216
 
217
 
218
 
219
                                                                decoding <= 1;
220
 
221
                                                                go_syndrome_reg         <= 0;
222
                                                                go_BM_reg                       <= 1;
223
                                                                go_chien_reg            <= 0;
224
                                                                go_forney_reg           <= 0;
225
 
226
                                                                if(ready_BM_wire)
227
                                                                        state <= CHIEN;
228
                                                                else
229
                                                                        state <= BERLEKAMP;
230
 
231
 
232
                                                        end
233
 
234
                                        CHIEN:
235
                                                        begin
236
 
237
 
238
                                                                go_syndrome_reg         <= 0;
239
                                                                go_BM_reg                       <= 0;
240
                                                                go_chien_reg            <= 1;
241
                                                                go_forney_reg           <= 0;
242
 
243
                                                                if(ready_chien_wire)
244
                                                                        state <= FORNEY;
245
                                                                else
246
                                                                        state <= CHIEN;
247
 
248
                                                        end
249
 
250
                                        FORNEY:
251
                                                        begin
252
 
253
 
254
 
255
                                                                        go_syndrome_reg         <= 0;
256
                                                                        go_BM_reg                       <= 0;
257
                                                                        go_chien_reg            <= 0;
258
                                                                        go_forney_reg           <= 1;
259
 
260
                                                                if(ready_forney_wire)
261
                                                                        state <= CORRECTOR;
262
                                                                else
263
                                                                        state <= FORNEY;
264
 
265
 
266
                                                        end
267
 
268
                                        CORRECTOR:
269
                                                        begin
270
 
271
 
272
                                                                go_syndrome_reg <= 0;
273
                                                                go_BM_reg <= 0;
274
                                                                go_chien_reg <= 0;
275
                                                                go_forney_reg <= 0;
276
 
277
                                                                global_ready <= 1;
278
 
279
 
280
                                                                if(corrector_ready)
281
                                                                        state <= FINISH;
282
                                                                else
283
                                                                        state <= CORRECTOR;
284
 
285
                                                        end
286
 
287
                                        FINISH:
288
                                                        begin
289
 
290
 
291
                                                                job_done_reg <= 1;
292
                                                                state <= IDLE;
293
 
294
                                                        end
295
 
296
                                        default: state <= IDLE;
297
 
298
 
299
 
300
                                endcase
301
 
302
 
303
 
304
 
305
 
306
 
307
                        end
308
 
309
 
310
        end
311
 
312
 
313
 
314
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.